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

#include <GrBufferAllocPool.h>

Inheritance diagram for GrIndexBufferAllocPool:
GrBufferAllocPool SkNoncopyable

Public Member Functions

 GrIndexBufferAllocPool (GrGpu *gpu, sk_sp< CpuBufferCache > cpuBufferCache)
 
void * makeSpace (int indexCount, sk_sp< const GrBuffer > *buffer, int *startIndex)
 
void * makeSpaceAtLeast (int minIndexCount, int fallbackIndexCount, sk_sp< const GrBuffer > *buffer, int *startIndex, int *actualIndexCount)
 
- Public Member Functions inherited from GrBufferAllocPool
void unmap ()
 
void reset ()
 
void putBack (size_t bytes)
 

Additional Inherited Members

- Static Public Attributes inherited from GrBufferAllocPool
static constexpr size_t kDefaultBufferSize = 1 << 15
 
- Protected Member Functions inherited from GrBufferAllocPool
 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< GrBuffergetBuffer (size_t size)
 

Detailed Description

A GrBufferAllocPool of index buffers

Definition at line 256 of file GrBufferAllocPool.h.

Constructor & Destructor Documentation

◆ GrIndexBufferAllocPool()

GrIndexBufferAllocPool::GrIndexBufferAllocPool ( GrGpu gpu,
sk_sp< CpuBufferCache cpuBufferCache 
)

Constructor

Parameters
gpuThe GrGpu used to create the index buffers.
cpuBufferCacheIf non-null a cache for client side array buffers or staging buffers used before data is uploaded to GPU buffer objects.

Definition at line 484 of file GrBufferAllocPool.cpp.

485 : GrBufferAllocPool(gpu, GrGpuBufferType::kIndex, std::move(cpuBufferCache)) {}
GrBufferAllocPool(GrGpu *gpu, GrGpuBufferType bufferType, sk_sp< CpuBufferCache > cpuBufferCache)

Member Function Documentation

◆ makeSpace()

void * GrIndexBufferAllocPool::makeSpace ( int  indexCount,
sk_sp< const GrBuffer > *  buffer,
int startIndex 
)

Returns a block of memory to hold indices. A buffer designated to hold the indices 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 indices are guaranteed to be in the buffer at the offset indicated by startIndex. Until that time they may be in temporary storage and/or the buffer may be locked.

Parameters
indexCountnumber of indices to allocate space for
bufferreturns the index buffer that will hold the indices.
startIndexreturns the offset into buffer of the first index.
Returns
pointer to first index.

Definition at line 487 of file GrBufferAllocPool.cpp.

488 {
489 SkASSERT(indexCount >= 0);
491 SkASSERT(startIndex);
492
494 void* ptr = INHERITED::makeSpace(SkSafeMath::Mul(indexCount, sizeof(uint16_t)),
495 sizeof(uint16_t),
496 buffer,
497 &offset);
498
499 SkASSERT(0 == offset % sizeof(uint16_t));
500 *startIndex = static_cast<int>(offset / sizeof(uint16_t));
501 return ptr;
502}
#define SkASSERT(cond)
Definition: SkAssert.h:116
#define SK_INIT_TO_AVOID_WARNING
Definition: SkMacros.h:58
void * makeSpace(size_t size, size_t alignment, sk_sp< const GrBuffer > *buffer, size_t *offset)
static size_t Mul(size_t x, size_t y)
Definition: SkSafeMath.cpp:16
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
SeparatedVector2 offset

◆ makeSpaceAtLeast()

void * GrIndexBufferAllocPool::makeSpaceAtLeast ( int  minIndexCount,
int  fallbackIndexCount,
sk_sp< const GrBuffer > *  buffer,
int startIndex,
int actualIndexCount 
)

Returns a block of memory to hold indices. A buffer designated to hold the indices 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 indices are guaranteed to be in the buffer at the offset indicated by startIndex. Until that time they may be in temporary storage and/or the buffer may be locked.

The caller requests a minimum number of indices, but the block may be (much) larger. Assuming that a new block must be allocated, it will be sized to hold fallbackIndexCount indices. The actual block size (in indices) is returned in actualIndexCount.

Parameters
minIndexCountminimum number of indices to allocate space for
fallbackIndexCountnumber of indices to allocate space for if a new block is needed
bufferreturns the index buffer that will hold the indices.
startIndexreturns the offset into buffer of the first index.
actualIndexCountreturns the capacity of the block (in indices)
Returns
pointer to first index.

Definition at line 504 of file GrBufferAllocPool.cpp.

506 {
507 SkASSERT(minIndexCount >= 0);
508 SkASSERT(fallbackIndexCount >= minIndexCount);
510 SkASSERT(startIndex);
511 SkASSERT(actualIndexCount);
512
514 size_t actualSize SK_INIT_TO_AVOID_WARNING;
515 void* ptr = INHERITED::makeSpaceAtLeast(SkSafeMath::Mul(minIndexCount, sizeof(uint16_t)),
516 SkSafeMath::Mul(fallbackIndexCount, sizeof(uint16_t)),
517 sizeof(uint16_t),
518 buffer,
519 &offset,
520 &actualSize);
521
522 SkASSERT(0 == offset % sizeof(uint16_t));
523 *startIndex = static_cast<int>(offset / sizeof(uint16_t));
524
525 SkASSERT(0 == actualSize % sizeof(uint16_t));
526 SkASSERT(actualSize >= minIndexCount * sizeof(uint16_t));
527 *actualIndexCount = static_cast<int>(actualSize / sizeof(uint16_t));
528 return ptr;
529}
void * makeSpaceAtLeast(size_t minSize, size_t fallbackSize, size_t alignment, sk_sp< const GrBuffer > *buffer, size_t *offset, size_t *actualSize)

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