Greg Daniel | e227fe4 | 2019-08-21 13:52:24 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 Google LLC |
| 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 | |
| 8 | #ifndef GrCopyRenderTask_DEFINED |
| 9 | #define GrCopyRenderTask_DEFINED |
| 10 | |
| 11 | #include "src/gpu/GrRenderTask.h" |
| 12 | |
| 13 | class GrCopyRenderTask final : public GrRenderTask { |
| 14 | public: |
Greg Daniel | 16f5c65 | 2019-10-29 11:26:01 -0400 | [diff] [blame] | 15 | static sk_sp<GrRenderTask> Make(GrSurfaceProxyView srcView, |
Greg Daniel | e227fe4 | 2019-08-21 13:52:24 -0400 | [diff] [blame] | 16 | const SkIRect& srcRect, |
Greg Daniel | 16f5c65 | 2019-10-29 11:26:01 -0400 | [diff] [blame] | 17 | GrSurfaceProxyView dstView, |
Brian Salomon | e4bce01 | 2019-09-20 15:34:23 -0400 | [diff] [blame] | 18 | const SkIPoint& dstPoint, |
| 19 | const GrCaps*); |
Greg Daniel | e227fe4 | 2019-08-21 13:52:24 -0400 | [diff] [blame] | 20 | |
| 21 | private: |
Greg Daniel | 16f5c65 | 2019-10-29 11:26:01 -0400 | [diff] [blame] | 22 | GrCopyRenderTask(GrSurfaceProxyView srcView, |
Greg Daniel | e227fe4 | 2019-08-21 13:52:24 -0400 | [diff] [blame] | 23 | const SkIRect& srcRect, |
Greg Daniel | 16f5c65 | 2019-10-29 11:26:01 -0400 | [diff] [blame] | 24 | GrSurfaceProxyView dstView, |
Greg Daniel | e227fe4 | 2019-08-21 13:52:24 -0400 | [diff] [blame] | 25 | const SkIPoint& dstPoint); |
| 26 | |
Greg Daniel | e227fe4 | 2019-08-21 13:52:24 -0400 | [diff] [blame] | 27 | bool onIsUsed(GrSurfaceProxy* proxy) const override { |
Greg Daniel | 16f5c65 | 2019-10-29 11:26:01 -0400 | [diff] [blame] | 28 | // This case should be handled by GrRenderTask. |
| 29 | SkASSERT(proxy != fTargetView.proxy()); |
| 30 | return proxy == fSrcView.proxy(); |
Greg Daniel | e227fe4 | 2019-08-21 13:52:24 -0400 | [diff] [blame] | 31 | } |
| 32 | // If instantiation failed, at flush time we simply will skip doing the copy. |
| 33 | void handleInternalAllocationFailure() override {} |
| 34 | void gatherProxyIntervals(GrResourceAllocator*) const override; |
Chris Dalton | 16a33c6 | 2019-09-24 22:19:17 -0600 | [diff] [blame] | 35 | ExpectedOutcome onMakeClosed(const GrCaps&, SkIRect* targetUpdateBounds) override { |
| 36 | targetUpdateBounds->setXYWH(fDstPoint.x(), fDstPoint.y(), fSrcRect.width(), |
| 37 | fSrcRect.height()); |
Greg Daniel | e227fe4 | 2019-08-21 13:52:24 -0400 | [diff] [blame] | 38 | return ExpectedOutcome::kTargetDirty; |
| 39 | } |
| 40 | bool onExecute(GrOpFlushState*) override; |
| 41 | |
Chris Dalton | c4b4735 | 2019-08-23 10:10:36 -0600 | [diff] [blame] | 42 | #ifdef SK_DEBUG |
Michael Ludwig | fcdd061 | 2019-11-25 08:34:31 -0500 | [diff] [blame] | 43 | void visitProxies_debugOnly(const GrOp::VisitProxyFunc& fn) const override { |
Greg Daniel | 16f5c65 | 2019-10-29 11:26:01 -0400 | [diff] [blame] | 44 | fn(fSrcView.proxy(), GrMipMapped::kNo); |
Chris Dalton | c4b4735 | 2019-08-23 10:10:36 -0600 | [diff] [blame] | 45 | } |
| 46 | #endif |
| 47 | |
Greg Daniel | 16f5c65 | 2019-10-29 11:26:01 -0400 | [diff] [blame] | 48 | GrSurfaceProxyView fSrcView; |
Greg Daniel | e227fe4 | 2019-08-21 13:52:24 -0400 | [diff] [blame] | 49 | SkIRect fSrcRect; |
| 50 | SkIPoint fDstPoint; |
| 51 | }; |
| 52 | |
| 53 | #endif |
| 54 | |