add more tests for discardable caches
BUG=
R=halcanary@google.com
Review URL: https://codereview.chromium.org/112833003
git-svn-id: http://skia.googlecode.com/svn/trunk@12618 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/lazy/SkDiscardableMemoryPool.h b/src/lazy/SkDiscardableMemoryPool.h
index e9f3b04..61bad70 100644
--- a/src/lazy/SkDiscardableMemoryPool.h
+++ b/src/lazy/SkDiscardableMemoryPool.h
@@ -12,6 +12,8 @@
#include "SkTInternalLList.h"
#include "SkThread.h"
+class SkPoolDiscardableMemory;
+
#ifdef SK_DEBUG
#define LAZY_CACHE_STATS 1
#elif !defined(LAZY_CACHE_STATS)
@@ -22,20 +24,22 @@
* This non-global pool can be used for unit tests to verify that the
* pool works.
*/
-class SkPoolDiscardableMemory;
class SkDiscardableMemoryPool : public SkDiscardableMemory::Factory {
public:
/**
* Without mutex, will be not be thread safe.
*/
SkDiscardableMemoryPool(size_t budget, SkBaseMutex* mutex = NULL);
- ~SkDiscardableMemoryPool();
- SkDiscardableMemory* create(size_t bytes) SK_OVERRIDE;
+ virtual ~SkDiscardableMemoryPool();
+
+ virtual SkDiscardableMemory* create(size_t bytes) SK_OVERRIDE;
+
size_t getRAMUsed();
void setRAMBudget(size_t budget);
+
/** purges all unlocked DMs */
void dumpPool();
- friend class SkPoolDiscardableMemory;
+
#if LAZY_CACHE_STATS
int fCacheHits;
int fCacheMisses;
@@ -46,6 +50,7 @@
size_t fBudget;
size_t fUsed;
SkTInternalLList<SkPoolDiscardableMemory> fList;
+
/** Function called to free memory if needed */
void dumpDownTo(size_t budget);
/** called by SkDiscardableMemoryPool upon destruction */
@@ -54,6 +59,9 @@
bool lock(SkPoolDiscardableMemory* dm);
/** called by SkDiscardableMemoryPool::unlock() */
void unlock(SkPoolDiscardableMemory* dm);
+
+ friend class SkPoolDiscardableMemory;
+
typedef SkDiscardableMemory::Factory INHERITED;
};