Dali 3D User Interface Engine
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
Dali::Internal::GpuBuffer Class Reference

Used to create and update a GPU memory buffer. More...

#include <gpu-buffer.h>

Collaboration diagram for Dali::Internal::GpuBuffer:
Collaboration graph
[legend]

Public Types

enum  Target { ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER, TRANSFORM_FEEDBACK_BUFFER }
 Enum to encapsulate the GL buffer type. More...
 
enum  Usage { STREAM_DRAW, STATIC_DRAW, DYNAMIC_DRAW }
 Enum to encapsulate the GL draw mode. More...
 

Public Member Functions

 GpuBuffer (Context &context)
 constructor More...
 
 ~GpuBuffer ()
 Destructor, non virtual as no virtual methods or inheritance. More...
 
void UpdateDataBuffer (GLsizeiptr size, const GLvoid *data, Usage usage, Target target)
 Creates or updates a buffer object and binds it to the target. More...
 
void Bind (Target target) const
 Bind the buffer object to the target Will assert if the buffer size is zero. More...
 
bool BufferIsValid () const
 
GLsizeiptr GetBufferSize () const
 Get the size of the buffer. More...
 
void GlContextDestroyed ()
 Needs to be called when GL context is destroyed. More...
 

Private Member Functions

void BindNoChecks (GLuint bufferId) const
 Perfoms a bind without checking the size of the buffer. More...
 

Private Attributes

ContextmContext
 dali drawing context More...
 
GLsizeiptr mCapacity
 buffer capacity More...
 
GLsizeiptr mSize
 buffer size More...
 
GLuint mBufferId
 buffer object name(id) More...
 
bool mBufferCreated:1
 whether buffer has been created More...
 

Detailed Description

Used to create and update a GPU memory buffer.

The buffer can be used for storing vertex data, index arrays (indices) or pixel data (PBO).

The buffer allows data to be stored in high-performance graphics memory on the server side and promotes efficient data transfer.

Definition at line 40 of file gpu-buffer.h.

Member Enumeration Documentation

Enum to encapsulate the GL buffer type.

This is to avoid having to store a whole int for type

Enumerator
ARRAY_BUFFER 

GL_ARRAY_BUFFER.

ELEMENT_ARRAY_BUFFER 

GL_ELEMENT_ARRAY_BUFFER.

TRANSFORM_FEEDBACK_BUFFER 

GL_TRANSFORM_FEEDBACK_BUFFER.

Definition at line 47 of file gpu-buffer.h.

Enum to encapsulate the GL draw mode.

This is to avoid having to store a whole int for mode

Enumerator
STREAM_DRAW 

GL_STREAM_DRAW.

STATIC_DRAW 

GL_STATIC_DRAW.

DYNAMIC_DRAW 

GL_DYNAMIC_DRAW.

Definition at line 57 of file gpu-buffer.h.

Constructor & Destructor Documentation

Dali::Internal::GpuBuffer::GpuBuffer ( Context context)

constructor

Parameters
contextdrawing context

Definition at line 64 of file gpu-buffer.cpp.

Dali::Internal::GpuBuffer::~GpuBuffer ( )

Destructor, non virtual as no virtual methods or inheritance.

Definition at line 73 of file gpu-buffer.cpp.

References Dali::Internal::Context::DeleteBuffers(), mBufferId, and mContext.

Here is the call graph for this function:

Member Function Documentation

void Dali::Internal::GpuBuffer::Bind ( Target  target) const

Bind the buffer object to the target Will assert if the buffer size is zero.

Definition at line 162 of file gpu-buffer.cpp.

References ARRAY_BUFFER, Dali::Internal::Context::BindArrayBuffer(), Dali::Internal::Context::BindElementArrayBuffer(), Dali::Internal::Context::BindTransformFeedbackBuffer(), DALI_ASSERT_DEBUG, ELEMENT_ARRAY_BUFFER, mBufferId, mCapacity, mContext, and TRANSFORM_FEEDBACK_BUFFER.

Here is the call graph for this function:

void Dali::Internal::GpuBuffer::BindNoChecks ( GLuint  bufferId) const
private

Perfoms a bind without checking the size of the buffer.

Parameters
bufferIdto bind
bool Dali::Internal::GpuBuffer::BufferIsValid ( ) const
Returns
true if the GPU buffer is valid, i.e. its created and not empty

Definition at line 180 of file gpu-buffer.cpp.

References mBufferCreated, and mCapacity.

GLsizeiptr Dali::Internal::GpuBuffer::GetBufferSize ( ) const
inline

Get the size of the buffer.

Returns
size

Definition at line 102 of file gpu-buffer.h.

References mSize.

void Dali::Internal::GpuBuffer::GlContextDestroyed ( )

Needs to be called when GL context is destroyed.

Definition at line 185 of file gpu-buffer.cpp.

References mBufferCreated, mBufferId, mCapacity, and mSize.

void Dali::Internal::GpuBuffer::UpdateDataBuffer ( GLsizeiptr  size,
const GLvoid data,
Usage  usage,
Target  target 
)

Creates or updates a buffer object and binds it to the target.

Parameters
sizeSpecifies the size in bytes of the buffer object's new data store.
datapointer to the data to load
usageHow the buffer will be used
targetThe target buffer to update

Definition at line 88 of file gpu-buffer.cpp.

References ARRAY_BUFFER, Dali::Internal::Context::BindArrayBuffer(), Dali::Internal::Context::BindElementArrayBuffer(), Dali::Internal::Context::BindTransformFeedbackBuffer(), Dali::Internal::Context::BufferData(), Dali::Internal::Context::BufferSubData(), DALI_ASSERT_DEBUG, ELEMENT_ARRAY_BUFFER, Dali::Internal::Context::GenBuffers(), GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER, GL_TRANSFORM_FEEDBACK_BUFFER, mBufferCreated, mBufferId, mCapacity, mContext, Dali::Internal::anonymous_namespace{gpu-buffer.cpp}::ModeAsGlEnum(), mSize, and TRANSFORM_FEEDBACK_BUFFER.

Here is the call graph for this function:

Member Data Documentation

bool Dali::Internal::GpuBuffer::mBufferCreated
private

whether buffer has been created

Definition at line 127 of file gpu-buffer.h.

Referenced by BufferIsValid(), GlContextDestroyed(), and UpdateDataBuffer().

GLuint Dali::Internal::GpuBuffer::mBufferId
private

buffer object name(id)

Definition at line 125 of file gpu-buffer.h.

Referenced by Bind(), GlContextDestroyed(), UpdateDataBuffer(), and ~GpuBuffer().

GLsizeiptr Dali::Internal::GpuBuffer::mCapacity
private

buffer capacity

Definition at line 123 of file gpu-buffer.h.

Referenced by Bind(), BufferIsValid(), GlContextDestroyed(), and UpdateDataBuffer().

Context& Dali::Internal::GpuBuffer::mContext
private

dali drawing context

Definition at line 122 of file gpu-buffer.h.

Referenced by Bind(), UpdateDataBuffer(), and ~GpuBuffer().

GLsizeiptr Dali::Internal::GpuBuffer::mSize
private

buffer size

Definition at line 124 of file gpu-buffer.h.

Referenced by GetBufferSize(), GlContextDestroyed(), and UpdateDataBuffer().


The documentation for this class was generated from the following files:
Dali Docs Home
Read more about Dali