blob: 6bfb4db62ff87443ccdb635efedef1f37271307c [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
Adlai Hollere9ea4142021-04-27 14:31:56 -040034 void onMakeSkippable() override { fSrc.reset(); }
Brian Salomon982127b2021-01-21 10:43:35 -050035 bool onIsUsed(GrSurfaceProxy* proxy) const override { return proxy == fSrc.get(); }
Greg Daniele227fe42019-08-21 13:52:24 -040036 void gatherProxyIntervals(GrResourceAllocator*) const override;
Chris Daltonaa938ce2021-06-23 18:13:59 -060037 ExpectedOutcome onMakeClosed(GrRecordingContext*, SkIRect* targetUpdateBounds) override;
Greg Daniele227fe42019-08-21 13:52:24 -040038 bool onExecute(GrOpFlushState*) override;
39
John Stiles1e0136e2020-08-12 18:44:00 -040040#if GR_TEST_UTILS
Robert Phillips44e2c5f2020-04-14 13:00:04 -040041 const char* name() const final { return "Copy"; }
John Stiles1e0136e2020-08-12 18:44:00 -040042#endif
43#ifdef SK_DEBUG
Robert Phillips294723d2021-06-17 09:23:58 -040044 void visitProxies_debugOnly(const GrVisitProxyFunc& func) const override {
45 func(fSrc.get(), GrMipmapped::kNo);
Chris Daltonc4b47352019-08-23 10:10:36 -060046 }
47#endif
48
Brian Salomon982127b2021-01-21 10:43:35 -050049 sk_sp<GrSurfaceProxy> fSrc;
Greg Daniele227fe42019-08-21 13:52:24 -040050 SkIRect fSrcRect;
51 SkIPoint fDstPoint;
Brian Salomon0f9f8002021-01-22 16:30:50 -050052 GrSurfaceOrigin fOrigin;
Greg Daniele227fe42019-08-21 13:52:24 -040053};
54
55#endif
56