Flutter Engine
The Flutter Engine
GrGLBuffer.h
Go to the documentation of this file.
1/*
2 * Copyright 2016 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 GrGLBuffer_DEFINED
9#define GrGLBuffer_DEFINED
10
13
14class GrGLGpu;
15class GrGLCaps;
16
17class GrGLBuffer : public GrGpuBuffer {
18public:
20 size_t size,
23
24 ~GrGLBuffer() override {
25 // either release or abandon should have been called by the owner of this object.
26 SkASSERT(0 == fBufferID);
27 }
28
29 GrGLuint bufferID() const { return fBufferID; }
30
31 void setHasAttachedToTexture() { fHasAttachedToTexture = true; }
32 bool hasAttachedToTexture() const { return fHasAttachedToTexture; }
33
34protected:
36 size_t size,
39 std::string_view label);
40
41 void onAbandon() override;
42 void onRelease() override;
43 void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump,
44 const SkString& dumpName) const override;
45
46private:
47 GrGLGpu* glGpu() const;
48 const GrGLCaps& glCaps() const;
49
50 void onMap(MapType) override;
51 void onUnmap(MapType) override;
52 bool onClearToZero() override;
53 bool onUpdateData(const void* src, size_t offset, size_t size, bool preserve) override;
54
55 void onSetLabel() override;
56
57 GrGpuBufferType fIntendedType;
58 GrGLuint fBufferID;
59 GrGLenum fUsage;
60 bool fHasAttachedToTexture;
61
62 using INHERITED = GrGpuBuffer;
63};
64
65#endif
unsigned int GrGLuint
Definition: GrGLTypes.h:113
unsigned int GrGLenum
Definition: GrGLTypes.h:102
GrGpuBufferType
Definition: GrTypesPriv.h:411
GrAccessPattern
Definition: GrTypesPriv.h:424
#define SkASSERT(cond)
Definition: SkAssert.h:116
static sk_sp< GrGLBuffer > Make(GrGLGpu *, size_t size, GrGpuBufferType intendedType, GrAccessPattern)
Definition: GrGLBuffer.cpp:31
void onAbandon() override
Definition: GrGLBuffer.cpp:155
~GrGLBuffer() override
Definition: GrGLBuffer.h:24
void setMemoryBacking(SkTraceMemoryDump *traceMemoryDump, const SkString &dumpName) const override
Definition: GrGLBuffer.cpp:288
void setHasAttachedToTexture()
Definition: GrGLBuffer.h:31
GrGLuint bufferID() const
Definition: GrGLBuffer.h:29
bool hasAttachedToTexture() const
Definition: GrGLBuffer.h:32
void onRelease() override
Definition: GrGLBuffer.cpp:140
GrGLBuffer(GrGLGpu *, size_t size, GrGpuBufferType intendedType, GrAccessPattern, std::string_view label)
Definition: GrGLBuffer.cpp:103
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
SeparatedVector2 offset