Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2013 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #ifndef SkPurgeableImageCache_DEFINED | |
| 9 #define SkPurgeableImageCache_DEFINED | |
| 10 | |
| 11 #include "SkImageCache.h" | |
| 12 | |
| 13 #ifdef SK_DEBUG | |
| 14 #include "SkTDArray.h" | |
| 15 #endif | |
| 16 | |
| 17 /** | |
| 18 * Implementation for SkImageCache that uses system defined purgeable memory. | |
| 19 */ | |
| 20 class SkPurgeableImageCache : public SkImageCache { | |
| 21 | |
| 22 public: | |
| 23 /** | |
| 24 * Get a pointer to the single global instance of the purgeable image cache . | |
| 25 * If there is no Skia implementation for purgeable memory, this returns NU LL. | |
| 26 * If non-NULL, the caller must unref it after use. | |
| 27 */ | |
| 28 static SkImageCache* GetPurgeableImageCache(); | |
|
reed1
2013/03/18 21:25:17
Why isn't this just called Create()?
scroggo
2013/03/18 21:37:16
Done.
| |
| 29 | |
| 30 virtual void* allocAndPinCache(size_t bytes, intptr_t* ID) SK_OVERRIDE; | |
| 31 virtual void* pinCache(intptr_t ID, SkImageCache::DataStatus*) SK_OVERRIDE; | |
| 32 virtual void releaseCache(intptr_t ID) SK_OVERRIDE; | |
| 33 virtual void throwAwayCache(intptr_t ID) SK_OVERRIDE; | |
| 34 | |
| 35 #ifdef SK_DEBUG | |
| 36 virtual MemoryStatus getMemoryStatus(intptr_t ID) const SK_OVERRIDE; | |
| 37 virtual void purgeAllUnpinnedCaches() SK_OVERRIDE; | |
| 38 virtual ~SkPurgeableImageCache(); | |
| 39 #endif | |
| 40 | |
| 41 private: | |
| 42 /** | |
| 43 * Constructor is private. The correct way to get this cache is through | |
| 44 * GetPurgeableImageCache, which will return the single global. | |
| 45 */ | |
| 46 SkPurgeableImageCache(); | |
| 47 | |
| 48 #ifdef SK_DEBUG | |
| 49 SkTDArray<intptr_t> fRecs; | |
| 50 int findRec(intptr_t) const; | |
| 51 #endif | |
| 52 void removeRec(intptr_t); | |
| 53 }; | |
| 54 #endif // SkPurgeableImageCache_DEFINED | |
| OLD | NEW |