Fix the speeling of "purgeable" in Gr code
TBR=robertphillips@google.com Review URL: https://codereview.chromium.org/874693002
This commit is contained in:
parent
6a144345d7
commit
63c992f6c0
@ -34,7 +34,7 @@ class GrResourceCache2;
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
@ -69,7 +69,7 @@ public:
|
||||
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); }
|
||||
@ -103,7 +103,7 @@ private:
|
||||
private:
|
||||
void didUnref() const {
|
||||
if (0 == fPendingReads && 0 == fPendingWrites && 0 == fRefCnt) {
|
||||
static_cast<const DERIVED*>(this)->notifyIsPurgable();
|
||||
static_cast<const DERIVED*>(this)->notifyIsPurgeable();
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,7 +260,7 @@ private:
|
||||
|
||||
// See comments in CacheAccess.
|
||||
bool setContentKey(const GrContentKey& contentKey);
|
||||
void notifyIsPurgable() const;
|
||||
void notifyIsPurgeable() const;
|
||||
void removeScratchKey();
|
||||
void makeBudgeted();
|
||||
void makeUnbudgeted();
|
||||
@ -290,7 +290,7 @@ private:
|
||||
SkAutoTUnref<const SkData> fData;
|
||||
|
||||
typedef GrIORef<GrGpuResource> INHERITED;
|
||||
friend class GrIORef<GrGpuResource>; // to access notifyIsPurgable.
|
||||
friend class GrIORef<GrGpuResource>; // to access notifyIsPurgeable.
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -104,13 +104,13 @@ bool GrGpuResource::setContentKey(const GrContentKey& key) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ public:
|
||||
*/
|
||||
void release() {
|
||||
fResource->release();
|
||||
if (fResource->isPurgable()) {
|
||||
if (fResource->isPurgeable()) {
|
||||
SkDELETE(fResource);
|
||||
}
|
||||
}
|
||||
@ -96,7 +96,7 @@ public:
|
||||
*/
|
||||
void abandon() {
|
||||
fResource->abandon();
|
||||
if (fResource->isPurgable()) {
|
||||
if (fResource->isPurgeable()) {
|
||||
SkDELETE(fResource);
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ GrResourceCache2::GrResourceCache2()
|
||||
, fBudgetedCount(0)
|
||||
, fBudgetedBytes(0)
|
||||
, fPurging(false)
|
||||
, fNewlyPurgableResourceWhilePurging(false)
|
||||
, fNewlyPurgeableResourceWhilePurging(false)
|
||||
, fOverBudgetCB(NULL)
|
||||
, fOverBudgetData(NULL) {
|
||||
}
|
||||
@ -245,15 +245,15 @@ void GrResourceCache2::makeResourceMRU(GrGpuResource* resource) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -343,21 +343,21 @@ void GrResourceCache2::didChangeBudgetStatus(GrGpuResource* resource) {
|
||||
|
||||
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;
|
||||
@ -367,41 +367,41 @@ void GrResourceCache2::internalPurgeAsNeeded() {
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
@ -430,7 +430,7 @@ void GrResourceCache2::validate() const {
|
||||
bytes += resource->gpuMemorySize();
|
||||
++count;
|
||||
|
||||
if (!resource->isPurgable()) {
|
||||
if (!resource->isPurgeable()) {
|
||||
++locked;
|
||||
}
|
||||
|
||||
@ -477,7 +477,7 @@ void GrResourceCache2::validate() const {
|
||||
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);
|
||||
@ -497,7 +497,7 @@ void GrResourceCache2::printStats() const {
|
||||
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()) {
|
||||
|
@ -155,7 +155,7 @@ private:
|
||||
////
|
||||
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*);
|
||||
@ -230,7 +230,7 @@ private:
|
||||
|
||||
// prevents recursive purging
|
||||
bool fPurging;
|
||||
bool fNewlyPurgableResourceWhilePurging;
|
||||
bool fNewlyPurgeableResourceWhilePurging;
|
||||
|
||||
PFOverBudgetCB fOverBudgetCB;
|
||||
void* fOverBudgetData;
|
||||
@ -254,9 +254,9 @@ private:
|
||||
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.
|
||||
|
@ -71,7 +71,7 @@ bool SkDiscardablePixelRef::onNewLockPixels(LockRec* rec) {
|
||||
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
|
||||
|
@ -269,7 +269,7 @@ static void test_budgeting(skiatest::Reporter* reporter) {
|
||||
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() +
|
||||
@ -472,7 +472,7 @@ static void test_duplicate_scratch_key(skiatest::Reporter* reporter) {
|
||||
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());
|
||||
@ -483,7 +483,7 @@ static void test_duplicate_scratch_key(skiatest::Reporter* reporter) {
|
||||
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());
|
||||
|
Loading…
Reference in New Issue
Block a user