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