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 skgpu_graphite_ClearBuffersTask_DEFINED 9 #define skgpu_graphite_ClearBuffersTask_DEFINED 10 11 #include "src/gpu/graphite/Buffer.h" 12 #include "src/gpu/graphite/Task.h" 13 14 #include <vector> 15 16 namespace skgpu::graphite { 17 18 class Buffer; 19 20 /** 21 * Represents a buffer region that will be cleared. A ClearBuffersTask does not take a reference to 22 * the buffer it clears. A higher layer is responsible for managing the lifetime and usage refs of 23 * the buffer. 24 */ 25 struct ClearBufferInfo { 26 const Buffer* fBuffer; 27 size_t fOffset = 0; 28 size_t fSize = 0; 29 }; 30 31 /** 32 * Task that clears a region of a list of buffers to 0. 33 */ 34 class ClearBuffersTask final : public Task { 35 public: 36 static sk_sp<ClearBuffersTask> Make(std::vector<ClearBufferInfo>); 37 ~ClearBuffersTask() override; 38 prepareResources(ResourceProvider *,const RuntimeEffectDictionary *)39 bool prepareResources(ResourceProvider*, const RuntimeEffectDictionary*) override { 40 return true; 41 } 42 43 bool addCommands(Context*, CommandBuffer*, ReplayTargetData) override; 44 45 private: ClearBuffersTask(std::vector<ClearBufferInfo> clearList)46 explicit ClearBuffersTask(std::vector<ClearBufferInfo> clearList) 47 : fClearList(std::move(clearList)) {} 48 49 std::vector<ClearBufferInfo> fClearList; 50 }; 51 52 } // namespace skgpu::graphite 53 54 #endif // skgpu_graphite_ClearBuffersTask_DEFINED 55