Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1286)

Unified Diff: src/gpu/GrResourceCache2.cpp

Issue 737533002: Reduce the amount of validation in GrResourceCache2 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrResourceCache2.cpp
diff --git a/src/gpu/GrResourceCache2.cpp b/src/gpu/GrResourceCache2.cpp
index 9764e623292d0755f2de8d7cfdcdbb71494de08f..d30397337fcd96a0abaa7a3d3f4587857bfdc3cc 100644
--- a/src/gpu/GrResourceCache2.cpp
+++ b/src/gpu/GrResourceCache2.cpp
@@ -90,8 +90,6 @@ void GrResourceCache2::setLimits(int count, size_t bytes) {
}
void GrResourceCache2::insertResource(GrGpuResource* resource) {
- AutoValidate av(this);
-
SkASSERT(resource);
SkASSERT(!resource->wasDestroyed());
SkASSERT(!this->isInCache(resource));
@@ -122,8 +120,6 @@ void GrResourceCache2::insertResource(GrGpuResource* resource) {
}
void GrResourceCache2::removeResource(GrGpuResource* resource) {
- AutoValidate av(this);
-
SkASSERT(this->isInCache(resource));
size_t size = resource->gpuMemorySize();
@@ -141,6 +137,7 @@ void GrResourceCache2::removeResource(GrGpuResource* resource) {
if (const GrResourceKey* contentKey = resource->cacheAccess().getContentKey()) {
fContentHash.remove(*contentKey);
}
+ this->validate();
}
void GrResourceCache2::abandonAll() {
@@ -195,8 +192,6 @@ private:
GrGpuResource* GrResourceCache2::findAndRefScratchResource(const GrResourceKey& scratchKey,
uint32_t flags) {
- AutoValidate av(this);
-
SkASSERT(!fPurging);
SkASSERT(scratchKey.isScratch());
@@ -204,8 +199,10 @@ GrGpuResource* GrResourceCache2::findAndRefScratchResource(const GrResourceKey&
if (flags & (kPreferNoPendingIO_ScratchFlag | kRequireNoPendingIO_ScratchFlag)) {
resource = fScratchMap.find(scratchKey, AvailableForScratchUse(true));
if (resource) {
+ resource->ref();
this->makeResourceMRU(resource);
- return SkRef(resource);
+ this->validate();
+ return resource;
} else if (flags & kRequireNoPendingIO_ScratchFlag) {
return NULL;
}
@@ -216,6 +213,7 @@ GrGpuResource* GrResourceCache2::findAndRefScratchResource(const GrResourceKey&
if (resource) {
resource->ref();
this->makeResourceMRU(resource);
+ this->validate();
}
return resource;
}
@@ -238,13 +236,11 @@ bool GrResourceCache2::didSetContentKey(GrGpuResource* resource) {
}
void GrResourceCache2::makeResourceMRU(GrGpuResource* resource) {
- AutoValidate av(this);
-
SkASSERT(!fPurging);
SkASSERT(resource);
SkASSERT(this->isInCache(resource));
fResources.remove(resource);
- fResources.addToHead(resource);
+ fResources.addToHead(resource);
}
void GrResourceCache2::notifyPurgable(GrGpuResource* resource) {
@@ -329,8 +325,6 @@ void GrResourceCache2::internalPurgeAsNeeded() {
fPurging = true;
- AutoValidate av(this); // Put this after setting fPurging so we're allowed to be over budget.
-
bool overBudget = true;
do {
fNewlyPurgableResourceWhilePurging = false;
@@ -358,6 +352,7 @@ void GrResourceCache2::internalPurgeAsNeeded() {
fNewlyPurgableResourceWhilePurging = false;
fPurging = false;
+ this->validate();
}
void GrResourceCache2::purgeAllUnlocked() {
@@ -366,8 +361,6 @@ void GrResourceCache2::purgeAllUnlocked() {
fPurging = true;
- AutoValidate av(this); // Put this after setting fPurging so we're allowed to be over budget.
-
do {
fNewlyPurgableResourceWhilePurging = false;
ResourceList::Iter resourceIter;
@@ -387,6 +380,7 @@ void GrResourceCache2::purgeAllUnlocked() {
}
} while (fNewlyPurgableResourceWhilePurging);
fPurging = false;
+ this->validate();
}
#ifdef SK_DEBUG
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698