Flutter Engine
The Flutter Engine
GrMtlBuffer.h
Go to the documentation of this file.
1/*
2 * Copyright 2018 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 GrMtlBuffer_DEFINED
9#define GrMtlBuffer_DEFINED
10
13
14#import <Metal/Metal.h>
15
16class GrMtlCaps;
17class GrMtlGpu;
18
19class GrMtlBuffer: public GrGpuBuffer {
20public:
22 size_t size,
25
26 ~GrMtlBuffer() override;
27
28 id<MTLBuffer> mtlBuffer() const { return fMtlBuffer; }
29
30protected:
32 size_t size,
35 std::string_view label);
36
37 void onAbandon() override;
38 void onRelease() override;
39
40private:
41 GrMtlGpu* mtlGpu() const;
42
43 void onMap(MapType) override;
44 bool onClearToZero() override;
45 void onUnmap(MapType) override;
46 bool onUpdateData(const void* src, size_t offset, size_t size, bool preserve) override;
47
48 void internalMap();
49 void internalUnmap(size_t writtenOffset, size_t writtenSize);
50
51#ifdef SK_DEBUG
52 void validate() const;
53#endif
54
55 void onSetLabel() override;
56
57 bool fIsDynamic;
58 id<MTLBuffer> fMtlBuffer;
59
60 using INHERITED = GrGpuBuffer;
61};
62
63#endif
GrGpuBufferType
Definition: GrTypesPriv.h:411
GrAccessPattern
Definition: GrTypesPriv.h:424
size_t size() const final
Definition: GrGpuBuffer.h:34
GrGpuBuffer(GrGpu *, size_t sizeInBytes, GrGpuBufferType, GrAccessPattern, std::string_view label)
Definition: GrGpuBuffer.cpp:19
GrGpuBufferType intendedType() const
Definition: GrGpuBuffer.h:99
GrMtlBuffer(GrMtlGpu *, size_t size, GrGpuBufferType intendedType, GrAccessPattern, std::string_view label)
Definition: GrMtlBuffer.mm:49
void onRelease() override
Definition: GrMtlBuffer.mm:142
~GrMtlBuffer() override
Definition: GrMtlBuffer.mm:81
static sk_sp< GrMtlBuffer > Make(GrMtlGpu *, size_t size, GrGpuBufferType intendedType, GrAccessPattern)
Definition: GrMtlBuffer.mm:38
void onAbandon() override
Definition: GrMtlBuffer.mm:135
id< MTLBuffer > mtlBuffer() const
Definition: GrMtlBuffer.h:28
SeparatedVector2 offset