blob: d8f6c1287df498771865d6a8fd3b8bb4425055ee [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 {
Greg Daniel16f5c652019-10-29 11:26:01 -040031 SkASSERT(!fTargetView.proxy());
Greg Danielbbfec9d2019-08-20 10:56:51 -040032 return proxy == fSrcProxy.get();
33 }
34 // If fSrcProxy is uninstantiated at flush time we simply will skip doing the transfer.
35 void handleInternalAllocationFailure() override {}
36 void gatherProxyIntervals(GrResourceAllocator*) const override;
Chris Daltonaa3cbb82019-08-21 00:01:21 -060037
Chris Dalton16a33c62019-09-24 22:19:17 -060038 ExpectedOutcome onMakeClosed(const GrCaps&, SkIRect*) override {
Chris Daltonaa3cbb82019-08-21 00:01:21 -060039 return ExpectedOutcome::kTargetUnchanged;
40 }
41
Greg Danielbbfec9d2019-08-20 10:56:51 -040042 bool onExecute(GrOpFlushState*) override;
43
Chris Daltonc4b47352019-08-23 10:10:36 -060044#ifdef SK_DEBUG
Greg Danieldcf9ca12019-08-27 14:30:21 -040045 void visitProxies_debugOnly(const VisitSurfaceProxyFunc& fn) const override {
Chris Daltonc4b47352019-08-23 10:10:36 -060046 fn(fSrcProxy.get(), GrMipMapped::kNo);
47 }
48#endif
49
Greg Danielbbfec9d2019-08-20 10:56:51 -040050 sk_sp<GrSurfaceProxy> fSrcProxy;
51 SkIRect fSrcRect;
52 GrColorType fSurfaceColorType;
53 GrColorType fDstColorType;
54 sk_sp<GrGpuBuffer> fDstBuffer;
55 size_t fDstOffset;
56
57};
58
59#endif
60