Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
GrGLBuffer Class Reference

#include <GrGLBuffer.h>

Inheritance diagram for GrGLBuffer:
GrGpuBuffer GrGpuResource GrBuffer GrIORef< GrGpuResource > SkNoncopyable

Public Member Functions

 ~GrGLBuffer () override
 
GrGLuint bufferID () const
 
void setHasAttachedToTexture ()
 
bool hasAttachedToTexture () const
 
- Public Member Functions inherited from GrGpuBuffer
GrAccessPattern accessPattern () const
 
size_t size () const final
 
void ref () const final
 
void unref () const final
 
void * map ()
 
void unmap ()
 
bool isMapped () const
 
bool isCpuBuffer () const final
 
bool clearToZero ()
 
bool updateData (const void *src, size_t offset, size_t size, bool preserve)
 
GrGpuBufferType intendedType () const
 
- Public Member Functions inherited from GrGpuResource
bool wasDestroyed () const
 
const GrDirectContextgetContext () const
 
GrDirectContextgetContext ()
 
size_t gpuMemorySize () const
 
UniqueID uniqueID () const
 
const skgpu::UniqueKeygetUniqueKey () const
 
std::string getLabel () const
 
void setLabel (std::string_view label)
 
CacheAccess cacheAccess ()
 
const CacheAccess cacheAccess () const
 
ProxyAccess proxyAccess ()
 
ResourcePriv resourcePriv ()
 
const ResourcePriv resourcePriv () const
 
virtual void dumpMemoryStatistics (SkTraceMemoryDump *traceMemoryDump) const
 
virtual const char * getResourceType () const =0
 
- Public Member Functions inherited from GrIORef< GrGpuResource >
bool unique () const
 
void ref () const
 
void unref () const
 
void refCommandBuffer () const
 
void unrefCommandBuffer () const
 
- Public Member Functions inherited from SkNoncopyable
 SkNoncopyable ()=default
 
 SkNoncopyable (SkNoncopyable &&)=default
 
SkNoncopyableoperator= (SkNoncopyable &&)=default
 
- Public Member Functions inherited from GrBuffer
 GrBuffer (const GrBuffer &)=delete
 
GrBufferoperator= (const GrBuffer &)=delete
 
virtual ~GrBuffer ()=default
 
virtual void ref () const =0
 
virtual void unref () const =0
 
virtual size_t size () const =0
 
virtual bool isCpuBuffer () const =0
 

Static Public Member Functions

static sk_sp< GrGLBufferMake (GrGLGpu *, size_t size, GrGpuBufferType intendedType, GrAccessPattern)
 
- Static Public Member Functions inherited from GrGpuBuffer
static void ComputeScratchKeyForDynamicBuffer (size_t size, GrGpuBufferType, skgpu::ScratchKey *)
 
- Static Public Member Functions inherited from GrGpuResource
static uint32_t CreateUniqueID ()
 

Protected Member Functions

 GrGLBuffer (GrGLGpu *, size_t size, GrGpuBufferType intendedType, GrAccessPattern, std::string_view label)
 
void onAbandon () override
 
void onRelease () override
 
void setMemoryBacking (SkTraceMemoryDump *traceMemoryDump, const SkString &dumpName) const override
 
- Protected Member Functions inherited from GrGpuBuffer
 GrGpuBuffer (GrGpu *, size_t sizeInBytes, GrGpuBufferType, GrAccessPattern, std::string_view label)
 
- Protected Member Functions inherited from GrGpuResource
void registerWithCache (skgpu::Budgeted)
 
void registerWithCacheWrapped (GrWrapCacheable)
 
 GrGpuResource (GrGpu *, std::string_view label)
 
virtual ~GrGpuResource ()
 
GrGpugetGpu () const
 
virtual void onRelease ()
 
virtual void onAbandon ()
 
virtual void setMemoryBacking (SkTraceMemoryDump *, const SkString &) const
 
SkString getResourceName () const
 
void dumpMemoryStatisticsPriv (SkTraceMemoryDump *traceMemoryDump, const SkString &resourceName, const char *type, size_t size) const
 
- Protected Member Functions inherited from GrIORef< GrGpuResource >
 GrIORef ()
 
bool internalHasRef () const
 
bool internalHasNoCommandBufferUsages () const
 
void addInitialRef () const
 
- Protected Member Functions inherited from GrBuffer
 GrBuffer ()=default
 

Additional Inherited Members

- Public Types inherited from GrIORef< GrGpuResource >
enum  LastRemovedRef
 
- Protected Types inherited from GrGpuBuffer
enum class  MapType { kRead , kWriteDiscard }
 
- Protected Attributes inherited from GrGpuBuffer
void * fMapPtr
 

Detailed Description

Definition at line 17 of file GrGLBuffer.h.

Constructor & Destructor Documentation

◆ ~GrGLBuffer()

GrGLBuffer::~GrGLBuffer ( )
inlineoverride

Definition at line 24 of file GrGLBuffer.h.

24 {
25 // either release or abandon should have been called by the owner of this object.
26 SkASSERT(0 == fBufferID);
27 }
#define SkASSERT(cond)
Definition: SkAssert.h:116

◆ GrGLBuffer()

GrGLBuffer::GrGLBuffer ( GrGLGpu gpu,
size_t  size,
GrGpuBufferType  intendedType,
GrAccessPattern  accessPattern,
std::string_view  label 
)
protected

Definition at line 103 of file GrGLBuffer.cpp.

