blob: 13f502a50197390b836ae5d260e60de6f80e6341 [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,
Brian Salomone4bce012019-09-20 15:34:23 -040018 const SkIPoint& dstPoint,
19 const GrCaps*);
Greg Daniele227fe42019-08-21 13:52:24 -040020
21private:
22 GrCopyRenderTask(sk_sp<GrSurfaceProxy> srcProxy,
23 const SkIRect& srcRect,
24 sk_sp<GrSurfaceProxy> dstProxy,
25 const SkIPoint& dstPoint);
26
27 void onPrepare(GrOpFlushState*) override {}
28 bool onIsUsed(GrSurfaceProxy* proxy) const override {
29 SkASSERT(proxy != fTarget.get()); // This case should be handled by GrRenderTask.
30 return proxy == fSrcProxy.get();
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&) override {
36 return ExpectedOutcome::kTargetDirty;
37 }
38 bool onExecute(GrOpFlushState*) override;
39
Chris Daltonc4b47352019-08-23 10:10:36 -060040#ifdef SK_DEBUG
Greg Danieldcf9ca12019-08-27 14:30:21 -040041 void visitProxies_debugOnly(const VisitSurfaceProxyFunc& fn) const override {
Chris Daltonc4b47352019-08-23 10:10:36 -060042 fn(fSrcProxy.get(), GrMipMapped::kNo);
43 }
44#endif
45
Greg Daniele227fe42019-08-21 13:52:24 -040046 sk_sp<GrSurfaceProxy> fSrcProxy;
47 SkIRect fSrcRect;
48 SkIPoint fDstPoint;
49};
50
51#endif
52