Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
SkSL::Pool Class Reference

#include <SkSLPool.h>

Public Member Functions

 ~Pool ()
 
void attachToThread ()
 
void detachFromThread ()
 

Static Public Member Functions

static std::unique_ptr< PoolCreate ()
 
static void * AllocMemory (size_t size)
 
static void FreeMemory (void *ptr)
 
static bool IsAttached ()
 

Detailed Description

Efficiently allocates memory in an SkSL program. Optimized for allocate/release performance over memory efficiency.

All allocated memory must be released back to the pool before it can be destroyed or recycled.

Definition at line 25 of file SkSLPool.h.

Constructor & Destructor Documentation

◆ ~Pool()

SkSL::Pool::~Pool ( )

Definition at line 28 of file SkSLPool.cpp.

28 {
29 if (get_thread_local_memory_pool() == fMemPool.get()) {
30 SkDEBUGFAIL("SkSL pool is being destroyed while it is still attached to the thread");
32 }
33
34 SkVLOG("DELETE Pool:0x%016llX\n", (uint64_t)fMemPool.get());
35}
#define SkDEBUGFAIL(message)
Definition: SkAssert.h:118
#define SkVLOG(...)
Definition: SkSLPool.cpp:12
static MemoryPool * get_thread_local_memory_pool()
Definition: SkSLPool.cpp:18
static void set_thread_local_memory_pool(MemoryPool *memPool)
Definition: SkSLPool.cpp:22

Member Function Documentation

◆ AllocMemory()

void * SkSL::Pool::AllocMemory ( size_t  size)
static

Definition at line 60 of file SkSLPool.cpp.

60 {
61 // Is a pool attached?
62 MemoryPool* memPool = get_thread_local_memory_pool();
63 if (memPool) {
64 void* ptr = memPool->allocate(size);
65 SkVLOG("ALLOC Pool:0x%016llX 0x%016llX\n", (uint64_t)memPool, (uint64_t)ptr);
66 return ptr;
67 }
68
69 // There's no pool attached. Allocate memory using the system allocator.
70 void* ptr = ::operator new(size);
71 SkVLOG("ALLOC Pool:__________________ 0x%016llX\n", (uint64_t)ptr);
72 return ptr;
73}
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

◆ attachToThread()

void SkSL::Pool::attachToThread ( )

Definition at line 48 of file SkSLPool.cpp.

48 {
49 SkVLOG("ATTACH Pool:0x%016llX\n", (uint64_t)fMemPool.get());
51 set_thread_local_memory_pool(fMemPool.get());
52}
#define SkASSERT(cond)
Definition: SkAssert.h:116

◆ Create()

std::unique_ptr< Pool > SkSL::Pool::Create ( )
static

Definition at line 37 of file SkSLPool.cpp.

37 {
38 auto pool = std::unique_ptr<Pool>(new Pool);
39 pool->fMemPool = MemoryPool::Make();
40 SkVLOG("CREATE Pool:0x%016llX\n", (uint64_t)pool->fMemPool.get());
41 return pool;
42}
AutoreleasePool pool
static std::unique_ptr< MemoryPool > Make()

◆ detachFromThread()

void SkSL::Pool::detachFromThread ( )

Definition at line 54 of file SkSLPool.cpp.

54 {
55 SkVLOG("DETACH Pool:0x%016llX\n", (uint64_t)memPool);
56 SkASSERT(get_thread_local_memory_pool() == fMemPool.get());
58}

◆ FreeMemory()

void SkSL::Pool::FreeMemory ( void *  ptr)
static

Definition at line 75 of file SkSLPool.cpp.

75 {
76 // Is a pool attached?
77 MemoryPool* memPool = get_thread_local_memory_pool();
78 if (memPool) {
79 SkVLOG("FREE Pool:0x%016llX 0x%016llX\n", (uint64_t)memPool, (uint64_t)ptr);
80 memPool->release(ptr);
81 return;
82 }
83
84 // There's no pool attached. Free it using the system allocator.
85 SkVLOG("FREE Pool:__________________ 0x%016llX\n", (uint64_t)ptr);
86 ::operator delete(ptr);
87}

◆ IsAttached()

bool SkSL::Pool::IsAttached ( )
static

Definition at line 44 of file SkSLPool.cpp.

44 {
46}

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