bsalomon | 872062c | 2015-08-18 12:12:35 -0700 | [diff] [blame] | 1 | /* |
| 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 Salomon | 7dae46a | 2016-12-14 16:21:37 -0500 | [diff] [blame] | 8 | #ifndef GrCopySurfaceOp_DEFINED |
| 9 | #define GrCopySurfaceOp_DEFINED |
bsalomon | 872062c | 2015-08-18 12:12:35 -0700 | [diff] [blame] | 10 | |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame] | 11 | #include "GrOp.h" |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 12 | #include "GrOpFlushState.h" |
bsalomon | 872062c | 2015-08-18 12:12:35 -0700 | [diff] [blame] | 13 | |
Brian Salomon | 7dae46a | 2016-12-14 16:21:37 -0500 | [diff] [blame] | 14 | class GrCopySurfaceOp final : public GrOp { |
bsalomon | 872062c | 2015-08-18 12:12:35 -0700 | [diff] [blame] | 15 | public: |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame] | 16 | DEFINE_OP_CLASS_ID |
reed | 1b55a96 | 2015-09-17 20:16:13 -0700 | [diff] [blame] | 17 | |
Robert Phillips | a16f6cb | 2017-06-01 11:06:13 -0400 | [diff] [blame] | 18 | static std::unique_ptr<GrOp> Make(GrSurfaceProxy* dst, GrSurfaceProxy* src, |
Robert Phillips | bf25d43 | 2017-04-07 10:08:53 -0400 | [diff] [blame] | 19 | const SkIRect& srcRect, |
Brian Salomon | f833478 | 2017-01-03 09:42:58 -0500 | [diff] [blame] | 20 | const SkIPoint& dstPoint); |
bsalomon | 872062c | 2015-08-18 12:12:35 -0700 | [diff] [blame] | 21 | |
| 22 | const char* name() const override { return "CopySurface"; } |
| 23 | |
bsalomon | 872062c | 2015-08-18 12:12:35 -0700 | [diff] [blame] | 24 | SkString dumpInfo() const override { |
| 25 | SkString string; |
Robert Phillips | f5442bb | 2017-04-17 14:18:34 -0400 | [diff] [blame] | 26 | string.append(INHERITED::dumpInfo()); |
Robert Phillips | a16f6cb | 2017-06-01 11:06:13 -0400 | [diff] [blame] | 27 | 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 Phillips | bf25d43 | 2017-04-07 10:08:53 -0400 | [diff] [blame] | 31 | fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBottom, |
| 32 | fDstPoint.fX, fDstPoint.fY); |
bsalomon | 872062c | 2015-08-18 12:12:35 -0700 | [diff] [blame] | 33 | return string; |
| 34 | } |
| 35 | |
Robert Phillips | 178ce3e | 2017-04-13 09:15:47 -0400 | [diff] [blame] | 36 | bool needsCommandBufferIsolation() const override { return true; } |
| 37 | |
bsalomon | 872062c | 2015-08-18 12:12:35 -0700 | [diff] [blame] | 38 | private: |
Robert Phillips | a16f6cb | 2017-06-01 11:06:13 -0400 | [diff] [blame] | 39 | GrCopySurfaceOp(GrSurfaceProxy* dst, GrSurfaceProxy* src, |
Robert Phillips | bf25d43 | 2017-04-07 10:08:53 -0400 | [diff] [blame] | 40 | const SkIRect& srcRect, const SkIPoint& dstPoint) |
| 41 | : INHERITED(ClassID()) |
Robert Phillips | bf25d43 | 2017-04-07 10:08:53 -0400 | [diff] [blame] | 42 | , fDst(dst) |
| 43 | , fSrc(src) |
| 44 | , fSrcRect(srcRect) |
| 45 | , fDstPoint(dstPoint) { |
bsalomon | 88cf17d | 2016-07-08 06:40:56 -0700 | [diff] [blame] | 46 | 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); |
bsalomon | 872062c | 2015-08-18 12:12:35 -0700 | [diff] [blame] | 50 | } |
| 51 | |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame] | 52 | bool onCombineIfPossible(GrOp* that, const GrCaps& caps) override { return false; } |
bsalomon | 872062c | 2015-08-18 12:12:35 -0700 | [diff] [blame] | 53 | |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 54 | void onPrepare(GrOpFlushState*) override {} |
bsalomon | 872062c | 2015-08-18 12:12:35 -0700 | [diff] [blame] | 55 | |
Robert Phillips | 646e429 | 2017-06-13 12:44:56 -0400 | [diff] [blame] | 56 | void onExecute(GrOpFlushState* state) override; |
bsalomon | 872062c | 2015-08-18 12:12:35 -0700 | [diff] [blame] | 57 | |
Robert Phillips | a16f6cb | 2017-06-01 11:06:13 -0400 | [diff] [blame] | 58 | // 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; |
reed | 1b55a96 | 2015-09-17 20:16:13 -0700 | [diff] [blame] | 64 | |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame] | 65 | typedef GrOp INHERITED; |
bsalomon | 872062c | 2015-08-18 12:12:35 -0700 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | #endif |