diff options
author | scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-11-16 20:34:37 +0000 |
---|---|---|
committer | scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-11-16 20:34:37 +0000 |
commit | 013c5d9107a4abd50e879ca66cf60b0c3a8256d4 (patch) | |
tree | 9a24b4c1fd6f8dd984801044ed7b9b060e9fcd67 /src | |
parent | 6ec1526680bcc05b8b8b2c7ad9f78ba247e123b7 (diff) |
In SkBitmapHeap, defer adding owners for new bitmaps.
When using an SkFlatDictionary to flatten shaders, the
dictionary can try to insert a duplicate bitmap shader
that uses a bitmap which has been removed from the
bitmap heap.
This change was originally suggested by junov in
https://codereview.appspot.com/6713048/.
Add a test to verify that deferring the owners works.
Without the change to bitmap heap the test would fail
(and crash in debug mode).
Also remove an unused function from SkFlatDictionary.
BUG=http://code.google.com/p/chromium/issues/detail?id=143923
Review URL: https://codereview.appspot.com/6842051
git-svn-id: http://skia.googlecode.com/svn/trunk@6471 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkBitmapHeap.cpp | 6 | ||||
-rw-r--r-- | src/core/SkBitmapHeap.h | 1 | ||||
-rw-r--r-- | src/core/SkPictureFlat.h | 14 |
3 files changed, 6 insertions, 15 deletions
diff --git a/src/core/SkBitmapHeap.cpp b/src/core/SkBitmapHeap.cpp index 026381450c..48194b1eaa 100644 --- a/src/core/SkBitmapHeap.cpp +++ b/src/core/SkBitmapHeap.cpp @@ -373,7 +373,11 @@ int32_t SkBitmapHeap::insert(const SkBitmap& originalBitmap) { fBytesAllocated += entry->fBytesAllocated; if (fOwnerCount != IGNORE_OWNERS) { - entry->addReferences(fOwnerCount); + if (fDeferAddingOwners) { + *fDeferredEntries.append() = entry->fSlot; + } else { + entry->addReferences(fOwnerCount); + } } if (fPreferredCount != UNLIMITED_SIZE) { this->appendToLRU(fLookupTable[searchIndex]); diff --git a/src/core/SkBitmapHeap.h b/src/core/SkBitmapHeap.h index badbc9cd84..be99e191a4 100644 --- a/src/core/SkBitmapHeap.h +++ b/src/core/SkBitmapHeap.h @@ -47,6 +47,7 @@ private: size_t fBytesAllocated; friend class SkBitmapHeap; + friend class SkBitmapHeapTester; }; diff --git a/src/core/SkPictureFlat.h b/src/core/SkPictureFlat.h index 2c8aa2c18e..a00596fed0 100644 --- a/src/core/SkPictureFlat.h +++ b/src/core/SkPictureFlat.h @@ -448,20 +448,6 @@ public: } /** - * Given a pointer to an array of type T we allocate the array and fill it - * with the unflattened dictionary contents. The return value is the size of - * the allocated array. - */ - int unflattenDictionary(T*& array) const { - int elementCount = fData.count(); - if (elementCount > 0) { - array = SkNEW_ARRAY(T, elementCount); - this->unflattenIntoArray(array); - } - return elementCount; - } - - /** * Unflatten the objects and return them in SkTRefArray, or return NULL * if there no objects (instead of an empty array). */ |