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

Unified Diff: src/core/SkImageFilter.cpp

Issue 1148973002: purge imagefilter cache so we can better track leaks (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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
Index: src/core/SkImageFilter.cpp
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index 0a5aca85edd2abf8a98c4f675114565f935afae0..0a5e16e1d7a54d44640a0ff86cc5c343cb4dea42 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -474,6 +474,16 @@ public:
removeInternal(tail);
}
}
+
+ void purge() override {
+ SkAutoMutexAcquire mutex(fMutex);
+ while (fCurrentBytes > 0) {
+ Value* tail = fLRU.tail();
+ SkASSERT(tail);
+ this->removeInternal(tail);
+ }
+ }
+
private:
void removeInternal(Value* v) {
fCurrentBytes -= v->fBitmap.getSize();
@@ -504,3 +514,7 @@ SK_DECLARE_STATIC_LAZY_PTR(SkImageFilter::Cache, cache, CreateCache);
SkImageFilter::Cache* SkImageFilter::Cache::Get() {
return cache.get();
}
+
+void SkImageFilter::PurgeCache() {
robertphillips 2015/05/20 20:28:19 Should this be gCache ?
+ cache.get()->purge();
+}

Powered by Google App Engine
This is Rietveld 408576698