diff options
-rw-r--r-- | src/core/SkPicture.cpp | 1 | ||||
-rw-r--r-- | src/core/SkPictureRecord.cpp | 8 | ||||
-rw-r--r-- | src/core/SkPictureRecord.h | 2 | ||||
-rw-r--r-- | tests/CanvasTest.cpp | 12 |
4 files changed, 23 insertions, 0 deletions
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp index 350784577a..58098e7bfc 100644 --- a/src/core/SkPicture.cpp +++ b/src/core/SkPicture.cpp @@ -180,6 +180,7 @@ SkCanvas* SkPicture::getRecordingCanvas() const { void SkPicture::endRecording() { if (NULL == fPlayback) { if (NULL != fRecord) { + fRecord->endRecording(); fPlayback = SkNEW_ARGS(SkPicturePlayback, (*fRecord)); fRecord->unref(); fRecord = NULL; diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp index f961bc4c62..630a1bb649 100644 --- a/src/core/SkPictureRecord.cpp +++ b/src/core/SkPictureRecord.cpp @@ -170,6 +170,14 @@ void SkPictureRecord::fillRestoreOffsetPlaceholdersForCurrentStackLevel( } } +void SkPictureRecord::endRecording() { + // clear any remaining unhandled restore offset placeholders + while (fRestoreOffsetStack.count()) { + this->fillRestoreOffsetPlaceholdersForCurrentStackLevel(0); + fRestoreOffsetStack.pop(); + } +} + void SkPictureRecord::recordRestoreOffsetPlaceholder(SkRegion::Op op) { if (regionOpExpands(op)) { // Run back through any previous clip ops, and mark their offset to diff --git a/src/core/SkPictureRecord.h b/src/core/SkPictureRecord.h index 7e5f086c7b..c970696f18 100644 --- a/src/core/SkPictureRecord.h +++ b/src/core/SkPictureRecord.h @@ -95,6 +95,8 @@ public: } bool shouldFlattenPixels(const SkBitmap&) const; + + void endRecording(); private: struct PixelRefDictionaryEntry { uint32_t fKey; // SkPixelRef GenerationID. diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp index 0677ce8e56..a1ca236ab6 100644 --- a/tests/CanvasTest.cpp +++ b/tests/CanvasTest.cpp @@ -327,6 +327,18 @@ SIMPLE_TEST_STEP(DrawData, drawData(kTestText.c_str(), kTestText.size())); /////////////////////////////////////////////////////////////////////////////// // Complex test steps +static void TwoClipOpsStep(SkCanvas* canvas, + skiatest::Reporter* reporter, + CanvasTestStep* testStep) { + // This test exercises a functionality in SkPicture that leads to the + // recording of restore offset placeholders. This test will trigger an + // assertion at playback time if the placeholders are not properly + // filled when the recording ends. + canvas->clipRect(kTestRect); + canvas->clipRegion(kTestRegion); +} +TEST_STEP(TwoClipOps, TwoClipOpsStep); + // exercise fix for http://code.google.com/p/skia/issues/detail?id=560 // ('SkPathStroker::lineTo() fails for line with length SK_ScalarNearlyZero') static void DrawNearlyZeroLengthPathTestStep(SkCanvas* canvas, |