xref: /aosp_15_r20/external/skia/src/gpu/graphite/mtl/MtlBuffer.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
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_MtlBuffer_DEFINED
9 #define skgpu_graphite_MtlBuffer_DEFINED
10 
11 #include "include/core/SkRefCnt.h"
12 #include "include/gpu/graphite/mtl/MtlGraphiteTypes.h"
13 #include "src/gpu/graphite/Buffer.h"
14 
15 #import <Metal/Metal.h>
16 
17 namespace skgpu::graphite {
18 class MtlSharedContext;
19 
20 class MtlBuffer : public Buffer {
21 public:
22     static sk_sp<Buffer> Make(const MtlSharedContext*, size_t size, BufferType type, AccessPattern);
23 
mtlBuffer()24     id<MTLBuffer> mtlBuffer() const { return fBuffer.get(); }
25 
26 private:
27     MtlBuffer(const MtlSharedContext*, size_t size, sk_cfp<id<MTLBuffer>>);
28 
29     void onMap() override;
30     void onUnmap() override;
31 
32     void freeGpuData() override;
33 
34     void setBackendLabel(char const* label) override;
35 
36     sk_cfp<id<MTLBuffer>> fBuffer;
37 };
38 
39 } // namespace skgpu::graphite
40 
41 #endif // skgpu_graphite_MtlBuffer_DEFINED
42 
43