| Index: src/core/SkScaledImageCache.cpp
|
| diff --git a/src/core/SkScaledImageCache.cpp b/src/core/SkScaledImageCache.cpp
|
| index b3956f4a8dbd43d225dccd159eab687e572bd63e..7c8b66498e342f84e26a9d9236ef98bfc10eff49 100644
|
| --- a/src/core/SkScaledImageCache.cpp
|
| +++ b/src/core/SkScaledImageCache.cpp
|
| @@ -239,9 +239,18 @@ void* SkOneShotDiscardablePixelRef::onLockPixels(SkColorTable** ctable) {
|
| return fDM->data();
|
| }
|
|
|
| - SkASSERT(!fIsLocked);
|
| - fIsLocked = fDM->lock();
|
| - return fIsLocked ? fDM->data() : NULL;
|
| + // A previous call to onUnlock may have deleted our DM, so check for that
|
| + if (NULL == fDM) {
|
| + return NULL;
|
| + }
|
| +
|
| + if (!fDM->lock()) {
|
| + // since it failed, we delete it now, to free-up the resource
|
| + delete fDM;
|
| + fDM = NULL;
|
| + return NULL;
|
| + }
|
| + return fDM->data();
|
| }
|
|
|
| void SkOneShotDiscardablePixelRef::onUnlockPixels() {
|
| @@ -613,6 +622,8 @@ void SkScaledImageCache::addToHead(Rec* rec) {
|
| this->validate();
|
| }
|
|
|
| +///////////////////////////////////////////////////////////////////////////////
|
| +
|
| #ifdef SK_DEBUG
|
| void SkScaledImageCache::validate() const {
|
| if (NULL == fHead) {
|
| @@ -658,6 +669,21 @@ void SkScaledImageCache::validate() const {
|
| }
|
| #endif
|
|
|
| +void SkScaledImageCache::dump() const {
|
| + this->validate();
|
| +
|
| + const Rec* rec = fHead;
|
| + int locked = 0;
|
| + while (rec) {
|
| + locked += rec->fLockCount > 0;
|
| + rec = rec->fNext;
|
| + }
|
| +
|
| + SkDebugf("SkScaledImageCache: count=%d bytes=%d locked=%d %s\n",
|
| + fCount, fBytesUsed, locked,
|
| + fDiscardableFactory ? "discardable" : "malloc");
|
| +}
|
| +
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| #include "SkThread.h"
|
| @@ -730,7 +756,9 @@ SkScaledImageCache::ID* SkScaledImageCache::AddAndLockMip(const SkBitmap& orig,
|
|
|
| void SkScaledImageCache::Unlock(SkScaledImageCache::ID* id) {
|
| SkAutoMutexAcquire am(gMutex);
|
| - return get_cache()->unlock(id);
|
| + get_cache()->unlock(id);
|
| +
|
| +// get_cache()->dump();
|
| }
|
|
|
| size_t SkScaledImageCache::GetBytesUsed() {
|
| @@ -753,6 +781,11 @@ SkBitmap::Allocator* SkScaledImageCache::GetAllocator() {
|
| return get_cache()->allocator();
|
| }
|
|
|
| +void SkScaledImageCache::Dump() {
|
| + SkAutoMutexAcquire am(gMutex);
|
| + get_cache()->dump();
|
| +}
|
| +
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| #include "SkGraphics.h"
|
|
|