1 /* 2 * Copyright 2022 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 GrBufferUpdateRenderTask_DEFINED 9 #define GrBufferUpdateRenderTask_DEFINED 10 11 #include "include/core/SkRefCnt.h" 12 #include "include/private/base/SkDebug.h" 13 #include "include/private/gpu/ganesh/GrTypesPriv.h" 14 #include "src/gpu/ganesh/GrRenderTask.h" 15 16 #include <cstddef> 17 18 class GrGpuBuffer; 19 class GrOpFlushState; 20 class GrRecordingContext; 21 class GrResourceAllocator; 22 class GrSurfaceProxy; 23 class SkData; 24 struct SkIRect; 25 26 class GrBufferUpdateRenderTask final : public GrRenderTask { 27 public: 28 static sk_sp<GrRenderTask> Make(sk_sp<SkData> src, sk_sp<GrGpuBuffer> dst, size_t dstOffset); 29 30 ~GrBufferUpdateRenderTask() override; 31 32 private: 33 GrBufferUpdateRenderTask(sk_sp<SkData> src, sk_sp<GrGpuBuffer> dst, size_t dstOffset); 34 onIsUsed(GrSurfaceProxy * proxy)35 bool onIsUsed(GrSurfaceProxy* proxy) const override { return false; } gatherProxyIntervals(GrResourceAllocator *)36 void gatherProxyIntervals(GrResourceAllocator*) const override {} // no proxies onMakeClosed(GrRecordingContext *,SkIRect * targetUpdateBounds)37 ExpectedOutcome onMakeClosed(GrRecordingContext*, SkIRect* targetUpdateBounds) override { 38 return ExpectedOutcome::kTargetUnchanged; // no target 39 } 40 bool onExecute(GrOpFlushState*) override; 41 42 #if defined(GPU_TEST_UTILS) name()43 const char* name() const final { return "BufferUpdate"; } 44 #endif 45 #ifdef SK_DEBUG visitProxies_debugOnly(const GrVisitProxyFunc &)46 void visitProxies_debugOnly(const GrVisitProxyFunc&) const override {} 47 #endif 48 49 sk_sp<SkData> fSrc; 50 sk_sp<GrGpuBuffer> fDst; 51 size_t fDstOffset; 52 }; 53 54 #endif 55