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_MtlBuffer_DEFINED 9 #define skgpu_MtlBuffer_DEFINED 10 11 #include "experimental/graphite/src/Buffer.h" 12 13 #include "experimental/graphite/include/mtl/MtlTypes.h" 14 15 #import <Metal/Metal.h> 16 17 namespace skgpu::mtl { 18 19 class Gpu; 20 21 class Buffer : public skgpu::Buffer { 22 public: 23 static sk_sp<Buffer> Make(const Gpu*, size_t size, BufferType type, PrioritizeGpuReads); 24 mtlBuffer()25 id<MTLBuffer> mtlBuffer() const { return fBuffer.get(); } 26 27 private: 28 Buffer(size_t size, BufferType type, PrioritizeGpuReads, sk_cfp<id<MTLBuffer>>); 29 30 void onMap() override; 31 void onUnmap() override; 32 33 sk_cfp<id<MTLBuffer>> fBuffer; 34 }; 35 36 } // namespace skgpu::mtl 37 38 #endif // skgpu_MtlBuffer_DEFINED 39 40