Support Forum G3D Web Page |
A PixelTransferBuffer in main memory. More...
Inherits G3D::PixelTransferBuffer.
Public Member Functions | |
virtual | ~CPUPixelTransferBuffer () |
void * | buffer () |
Returns pointer to raw pixel data. More... | |
const void * | buffer () const |
Returns pointer to raw pixel data. More... | |
int | depth () const |
const ImageFormat * | format () const |
virtual void | getData (void *data) const override |
Read back the current contents to data. More... | |
int | height () const |
virtual const void * | mapRead () const override |
Obtain a pointer for read-only access. More... | |
virtual void * | mapReadWrite () override |
Obtain a pointer for general access. More... | |
virtual void * | mapWrite () override |
Obtain a pointer for write-only access. More... | |
virtual bool | ownsMemory () const override |
If true, the data lifetime is independent of the PixelTransferBuffer lifetime. More... | |
int | pixelCount () const |
virtual bool | readyToMap () const override |
If true, mapReadWrite, mapRead, and mapWrite will return immediately. More... | |
virtual bool | requiresGPUContext () const override |
If true, then readyToMap(), mapRead(), mapWrite(), mapReadWrite(), and unmap() can only be invoked on a thread that currently has an active OpenGL context. More... | |
void * | row (int y, int d=0) |
Return row to raw pixel data at start of row y of depth d. More... | |
const void * | row (int y, int d=0) const |
Return row to raw pixel data at start of row y of depth d. More... | |
size_t | rowAlignment () const |
Returns alignment of each row of pixel data in bytes. More... | |
size_t | rowOffset (int y, int d=0) const |
Return the byte offset from the mapped pointer for the row to raw pixel data at start of row y of depth d. More... | |
virtual void | setData (const void *data) override |
Overwrite the current contents with data. More... | |
size_t | size () const |
Returns entire size of pixel data in bytes. More... | |
size_t | stride () const |
Returns size of each row of pixel data in bytes. More... | |
virtual void | unmap () const override |
template<class T > | |
void | unmap (const T *&setToNull) const |
int | width () const |
Static Public Member Functions | |
static shared_ptr< CPUPixelTransferBuffer > | create (int width, int height, const ImageFormat *format, const shared_ptr< MemoryManager > &memoryManager=MemoryManager::create(), int depth=1, int rowAlignment=1) |
Creates a buffer backed by a CPU array of uninitialized contents. More... | |
static shared_ptr< CPUPixelTransferBuffer > | fromData (int width, int height, const ImageFormat *format, void *data, int depth=1, int rowAlignment=1) |
Creates a buffer backed by a CPU array of existing data that will be managed by the caller. More... | |
Protected Member Functions | |
CPUPixelTransferBuffer (const ImageFormat *format, int width, int height, int depth, int rowAlignment) | |
void | allocateBuffer (const shared_ptr< MemoryManager > &memoryManager) |
void | freeBuffer () |
Static Protected Member Functions | |
template<class T , class ... ArgTypes> | |
static shared_ptr< T > | createShared (ArgTypes &&... args) |
Like std::make_shared, but works for protected constructors. More... | |
Protected Attributes | |
void * | m_buffer |
int | m_depth |
const ImageFormat * | m_format |
int | m_height |
void * | m_mappedPointer |
nullptr if not currently mapped. More... | |
shared_ptr< MemoryManager > | m_memoryManager |
size_t | m_rowAlignment |
size_t | m_rowStride |
int | m_width |
A PixelTransferBuffer in main memory.
|
protected |
|
virtual |
|
protected |
|
inline |
Returns pointer to raw pixel data.
|
inline |
Returns pointer to raw pixel data.
|
static |
Creates a buffer backed by a CPU array of uninitialized contents.
|
inlinestaticprotectedinherited |
Like std::make_shared, but works for protected constructors.
Call as createShared<myclass>.
|
inlineinherited |
|
inlineinherited |
|
protected |
|
static |
Creates a buffer backed by a CPU array of existing data that will be managed by the caller.
It is the caller's responsibility to ensure that data remains allocated while the buffer is in use.
|
overridevirtual |
Read back the current contents to data.
Cannot call while mapped.
Implements G3D::PixelTransferBuffer.
|
inlineinherited |
|
overridevirtual |
Obtain a pointer for read-only access.
Implements G3D::PixelTransferBuffer.
|
overridevirtual |
Obtain a pointer for general access.
Implements G3D::PixelTransferBuffer.
|
overridevirtual |
Obtain a pointer for write-only access.
Implements G3D::PixelTransferBuffer.
|
inlineoverridevirtual |
If true, the data lifetime is independent of the PixelTransferBuffer lifetime.
For example, holding the PixelTransferBuffer may not keep the data valid if ownsMemory() = false.
Reimplemented from G3D::PixelTransferBuffer.
|
inlineinherited |
|
inlineoverridevirtual |
If true, mapReadWrite, mapRead, and mapWrite will return immediately.
This is always true for the base class but subclasses that map Pixel Buffer Objects and files may have a delay between when they are constructed and when they are available for mapping. The standard usage in those cases is to have the GL thread check if data is ready to map, and if not, then wait until the next frame to perform the mapping.
Implements G3D::PixelTransferBuffer.
|
inlineoverridevirtual |
If true, then readyToMap(), mapRead(), mapWrite(), mapReadWrite(), and unmap() can only be invoked on a thread that currently has an active OpenGL context.
Always returns false for the base class.
Implements G3D::PixelTransferBuffer.
|
inline |
Return row to raw pixel data at start of row y of depth d.
Referenced by row().
|
inline |
Return row to raw pixel data at start of row y of depth d.
|
inlineinherited |
Returns alignment of each row of pixel data in bytes.
|
inlineinherited |
Return the byte offset from the mapped pointer for the row to raw pixel data at start of row y of depth d.
Referenced by row().
|
overridevirtual |
Overwrite the current contents with data.
Cannot call while mapped.
Implements G3D::PixelTransferBuffer.
|
inlineinherited |
Returns entire size of pixel data in bytes.
|
inlineinherited |
Returns size of each row of pixel data in bytes.
|
overridevirtual |
Implements G3D::PixelTransferBuffer.
|
inlineinherited |
|
inlineinherited |
|
protectedinherited |
|
protectedinherited |
Referenced by G3D::PixelTransferBuffer::format().
|
protectedinherited |
|
mutableprotectedinherited |
nullptr if not currently mapped.
|
protected |
Referenced by ownsMemory().
|
protectedinherited |
Referenced by G3D::PixelTransferBuffer::rowAlignment().
|
protectedinherited |
|
protectedinherited |
Referenced by G3D::PixelTransferBuffer::pixelCount(), and G3D::PixelTransferBuffer::width().