Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Static Public Member Functions | List of all members
GrBufferAllocPool::CpuBufferCache Class Reference

#include <GrBufferAllocPool.h>

Inheritance diagram for GrBufferAllocPool::CpuBufferCache:
GrNonAtomicRef< CpuBufferCache > SkNoncopyable

Public Member Functions

sk_sp< GrCpuBuffermakeBuffer (size_t size, bool mustBeInitialized)
 
void releaseAll ()
 
- Public Member Functions inherited from GrNonAtomicRef< CpuBufferCache >
 GrNonAtomicRef ()
 
bool unique () const
 
int refCnt () const
 
void ref () const
 
void unref () const
 
- Public Member Functions inherited from SkNoncopyable
 SkNoncopyable ()=default
 
 SkNoncopyable (SkNoncopyable &&)=default
 
SkNoncopyableoperator= (SkNoncopyable &&)=default
 

Static Public Member Functions

static sk_sp< CpuBufferCacheMake (int maxBuffersToCache)
 

Detailed Description

A cache object that can be shared by multiple GrBufferAllocPool instances. It caches cpu buffer allocations to avoid reallocating them.

Definition at line 43 of file GrBufferAllocPool.h.

Member Function Documentation

◆ Make()

sk_sp< GrBufferAllocPool::CpuBufferCache > GrBufferAllocPool::CpuBufferCache::Make ( int  maxBuffersToCache)
static

Definition at line 23 of file GrBufferAllocPool.cpp.

24 {
25 return sk_sp<CpuBufferCache>(new CpuBufferCache(maxBuffersToCache));
26}

◆ makeBuffer()

sk_sp< GrCpuBuffer > GrBufferAllocPool::CpuBufferCache::makeBuffer ( size_t  size,
bool  mustBeInitialized 
)

Definition at line 35 of file GrBufferAllocPool.cpp.

36 {
37 SkASSERT(size > 0);
38 Buffer* result = nullptr;
39 if (size == kDefaultBufferSize) {
40 int i = 0;
41 for (; i < fMaxBuffersToCache && fBuffers[i].fBuffer; ++i) {
42 SkASSERT(fBuffers[i].fBuffer->size() == kDefaultBufferSize);
43 if (fBuffers[i].fBuffer->unique()) {
44 result = &fBuffers[i];
45 }
46 }
47 if (!result && i < fMaxBuffersToCache) {
48 fBuffers[i].fBuffer = GrCpuBuffer::Make(size);
49 result = &fBuffers[i];
50 }
51 }
52 Buffer tempResult;
53 if (!result) {
54 tempResult.fBuffer = GrCpuBuffer::Make(size);
55 result = &tempResult;
56 }
57 if (mustBeInitialized && !result->fCleared) {
58 result->fCleared = true;
59 memset(result->fBuffer->data(), 0, result->fBuffer->size());
60 }
61 return result->fBuffer;
62}
#define SkASSERT(cond)
Definition: SkAssert.h:116
static constexpr size_t kDefaultBufferSize
static sk_sp< GrCpuBuffer > Make(size_t size)
Definition: GrCpuBuffer.h:17
GAsyncResult * result
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259

◆ releaseAll()

void GrBufferAllocPool::CpuBufferCache::releaseAll ( )

Definition at line 64 of file GrBufferAllocPool.cpp.

64 {
65 for (int i = 0; i < fMaxBuffersToCache && fBuffers[i].fBuffer; ++i) {
66 fBuffers[i].fBuffer.reset();
67 fBuffers[i].fCleared = false;
68 }
69}

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