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 138063005: Serialization of SkPictureImageFilter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Updated past revert point, will re-land tonight 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 @@ void SkPicturePlayback::serialize(SkWStream* stream,
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 @@ SkPicturePlayback* SkPicturePlayback::CreateFromStream(SkStream* stream,
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 (;;) {
@@ -609,6 +634,21 @@ bool SkPicturePlayback::parseStream(SkStream* stream, const SkPictInfo& info,
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
+ }
+ }
+ return true;
+}
+
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
« 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