Greg Daniel | bbfec9d | 2019-08-20 10:56:51 -0400 | [diff] [blame] | 1 | /* |
| 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 | |
| 13 | class GrTransferFromRenderTask final : public GrRenderTask { |
| 14 | public: |
| 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) |
| 21 | : GrRenderTask(nullptr) |
| 22 | , fSrcProxy(std::move(srcProxy)) |
| 23 | , fSrcRect(srcRect) |
| 24 | , fSurfaceColorType(surfaceColorType) |
| 25 | , fDstColorType(dstColorType) |
| 26 | , fDstBuffer(std::move(dstBuffer)) |
| 27 | , fDstOffset(dstOffset) {} |
| 28 | |
| 29 | private: |
| 30 | void onPrepare(GrOpFlushState*) override {} |
| 31 | bool onIsUsed(GrSurfaceProxy* proxy) const override { |
| 32 | SkASSERT(!fTarget); |
| 33 | return proxy == fSrcProxy.get(); |
| 34 | } |
| 35 | // If fSrcProxy is uninstantiated at flush time we simply will skip doing the transfer. |
| 36 | void handleInternalAllocationFailure() override {} |
| 37 | void gatherProxyIntervals(GrResourceAllocator*) const override; |
Chris Dalton | aa3cbb8 | 2019-08-21 00:01:21 -0600 | [diff] [blame^] | 38 | |
| 39 | ExpectedOutcome onMakeClosed(const GrCaps&) override { |
| 40 | return ExpectedOutcome::kTargetUnchanged; |
| 41 | } |
| 42 | |
Greg Daniel | bbfec9d | 2019-08-20 10:56:51 -0400 | [diff] [blame] | 43 | bool onExecute(GrOpFlushState*) override; |
| 44 | |
| 45 | sk_sp<GrSurfaceProxy> fSrcProxy; |
| 46 | SkIRect fSrcRect; |
| 47 | GrColorType fSurfaceColorType; |
| 48 | GrColorType fDstColorType; |
| 49 | sk_sp<GrGpuBuffer> fDstBuffer; |
| 50 | size_t fDstOffset; |
| 51 | |
| 52 | }; |
| 53 | |
| 54 | #endif |
| 55 | |