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: |
| 15 | static sk_sp<GrRenderTask> Make(sk_sp<GrSurfaceProxy> srcProxy, |
| 16 | const SkIRect& srcRect, |
| 17 | sk_sp<GrSurfaceProxy> dstProxy, |
| 18 | const SkIPoint& dstPoint); |
| 19 | |
| 20 | private: |
| 21 | GrCopyRenderTask(sk_sp<GrSurfaceProxy> srcProxy, |
| 22 | const SkIRect& srcRect, |
| 23 | sk_sp<GrSurfaceProxy> dstProxy, |
| 24 | const SkIPoint& dstPoint); |
| 25 | |
| 26 | void onPrepare(GrOpFlushState*) override {} |
| 27 | bool onIsUsed(GrSurfaceProxy* proxy) const override { |
| 28 | SkASSERT(proxy != fTarget.get()); // This case should be handled by GrRenderTask. |
| 29 | return proxy == fSrcProxy.get(); |
| 30 | } |
| 31 | // If instantiation failed, at flush time we simply will skip doing the copy. |
| 32 | void handleInternalAllocationFailure() override {} |
| 33 | void gatherProxyIntervals(GrResourceAllocator*) const override; |
| 34 | ExpectedOutcome onMakeClosed(const GrCaps&) override { |
| 35 | return ExpectedOutcome::kTargetDirty; |
| 36 | } |
| 37 | bool onExecute(GrOpFlushState*) override; |
| 38 | |
Chris Dalton | c4b4735 | 2019-08-23 10:10:36 -0600 | [diff] [blame] | 39 | #ifdef SK_DEBUG |
Greg Daniel | dcf9ca1 | 2019-08-27 14:30:21 -0400 | [diff] [blame] | 40 | void visitProxies_debugOnly(const VisitSurfaceProxyFunc& fn) const override { |
Chris Dalton | c4b4735 | 2019-08-23 10:10:36 -0600 | [diff] [blame] | 41 | fn(fSrcProxy.get(), GrMipMapped::kNo); |
| 42 | } |
| 43 | #endif |
| 44 | |
Greg Daniel | e227fe4 | 2019-08-21 13:52:24 -0400 | [diff] [blame] | 45 | sk_sp<GrSurfaceProxy> fSrcProxy; |
| 46 | SkIRect fSrcRect; |
| 47 | SkIPoint fDstPoint; |
| 48 | }; |
| 49 | |
| 50 | #endif |
| 51 | |