blob: 7577ffc7e8bc31f9acf6469c1b73ac85fde4c0aa [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:
Greg Daniel16f5c652019-10-29 11:26:01 -040015 static sk_sp<GrRenderTask> Make(GrSurfaceProxyView srcView,
Greg Daniele227fe42019-08-21 13:52:24 -040016 const SkIRect& srcRect,
Greg Daniel16f5c652019-10-29 11:26:01 -040017 GrSurfaceProxyView dstView,
Brian Salomone4bce012019-09-20 15:34:23 -040018 const SkIPoint& dstPoint,
19 const GrCaps*);
Greg Daniele227fe42019-08-21 13:52:24 -040020
21private:
Greg Daniel16f5c652019-10-29 11:26:01 -040022 GrCopyRenderTask(GrSurfaceProxyView srcView,
Greg Daniele227fe42019-08-21 13:52:24 -040023 const SkIRect& srcRect,
Greg Daniel16f5c652019-10-29 11:26:01 -040024 GrSurfaceProxyView dstView,
Greg Daniele227fe42019-08-21 13:52:24 -040025 const SkIPoint& dstPoint);
26
Greg Daniele227fe42019-08-21 13:52:24 -040027 bool onIsUsed(GrSurfaceProxy* proxy) const override {
Greg Daniel16f5c652019-10-29 11:26:01 -040028 // This case should be handled by GrRenderTask.
29 SkASSERT(proxy != fTargetView.proxy());
30 return proxy == fSrcView.proxy();
Greg Daniele227fe42019-08-21 13:52:24 -040031 }
32 // If instantiation failed, at flush time we simply will skip doing the copy.
33 void handleInternalAllocationFailure() override {}
34 void gatherProxyIntervals(GrResourceAllocator*) const override;
Chris Dalton16a33c62019-09-24 22:19:17 -060035 ExpectedOutcome onMakeClosed(const GrCaps&, SkIRect* targetUpdateBounds) override {
36 targetUpdateBounds->setXYWH(fDstPoint.x(), fDstPoint.y(), fSrcRect.width(),
37 fSrcRect.height());
Greg Daniele227fe42019-08-21 13:52:24 -040038 return ExpectedOutcome::kTargetDirty;
39 }
40 bool onExecute(GrOpFlushState*) override;
41
Chris Daltonc4b47352019-08-23 10:10:36 -060042#ifdef SK_DEBUG
Michael Ludwigfcdd0612019-11-25 08:34:31 -050043 void visitProxies_debugOnly(const GrOp::VisitProxyFunc& fn) const override {
Greg Daniel16f5c652019-10-29 11:26:01 -040044 fn(fSrcView.proxy(), GrMipMapped::kNo);
Chris Daltonc4b47352019-08-23 10:10:36 -060045 }
46#endif
47
Greg Daniel16f5c652019-10-29 11:26:01 -040048 GrSurfaceProxyView fSrcView;
Greg Daniele227fe42019-08-21 13:52:24 -040049 SkIRect fSrcRect;
50 SkIPoint fDstPoint;
51};
52
53#endif
54