blob: 319d5daa11287ce057b08e642e35ac7fb2e10432 [file] [log] [blame]
Greg Daniele227fe42019-08-21 13:52:24 -04001/*
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
13class GrCopyRenderTask final : public GrRenderTask {
14public:
15 static sk_sp<GrRenderTask> Make(sk_sp<GrSurfaceProxy> srcProxy,
16 const SkIRect& srcRect,
17 sk_sp<GrSurfaceProxy> dstProxy,
18 const SkIPoint& dstPoint);
19
20private:
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 Daltonc4b47352019-08-23 10:10:36 -060039#ifdef SK_DEBUG
40 void visitProxies_debugOnly(const GrOp::VisitProxyFunc& fn) const override {
41 fn(fSrcProxy.get(), GrMipMapped::kNo);
42 }
43#endif
44
Greg Daniele227fe42019-08-21 13:52:24 -040045 sk_sp<GrSurfaceProxy> fSrcProxy;
46 SkIRect fSrcRect;
47 SkIPoint fDstPoint;
48};
49
50#endif
51