*
* The latter two ref types are private and intended only for Gr core code.
*
- * When an item is purgable DERIVED:notifyIsPurgable() will be called (static poly morphism using
+ * When an item is purgeable DERIVED:notifyIsPurgeable() will be called (static poly morphism using
* CRTP). GrIORef and GrGpuResource are separate classes for organizational reasons and to be
* able to give access via friendship to only the functions related to pending IO operations.
*/
protected:
GrIORef() : fRefCnt(1), fPendingReads(0), fPendingWrites(0) { }
- bool isPurgable() const { return !this->internalHasRef() && !this->internalHasPendingIO(); }
+ bool isPurgeable() const { return !this->internalHasRef() && !this->internalHasPendingIO(); }
bool internalHasPendingRead() const { return SkToBool(fPendingReads); }
bool internalHasPendingWrite() const { return SkToBool(fPendingWrites); }
private:
void didUnref() const {
if (0 == fPendingReads && 0 == fPendingWrites && 0 == fRefCnt) {
- static_cast<const DERIVED*>(this)->notifyIsPurgable();
+ static_cast<const DERIVED*>(this)->notifyIsPurgeable();
}
}
// See comments in CacheAccess.
bool setContentKey(const GrContentKey& contentKey);
- void notifyIsPurgable() const;
+ void notifyIsPurgeable() const;
void removeScratchKey();
void makeBudgeted();
void makeUnbudgeted();
SkAutoTUnref<const SkData> fData;
typedef GrIORef<GrGpuResource> INHERITED;
- friend class GrIORef<GrGpuResource>; // to access notifyIsPurgable.
+ friend class GrIORef<GrGpuResource>; // to access notifyIsPurgeable.
};
#endif
return true;
}
-void GrGpuResource::notifyIsPurgable() const {
+void GrGpuResource::notifyIsPurgeable() const {
if (this->wasDestroyed()) {
// We've already been removed from the cache. Goodbye cruel world!
SkDELETE(this);
} else {
GrGpuResource* mutableThis = const_cast<GrGpuResource*>(this);
- get_resource_cache2(fGpu)->resourceAccess().notifyPurgable(mutableThis);
+ get_resource_cache2(fGpu)->resourceAccess().notifyPurgeable(mutableThis);
}
}
*/
void release() {
fResource->release();
- if (fResource->isPurgable()) {
+ if (fResource->isPurgeable()) {
SkDELETE(fResource);
}
}
*/
void abandon() {
fResource->abandon();
- if (fResource->isPurgable()) {
+ if (fResource->isPurgeable()) {
SkDELETE(fResource);
}
}
, fBudgetedCount(0)
, fBudgetedBytes(0)
, fPurging(false)
- , fNewlyPurgableResourceWhilePurging(false)
+ , fNewlyPurgeableResourceWhilePurging(false)
, fOverBudgetCB(NULL)
, fOverBudgetData(NULL) {
}
fResources.addToHead(resource);
}
-void GrResourceCache2::notifyPurgable(GrGpuResource* resource) {
+void GrResourceCache2::notifyPurgeable(GrGpuResource* resource) {
SkASSERT(resource);
SkASSERT(this->isInCache(resource));
- SkASSERT(resource->isPurgable());
+ SkASSERT(resource->isPurgeable());
// We can't purge if in the middle of purging because purge is iterating. Instead record
- // that additional resources became purgable.
+ // that additional resources became purgeable.
if (fPurging) {
- fNewlyPurgableResourceWhilePurging = true;
+ fNewlyPurgeableResourceWhilePurging = true;
return;
}
void GrResourceCache2::internalPurgeAsNeeded() {
SkASSERT(!fPurging);
- SkASSERT(!fNewlyPurgableResourceWhilePurging);
+ SkASSERT(!fNewlyPurgeableResourceWhilePurging);
SkASSERT(fBudgetedCount > fMaxCount || fBudgetedBytes > fMaxBytes);
fPurging = true;
bool overBudget = true;
do {
- fNewlyPurgableResourceWhilePurging = false;
+ fNewlyPurgeableResourceWhilePurging = false;
ResourceList::Iter resourceIter;
GrGpuResource* resource = resourceIter.init(fResources,
ResourceList::Iter::kTail_IterStart);
while (resource) {
GrGpuResource* prev = resourceIter.prev();
- if (resource->isPurgable()) {
+ if (resource->isPurgeable()) {
resource->cacheAccess().release();
}
resource = prev;
}
}
- if (!fNewlyPurgableResourceWhilePurging && overBudget && fOverBudgetCB) {
+ if (!fNewlyPurgeableResourceWhilePurging && overBudget && fOverBudgetCB) {
// Despite the purge we're still over budget. Call our over budget callback.
(*fOverBudgetCB)(fOverBudgetData);
}
- } while (overBudget && fNewlyPurgableResourceWhilePurging);
+ } while (overBudget && fNewlyPurgeableResourceWhilePurging);
- fNewlyPurgableResourceWhilePurging = false;
+ fNewlyPurgeableResourceWhilePurging = false;
fPurging = false;
this->validate();
}
void GrResourceCache2::purgeAllUnlocked() {
SkASSERT(!fPurging);
- SkASSERT(!fNewlyPurgableResourceWhilePurging);
+ SkASSERT(!fNewlyPurgeableResourceWhilePurging);
fPurging = true;
do {
- fNewlyPurgableResourceWhilePurging = false;
+ fNewlyPurgeableResourceWhilePurging = false;
ResourceList::Iter resourceIter;
GrGpuResource* resource =
resourceIter.init(fResources, ResourceList::Iter::kTail_IterStart);
while (resource) {
GrGpuResource* prev = resourceIter.prev();
- if (resource->isPurgable()) {
+ if (resource->isPurgeable()) {
resource->cacheAccess().release();
}
resource = prev;
}
- if (!fNewlyPurgableResourceWhilePurging && fCount && fOverBudgetCB) {
+ if (!fNewlyPurgeableResourceWhilePurging && fCount && fOverBudgetCB) {
(*fOverBudgetCB)(fOverBudgetData);
}
- } while (fNewlyPurgableResourceWhilePurging);
+ } while (fNewlyPurgeableResourceWhilePurging);
fPurging = false;
this->validate();
}
bytes += resource->gpuMemorySize();
++count;
- if (!resource->isPurgable()) {
+ if (!resource->isPurgeable()) {
++locked;
}
SkASSERT(content == fContentHash.count());
SkASSERT(scratch + couldBeScratch == fScratchMap.count());
- // This assertion is not currently valid because we can be in recursive notifyIsPurgable()
+ // This assertion is not currently valid because we can be in recursive notifyIsPurgeable()
// calls. This will be fixed when subresource registration is explicit.
// bool overBudget = budgetedBytes > fMaxBytes || budgetedCount > fMaxCount;
// SkASSERT(!overBudget || locked == count || fPurging);
GrGpuResource* resource = iter.init(fResources, ResourceList::Iter::kHead_IterStart);
for ( ; resource; resource = iter.next()) {
- if (!resource->isPurgable()) {
+ if (!resource->isPurgeable()) {
++locked;
}
if (resource->cacheAccess().isScratch()) {
////
void insertResource(GrGpuResource*);
void removeResource(GrGpuResource*);
- void notifyPurgable(GrGpuResource*);
+ void notifyPurgeable(GrGpuResource*);
void didChangeGpuMemorySize(const GrGpuResource*, size_t oldSize);
bool didSetContentKey(GrGpuResource*);
void willRemoveScratchKey(const GrGpuResource*);
// prevents recursive purging
bool fPurging;
- bool fNewlyPurgableResourceWhilePurging;
+ bool fNewlyPurgeableResourceWhilePurging;
PFOverBudgetCB fOverBudgetCB;
void* fOverBudgetData;
void removeResource(GrGpuResource* resource) { fCache->removeResource(resource); }
/**
- * Called by GrGpuResources when they detects that they are newly purgable.
+ * Called by GrGpuResources when they detects that they are newly purgeable.
*/
- void notifyPurgable(GrGpuResource* resource) { fCache->notifyPurgable(resource); }
+ void notifyPurgeable(GrGpuResource* resource) { fCache->notifyPurgeable(resource); }
/**
* Called by GrGpuResources when their sizes change.
return false;
}
- // Note: our ctable is not purgable, as it is not stored in the discardablememory block.
+ // Note: our ctable is not purgeable, as it is not stored in the discardablememory block.
// This is because SkColorTable is refcntable, and therefore our caller could hold onto it
// beyond the scope of a lock/unlock. If we change the API/lifecycle for SkColorTable, we
// could move it into the block, but then again perhaps it is small enough that this doesn't
REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize() ==
cache2->getBudgetedResourceBytes());
- // Our refs mean that the resources are non purgable.
+ // Our refs mean that the resources are non purgeable.
cache2->purgeAllUnlocked();
REPORTER_ASSERT(reporter, 4 == cache2->getResourceCount());
REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize() +
REPORTER_ASSERT(reporter, a->gpuMemorySize() + b->gpuMemorySize() ==
cache2->getResourceBytes());
- // Our refs mean that the resources are non purgable.
+ // Our refs mean that the resources are non purgeable.
cache2->purgeAllUnlocked();
REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount());
REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
SkDEBUGCODE(REPORTER_ASSERT(reporter, 2 == cache2->countScratchEntriesForKey(scratchKey));)
- // Purge again. This time resources should be purgable.
+ // Purge again. This time resources should be purgeable.
cache2->purgeAllUnlocked();
REPORTER_ASSERT(reporter, 0 == TestResource::NumAlive());
REPORTER_ASSERT(reporter, 0 == cache2->getResourceCount());