diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-07-09 21:31:54 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-07-09 21:31:54 +0000 |
commit | 6e8b7ddefdac3793307782f8bdca8cf011288a06 (patch) | |
tree | 65846a06f271a876b0809c88e8c8f6b4e99d89b7 | |
parent | 9432c0c2843112c293be2630421ddc52cbf62583 (diff) |
use typedef to name our ID type in SkImageCache
BUG=
R=scroggo@google.com
Review URL: https://codereview.chromium.org/18612003
git-svn-id: http://skia.googlecode.com/svn/trunk@9943 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | include/lazy/SkImageCache.h | 12 | ||||
-rw-r--r-- | include/lazy/SkLruImageCache.h | 12 | ||||
-rw-r--r-- | include/lazy/SkPurgeableImageCache.h | 16 |
3 files changed, 21 insertions, 19 deletions
diff --git a/include/lazy/SkImageCache.h b/include/lazy/SkImageCache.h index bfd5269ee9..7c4926109a 100644 --- a/include/lazy/SkImageCache.h +++ b/include/lazy/SkImageCache.h @@ -17,6 +17,8 @@ class SkImageCache : public SkRefCnt { public: + typedef intptr_t ID; + /** * Allocate memory whose lifetime is managed by the cache. On success, MUST be balanced with a * call to releaseCache and a call to throwAwayCache. @@ -27,7 +29,7 @@ public: * @return Pointer to the newly allocated memory, or NULL. This memory is safe to use until * releaseCache is called with ID. */ - virtual void* allocAndPinCache(size_t bytes, intptr_t* ID) = 0; + virtual void* allocAndPinCache(size_t bytes, ID*) = 0; /** * Output parameter for pinCache, stating whether the memory still contains the data it held @@ -60,7 +62,7 @@ public: * this call must be balanced with a call to releaseCache. If NULL, the memory * has been reclaimed, and throwAwayCache MUST NOT be called. */ - virtual void* pinCache(intptr_t ID, DataStatus* status) = 0; + virtual void* pinCache(ID, DataStatus* status) = 0; /** * Inform the cache that it is safe to free the block of memory corresponding to ID. After @@ -69,19 +71,19 @@ public: * the same ID. * @param ID Unique ID for the memory block which is now safe to age out of the cache. */ - virtual void releaseCache(intptr_t ID) = 0; + virtual void releaseCache(ID) = 0; /** * Inform the cache that the block of memory associated with ID will not be asked for again. * After this call, ID is no longer valid. Must not be called while the associated memory is * pinned. Must be called to balance a successful allocAndPinCache. */ - virtual void throwAwayCache(intptr_t ID) = 0; + virtual void throwAwayCache(ID) = 0; /** * ID which does not correspond to any valid cache. */ - static const intptr_t UNINITIALIZED_ID = 0; + static const ID UNINITIALIZED_ID = 0; #ifdef SK_DEBUG /** diff --git a/include/lazy/SkLruImageCache.h b/include/lazy/SkLruImageCache.h index f655230a93..3e9d315095 100644 --- a/include/lazy/SkLruImageCache.h +++ b/include/lazy/SkLruImageCache.h @@ -25,7 +25,7 @@ public: virtual ~SkLruImageCache(); #ifdef SK_DEBUG - virtual MemoryStatus getMemoryStatus(intptr_t ID) const SK_OVERRIDE; + virtual MemoryStatus getMemoryStatus(ID) const SK_OVERRIDE; virtual void purgeAllUnpinnedCaches() SK_OVERRIDE; #endif @@ -45,10 +45,10 @@ public: */ size_t getImageCacheUsed() const { return fRamUsed; } - virtual void* allocAndPinCache(size_t bytes, intptr_t* ID) SK_OVERRIDE; - virtual void* pinCache(intptr_t ID, SkImageCache::DataStatus*) SK_OVERRIDE; - virtual void releaseCache(intptr_t ID) SK_OVERRIDE; - virtual void throwAwayCache(intptr_t ID) SK_OVERRIDE; + virtual void* allocAndPinCache(size_t bytes, ID*) SK_OVERRIDE; + virtual void* pinCache(ID, SkImageCache::DataStatus*) SK_OVERRIDE; + virtual void releaseCache(ID) SK_OVERRIDE; + virtual void throwAwayCache(ID) SK_OVERRIDE; private: // Linked list of recently used. Head is the most recently used, and tail is the least. @@ -67,7 +67,7 @@ private: * Find the CachedPixels represented by ID, or NULL if not in the cache. Mutex must be locked * before calling. */ - CachedPixels* findByID(intptr_t ID) const; + CachedPixels* findByID(ID) const; /** * If over budget, throw away pixels which are not currently in use until below budget or there diff --git a/include/lazy/SkPurgeableImageCache.h b/include/lazy/SkPurgeableImageCache.h index 0516ff18ef..cc2db819f9 100644 --- a/include/lazy/SkPurgeableImageCache.h +++ b/include/lazy/SkPurgeableImageCache.h @@ -22,13 +22,13 @@ class SkPurgeableImageCache : public SkImageCache { public: static SkImageCache* Create(); - virtual void* allocAndPinCache(size_t bytes, intptr_t* ID) SK_OVERRIDE; - virtual void* pinCache(intptr_t ID, SkImageCache::DataStatus*) SK_OVERRIDE; - virtual void releaseCache(intptr_t ID) SK_OVERRIDE; - virtual void throwAwayCache(intptr_t ID) SK_OVERRIDE; + virtual void* allocAndPinCache(size_t bytes, ID*) SK_OVERRIDE; + virtual void* pinCache(ID, SkImageCache::DataStatus*) SK_OVERRIDE; + virtual void releaseCache(ID) SK_OVERRIDE; + virtual void throwAwayCache(ID) SK_OVERRIDE; #ifdef SK_DEBUG - virtual MemoryStatus getMemoryStatus(intptr_t ID) const SK_OVERRIDE; + virtual MemoryStatus getMemoryStatus(ID) const SK_OVERRIDE; virtual void purgeAllUnpinnedCaches() SK_OVERRIDE; virtual ~SkPurgeableImageCache(); #endif @@ -37,9 +37,9 @@ private: SkPurgeableImageCache(); #ifdef SK_DEBUG - SkTDArray<intptr_t> fRecs; - int findRec(intptr_t) const; + SkTDArray<ID> fRecs; + int findRec(ID) const; #endif - void removeRec(intptr_t); + void removeRec(ID); }; #endif // SkPurgeableImageCache_DEFINED |