1 /* 2 * Copyright 2021 Google Inc. 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_Buffer_DEFINED 9 #define skgpu_graphite_Buffer_DEFINED 10 11 #include "include/gpu/GpuTypes.h" 12 #include "src/gpu/graphite/Resource.h" 13 #include "src/gpu/graphite/ResourceTypes.h" 14 15 namespace skgpu::graphite { 16 17 class Buffer : public Resource { 18 public: size()19 size_t size() const { return fSize; } 20 21 // TODO(b/262249983): Separate into mapRead(), mapWrite() methods. 22 void* map(); 23 void unmap(); 24 isMapped()25 bool isMapped() const { return fMapPtr; } 26 27 protected: Buffer(const SharedContext * sharedContext,size_t size)28 Buffer(const SharedContext* sharedContext, size_t size) 29 : Resource(sharedContext, Ownership::kOwned, skgpu::Budgeted::kYes), fSize(size) {} 30 31 void* fMapPtr = nullptr; 32 33 private: 34 virtual void onMap() = 0; 35 virtual void onUnmap() = 0; 36 37 size_t fSize; 38 }; 39 40 } // namespace skgpu::graphite 41 42 #endif // skgpu_graphite_Buffer_DEFINED 43 44