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: GrTransferFromRenderTask(sk_sp<GrSurfaceProxy> srcProxy,const SkIRect & srcRect,GrColorType surfaceColorType,GrColorType dstColorType,sk_sp<GrGpuBuffer> dstBuffer,size_t dstOffset)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() 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: onIsUsed(GrSurfaceProxy * proxy)30 bool onIsUsed(GrSurfaceProxy* proxy) const override { 31 SkASSERT(0 == this->numTargets()); 32 return proxy == fSrcProxy.get(); 33 } 34 void gatherProxyIntervals(GrResourceAllocator*) const override; 35 onMakeClosed(GrRecordingContext *,SkIRect *)36 ExpectedOutcome onMakeClosed(GrRecordingContext*, SkIRect*) override { 37 return ExpectedOutcome::kTargetUnchanged; 38 } 39 40 bool onExecute(GrOpFlushState*) override; 41 42 #if GR_TEST_UTILS name()43 const char* name() const final { return "TransferFrom"; } 44 #endif 45 #ifdef SK_DEBUG visitProxies_debugOnly(const GrVisitProxyFunc & func)46 void visitProxies_debugOnly(const GrVisitProxyFunc& func) const override { 47 func(fSrcProxy.get(), GrMipmapped::kNo); 48 } 49 #endif 50 51 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 62