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 | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 18 | static std::unique_ptr<GrOp> Make(GrContext*, |
| 19 | GrSurfaceProxy* dst, |
| 20 | GrSurfaceProxy* src, |
Robert Phillips | bf25d43 | 2017-04-07 10:08:53 -0400 | [diff] [blame] | 21 | const SkIRect& srcRect, |
Brian Salomon | f833478 | 2017-01-03 09:42:58 -0500 | [diff] [blame] | 22 | const SkIPoint& dstPoint); |
bsalomon | 872062c | 2015-08-18 12:12:35 -0700 | [diff] [blame] | 23 | |
| 24 | const char* name() const override { return "CopySurface"; } |
| 25 | |
Brian Salomon | 7d94bb5 | 2018-10-12 14:37:19 -0400 | [diff] [blame] | 26 | void visitProxies(const VisitProxyFunc& func, VisitorType) const override { func(fSrc.get()); } |
Robert Phillips | 9d6c64f | 2017-09-14 10:56:45 -0400 | [diff] [blame] | 27 | |
Brian Osman | 9a390ac | 2018-11-12 09:47:48 -0500 | [diff] [blame] | 28 | #ifdef SK_DEBUG |
bsalomon | 872062c | 2015-08-18 12:12:35 -0700 | [diff] [blame] | 29 | SkString dumpInfo() const override { |
| 30 | SkString string; |
Robert Phillips | f5442bb | 2017-04-17 14:18:34 -0400 | [diff] [blame] | 31 | string.append(INHERITED::dumpInfo()); |
Robert Phillips | 47c315e | 2017-11-08 16:26:53 -0500 | [diff] [blame] | 32 | string.printf("srcProxyID: %d,\n" |
Robert Phillips | a16f6cb | 2017-06-01 11:06:13 -0400 | [diff] [blame] | 33 | "srcRect: [ L: %d, T: %d, R: %d, B: %d ], dstPt: [ X: %d, Y: %d ]\n", |
| 34 | fSrc.get()->uniqueID().asUInt(), |
Robert Phillips | bf25d43 | 2017-04-07 10:08:53 -0400 | [diff] [blame] | 35 | fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBottom, |
| 36 | fDstPoint.fX, fDstPoint.fY); |
bsalomon | 872062c | 2015-08-18 12:12:35 -0700 | [diff] [blame] | 37 | return string; |
| 38 | } |
Brian Osman | 9a390ac | 2018-11-12 09:47:48 -0500 | [diff] [blame] | 39 | #endif |
bsalomon | 872062c | 2015-08-18 12:12:35 -0700 | [diff] [blame] | 40 | |
| 41 | private: |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 42 | friend class GrOpMemoryPool; // for ctor |
| 43 | |
Robert Phillips | a16f6cb | 2017-06-01 11:06:13 -0400 | [diff] [blame] | 44 | GrCopySurfaceOp(GrSurfaceProxy* dst, GrSurfaceProxy* src, |
Robert Phillips | bf25d43 | 2017-04-07 10:08:53 -0400 | [diff] [blame] | 45 | const SkIRect& srcRect, const SkIPoint& dstPoint) |
| 46 | : INHERITED(ClassID()) |
Robert Phillips | bf25d43 | 2017-04-07 10:08:53 -0400 | [diff] [blame] | 47 | , fSrc(src) |
| 48 | , fSrcRect(srcRect) |
| 49 | , fDstPoint(dstPoint) { |
bsalomon | 88cf17d | 2016-07-08 06:40:56 -0700 | [diff] [blame] | 50 | SkRect bounds = |
| 51 | SkRect::MakeXYWH(SkIntToScalar(dstPoint.fX), SkIntToScalar(dstPoint.fY), |
| 52 | SkIntToScalar(srcRect.width()), SkIntToScalar(srcRect.height())); |
| 53 | this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo); |
bsalomon | 872062c | 2015-08-18 12:12:35 -0700 | [diff] [blame] | 54 | } |
| 55 | |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 56 | void onPrepare(GrOpFlushState*) override {} |
bsalomon | 872062c | 2015-08-18 12:12:35 -0700 | [diff] [blame] | 57 | |
Brian Salomon | 588cec7 | 2018-11-14 13:56:37 -0500 | [diff] [blame] | 58 | void onExecute(GrOpFlushState*, const SkRect& chainBounds) override; |
bsalomon | 872062c | 2015-08-18 12:12:35 -0700 | [diff] [blame] | 59 | |
Robert Phillips | a16f6cb | 2017-06-01 11:06:13 -0400 | [diff] [blame] | 60 | GrPendingIOResource<GrSurfaceProxy, kRead_GrIOType> fSrc; |
| 61 | SkIRect fSrcRect; |
| 62 | SkIPoint fDstPoint; |
reed | 1b55a96 | 2015-09-17 20:16:13 -0700 | [diff] [blame] | 63 | |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame] | 64 | typedef GrOp INHERITED; |
bsalomon | 872062c | 2015-08-18 12:12:35 -0700 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | #endif |