aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-02-01 16:18:09 +0000
committerGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-02-01 16:18:09 +0000
commitd9b0f480be398cb37c447605109c419e8314cf61 (patch)
tree3f89d0eb20dee4f1664af25a81266492f89e73e1
parent528a556514fddfd1275cda9f2c2af17abc02c693 (diff)
Only support SkPicture abort for Android due to the fragility of the existing API
Review URL: https://codereview.appspot.com/7225083 git-svn-id: http://skia.googlecode.com/svn/trunk@7515 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--include/core/SkPicture.h3
-rw-r--r--src/core/SkPicture.cpp2
-rw-r--r--src/core/SkPicturePlayback.cpp15
-rw-r--r--src/core/SkPicturePlayback.h5
4 files changed, 19 insertions, 6 deletions
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h
index 3525695d02..44e4f862cc 100644
--- a/include/core/SkPicture.h
+++ b/include/core/SkPicture.h
@@ -142,11 +142,14 @@ public:
*/
void serialize(SkWStream*, SkSerializationHelpers::EncodeBitmap encoder = NULL) const;
+#ifdef SK_BUILD_FOR_ANDROID
/** Signals that the caller is prematurely done replaying the drawing
commands. This can be called from a canvas virtual while the picture
is drawing. Has no effect if the picture is not drawing.
+ @deprecated preserving for legacy purposes
*/
void abortPlayback();
+#endif
protected:
// V2 : adds SkPixelRef's generation ID.
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp
index 93c996a44a..3e464e0eb7 100644
--- a/src/core/SkPicture.cpp
+++ b/src/core/SkPicture.cpp
@@ -321,9 +321,11 @@ void SkPicture::serialize(SkWStream* stream, SkSerializationHelpers::EncodeBitma
}
}
+#ifdef SK_BUILD_FOR_ANDROID
void SkPicture::abortPlayback() {
if (NULL == fPlayback) {
return;
}
fPlayback->abort();
}
+#endif
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index 7cd25cc837..3ca26d4565 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -680,7 +680,17 @@ void SkPicturePlayback::draw(SkCanvas& canvas) {
// Record this, so we can concat w/ it if we encounter a setMatrix()
SkMatrix initialMatrix = canvas.getTotalMatrix();
+#ifdef SK_BUILD_FOR_ANDROID
+ fAbortCurrentPlayback = false;
+#endif
+
while (!reader.eof()) {
+#ifdef SK_BUILD_FOR_ANDROID
+ if (fAbortCurrentPlayback) {
+ return;
+ }
+#endif
+
#ifdef SK_DEVELOPER
size_t curOffset = reader.offset();
#endif
@@ -987,11 +997,6 @@ void SkPicturePlayback::draw(SkCanvas& canvas) {
// this->dumpSize();
}
-void SkPicturePlayback::abort() {
- SkASSERT(!"not supported");
-// fReader.skip(fReader.size() - fReader.offset());
-}
-
///////////////////////////////////////////////////////////////////////////////
#ifdef SK_DEBUG_SIZE
diff --git a/src/core/SkPicturePlayback.h b/src/core/SkPicturePlayback.h
index e0010fc919..cd3a6a5c7b 100644
--- a/src/core/SkPicturePlayback.h
+++ b/src/core/SkPicturePlayback.h
@@ -74,9 +74,11 @@ public:
void dumpSize() const;
+#ifdef SK_BUILD_FOR_ANDROID
// Can be called in the middle of playback (the draw() call). WIll abort the
// drawing and return from draw() after the "current" op code is done
- void abort();
+ void abort() { fAbortCurrentPlayback = true; }
+#endif
protected:
#ifdef SK_DEVELOPER
@@ -219,6 +221,7 @@ private:
SkFactoryPlayback* fFactoryPlayback;
#ifdef SK_BUILD_FOR_ANDROID
SkMutex fDrawMutex;
+ bool fAbortCurrentPlayback;
#endif
};