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

Unified Diff: src/core/SkPixelRef.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/SkPixelRef.cpp
diff --git a/src/core/SkPixelRef.cpp b/src/core/SkPixelRef.cpp
index 20a8b34f067ff7eafc35759cb96b1b94de475a56..3191b0333b84deed555c3b12365c9c38255649c0 100644
--- a/src/core/SkPixelRef.cpp
+++ b/src/core/SkPixelRef.cpp
@@ -10,6 +10,8 @@
#include "SkThread.h"
#include "SkTraceEvent.h"
+//#define SK_TRACE_PIXELREF_LIFETIME
+
#ifdef SK_BUILD_FOR_WIN32
// We don't have SK_BASE_MUTEX_INIT on Windows.
@@ -85,6 +87,10 @@ static SkImageInfo validate_info(const SkImageInfo& info) {
return info.makeAlphaType(newAlphaType);
}
+#ifdef SK_TRACE_PIXELREF_LIFETIME
+ static int32_t gInstCounter;
+#endif
+
SkPixelRef::SkPixelRef(const SkImageInfo& info)
: fInfo(validate_info(info))
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
@@ -92,6 +98,9 @@ SkPixelRef::SkPixelRef(const SkImageInfo& info)
#endif
{
+#ifdef SK_TRACE_PIXELREF_LIFETIME
+ SkDebugf(" pixelref %d\n", sk_atomic_inc(&gInstCounter));
+#endif
this->setMutex(NULL);
fRec.zero();
fLockCount = 0;
@@ -108,6 +117,9 @@ SkPixelRef::SkPixelRef(const SkImageInfo& info, SkBaseMutex* mutex)
, fStableID(next_gen_id())
#endif
{
+#ifdef SK_TRACE_PIXELREF_LIFETIME
+ SkDebugf(" pixelref %d\n", sk_atomic_inc(&gInstCounter));
+#endif
this->setMutex(mutex);
fRec.zero();
fLockCount = 0;
@@ -118,6 +130,9 @@ SkPixelRef::SkPixelRef(const SkImageInfo& info, SkBaseMutex* mutex)
}
SkPixelRef::~SkPixelRef() {
+#ifdef SK_TRACE_PIXELREF_LIFETIME
+ SkDebugf("~pixelref %d\n", sk_atomic_dec(&gInstCounter) - 1);
+#endif
this->callGenIDChangeListeners();
}

Powered by Google App Engine
This is Rietveld 408576698