From 83787d0ff0a2b2f839a4a3ce6dadd033f83fe643 Mon Sep 17 00:00:00 2001 From: reed Date: Wed, 25 Feb 2015 07:17:11 -0800 Subject: only notify bitmaps that have been added to the cache old code: - calls=2677 hit-rate=3.51139% new code: - calls=94 hit-rate=97.8723% BUG=skia: Review URL: https://codereview.chromium.org/960563002 --- include/core/SkPixelRef.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include/core/SkPixelRef.h') diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h index 5027a35329..01303e5be5 100644 --- a/include/core/SkPixelRef.h +++ b/include/core/SkPixelRef.h @@ -245,6 +245,12 @@ public: // Takes ownership of listener. void addGenIDChangeListener(GenIDChangeListener* listener); + // Call when this pixelref is part of the key to a resourcecache entry. This allows the cache + // to know automatically those entries can be purged when this pixelref is changed or deleted. + void notifyAddedToCache() { + fAddedToCache.store(true); + } + protected: /** * On success, returns true and fills out the LockRec for the pixels. On @@ -315,6 +321,7 @@ private: mutable SkAtomic fGenerationID; mutable SkAtomic fUniqueGenerationID; + SkAtomic fAddedToCache; #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK const uint32_t fStableID; #endif -- cgit v1.2.3