Chromium Code Reviews| Index: src/lazy/SkDiscardablePixelRef.h |
| diff --git a/src/lazy/SkDiscardablePixelRef.h b/src/lazy/SkDiscardablePixelRef.h |
| index bbe19b8b20727dc5672bf6dcadcdd9c278a8fc35..53f6c1773517cd760ed34ee2dab51927f73c585c 100644 |
| --- a/src/lazy/SkDiscardablePixelRef.h |
| +++ b/src/lazy/SkDiscardablePixelRef.h |
| @@ -8,11 +8,16 @@ |
| #ifndef SkDiscardablePixelRef_DEFINED |
| #define SkDiscardablePixelRef_DEFINED |
| +#include "SkDiscardableMemory.h" |
| #include "SkPixelRef.h" |
| #include "SkImageGenerator.h" |
| #include "SkImageInfo.h" |
| -class SkDiscardableMemory; |
| +#ifdef SK_DEBUG |
| + #define LAZY_CACHE_STATS 1 |
| +#elif !defined(LAZY_CACHE_STATS) |
| + #define LAZY_CACHE_STATS 0 |
| +#endif |
| /** |
| * An interface that allows a purgable PixelRef to re-decode an image. |
| @@ -31,13 +36,20 @@ public: |
| * SkDELETE() on the generator. Therefore, generator should be |
| * allocated with SkNEW() or SkNEW_ARGS(). |
| */ |
| - static bool Install(SkImageGenerator* generator, SkBitmap* destination); |
| + static bool Install(SkImageGenerator* generator, SkBitmap* destination, |
| + SkDiscardableMemory::Factory* factory = NULL); |
|
scroggo
2013/12/02 19:00:09
Can you add a comment explaining how the factory i
|
| + |
| + #if LAZY_CACHE_STATS |
| + static int32_t GetCacheHits() { return gCacheHits; } |
| + static int32_t GetCacheMisses() { return gCacheMisses; } |
| + static void ResetCacheStats() { gCacheHits = gCacheMisses = 0; } |
| + #endif |
| SK_DECLARE_UNFLATTENABLE_OBJECT() |
| protected: |
| ~SkDiscardablePixelRef(); |
| - virtual void* onLockPixels(SkColorTable**) SK_OVERRIDE; |
| + virtual void* onLockPixels(SkColorTable** colorTable) SK_OVERRIDE; |
| virtual void onUnlockPixels() SK_OVERRIDE; |
| virtual bool onLockPixelsAreWritable() const SK_OVERRIDE { return false; } |
| @@ -46,17 +58,24 @@ protected: |
| } |
| private: |
| - SkImageGenerator* const fGenerator; |
| - const SkImageInfo fInfo; |
| - const size_t fSize; // size of memory to be allocated |
| - const size_t fRowBytes; |
| + SkDiscardableMemory::Factory* const fDMFactory; |
| + SkImageGenerator* const fGenerator; |
| + const SkImageInfo fInfo; |
| + const size_t fSize; // size of allocation |
| + const size_t fRowBytes; |
| // These const members should not change over the life of the |
| // PixelRef, since the SkBitmap doesn't expect them to change. |
| - SkDiscardableMemory* fDiscardableMemory; |
| + SkDiscardableMemory* fDiscardableMemory; |
| + |
| + #if LAZY_CACHE_STATS |
| + static int32_t gCacheHits; |
| + static int32_t gCacheMisses; |
| + #endif |
| /* Takes ownership of SkImageGenerator. */ |
| - SkDiscardablePixelRef(SkImageGenerator* generator, |
| + SkDiscardablePixelRef(SkDiscardableMemory::Factory* factory, |
| + SkImageGenerator* generator, |
| const SkImageInfo& info, |
| size_t size, |
| size_t rowBytes); |