aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-08-28 13:35:23 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-08-28 13:35:23 -0700
commit011f39aeb2b9715546eb74d9ebb71be7baf95fde (patch)
tree53256ae14d50c54ba1c022d9829a8cfbc3244726 /src/core
parent7ba2828aa6687f9d12f4fa0b0a2ef9a9dc2efa68 (diff)
rename ScaledImageCache to ResourceCache
BUG=skia: R=bsalomon@google.com, mtklein@google.com Author: reed@google.com Review URL: https://codereview.chromium.org/511283002
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkBitmapCache.cpp27
-rw-r--r--src/core/SkBitmapProcState.cpp26
-rw-r--r--src/core/SkBitmapProcState.h3
-rw-r--r--src/core/SkResourceCache.cpp (renamed from src/core/SkScaledImageCache.cpp)122
-rw-r--r--src/core/SkResourceCache.h (renamed from src/core/SkScaledImageCache.h)16
5 files changed, 84 insertions, 110 deletions
diff --git a/src/core/SkBitmapCache.cpp b/src/core/SkBitmapCache.cpp
index c0ce0e6369..99e2f5c503 100644
--- a/src/core/SkBitmapCache.cpp
+++ b/src/core/SkBitmapCache.cpp
@@ -6,7 +6,7 @@
*/
#include "SkBitmapCache.h"
-#include "SkScaledImageCache.h"
+#include "SkResourceCache.h"
#include "SkMipMap.h"
#include "SkRect.h"
@@ -24,7 +24,7 @@ static SkIRect get_bounds_from_bitmap(const SkBitmap& bm) {
return SkIRect::MakeXYWH(origin.fX, origin.fY, bm.width(), bm.height());
}
-struct BitmapKey : public SkScaledImageCache::Key {
+struct BitmapKey : public SkResourceCache::Key {
public:
BitmapKey(uint32_t genID, SkScalar scaleX, SkScalar scaleY, const SkIRect& bounds)
: fGenID(genID)
@@ -43,7 +43,7 @@ public:
//////////////////////////////////////////////////////////////////////////////////////////
-struct BitmapRec : public SkScaledImageCache::Rec {
+struct BitmapRec : public SkResourceCache::Rec {
BitmapRec(uint32_t genID, SkScalar scaleX, SkScalar scaleY, const SkIRect& bounds,
const SkBitmap& result)
: fKey(genID, scaleX, scaleY, bounds)
@@ -58,10 +58,10 @@ struct BitmapRec : public SkScaledImageCache::Rec {
};
static bool find_and_return(const BitmapKey& key, SkBitmap* result) {
- const BitmapRec* rec = (BitmapRec*)SkScaledImageCache::FindAndLock(key);
+ const BitmapRec* rec = (BitmapRec*)SkResourceCache::FindAndLock(key);
if (rec) {
*result = rec->fBitmap;
- SkScaledImageCache::Unlock(rec);
+ SkResourceCache::Unlock(rec);
result->lockPixels();
if (result->getPixels()) {
@@ -91,9 +91,8 @@ void SkBitmapCache::Add(const SkBitmap& src, SkScalar invScaleX, SkScalar invSca
// degenerate, and the key we use for mipmaps
return;
}
- SkScaledImageCache::Add(SkNEW_ARGS(BitmapRec,
- (src.getGenerationID(), invScaleX, invScaleY,
- get_bounds_from_bitmap(src), result)));
+ SkResourceCache::Add(SkNEW_ARGS(BitmapRec, (src.getGenerationID(), invScaleX, invScaleY,
+ get_bounds_from_bitmap(src), result)));
}
bool SkBitmapCache::Find(uint32_t genID, int width, int height, SkBitmap* result) {
@@ -102,13 +101,13 @@ bool SkBitmapCache::Find(uint32_t genID, int width, int height, SkBitmap* result
}
void SkBitmapCache::Add(uint32_t genID, int width, int height, const SkBitmap& result) {
- SkScaledImageCache::Add(SkNEW_ARGS(BitmapRec, (genID, SK_Scalar1, SK_Scalar1,
- SkIRect::MakeWH(width, height), result)));
+ SkResourceCache::Add(SkNEW_ARGS(BitmapRec, (genID, SK_Scalar1, SK_Scalar1,
+ SkIRect::MakeWH(width, height), result)));
}
//////////////////////////////////////////////////////////////////////////////////////////
-struct MipMapRec : public SkScaledImageCache::Rec {
+struct MipMapRec : public SkResourceCache::Rec {
MipMapRec(const SkBitmap& src, const SkMipMap* result)
: fKey(src.getGenerationID(), 0, 0, get_bounds_from_bitmap(src))
, fMipMap(SkRef(result))
@@ -128,18 +127,18 @@ struct MipMapRec : public SkScaledImageCache::Rec {
const SkMipMap* SkMipMapCache::FindAndRef(const SkBitmap& src) {
BitmapKey key(src.getGenerationID(), 0, 0, get_bounds_from_bitmap(src));
- const MipMapRec* rec = (MipMapRec*)SkScaledImageCache::FindAndLock(key);
+ const MipMapRec* rec = (MipMapRec*)SkResourceCache::FindAndLock(key);
const SkMipMap* result = NULL;
if (rec) {
result = SkRef(rec->fMipMap);
- SkScaledImageCache::Unlock(rec);
+ SkResourceCache::Unlock(rec);
}
return result;
}
void SkMipMapCache::Add(const SkBitmap& src, const SkMipMap* result) {
if (result) {
- SkScaledImageCache::Add(SkNEW_ARGS(MipMapRec, (src, result)));
+ SkResourceCache::Add(SkNEW_ARGS(MipMapRec, (src, result)));
}
}
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp
index 7640573596..52a2ecf25c 100644
--- a/src/core/SkBitmapProcState.cpp
+++ b/src/core/SkBitmapProcState.cpp
@@ -16,6 +16,7 @@
#include "SkMipMap.h"
#include "SkPixelRef.h"
#include "SkImageEncoder.h"
+#include "SkResourceCache.h"
#if !SK_ARM_NEON_IS_NONE
// These are defined in src/opts/SkBitmapProcState_arm_neon.cpp
@@ -107,31 +108,10 @@ static SkScalar effective_matrix_scale_sqrd(const SkMatrix& mat) {
return SkMaxScalar(v1.lengthSqd(), v2.lengthSqd());
}
-class AutoScaledCacheUnlocker {
-public:
- AutoScaledCacheUnlocker(SkScaledImageCache::ID* idPtr) : fIDPtr(idPtr) {}
- ~AutoScaledCacheUnlocker() {
- if (fIDPtr && *fIDPtr) {
- SkScaledImageCache::Unlock(*fIDPtr);
- *fIDPtr = NULL;
- }
- }
-
- // forgets the ID, so it won't call Unlock
- void release() {
- fIDPtr = NULL;
- }
-
-private:
- SkScaledImageCache::ID* fIDPtr;
-};
-#define AutoScaledCacheUnlocker(...) SK_REQUIRE_LOCAL_VAR(AutoScaledCacheUnlocker)
-
// Check to see that the size of the bitmap that would be produced by
// scaling by the given inverted matrix is less than the maximum allowed.
static inline bool cache_size_okay(const SkBitmap& bm, const SkMatrix& invMat) {
- size_t maximumAllocation
- = SkScaledImageCache::GetSingleAllocationByteLimit();
+ size_t maximumAllocation = SkResourceCache::GetSingleAllocationByteLimit();
if (0 == maximumAllocation) {
return true;
}
@@ -191,7 +171,7 @@ bool SkBitmapProcState::possiblyScaleImage() {
SkBitmapScaler::RESIZE_BEST,
dest_width,
dest_height,
- SkScaledImageCache::GetAllocator())) {
+ SkResourceCache::GetAllocator())) {
// we failed to create fScaledBitmap, so just return and let
// the scanline proc handle it.
return false;
diff --git a/src/core/SkBitmapProcState.h b/src/core/SkBitmapProcState.h
index 64dda2ecb3..289e308eed 100644
--- a/src/core/SkBitmapProcState.h
+++ b/src/core/SkBitmapProcState.h
@@ -1,4 +1,3 @@
-
/*
* Copyright 2007 The Android Open Source Project
*
@@ -6,7 +5,6 @@
* found in the LICENSE file.
*/
-
#ifndef SkBitmapProcState_DEFINED
#define SkBitmapProcState_DEFINED
@@ -15,7 +13,6 @@
#include "SkMatrix.h"
#include "SkMipMap.h"
#include "SkPaint.h"
-#include "SkScaledImageCache.h"
#define FractionalInt_IS_64BIT
diff --git a/src/core/SkScaledImageCache.cpp b/src/core/SkResourceCache.cpp
index 9d15422300..7ffdfffbaf 100644
--- a/src/core/SkScaledImageCache.cpp
+++ b/src/core/SkResourceCache.cpp
@@ -6,7 +6,7 @@
*/
#include "SkChecksum.h"
-#include "SkScaledImageCache.h"
+#include "SkResourceCache.h"
#include "SkMipMap.h"
#include "SkPixelRef.h"
@@ -21,7 +21,7 @@
#define SK_DEFAULT_IMAGE_CACHE_LIMIT (2 * 1024 * 1024)
#endif
-void SkScaledImageCache::Key::init(size_t length) {
+void SkResourceCache::Key::init(size_t length) {
SkASSERT(SkAlign4(length) == length);
// 2 is fCount32 and fHash
fCount32 = SkToS32(2 + (length >> 2));
@@ -31,8 +31,8 @@ void SkScaledImageCache::Key::init(size_t length) {
#include "SkTDynamicHash.h"
-class SkScaledImageCache::Hash :
- public SkTDynamicHash<SkScaledImageCache::Rec, SkScaledImageCache::Key> {};
+class SkResourceCache::Hash :
+ public SkTDynamicHash<SkResourceCache::Rec, SkResourceCache::Key> {};
///////////////////////////////////////////////////////////////////////////////
@@ -41,9 +41,9 @@ class SkScaledImageCache::Hash :
#define USE_HASH
#if !defined(USE_HASH)
-static inline SkScaledImageCache::Rec* find_rec_in_list(
- SkScaledImageCache::Rec* head, const Key & key) {
- SkScaledImageCache::Rec* rec = head;
+static inline SkResourceCache::Rec* find_rec_in_list(
+ SkResourceCache::Rec* head, const Key & key) {
+ SkResourceCache::Rec* rec = head;
while ((rec != NULL) && (rec->fKey != key)) {
rec = rec->fNext;
}
@@ -51,7 +51,7 @@ static inline SkScaledImageCache::Rec* find_rec_in_list(
}
#endif
-void SkScaledImageCache::init() {
+void SkResourceCache::init() {
fHead = NULL;
fTail = NULL;
#ifdef USE_HASH
@@ -142,10 +142,9 @@ size_t SkOneShotDiscardablePixelRef::getAllocatedSizeInBytes() const {
return this->info().getSafeSize(fRB);
}
-class SkScaledImageCacheDiscardableAllocator : public SkBitmap::Allocator {
+class SkResourceCacheDiscardableAllocator : public SkBitmap::Allocator {
public:
- SkScaledImageCacheDiscardableAllocator(
- SkScaledImageCache::DiscardableFactory factory) {
+ SkResourceCacheDiscardableAllocator(SkResourceCache::DiscardableFactory factory) {
SkASSERT(factory);
fFactory = factory;
}
@@ -153,11 +152,10 @@ public:
virtual bool allocPixelRef(SkBitmap*, SkColorTable*) SK_OVERRIDE;
private:
- SkScaledImageCache::DiscardableFactory fFactory;
+ SkResourceCache::DiscardableFactory fFactory;
};
-bool SkScaledImageCacheDiscardableAllocator::allocPixelRef(SkBitmap* bitmap,
- SkColorTable* ctable) {
+bool SkResourceCacheDiscardableAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) {
size_t size = bitmap->getSize();
uint64_t size64 = bitmap->computeSize64();
if (0 == size || size64 > (uint64_t)size) {
@@ -181,19 +179,19 @@ bool SkScaledImageCacheDiscardableAllocator::allocPixelRef(SkBitmap* bitmap,
return bitmap->readyToDraw();
}
-SkScaledImageCache::SkScaledImageCache(DiscardableFactory factory) {
+SkResourceCache::SkResourceCache(DiscardableFactory factory) {
this->init();
fDiscardableFactory = factory;
- fAllocator = SkNEW_ARGS(SkScaledImageCacheDiscardableAllocator, (factory));
+ fAllocator = SkNEW_ARGS(SkResourceCacheDiscardableAllocator, (factory));
}
-SkScaledImageCache::SkScaledImageCache(size_t byteLimit) {
+SkResourceCache::SkResourceCache(size_t byteLimit) {
this->init();
fTotalByteLimit = byteLimit;
}
-SkScaledImageCache::~SkScaledImageCache() {
+SkResourceCache::~SkResourceCache() {
SkSafeUnref(fAllocator);
Rec* rec = fHead;
@@ -207,7 +205,7 @@ SkScaledImageCache::~SkScaledImageCache() {
////////////////////////////////////////////////////////////////////////////////
-const SkScaledImageCache::Rec* SkScaledImageCache::findAndLock(const Key& key) {
+const SkResourceCache::Rec* SkResourceCache::findAndLock(const Key& key) {
#ifdef USE_HASH
Rec* rec = fHash->find(key);
#else
@@ -220,7 +218,7 @@ const SkScaledImageCache::Rec* SkScaledImageCache::findAndLock(const Key& key) {
return rec;
}
-const SkScaledImageCache::Rec* SkScaledImageCache::addAndLock(Rec* rec) {
+const SkResourceCache::Rec* SkResourceCache::addAndLock(Rec* rec) {
SkASSERT(rec);
// See if we already have this key (racy inserts, etc.)
const Rec* existing = this->findAndLock(rec->getKey());
@@ -240,7 +238,7 @@ const SkScaledImageCache::Rec* SkScaledImageCache::addAndLock(Rec* rec) {
return rec;
}
-void SkScaledImageCache::add(Rec* rec) {
+void SkResourceCache::add(Rec* rec) {
SkASSERT(rec);
// See if we already have this key (racy inserts, etc.)
const Rec* existing = this->findAndLock(rec->getKey());
@@ -259,7 +257,7 @@ void SkScaledImageCache::add(Rec* rec) {
this->unlock(rec);
}
-void SkScaledImageCache::unlock(SkScaledImageCache::ID id) {
+void SkResourceCache::unlock(SkResourceCache::ID id) {
SkASSERT(id);
#ifdef SK_DEBUG
@@ -288,7 +286,7 @@ void SkScaledImageCache::unlock(SkScaledImageCache::ID id) {
}
}
-void SkScaledImageCache::purgeAsNeeded() {
+void SkResourceCache::purgeAsNeeded() {
size_t byteLimit;
int countLimit;
@@ -330,7 +328,7 @@ void SkScaledImageCache::purgeAsNeeded() {
fCount = countUsed;
}
-size_t SkScaledImageCache::setTotalByteLimit(size_t newLimit) {
+size_t SkResourceCache::setTotalByteLimit(size_t newLimit) {
size_t prevLimit = fTotalByteLimit;
fTotalByteLimit = newLimit;
if (newLimit < prevLimit) {
@@ -341,7 +339,7 @@ size_t SkScaledImageCache::setTotalByteLimit(size_t newLimit) {
///////////////////////////////////////////////////////////////////////////////
-void SkScaledImageCache::detach(Rec* rec) {
+void SkResourceCache::detach(Rec* rec) {
Rec* prev = rec->fPrev;
Rec* next = rec->fNext;
@@ -361,7 +359,7 @@ void SkScaledImageCache::detach(Rec* rec) {
rec->fNext = rec->fPrev = NULL;
}
-void SkScaledImageCache::moveToHead(Rec* rec) {
+void SkResourceCache::moveToHead(Rec* rec) {
if (fHead == rec) {
return;
}
@@ -380,7 +378,7 @@ void SkScaledImageCache::moveToHead(Rec* rec) {
this->validate();
}
-void SkScaledImageCache::addToHead(Rec* rec) {
+void SkResourceCache::addToHead(Rec* rec) {
this->validate();
rec->fPrev = NULL;
@@ -401,7 +399,7 @@ void SkScaledImageCache::addToHead(Rec* rec) {
///////////////////////////////////////////////////////////////////////////////
#ifdef SK_DEBUG
-void SkScaledImageCache::validate() const {
+void SkResourceCache::validate() const {
if (NULL == fHead) {
SkASSERT(NULL == fTail);
SkASSERT(0 == fTotalBytesUsed);
@@ -445,7 +443,7 @@ void SkScaledImageCache::validate() const {
}
#endif
-void SkScaledImageCache::dump() const {
+void SkResourceCache::dump() const {
this->validate();
const Rec* rec = fHead;
@@ -455,18 +453,18 @@ void SkScaledImageCache::dump() const {
rec = rec->fNext;
}
- SkDebugf("SkScaledImageCache: count=%d bytes=%d locked=%d %s\n",
+ SkDebugf("SkResourceCache: count=%d bytes=%d locked=%d %s\n",
fCount, fTotalBytesUsed, locked,
fDiscardableFactory ? "discardable" : "malloc");
}
-size_t SkScaledImageCache::setSingleAllocationByteLimit(size_t newLimit) {
+size_t SkResourceCache::setSingleAllocationByteLimit(size_t newLimit) {
size_t oldLimit = fSingleAllocationByteLimit;
fSingleAllocationByteLimit = newLimit;
return oldLimit;
}
-size_t SkScaledImageCache::getSingleAllocationByteLimit() const {
+size_t SkResourceCache::getSingleAllocationByteLimit() const {
return fSingleAllocationByteLimit;
}
@@ -475,85 +473,85 @@ size_t SkScaledImageCache::getSingleAllocationByteLimit() const {
#include "SkThread.h"
SK_DECLARE_STATIC_MUTEX(gMutex);
-static SkScaledImageCache* gScaledImageCache = NULL;
-static void cleanup_gScaledImageCache() {
+static SkResourceCache* gResourceCache = NULL;
+static void cleanup_gResourceCache() {
// We'll clean this up in our own tests, but disable for clients.
// Chrome seems to have funky multi-process things going on in unit tests that
// makes this unsafe to delete when the main process atexit()s.
// SkLazyPtr does the same sort of thing.
#if SK_DEVELOPER
- SkDELETE(gScaledImageCache);
+ SkDELETE(gResourceCache);
#endif
}
/** Must hold gMutex when calling. */
-static SkScaledImageCache* get_cache() {
+static SkResourceCache* get_cache() {
// gMutex is always held when this is called, so we don't need to be fancy in here.
gMutex.assertHeld();
- if (NULL == gScaledImageCache) {
+ if (NULL == gResourceCache) {
#ifdef SK_USE_DISCARDABLE_SCALEDIMAGECACHE
- gScaledImageCache = SkNEW_ARGS(SkScaledImageCache, (SkDiscardableMemory::Create));
+ gResourceCache = SkNEW_ARGS(SkResourceCache, (SkDiscardableMemory::Create));
#else
- gScaledImageCache = SkNEW_ARGS(SkScaledImageCache, (SK_DEFAULT_IMAGE_CACHE_LIMIT));
+ gResourceCache = SkNEW_ARGS(SkResourceCache, (SK_DEFAULT_IMAGE_CACHE_LIMIT));
#endif
- atexit(cleanup_gScaledImageCache);
+ atexit(cleanup_gResourceCache);
}
- return gScaledImageCache;
+ return gResourceCache;
}
-void SkScaledImageCache::Unlock(SkScaledImageCache::ID id) {
+void SkResourceCache::Unlock(SkResourceCache::ID id) {
SkAutoMutexAcquire am(gMutex);
get_cache()->unlock(id);
// get_cache()->dump();
}
-size_t SkScaledImageCache::GetTotalBytesUsed() {
+size_t SkResourceCache::GetTotalBytesUsed() {
SkAutoMutexAcquire am(gMutex);
return get_cache()->getTotalBytesUsed();
}
-size_t SkScaledImageCache::GetTotalByteLimit() {
+size_t SkResourceCache::GetTotalByteLimit() {
SkAutoMutexAcquire am(gMutex);
return get_cache()->getTotalByteLimit();
}
-size_t SkScaledImageCache::SetTotalByteLimit(size_t newLimit) {
+size_t SkResourceCache::SetTotalByteLimit(size_t newLimit) {
SkAutoMutexAcquire am(gMutex);
return get_cache()->setTotalByteLimit(newLimit);
}
-SkBitmap::Allocator* SkScaledImageCache::GetAllocator() {
+SkBitmap::Allocator* SkResourceCache::GetAllocator() {
SkAutoMutexAcquire am(gMutex);
return get_cache()->allocator();
}
-void SkScaledImageCache::Dump() {
+void SkResourceCache::Dump() {
SkAutoMutexAcquire am(gMutex);
get_cache()->dump();
}
-size_t SkScaledImageCache::SetSingleAllocationByteLimit(size_t size) {
+size_t SkResourceCache::SetSingleAllocationByteLimit(size_t size) {
SkAutoMutexAcquire am(gMutex);
return get_cache()->setSingleAllocationByteLimit(size);
}
-size_t SkScaledImageCache::GetSingleAllocationByteLimit() {
+size_t SkResourceCache::GetSingleAllocationByteLimit() {
SkAutoMutexAcquire am(gMutex);
return get_cache()->getSingleAllocationByteLimit();
}
-const SkScaledImageCache::Rec* SkScaledImageCache::FindAndLock(const Key& key) {
+const SkResourceCache::Rec* SkResourceCache::FindAndLock(const Key& key) {
SkAutoMutexAcquire am(gMutex);
return get_cache()->findAndLock(key);
}
-const SkScaledImageCache::Rec* SkScaledImageCache::AddAndLock(Rec* rec) {
+const SkResourceCache::Rec* SkResourceCache::AddAndLock(Rec* rec) {
SkAutoMutexAcquire am(gMutex);
return get_cache()->addAndLock(rec);
}
-void SkScaledImageCache::Add(Rec* rec) {
+void SkResourceCache::Add(Rec* rec) {
SkAutoMutexAcquire am(gMutex);
get_cache()->add(rec);
}
@@ -562,23 +560,23 @@ void SkScaledImageCache::Add(Rec* rec) {
#include "SkGraphics.h"
-size_t SkGraphics::GetImageCacheTotalBytesUsed() {
- return SkScaledImageCache::GetTotalBytesUsed();
+size_t SkGraphics::GetResourceCacheTotalBytesUsed() {
+ return SkResourceCache::GetTotalBytesUsed();
}
-size_t SkGraphics::GetImageCacheTotalByteLimit() {
- return SkScaledImageCache::GetTotalByteLimit();
+size_t SkGraphics::GetResourceCacheTotalByteLimit() {
+ return SkResourceCache::GetTotalByteLimit();
}
-size_t SkGraphics::SetImageCacheTotalByteLimit(size_t newLimit) {
- return SkScaledImageCache::SetTotalByteLimit(newLimit);
+size_t SkGraphics::SetResourceCacheTotalByteLimit(size_t newLimit) {
+ return SkResourceCache::SetTotalByteLimit(newLimit);
}
-size_t SkGraphics::GetImageCacheSingleAllocationByteLimit() {
- return SkScaledImageCache::GetSingleAllocationByteLimit();
+size_t SkGraphics::GetResourceCacheSingleAllocationByteLimit() {
+ return SkResourceCache::GetSingleAllocationByteLimit();
}
-size_t SkGraphics::SetImageCacheSingleAllocationByteLimit(size_t newLimit) {
- return SkScaledImageCache::SetSingleAllocationByteLimit(newLimit);
+size_t SkGraphics::SetResourceCacheSingleAllocationByteLimit(size_t newLimit) {
+ return SkResourceCache::SetSingleAllocationByteLimit(newLimit);
}
diff --git a/src/core/SkScaledImageCache.h b/src/core/SkResourceCache.h
index c31f8ffed9..0873bd4c2e 100644
--- a/src/core/SkScaledImageCache.h
+++ b/src/core/SkResourceCache.h
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
-#ifndef SkScaledImageCache_DEFINED
-#define SkScaledImageCache_DEFINED
+#ifndef SkResourceCache_DEFINED
+#define SkResourceCache_DEFINED
#include "SkBitmap.h"
@@ -23,7 +23,7 @@ class SkMipMap;
* As a convenience, a global instance is also defined, which can be safely
* access across threads via the static methods (e.g. FindAndLock, etc.).
*/
-class SkScaledImageCache {
+class SkResourceCache {
public:
struct Key {
// Call this to access your private contents. Must not use the address after calling init()
@@ -58,7 +58,7 @@ public:
};
struct Rec {
- typedef SkScaledImageCache::Key Key;
+ typedef SkResourceCache::Key Key;
Rec() : fLockCount(1) {}
virtual ~Rec() {}
@@ -78,7 +78,7 @@ public:
int32_t fLockCount;
int32_t fPad;
- friend class SkScaledImageCache;
+ friend class SkResourceCache;
};
typedef const Rec* ID;
@@ -122,7 +122,7 @@ public:
* and getTotalByteLimit() will return 0, and setTotalByteLimit
* will ignore its argument and return 0.
*/
- SkScaledImageCache(DiscardableFactory);
+ SkResourceCache(DiscardableFactory);
/**
* Construct the cache, allocating memory with malloc, and respect the
@@ -130,8 +130,8 @@ public:
* that pushes the total bytesUsed over the limit. Note: The limit can be
* changed at runtime with setTotalByteLimit.
*/
- explicit SkScaledImageCache(size_t byteLimit);
- ~SkScaledImageCache();
+ explicit SkResourceCache(size_t byteLimit);
+ ~SkResourceCache();
const Rec* findAndLock(const Key& key);
const Rec* addAndLock(Rec*);