Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Unified Diff: src/core/SkPicturePlayback.cpp

Issue 14598023: add SkDrawPictureCallback optional parameter to drawPicture(), which can abort the picture drawing. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« include/core/SkPicture.h ('K') | « src/core/SkPicturePlayback.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPicturePlayback.cpp
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index d54a6c5f3b3384d99499e6966dd139b4fce280e5..e1c9a3a65f98c78df4caeae806a01ca716ee782d 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;
« include/core/SkPicture.h ('K') | « src/core/SkPicturePlayback.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698