8#ifndef SkResourceCache_DEFINED
9#define SkResourceCache_DEFINED
40 void init(
void* nameSpace, uint64_t sharedID,
size_t dataSize);
48 uint64_t
getSharedID()
const {
return ((uint64_t)fSharedID_hi << 32) | fSharedID_lo; }
51 uint32_t
hash()
const {
return fHash; }
54 const uint32_t*
a = this->as32();
55 const uint32_t*
b = other.as32();
56 for (
int i = 0;
i < fCount32; ++
i) {
68 uint32_t fSharedID_lo;
69 uint32_t fSharedID_hi;
73 const uint32_t* as32()
const {
return (
const uint32_t*)
this; }
84 virtual const Key&
getKey()
const = 0;
155 static void Add(
Rec*,
void* payload =
nullptr);
223 void add(
Rec*,
void* payload =
nullptr);
250 this->purgeAsNeeded(
true);
271 size_t fTotalBytesUsed;
272 size_t fTotalByteLimit;
273 size_t fSingleAllocationByteLimit;
278 void checkMessages();
279 void purgeAsNeeded(
bool forcePurge =
false);
282 void moveToHead(Rec*);
283 void addToHead(Rec*);
290 void validate()
const;
292 void validate()
const {}
SkResourceCache(DiscardableFactory)
static size_t SetSingleAllocationByteLimit(size_t)
static SkCachedData * NewCachedData(size_t bytes)
static void Add(Rec *, void *payload=nullptr)
size_t getSingleAllocationByteLimit() const
size_t getTotalByteLimit() const
static size_t GetEffectiveSingleAllocationByteLimit()
DiscardableFactory discardableFactory() const
size_t getTotalBytesUsed() const
void visitAll(Visitor, void *context)
static void PostPurgeSharedID(uint64_t sharedID)
static size_t GetTotalBytesUsed()
void purgeSharedID(uint64_t sharedID)
static void CheckMessages()
static DiscardableFactory GetDiscardableFactory()
bool find(const Key &, FindVisitor, void *context)
static void DumpMemoryStatistics(SkTraceMemoryDump *dump)
static size_t GetSingleAllocationByteLimit()
static void VisitAll(Visitor, void *context)
static size_t GetTotalByteLimit()
static bool Find(const Key &key, FindVisitor, void *context)
static void TestDumpMemoryStatistics()
size_t setTotalByteLimit(size_t newLimit)
SkCachedData * newCachedData(size_t bytes)
SkDiscardableMemory *(* DiscardableFactory)(size_t bytes)
bool(* FindVisitor)(const Rec &, void *context)
size_t setSingleAllocationByteLimit(size_t maximumAllocationSize)
size_t getEffectiveSingleAllocationByteLimit() const
void(* Visitor)(const Rec &, void *context)
static size_t SetTotalByteLimit(size_t newLimit)
void add(Rec *, void *payload=nullptr)
static uint32_t Hash(uint32_t key)
uint64_t getSharedID() const
void * getNamespace() const
bool operator==(const Key &other) const
void init(void *nameSpace, uint64_t sharedID, size_t dataSize)
PurgeSharedIDMessage(uint64_t sharedID)
virtual void postAddInstall(void *)
virtual const char * getCategory() const =0
virtual SkDiscardableMemory * diagnostic_only_getDiscardable() const
virtual size_t bytesUsed() const =0
virtual const Key & getKey() const =0
virtual bool canBePurged()