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(GrDrawingManager*, |
16 | GrSurfaceProxyView srcView, |
17 | const SkIRect& srcRect, |
18 | GrSurfaceProxyView dstView, |
19 | const SkIPoint& dstPoint, |
20 | const GrCaps*); |
21 | |
22 | private: |
23 | GrCopyRenderTask(GrDrawingManager*, |
24 | GrSurfaceProxyView srcView, |
25 | const SkIRect& srcRect, |
26 | GrSurfaceProxyView dstView, |
27 | const SkIPoint& dstPoint); |
28 | |
29 | bool onIsUsed(GrSurfaceProxy* proxy) const override { |
30 | return proxy == fSrcView.proxy(); |
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; |
35 | ExpectedOutcome onMakeClosed(const GrCaps&, SkIRect* targetUpdateBounds) override { |
36 | targetUpdateBounds->setXYWH(fDstPoint.x(), fDstPoint.y(), fSrcRect.width(), |
37 | fSrcRect.height()); |
38 | return ExpectedOutcome::kTargetDirty; |
39 | } |
40 | bool onExecute(GrOpFlushState*) override; |
41 | |
42 | #if GR_TEST_UTILS |
43 | const char* name() const final { return "Copy" ; } |
44 | #endif |
45 | #ifdef SK_DEBUG |
46 | void visitProxies_debugOnly(const GrOp::VisitProxyFunc& fn) const override { |
47 | fn(fSrcView.proxy(), GrMipmapped::kNo); |
48 | } |
49 | #endif |
50 | |
51 | GrSurfaceProxyView fSrcView; |
52 | SkIRect fSrcRect; |
53 | SkIPoint fDstPoint; |
54 | }; |
55 | |
56 | #endif |
57 | |
58 | |