23class PoolDiscardableMemory;
31 DiscardableMemoryPool(
size_t budget);
32 ~DiscardableMemoryPool()
override;
34 std::unique_ptr<SkDiscardableMemory>
make(
size_t bytes);
36 return this->
make(bytes).release();
46 #if SK_LAZY_CACHE_STATS
47 int getCacheHits()
override {
return fCacheHits; }
48 int getCacheMisses()
override {
return fCacheMisses; }
49 void resetCacheHitsAndMisses()
override {
50 fCacheHits = fCacheMisses = 0;
63 void dumpDownTo(
size_t budget);
65 void removeFromPool(PoolDiscardableMemory* dm);
67 bool lock(PoolDiscardableMemory* dm);
69 void unlock(PoolDiscardableMemory* dm);
71 friend class PoolDiscardableMemory;
83 ~PoolDiscardableMemory()
override;
85 void*
data()
override;
87 friend class DiscardableMemoryPool;
99 : fPool(
std::move(
pool)), fLocked(
true), fPointer(
std::move(pointer)), fBytes(bytes) {
105PoolDiscardableMemory::~PoolDiscardableMemory() {
107 fPool->removeFromPool(
this);
110bool PoolDiscardableMemory::lock() {
112 return fPool->lock(
this);
117 return fPointer.get();
120void PoolDiscardableMemory::unlock() {
127DiscardableMemoryPool::DiscardableMemoryPool(
size_t budget)
130 #if SK_LAZY_CACHE_STATS
135DiscardableMemoryPool::~DiscardableMemoryPool() {
142void DiscardableMemoryPool::dumpDownTo(
size_t budget) {
144 if (fUsed <= budget) {
149 PoolDiscardableMemory* cur = iter.
init(fList, Iter::kTail_IterStart);
150 while ((fUsed > budget) && (cur)) {
152 PoolDiscardableMemory* dm = cur;
154 dm->fPointer =
nullptr;
169 if (
nullptr ==
addr) {
172 auto dm = std::make_unique<PoolDiscardableMemory>(
sk_ref_sp(
this), std::move(
addr), bytes);
174 fList.addToHead(dm.get());
176 this->dumpDownTo(fBudget);
180void DiscardableMemoryPool::removeFromPool(PoolDiscardableMemory* dm) {
183 if (dm->fPointer !=
nullptr) {
192bool DiscardableMemoryPool::lock(PoolDiscardableMemory* dm) {
195 if (
nullptr == dm->fPointer) {
197 #if SK_LAZY_CACHE_STATS
205 #if SK_LAZY_CACHE_STATS
211void DiscardableMemoryPool::unlock(PoolDiscardableMemory* dm) {
215 this->dumpDownTo(fBudget);
218size_t DiscardableMemoryPool::getRAMUsed() {
221void DiscardableMemoryPool::setRAMBudget(
size_t budget) {
224 this->dumpDownTo(fBudget);
226void DiscardableMemoryPool::dumpPool() {
234 return sk_make_sp<DiscardableMemoryPool>(
size);
SkDiscardableMemoryPool * SkGetGlobalDiscardableMemoryPool()
#define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE
static void * sk_malloc_canfail(size_t size)
#define INHERITED(method,...)
sk_sp< T > sk_ref_sp(T *obj)
#define SK_DECLARE_INTERNAL_LLIST_INTERFACE(ClassName)
virtual void dumpPool()=0
static sk_sp< SkDiscardableMemoryPool > Make(size_t size)
virtual size_t getRAMUsed()=0
virtual void setRAMBudget(size_t budget)=0
virtual size_t getRAMBudget()=0
virtual SkDiscardableMemory * create(size_t bytes)=0
T * init(const SkTInternalLList &list, IterStart startLoc)
SKSHAPER_API sk_sp< Factory > Factory()
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
std::unique_ptr< void, SkOverloadedFunctionObject< void(void *), sk_free > > UniqueVoidPtr
static void make(SkBitmap *bitmap, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace)
std::shared_ptr< const fml::Mapping > data