blob: 515077eb85ca487e2bfe779e14c60ffa17a13bdf [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:
Brian Salomon982127b2021-01-21 10:43:35 -050015 /**
16 * Copies pixels from srcRect in src to SkIRect::MakePtSize(dstPoint, srcRect.dimensions) in
Brian Salomon0f9f8002021-01-22 16:30:50 -050017 * dst. The src/dst share a common origin.
Brian Salomon982127b2021-01-21 10:43:35 -050018 */
Adlai Hollerd71b7b02020-06-08 15:55:00 -040019 static sk_sp<GrRenderTask> Make(GrDrawingManager*,
Brian Salomon982127b2021-01-21 10:43:35 -050020 sk_sp<GrSurfaceProxy> src,
21 SkIRect srcRect,
22 sk_sp<GrSurfaceProxy> dst,
23 SkIPoint dstPoint,
Brian Salomon0f9f8002021-01-22 16:30:50 -050024 GrSurfaceOrigin);
Greg Daniele227fe42019-08-21 13:52:24 -040025
26private:
Adlai Hollerd71b7b02020-06-08 15:55:00 -040027 GrCopyRenderTask(GrDrawingManager*,
Brian Salomon982127b2021-01-21 10:43:35 -050028 sk_sp<GrSurfaceProxy> src,
29 SkIRect srcRect,
30 sk_sp<GrSurfaceProxy> dst,
Brian Salomon0f9f8002021-01-22 16:30:50 -050031 SkIPoint dstPoint,
32 GrSurfaceOrigin);
Greg Daniele227fe42019-08-21 13:52:24 -040033
Brian Salomon982127b2021-01-21 10:43:35 -050034 bool onIsUsed(GrSurfaceProxy* proxy) const override { return proxy == fSrc.get(); }
Greg Daniele227fe42019-08-21 13:52:24 -040035 // If instantiation failed, at flush time we simply will skip doing the copy.
36 void handleInternalAllocationFailure() override {}
37 void gatherProxyIntervals(GrResourceAllocator*) const override;
Brian Salomon0f9f8002021-01-22 16:30:50 -050038 ExpectedOutcome onMakeClosed(const GrCaps&, SkIRect* targetUpdateBounds) override;
Greg Daniele227fe42019-08-21 13:52:24 -040039 bool onExecute(GrOpFlushState*) override;
40
John Stiles1e0136e2020-08-12 18:44:00 -040041#if GR_TEST_UTILS
Robert Phillips44e2c5f2020-04-14 13:00:04 -040042 const char* name() const final { return "Copy"; }
John Stiles1e0136e2020-08-12 18:44:00 -040043#endif
44#ifdef SK_DEBUG
Michael Ludwigfcdd0612019-11-25 08:34:31 -050045 void visitProxies_debugOnly(const GrOp::VisitProxyFunc& fn) const override {
Brian Salomon982127b2021-01-21 10:43:35 -050046 fn(fSrc.get(), GrMipmapped::kNo);
Chris Daltonc4b47352019-08-23 10:10:36 -060047 }
48#endif
49
Brian Salomon982127b2021-01-21 10:43:35 -050050 sk_sp<GrSurfaceProxy> fSrc;
Greg Daniele227fe42019-08-21 13:52:24 -040051 SkIRect fSrcRect;
52 SkIPoint fDstPoint;
Brian Salomon0f9f8002021-01-22 16:30:50 -050053 GrSurfaceOrigin fOrigin;
Greg Daniele227fe42019-08-21 13:52:24 -040054};
55
56#endif
57