blob: cdcdb29b746e866c8d8b6198ae5f013d98351e1c [file] [log] [blame]
Greg Danielbbfec9d2019-08-20 10:56:51 -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 GrTransferFromRenderTask_DEFINED
9#define GrTransferFromRenderTask_DEFINED
10
11#include "src/gpu/GrRenderTask.h"
12
13class GrTransferFromRenderTask final : public GrRenderTask {
14public:
15 GrTransferFromRenderTask(sk_sp<GrSurfaceProxy> srcProxy,
16 const SkIRect& srcRect,
17 GrColorType surfaceColorType,
18 GrColorType dstColorType,
19 sk_sp<GrGpuBuffer> dstBuffer,
20 size_t dstOffset)
Greg Daniel16f5c652019-10-29 11:26:01 -040021 : GrRenderTask()
Greg Danielbbfec9d2019-08-20 10:56:51 -040022 , fSrcProxy(std::move(srcProxy))
23 , fSrcRect(srcRect)
24 , fSurfaceColorType(surfaceColorType)
25 , fDstColorType(dstColorType)
26 , fDstBuffer(std::move(dstBuffer))
27 , fDstOffset(dstOffset) {}
28
29private:
Greg Danielbbfec9d2019-08-20 10:56:51 -040030 bool onIsUsed(GrSurfaceProxy* proxy) const override {
Adlai Holler33d569e2020-06-16 14:30:08 -040031 SkASSERT(0 == this->numTargets());
Greg Danielbbfec9d2019-08-20 10:56:51 -040032 return proxy == fSrcProxy.get();
33 }
Greg Danielbbfec9d2019-08-20 10:56:51 -040034 void gatherProxyIntervals(GrResourceAllocator*) const override;
Chris Daltonaa3cbb82019-08-21 00:01:21 -060035
Chris Daltonaa938ce2021-06-23 18:13:59 -060036 ExpectedOutcome onMakeClosed(GrRecordingContext*, SkIRect*) override {
Chris Daltonaa3cbb82019-08-21 00:01:21 -060037 return ExpectedOutcome::kTargetUnchanged;
38 }
39
Greg Danielbbfec9d2019-08-20 10:56:51 -040040 bool onExecute(GrOpFlushState*) override;
41
John Stiles1e0136e2020-08-12 18:44:00 -040042#if GR_TEST_UTILS
Robert Phillips44e2c5f2020-04-14 13:00:04 -040043 const char* name() const final { return "TransferFrom"; }
John Stiles1e0136e2020-08-12 18:44:00 -040044#endif
45#ifdef SK_DEBUG
Robert Phillips294723d2021-06-17 09:23:58 -040046 void visitProxies_debugOnly(const GrVisitProxyFunc& func) const override {
47 func(fSrcProxy.get(), GrMipmapped::kNo);
Chris Daltonc4b47352019-08-23 10:10:36 -060048 }
49#endif
50
Greg Danielbbfec9d2019-08-20 10:56:51 -040051 sk_sp<GrSurfaceProxy> fSrcProxy;
52 SkIRect fSrcRect;
53 GrColorType fSurfaceColorType;
54 GrColorType fDstColorType;
55 sk_sp<GrGpuBuffer> fDstBuffer;
56 size_t fDstOffset;
57
58};
59
60#endif
61