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 | 2b085248f9d5b3851a3fba6704f6df595c91c5f0 (patch) | |
tree | 64f3cd6eb1d243089c7983fd99645e6eae7e0573 | |
parent | edfef9d0453231ece1b817555328b25735ee269e (diff) | |
download | src-2b085248f9d5b3851a3fba6704f6df595c91c5f0.tar.gz |
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/src@6471 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | core/SkBitmapHeap.cpp | 6 | ||||
-rw-r--r-- | core/SkBitmapHeap.h | 1 | ||||
-rw-r--r-- | core/SkPictureFlat.h | 14 |
3 files changed, 6 insertions, 15 deletions
diff --git a/core/SkBitmapHeap.cpp b/core/SkBitmapHeap.cpp index 02638145..48194b1e 100644 --- a/core/SkBitmapHeap.cpp +++ b/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/core/SkBitmapHeap.h b/core/SkBitmapHeap.h index badbc9cd..be99e191 100644 --- a/core/SkBitmapHeap.h +++ b/core/SkBitmapHeap.h @@ -47,6 +47,7 @@ private: size_t fBytesAllocated; friend class SkBitmapHeap; + friend class SkBitmapHeapTester; }; diff --git a/core/SkPictureFlat.h b/core/SkPictureFlat.h index 2c8aa2c1..a00596fe 100644 --- a/core/SkPictureFlat.h +++ b/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). */ |