108 : INHERITED(gpu, size, intendedType, accessPattern, label)
109 , fIntendedType(intendedType)
110 , fBufferID(0)
112 , fHasAttachedToTexture(false) {
113 GL_CALL(GenBuffers(1, &fBufferID));
114 if (fBufferID) {
115 GrGLenum target = gpu->bindBuffer(fIntendedType, this);
116 GrGLenum error = GL_ALLOC_CALL(this->glGpu(), BufferData(target,
118 nullptr,
119 fUsage));
120 if (error != GR_GL_NO_ERROR) {
121 GL_CALL(DeleteBuffers(1, &fBufferID));
122 fBufferID = 0;
123 }
124 }
126 if (!fBufferID) {
128 }
129}
#define GL_ALLOC_CALL(gpu, call)
Definition: GrGLBuffer.cpp:19
#define GL_CALL(X)
Definition: GrGLBuffer.cpp:16
static GrGLenum gr_to_gl_access_pattern(GrGpuBufferType bufferType, GrAccessPattern accessPattern, const GrGLCaps &caps)
Definition: GrGLBuffer.cpp:53
#define GR_GL_NO_ERROR
Definition: GrGLDefines.h:175
unsigned int GrGLenum
Definition: GrGLTypes.h:102
signed long int GrGLsizeiptr
Definition: GrGLTypes.h:126
const GrGLCaps & glCaps() const
Definition: GrGLGpu.h:108
GrGLenum bindBuffer(GrGpuBufferType type, const GrBuffer *)
Definition: GrGLGpu.cpp:2154
size_t size() const final
Definition: GrGpuBuffer.h:34
GrGpuBufferType intendedType() const
Definition: GrGpuBuffer.h:99
GrAccessPattern accessPattern() const
Definition: GrGpuBuffer.h:32
void registerWithCache(skgpu::Budgeted)
ResourcePriv resourcePriv()
const uint8_t uint32_t uint32_t GError ** error
uint32_t * target

Member Function Documentation

◆ bufferID()

GrGLuint GrGLBuffer::bufferID ( ) const
inline

Definition at line 29 of file GrGLBuffer.h.

29{ return fBufferID; }

◆ hasAttachedToTexture()

bool GrGLBuffer::hasAttachedToTexture ( ) const
inline

Definition at line 32 of file GrGLBuffer.h.

32{ return fHasAttachedToTexture; }

◆ Make()

sk_sp< GrGLBuffer > GrGLBuffer::Make ( GrGLGpu gpu,
size_t  size,
GrGpuBufferType  intendedType,
GrAccessPattern  accessPattern 
)
static

Definition at line 31 of file GrGLBuffer.cpp.

34 {
38 return nullptr;
39 }
40
42 /*label=*/"MakeGlBuffer"));
43 if (0 == buffer->bufferID()) {
44 return nullptr;
45 }
46 return buffer;
47}
GrGLBuffer(GrGLGpu *, size_t size, GrGpuBufferType intendedType, GrAccessPattern, std::string_view label)
Definition: GrGLBuffer.cpp:103
TransferBufferType transferBufferType() const
What type of transfer buffer is supported?
Definition: GrGLCaps.h:329
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126

◆ onAbandon()

void GrGLBuffer::onAbandon ( )
overrideprotectedvirtual

Overridden to abandon any internal handles, ptrs, etc to backend API resources. This may be called when the underlying 3D context is no longer valid and so no backend API calls should be made.

Reimplemented from GrGpuResource.

Definition at line 155 of file GrGLBuffer.cpp.

155 {
156 fBufferID = 0;
157 fMapPtr = nullptr;
159}
void * fMapPtr
Definition: GrGpuBuffer.h:119
virtual void onAbandon()

◆ onRelease()

void GrGLBuffer::onRelease ( )
overrideprotectedvirtual

Overridden to free GPU resources in the backend API.

Reimplemented from GrGpuResource.

Definition at line 140 of file GrGLBuffer.cpp.

140 {
141 TRACE_EVENT0("skia.gpu", TRACE_FUNC);
142
143 if (!this->wasDestroyed()) {
144 // make sure we've not been abandoned or already released
145 if (fBufferID) {
146 GL_CALL(DeleteBuffers(1, &fBufferID));
147 fBufferID = 0;
148 }
149 fMapPtr = nullptr;
150 }
151
153}
#define TRACE_FUNC
Definition: SkTraceEvent.h:30
bool wasDestroyed() const
virtual void onRelease()
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:131

◆ setHasAttachedToTexture()

void GrGLBuffer::setHasAttachedToTexture ( )
inline

Definition at line 31 of file GrGLBuffer.h.

31{ fHasAttachedToTexture = true; }

◆ setMemoryBacking()

void GrGLBuffer::setMemoryBacking ( SkTraceMemoryDump ,
const SkString  
) const
overrideprotectedvirtual

Allows subclasses to add additional backing information to the SkTraceMemoryDump.

Reimplemented from GrGpuResource.

Definition at line 288 of file GrGLBuffer.cpp.

289 {
290 SkString buffer_id;
291 buffer_id.appendU32(this->bufferID());
292 traceMemoryDump->setMemoryBacking(dumpName.c_str(), "gl_buffer", buffer_id.c_str());
293}
GrGLuint bufferID() const
Definition: GrGLBuffer.h:29
void appendU32(uint32_t value)
Definition: SkString.h:210
const char * c_str() const
Definition: SkString.h:133

The documentation for this class was generated from the following files: