8#ifndef GrResourceCache_DEFINED
9#define GrResourceCache_DEFINED
73 static std::enable_if_t<std::is_base_of_v<GrGpuResource, T>,
void>
96 return fPurgeableQueue.
count() + fNonpurgeableResources.
size();
144 return fScratchMap.countForKey(scratchKey);
154 this->refAndMakeResourceMRU(
resource);
190 bool overBudget()
const {
return fBudgetedBytes > fMaxBytes; }
212 int fNumNonPurgeable;
216 size_t fUnbudgetedSize;
223 fNumNonPurgeable = 0;
230 if (
resource->cacheAccess().isScratch()) {
233 if (
resource->resourcePriv().refsWrappedObjects()) {
237 fUnbudgetedSize +=
resource->gpuMemorySize();
242 void getStats(
Stats*)
const;
244#if defined(GR_TEST_UTILS)
247 void dumpStatsKeyValuePairs(
253#if defined(GR_TEST_UTILS)
254 int countUniqueKeysWithTag(
const char* tag)
const;
256 void changeTimestamp(uint32_t newTimestamp);
266 fThreadSafeCache = threadSafeCache;
311 void processFreedGpuResources();
315 bool wouldFit(
size_t bytes)
const {
return fBudgetedBytes+bytes <= fMaxBytes; }
317 uint32_t getNextTimestamp();
324 void validate()
const;
326 void validate()
const {}
331 struct ScratchMapTraits {
341 struct UniqueHashTraits {
349 return a->cacheAccess().timestamp() <
b->cacheAccess().timestamp();
366 uint32_t fTimestamp = 0;
367 PurgeableQueue fPurgeableQueue;
368 ResourceArray fNonpurgeableResources;
371 ScratchMap fScratchMap;
373 UniqueHash fUniqueHash;
379 int fHighWaterCount = 0;
380 size_t fHighWaterBytes = 0;
381 int fBudgetedHighWaterCount = 0;
382 size_t fBudgetedHighWaterBytes = 0;
390 int fBudgetedCount = 0;
391 size_t fBudgetedBytes = 0;
392 size_t fPurgeableBytes = 0;
393 int fNumBudgetedResourcesFlushWillMakePurgeable = 0;
395 InvalidUniqueKeyInbox fInvalidUniqueKeyInbox;
433 enum RefNotificationFlags {
435 kAllCntsReachedZero_RefNotificationFlag = 0x1,
437 kRefCntReachedZero_RefNotificationFlag = 0x2,
445 fCache->notifyARefCntReachedZero(
resource, removedRef);
452 fCache->changeUniqueKey(
resource, newKey);
464 fCache->willRemoveScratchKey(
resource);
484 return potentialRecipient == msg.
recipient();
static bool SkShouldPostMessageToBus(const GrResourceCache::UnrefResourceMessage &msg, GrDirectContext::DirectContextID potentialRecipient)
static SkString resource(SkPDFResourceType type, int index)
static constexpr bool SkToBool(const T &x)
static constexpr uint32_t SK_InvalidUniqueID
const skgpu::ScratchKey & getScratchKey() const
const skgpu::UniqueKey & getUniqueKey() const
CacheAccess cacheAccess()
ResourcePriv resourcePriv()
UnrefResourceMessage & operator=(UnrefResourceMessage &&)=default
GrDirectContext::DirectContextID recipient() const
UnrefResourceMessage(UnrefResourceMessage &&)=default
size_t getResourceBytes() const
void setThreadSafeCache(GrThreadSafeCache *threadSafeCache)
void dumpMemoryStatistics(SkTraceMemoryDump *traceMemoryDump) const
void setLimit(size_t bytes)
int getBudgetedResourceCount() const
GrResourceCache(skgpu::SingleOwner *owner, GrDirectContext::DirectContextID owningContextID, uint32_t familyID)
size_t getPurgeableBytes() const
static std::enable_if_t< std::is_base_of_v< GrGpuResource, T >, void > ReturnResourceFromThread(sk_sp< T > &&resource, GrDirectContext::DirectContextID id)
bool hasUniqueKey(const skgpu::UniqueKey &key) const
int getResourceCount() const
bool requestsFlush() const
ResourceAccess resourceAccess()
size_t getMaxResourceBytes() const
bool purgeToMakeHeadroom(size_t desiredHeadroomBytes)
size_t getBudgetedResourceBytes() const
void setProxyProvider(GrProxyProvider *proxyProvider)
static const size_t kDefaultMaxSize
void purgeResourcesNotUsedSince(skgpu::StdSteadyClock::time_point purgeTime, GrPurgeResourceOptions opts)
void purgeUnlockedResources(GrPurgeResourceOptions opts)
GrGpuResource * findAndRefScratchResource(const skgpu::ScratchKey &scratchKey)
GrGpuResource * findAndRefUniqueResource(const skgpu::UniqueKey &key)
uint32_t contextUniqueID() const
SkDEBUGCODE(int fCount=0;) size_t fBytes=0
static void Post(Message m)
T * find(const Key &key) const
Dart_NativeFunction function
static uint32_t Hash(uint32_t key)
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 Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent cache