diff options
author | scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-14 20:38:28 +0000 |
---|---|---|
committer | scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-14 20:38:28 +0000 |
commit | d5d158b325f05902ac845f2f7c8c65ffe6074257 (patch) | |
tree | dacc677f3e66af15527c3ed7a9a57a1315d6a807 /src/pipe | |
parent | bda03db28935eef7f9a3aae05fdedca57cd984ad (diff) |
Ensure that Pipe does not crash when attempting to draw after endRecording.
Add a test for drawing a bitmap and a bitmapshader after endRecording.
BUG=https://code.google.com/p/skia/issues/detail?id=774&can=3
Test=PipeTest
Review URL: https://codereview.appspot.com/6459088
git-svn-id: http://skia.googlecode.com/svn/trunk@5099 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/pipe')
-rw-r--r-- | src/pipe/SkGPipeWrite.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp index e1eaabd9c0..4f408fd179 100644 --- a/src/pipe/SkGPipeWrite.cpp +++ b/src/pipe/SkGPipeWrite.cpp @@ -192,7 +192,7 @@ public: size_t freeMemoryIfPossible(size_t bytesToFree); size_t storageAllocatedForRecording() { - return fBitmapHeap->bytesAllocated(); + return (NULL == fBitmapHeap) ? 0 : fBitmapHeap->bytesAllocated(); } // overrides from SkCanvas @@ -348,11 +348,11 @@ bool SkGPipeCanvas::shuttleBitmap(const SkBitmap& bm, int32_t slot) { // return 0 for NULL (or unflattenable obj), or index-base-1 // return ~(index-base-1) if an old flattenable was replaced int SkGPipeCanvas::flattenToIndex(SkFlattenable* obj, PaintFlats paintflat) { + SkASSERT(!fDone && fBitmapHeap != NULL); if (NULL == obj) { return 0; } - fBitmapHeap->deferAddingOwners(); bool added, replaced; const SkFlatData* flat = fFlatDictionary.findAndReplace(*obj, fFlattenableHeap.flatToReplace(), @@ -703,15 +703,16 @@ bool SkGPipeCanvas::commonDrawBitmap(const SkBitmap& bm, DrawOps op, unsigned flags, size_t opBytesNeeded, const SkPaint* paint) { - int32_t bitmapIndex = fBitmapHeap->insert(bm); - if (SkBitmapHeap::INVALID_SLOT == bitmapIndex) { - return false; - } if (paint != NULL) { flags |= kDrawBitmap_HasPaint_DrawOpsFlag; this->writePaint(*paint); } if (this->needOpBytes(opBytesNeeded)) { + SkASSERT(fBitmapHeap != NULL); + int32_t bitmapIndex = fBitmapHeap->insert(bm); + if (SkBitmapHeap::INVALID_SLOT == bitmapIndex) { + return false; + } this->writeOp(op, flags, bitmapIndex); return true; } @@ -941,7 +942,7 @@ void SkGPipeCanvas::flushRecording(bool detachCurrentBlock) { } size_t SkGPipeCanvas::freeMemoryIfPossible(size_t bytesToFree) { - return fBitmapHeap->freeMemoryIfPossible(bytesToFree); + return (NULL == fBitmapHeap) ? 0 : fBitmapHeap->freeMemoryIfPossible(bytesToFree); } /////////////////////////////////////////////////////////////////////////////// @@ -956,6 +957,9 @@ template <typename T> uint32_t castToU32(T value) { } void SkGPipeCanvas::writePaint(const SkPaint& paint) { + if (fDone) { + return; + } SkPaint& base = fPaint; uint32_t storage[32]; uint32_t* ptr = storage; |