aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-01-19 14:30:26 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-01-19 14:30:26 +0000
commite49d57117507903a7d912218b4e1ebd2f15bbbd7 (patch)
tree9c633ad7c329e413c4577c514968de8cc7a4f161
parent117cc39f63c47625329d3c9a053f8d239abf8e1c (diff)
fix fEntryCount when we purge a cache entry (bug caught by our validate())
git-svn-id: http://skia.googlecode.com/svn/trunk@712 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--src/effects/SkBitmapCache.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/effects/SkBitmapCache.cpp b/src/effects/SkBitmapCache.cpp
index bcbde92394..2a3f87a7f8 100644
--- a/src/effects/SkBitmapCache.cpp
+++ b/src/effects/SkBitmapCache.cpp
@@ -105,11 +105,11 @@ bool SkBitmapCache::find(const void* buffer, size_t size, SkBitmap* bm) const {
void SkBitmapCache::add(const void* buffer, size_t len, const SkBitmap& bm) {
AutoValidate av(this);
-
+
if (fEntryCount == fMaxEntries) {
- if (fTail) {
- delete this->detach(fTail);
- }
+ SkASSERT(fTail);
+ delete this->detach(fTail);
+ fEntryCount -= 1;
}
Entry* entry = new Entry(buffer, len, bm);
@@ -123,7 +123,7 @@ void SkBitmapCache::add(const void* buffer, size_t len, const SkBitmap& bm) {
void SkBitmapCache::validate() const {
SkASSERT(fEntryCount >= 0 && fEntryCount <= fMaxEntries);
-
+
if (fEntryCount > 0) {
SkASSERT(NULL == fHead->fPrev);
SkASSERT(NULL == fTail->fNext);
@@ -141,7 +141,7 @@ void SkBitmapCache::validate() const {
entry = entry->fNext;
}
SkASSERT(count == fEntryCount);
-
+
entry = fTail;
while (entry) {
count -= 1;
@@ -151,7 +151,7 @@ void SkBitmapCache::validate() const {
} else {
SkASSERT(NULL == fHead);
SkASSERT(NULL == fTail);
- }
+ }
}
#endif