Index: src/pipe/SkPipeCanvas.cpp |
diff --git a/src/pipe/SkPipeCanvas.cpp b/src/pipe/SkPipeCanvas.cpp |
index 97c31ce57e5d93bda36cc553427c6a7ac24ec491..224451f2cac2f21f4d19dfbbd07e5386841f46f5 100644 |
--- a/src/pipe/SkPipeCanvas.cpp |
+++ b/src/pipe/SkPipeCanvas.cpp |
@@ -1028,15 +1028,30 @@ void SkPipeSerializer::resetCache() { |
fImpl->fDeduper.resetCaches(); |
} |
-void SkPipeSerializer::write(SkPicture* picture, SkWStream* stream) { |
- stream->write32(kDefinePicture_ExtPipeVerb); |
- SkRect cull = picture->cullRect(); |
- stream->write(&cull.fLeft, sizeof(SkRect)); |
- picture->playback(this->beginWrite(cull, stream)); |
- this->endWrite(); |
+sk_sp<SkData> SkPipeSerializer::writeImage(SkImage* image) { |
+ SkDynamicMemoryWStream stream; |
+ this->writeImage(image, &stream); |
+ return stream.detachAsData(); |
+} |
+ |
+sk_sp<SkData> SkPipeSerializer::writePicture(SkPicture* picture) { |
+ SkDynamicMemoryWStream stream; |
+ this->writePicture(picture, &stream); |
+ return stream.detachAsData(); |
+} |
+ |
+void SkPipeSerializer::writePicture(SkPicture* picture, SkWStream* stream) { |
+ int index = fImpl->fDeduper.findPicture(picture); |
+ if (0 == index) { |
+ // Try to define the picture |
+ this->beginWrite(picture->cullRect(), stream); |
+ index = fImpl->fDeduper.findOrDefinePicture(picture); |
+ this->endWrite(); |
+ } |
+ stream->write32(pack_verb(SkPipeVerb::kWritePicture, index)); |
} |
-void SkPipeSerializer::write(SkImage* image, SkWStream* stream) { |
+void SkPipeSerializer::writeImage(SkImage* image, SkWStream* stream) { |
int index = fImpl->fDeduper.findImage(image); |
if (0 == index) { |
// Try to define the image |