blob: 64431a523de953fed4c58d616f5c3254fc2a969e [file] [log] [blame]
bsalomon872062c2015-08-18 12:12:35 -07001/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
Brian Salomon7dae46a2016-12-14 16:21:37 -05008#ifndef GrCopySurfaceOp_DEFINED
9#define GrCopySurfaceOp_DEFINED
bsalomon872062c2015-08-18 12:12:35 -070010
Brian Salomon25a88092016-12-01 09:36:50 -050011#include "GrOp.h"
Brian Salomon742e31d2016-12-07 17:06:19 -050012#include "GrOpFlushState.h"
bsalomon872062c2015-08-18 12:12:35 -070013
Brian Salomon7dae46a2016-12-14 16:21:37 -050014class GrCopySurfaceOp final : public GrOp {
bsalomon872062c2015-08-18 12:12:35 -070015public:
Brian Salomon25a88092016-12-01 09:36:50 -050016 DEFINE_OP_CLASS_ID
reed1b55a962015-09-17 20:16:13 -070017
Robert Phillipsa16f6cb2017-06-01 11:06:13 -040018 static std::unique_ptr<GrOp> Make(GrSurfaceProxy* dst, GrSurfaceProxy* src,
Robert Phillipsbf25d432017-04-07 10:08:53 -040019 const SkIRect& srcRect,
Brian Salomonf8334782017-01-03 09:42:58 -050020 const SkIPoint& dstPoint);
bsalomon872062c2015-08-18 12:12:35 -070021
22 const char* name() const override { return "CopySurface"; }
23
bsalomon872062c2015-08-18 12:12:35 -070024 SkString dumpInfo() const override {
25 SkString string;
Robert Phillipsf5442bb2017-04-17 14:18:34 -040026 string.append(INHERITED::dumpInfo());
Robert Phillipsa16f6cb2017-06-01 11:06:13 -040027 string.printf("srcProxyID: %d, dstProxyID: %d,\n"
28 "srcRect: [ L: %d, T: %d, R: %d, B: %d ], dstPt: [ X: %d, Y: %d ]\n",
29 fSrc.get()->uniqueID().asUInt(),
30 fDst.get()->uniqueID().asUInt(),
Robert Phillipsbf25d432017-04-07 10:08:53 -040031 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBottom,
32 fDstPoint.fX, fDstPoint.fY);
bsalomon872062c2015-08-18 12:12:35 -070033 return string;
34 }
35
Robert Phillips178ce3e2017-04-13 09:15:47 -040036 bool needsCommandBufferIsolation() const override { return true; }
37
bsalomon872062c2015-08-18 12:12:35 -070038private:
Robert Phillipsa16f6cb2017-06-01 11:06:13 -040039 GrCopySurfaceOp(GrSurfaceProxy* dst, GrSurfaceProxy* src,
Robert Phillipsbf25d432017-04-07 10:08:53 -040040 const SkIRect& srcRect, const SkIPoint& dstPoint)
41 : INHERITED(ClassID())
Robert Phillipsbf25d432017-04-07 10:08:53 -040042 , fDst(dst)
43 , fSrc(src)
44 , fSrcRect(srcRect)
45 , fDstPoint(dstPoint) {
bsalomon88cf17d2016-07-08 06:40:56 -070046 SkRect bounds =
47 SkRect::MakeXYWH(SkIntToScalar(dstPoint.fX), SkIntToScalar(dstPoint.fY),
48 SkIntToScalar(srcRect.width()), SkIntToScalar(srcRect.height()));
49 this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo);
bsalomon872062c2015-08-18 12:12:35 -070050 }
51
Brian Salomon25a88092016-12-01 09:36:50 -050052 bool onCombineIfPossible(GrOp* that, const GrCaps& caps) override { return false; }
bsalomon872062c2015-08-18 12:12:35 -070053
Brian Salomon742e31d2016-12-07 17:06:19 -050054 void onPrepare(GrOpFlushState*) override {}
bsalomon872062c2015-08-18 12:12:35 -070055
Robert Phillips646e4292017-06-13 12:44:56 -040056 void onExecute(GrOpFlushState* state) override;
bsalomon872062c2015-08-18 12:12:35 -070057
Robert Phillipsa16f6cb2017-06-01 11:06:13 -040058 // For RenderTargetContexts 'fDst' is redundant with the RenderTarget that will be passed
59 // into onExecute in the drawOpArgs.
60 GrPendingIOResource<GrSurfaceProxy, kWrite_GrIOType> fDst;
61 GrPendingIOResource<GrSurfaceProxy, kRead_GrIOType> fSrc;
62 SkIRect fSrcRect;
63 SkIPoint fDstPoint;
reed1b55a962015-09-17 20:16:13 -070064
Brian Salomon25a88092016-12-01 09:36:50 -050065 typedef GrOp INHERITED;
bsalomon872062c2015-08-18 12:12:35 -070066};
67
68#endif