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

Unified Diff: src/core/SkPicturePlayback.cpp

Issue 143163005: Revert of Revert "Serialization of SkPictureImageFilter" (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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
« no previous file with comments | « src/core/SkPicturePlayback.h ('k') | src/effects/SkPictureImageFilter.cpp » ('j') | 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 e71a17fda51095ec44fa49d4e4aa6f81b2493b0b..8b8c6b0862dad7bb6d0bc643de3b09b0abca4fd7 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -431,6 +431,22 @@
stream->write32(PICT_EOF_TAG);
}
+void SkPicturePlayback::flatten(SkWriteBuffer& buffer) const {
+ writeTagSize(buffer, PICT_READER_TAG, fOpData->size());
+ buffer.writeByteArray(fOpData->bytes(), fOpData->size());
+
+ if (fPictureCount > 0) {
+ writeTagSize(buffer, PICT_PICTURE_TAG, fPictureCount);
+ for (int i = 0; i < fPictureCount; i++) {
+ fPictureRefs[i]->flatten(buffer);
+ }
+ }
+
+ // Write this picture playback's data into a writebuffer
+ this->flattenToBuffer(buffer);
+ buffer.write32(PICT_EOF_TAG);
+}
+
///////////////////////////////////////////////////////////////////////////////
/**
@@ -593,6 +609,15 @@
return playback.detach();
}
+SkPicturePlayback* SkPicturePlayback::CreateFromBuffer(SkReadBuffer& buffer) {
+ SkAutoTDelete<SkPicturePlayback> playback(SkNEW(SkPicturePlayback));
+
+ if (!playback->parseBuffer(buffer)) {
+ return NULL;
+ }
+ return playback.detach();
+}
+
bool SkPicturePlayback::parseStream(SkStream* stream, const SkPictInfo& info,
SkPicture::InstallPixelRefProc proc) {
for (;;) {
@@ -603,6 +628,21 @@
uint32_t size = stream->readU32();
if (!this->parseStreamTag(stream, info, tag, size, proc)) {
+ return false; // we're invalid
+ }
+ }
+ return true;
+}
+
+bool SkPicturePlayback::parseBuffer(SkReadBuffer& buffer) {
+ for (;;) {
+ uint32_t tag = buffer.readUInt();
+ if (PICT_EOF_TAG == tag) {
+ break;
+ }
+
+ uint32_t size = buffer.readUInt();
+ if (!this->parseBufferTag(buffer, tag, size)) {
return false; // we're invalid
}
}
« no previous file with comments | « src/core/SkPicturePlayback.h ('k') | src/effects/SkPictureImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698