Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
GrGLVertexArray Class Reference

#include <GrGLVertexArray.h>

Public Member Functions

 GrGLVertexArray (GrGLint id, int attribCount)
 
GrGLAttribArrayStatebind (GrGLGpu *)
 
GrGLAttribArrayStatebindWithIndexBuffer (GrGLGpu *gpu, const GrBuffer *indexBuffer)
 
GrGLuint arrayID () const
 
void invalidateCachedState ()
 

Detailed Description

This class represents an OpenGL vertex array object. It manages the lifetime of the vertex array and is used to track the state of the vertex array to avoid redundant GL calls.

Definition at line 102 of file GrGLVertexArray.h.

Constructor & Destructor Documentation

◆ GrGLVertexArray()

GrGLVertexArray::GrGLVertexArray ( GrGLint  id,
int  attribCount 
)

Definition at line 193 of file GrGLVertexArray.cpp.

194 : fID(id)
195 , fAttribArrays(attribCount)
196 , fIndexBufferUniqueID(SK_InvalidUniqueID) {
197}
static constexpr uint32_t SK_InvalidUniqueID
Definition: SkTypes.h:196

Member Function Documentation

◆ arrayID()

GrGLuint GrGLVertexArray::arrayID ( ) const
inline

Definition at line 119 of file GrGLVertexArray.h.

119{ return fID; }

◆ bind()

GrGLAttribArrayState * GrGLVertexArray::bind ( GrGLGpu gpu)

Binds this vertex array. If the ID has been deleted or abandoned then nullptr is returned. Otherwise, the GrGLAttribArrayState that is tracking this vertex array's attrib bindings is returned.

Definition at line 199 of file GrGLVertexArray.cpp.

199 {
200 if (0 == fID) {
201 return nullptr;
202 }
203 gpu->bindVertexArray(fID);
204 return &fAttribArrays;
205}
void bindVertexArray(GrGLuint id)
Definition: GrGLGpu.h:117

◆ bindWithIndexBuffer()

GrGLAttribArrayState * GrGLVertexArray::bindWithIndexBuffer ( GrGLGpu gpu,
const GrBuffer indexBuffer 
)

This is a version of the above function that also binds an index buffer to the vertex array object.

Definition at line 207 of file GrGLVertexArray.cpp.

207 {
208 GrGLAttribArrayState* state = this->bind(gpu);
209 if (!state) {
210 return nullptr;
211 }
212 if (ibuff->isCpuBuffer()) {
213 GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER, 0));
214 } else {
215 const GrGLBuffer* glBuffer = static_cast<const GrGLBuffer*>(ibuff);
216 if (fIndexBufferUniqueID != glBuffer->uniqueID()) {
217 GR_GL_CALL(gpu->glInterface(),
218 BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER, glBuffer->bufferID()));
219 fIndexBufferUniqueID = glBuffer->uniqueID();
220 }
221 }
222 return state;
223}
#define GR_GL_ELEMENT_ARRAY_BUFFER
Definition: GrGLDefines.h:111
#define GR_GL_CALL(IFACE, X)
Definition: GrGLUtil.h:381
GrGLuint bufferID() const
Definition: GrGLBuffer.h:29
const GrGLInterface * glInterface() const
Definition: GrGLGpu.h:103
GrGLAttribArrayState * bind(GrGLGpu *)
UniqueID uniqueID() const
AtkStateType state

◆ invalidateCachedState()

void GrGLVertexArray::invalidateCachedState ( )

Definition at line 225 of file GrGLVertexArray.cpp.

225 {
226 fAttribArrays.invalidate();
227 fIndexBufferUniqueID.makeInvalid();
228}

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