Add a way to monitor cache hits and misses for deferred decoding.
Adds a new flag to bench_pictures in order to do this. Also fix
a warning.
Review URL: https://codereview.chromium.org/12393046
git-svn-id: http://skia.googlecode.com/svn/trunk@7965 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/lazy/SkLazyPixelRef.h b/src/lazy/SkLazyPixelRef.h
index e5a20bd..af85f90 100644
--- a/src/lazy/SkLazyPixelRef.h
+++ b/src/lazy/SkLazyPixelRef.h
@@ -17,6 +17,12 @@
class SkData;
class SkImageCache;
+#ifdef SK_DEBUG
+ #define LAZY_CACHE_STATS 1
+#elif !defined(LAZY_CACHE_STATS)
+ #define LAZY_CACHE_STATS 0
+#endif
+
/**
* PixelRef which defers decoding until SkBitmap::lockPixels() is called.
*/
@@ -38,6 +44,12 @@
intptr_t getCacheId() const { return fCacheId; }
#endif
+#if LAZY_CACHE_STATS
+ static int32_t GetCacheHits() { return gCacheHits; }
+ static int32_t GetCacheMisses() { return gCacheMisses; }
+ static void ResetCacheStats() { gCacheHits = gCacheMisses = 0; }
+#endif
+
// No need to flatten this object. When flattening an SkBitmap, SkOrderedWriteBuffer will check
// the encoded data and write that instead.
// Future implementations of SkFlattenableWriteBuffer will need to special case for
@@ -57,6 +69,11 @@
SkImageCache* fImageCache;
intptr_t fCacheId;
+#if LAZY_CACHE_STATS
+ static int32_t gCacheHits;
+ static int32_t gCacheMisses;
+#endif
+
typedef SkPixelRef INHERITED;
};