diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-05-20 17:02:41 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-05-20 17:02:41 +0000 |
commit | 74babdfce524f478b9177834fe51d0394e42de6a (patch) | |
tree | dc03c11a46353414529ef40e4805ca8d9f65cf05 /src | |
parent | 67882ddc0efbe33070b5da16931f80ed7f21b1f1 (diff) |
add SkDrawPictureCallback optional parameter to drawPicture(), which can abort the picture drawing.
R=bsalomon@google.com
Review URL: https://codereview.chromium.org/14598023
git-svn-id: http://skia.googlecode.com/svn/trunk@9197 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkPicture.cpp | 4 | ||||
-rw-r--r-- | src/core/SkPicturePlayback.cpp | 7 | ||||
-rw-r--r-- | src/core/SkPicturePlayback.h | 2 |
3 files changed, 9 insertions, 4 deletions
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp index 1ff5865651..ab2faea6b6 100644 --- a/src/core/SkPicture.cpp +++ b/src/core/SkPicture.cpp @@ -253,10 +253,10 @@ void SkPicture::endRecording() { SkASSERT(NULL == fRecord); } -void SkPicture::draw(SkCanvas* surface) { +void SkPicture::draw(SkCanvas* surface, SkDrawPictureCallback* callback) { this->endRecording(); if (fPlayback) { - fPlayback->draw(*surface); + fPlayback->draw(*surface, callback); } } diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp index d54a6c5f3b..e1c9a3a65f 100644 --- a/src/core/SkPicturePlayback.cpp +++ b/src/core/SkPicturePlayback.cpp @@ -656,7 +656,7 @@ static DrawType read_op_and_size(SkReader32* reader, uint32_t* size) { return (DrawType) op; } -void SkPicturePlayback::draw(SkCanvas& canvas) { +void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback) { #ifdef ENABLE_TIME_DRAW SkAutoTime at("SkPicture::draw", 50); #endif @@ -706,12 +706,17 @@ void SkPicturePlayback::draw(SkCanvas& canvas) { // Record this, so we can concat w/ it if we encounter a setMatrix() SkMatrix initialMatrix = canvas.getTotalMatrix(); + int originalSaveCount = canvas.getSaveCount(); #ifdef SK_BUILD_FOR_ANDROID fAbortCurrentPlayback = false; #endif while (!reader.eof()) { + if (callback && callback->abortDrawing()) { + canvas.restoreToCount(originalSaveCount); + return; + } #ifdef SK_BUILD_FOR_ANDROID if (fAbortCurrentPlayback) { return; diff --git a/src/core/SkPicturePlayback.h b/src/core/SkPicturePlayback.h index b0af6942bc..801900124a 100644 --- a/src/core/SkPicturePlayback.h +++ b/src/core/SkPicturePlayback.h @@ -66,7 +66,7 @@ public: virtual ~SkPicturePlayback(); - void draw(SkCanvas& canvas); + void draw(SkCanvas& canvas, SkDrawPictureCallback*); void serialize(SkWStream*, SkPicture::EncodeBitmap) const; |