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
13class GrCopyRenderTask final : public GrRenderTask {
14public:
15 static sk_sp<GrRenderTask> Make(GrSurfaceProxyView srcView,
16 const SkIRect& srcRect,
17 GrSurfaceProxyView dstView,
18 const SkIPoint& dstPoint,
19 const GrCaps*);
20
21private:
22 GrCopyRenderTask(GrSurfaceProxyView srcView,
23 const SkIRect& srcRect,
24 GrSurfaceProxyView dstView,
25 const SkIPoint& dstPoint);
26
27 bool onIsUsed(GrSurfaceProxy* proxy) const override {
28 // This case should be handled by GrRenderTask.
29 SkASSERT(proxy != fTargetView.proxy());
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#ifdef SK_DEBUG
43 void visitProxies_debugOnly(const GrOp::VisitProxyFunc& fn) const override {
44 fn(fSrcView.proxy(), GrMipMapped::kNo);
45 }
46#endif
47
48 GrSurfaceProxyView fSrcView;
49 SkIRect fSrcRect;
50 SkIPoint fDstPoint;
51};
52
53#endif
54
55