Flutter Engine
The Flutter Engine
|
#include <GrBufferAllocPool.h>
Classes | |
class | CpuBufferCache |
Public Member Functions | |
void | unmap () |
void | reset () |
void | putBack (size_t bytes) |
Static Public Attributes | |
static constexpr size_t | kDefaultBufferSize = 1 << 15 |
Protected Member Functions | |
GrBufferAllocPool (GrGpu *gpu, GrGpuBufferType bufferType, sk_sp< CpuBufferCache > cpuBufferCache) | |
virtual | ~GrBufferAllocPool () |
void * | makeSpace (size_t size, size_t alignment, sk_sp< const GrBuffer > *buffer, size_t *offset) |
void * | makeSpaceAtLeast (size_t minSize, size_t fallbackSize, size_t alignment, sk_sp< const GrBuffer > *buffer, size_t *offset, size_t *actualSize) |
sk_sp< GrBuffer > | getBuffer (size_t size) |
A pool of geometry buffers tied to a GrGpu.
The pool allows a client to make space for geometry and then put back excess space if it over allocated. When a client is ready to draw from the pool it calls unmap on the pool ensure buffers are ready for drawing. The pool can be reset after drawing is completed to recycle space.
At creation time a minimum per-buffer size can be specified. Additionally, a number of buffers to preallocate can be specified. These will be allocated at the min size and kept around until the pool is destroyed.
Definition at line 35 of file GrBufferAllocPool.h.
|
protected |
Constructor
gpu | The GrGpu used to create the buffers. |
bufferType | The type of buffers to create. |
cpuBufferCache | If non-null a cache for client side array buffers or staging buffers used before data is uploaded to GPU buffer objects. |
Definition at line 88 of file GrBufferAllocPool.cpp.
|
protectedvirtual |
Definition at line 108 of file GrBufferAllocPool.cpp.
Definition at line 413 of file GrBufferAllocPool.cpp.
|
protected |
Returns a block of memory to hold data. A buffer designated to hold the data is given to the caller. The buffer may or may not be locked. The returned ptr remains valid until any of the following: *makeSpace is called again. *unmap is called. *reset is called. *this object is destroyed.
Once unmap on the pool is called the data is guaranteed to be in the buffer at the offset indicated by offset. Until that time it may be in temporary storage and/or the buffer may be locked.
size | the amount of data to make space for |
alignment | alignment constraint from start of buffer |
buffer | returns the buffer that will hold the data. |
offset | returns the offset into buffer of the data. |
Definition at line 189 of file GrBufferAllocPool.cpp.
|
protected |
Returns a block of memory to hold data. A buffer designated to hold the data is given to the caller. The buffer may or may not be locked. The returned ptr remains valid until any of the following: *makeSpace is called again. *unmap is called. *reset is called. *this object is destroyed.
Once unmap on the pool is called the data is guaranteed to be in the buffer at the offset indicated by offset. Until that time it may be in temporary storage and/or the buffer may be locked.
The caller requests a minimum number of bytes, but the block may be (much) larger. Assuming that a new block must be allocated, it will be fallbackSize bytes. The actual block size is returned in actualSize.
minSize | the minimum amount of data to make space for |
fallbackSize | the amount of data to make space for if a new block is needed |
alignment | alignment constraint from start of buffer |
buffer | returns the buffer that will hold the data. |
offset | returns the offset into buffer of the data. |
actualSize | returns the capacity of the block |
Definition at line 241 of file GrBufferAllocPool.cpp.
void GrBufferAllocPool::putBack | ( | size_t | bytes | ) |
Frees data from makeSpaces in LIFO order.
Definition at line 284 of file GrBufferAllocPool.cpp.
void GrBufferAllocPool::reset | ( | ) |
Invalidates all the data in the pool, unrefs non-preallocated buffers.
Definition at line 113 of file GrBufferAllocPool.cpp.
void GrBufferAllocPool::unmap | ( | ) |
Ensures all buffers are unmapped and have all data written to them. Call before drawing using buffers from the pool.
Definition at line 121 of file GrBufferAllocPool.cpp.
|
inlinestaticconstexpr |
Definition at line 37 of file GrBufferAllocPool.h.