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

Unified Diff: src/gpu/GrResourceCache.cpp

Issue 26734003: Proactive SkPixelRef invalidation (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: drop the check Created 7 years, 2 months 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 | « src/gpu/GrResourceCache.h ('k') | src/gpu/SkGr.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrResourceCache.cpp
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp
index 1d0f3845c5d5a4e08f417baa5fe4f52442bf6a54..5cf3f82c7d780d1acc5ee53ca20d9f6140b1a7b4 100644
--- a/src/gpu/GrResourceCache.cpp
+++ b/src/gpu/GrResourceCache.cpp
@@ -284,6 +284,8 @@ void GrResourceCache::purgeAsNeeded(int extraCount, size_t extraBytes) {
fPurging = true;
+ this->purgeInvalidated();
+
this->internalPurge(extraCount, extraBytes);
if (((fEntryCount+extraCount) > fMaxCount ||
(fEntryBytes+extraBytes) > fMaxBytes) &&
@@ -298,6 +300,25 @@ void GrResourceCache::purgeAsNeeded(int extraCount, size_t extraBytes) {
fPurging = false;
}
+void GrResourceCache::purgeInvalidated() {
+ SkTDArray<GrResourceInvalidatedMessage> invalidated;
+ fInvalidationInbox.poll(&invalidated);
+
+ for (int i = 0; i < invalidated.count(); i++) {
+ // We're somewhat missing an opportunity here. We could use the
+ // default find functor that gives us back resources whether we own
+ // them exclusively or not, and when they're not exclusively owned mark
+ // them for purging later when they do become exclusively owned.
+ //
+ // This is complicated and confusing. May try this in the future. For
+ // now, these resources are just LRU'd as if we never got the message.
+ GrResourceEntry* entry = fCache.find(invalidated[i].key, GrTFindUnreffedFunctor());
+ if (entry) {
+ this->deleteResource(entry);
+ }
+ }
+}
+
void GrResourceCache::deleteResource(GrResourceEntry* entry) {
SkASSERT(1 == entry->fResource->getRefCnt());
« no previous file with comments | « src/gpu/GrResourceCache.h ('k') | src/gpu/SkGr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698