blob: 4ecd3c7f1dccd8b0cec1543f8983deaee583ebc7 [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:
Adlai Hollerd71b7b02020-06-08 15:55:00 -040015 static sk_sp<GrRenderTask> Make(GrDrawingManager*,
16 GrSurfaceProxyView srcView,
Greg Daniele227fe42019-08-21 13:52:24 -040017 const SkIRect& srcRect,
Greg Daniel16f5c652019-10-29 11:26:01 -040018 GrSurfaceProxyView dstView,
Brian Salomone4bce012019-09-20 15:34:23 -040019 const SkIPoint& dstPoint,
20 const GrCaps*);
Greg Daniele227fe42019-08-21 13:52:24 -040021
22private:
Adlai Hollerd71b7b02020-06-08 15:55:00 -040023 GrCopyRenderTask(GrDrawingManager*,
24 GrSurfaceProxyView srcView,
Greg Daniele227fe42019-08-21 13:52:24 -040025 const SkIRect& srcRect,
Greg Daniel16f5c652019-10-29 11:26:01 -040026 GrSurfaceProxyView dstView,
Greg Daniele227fe42019-08-21 13:52:24 -040027 const SkIPoint& dstPoint);
28
Greg Daniele227fe42019-08-21 13:52:24 -040029 bool onIsUsed(GrSurfaceProxy* proxy) const override {
Greg Daniel16f5c652019-10-29 11:26:01 -040030 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
Robert Phillips44e2c5f2020-04-14 13:00:04 -040043 const char* name() const final { return "Copy"; }
Michael Ludwigfcdd0612019-11-25 08:34:31 -050044 void visitProxies_debugOnly(const GrOp::VisitProxyFunc& fn) const override {
Greg Daniel16f5c652019-10-29 11:26:01 -040045 fn(fSrcView.proxy(), GrMipMapped::kNo);
Chris Daltonc4b47352019-08-23 10:10:36 -060046 }
47#endif
48
Greg Daniel16f5c652019-10-29 11:26:01 -040049 GrSurfaceProxyView fSrcView;
Greg Daniele227fe42019-08-21 13:52:24 -040050 SkIRect fSrcRect;
51 SkIPoint fDstPoint;
52};
53
54#endif
55