Index: src/pipe/SkPipeCanvas.cpp |
diff --git a/src/pipe/SkPipeCanvas.cpp b/src/pipe/SkPipeCanvas.cpp |
index 062d416537e4fa7e8aabb72a4b6899d146118621..97c31ce57e5d93bda36cc553427c6a7ac24ec491 100644 |
--- a/src/pipe/SkPipeCanvas.cpp |
+++ b/src/pipe/SkPipeCanvas.cpp |
@@ -1037,9 +1037,13 @@ void SkPipeSerializer::write(SkPicture* picture, SkWStream* stream) { |
} |
void SkPipeSerializer::write(SkImage* image, SkWStream* stream) { |
- stream->write32(kDefineImage_ExtPipeVerb); |
- SkPipeWriter writer(stream, &fImpl->fDeduper); |
- writer.writeImage(image); |
+ int index = fImpl->fDeduper.findImage(image); |
+ if (0 == index) { |
+ // Try to define the image |
+ fImpl->fDeduper.setStream(stream); |
+ index = fImpl->fDeduper.findOrDefineImage(image); |
+ } |
+ stream->write32(pack_verb(SkPipeVerb::kWriteImage, index)); |
} |
SkCanvas* SkPipeSerializer::beginWrite(const SkRect& cull, SkWStream* stream) { |
@@ -1053,4 +1057,5 @@ SkCanvas* SkPipeSerializer::beginWrite(const SkRect& cull, SkWStream* stream) { |
void SkPipeSerializer::endWrite() { |
fImpl->fCanvas->restoreToCount(1); |
fImpl->fCanvas.reset(nullptr); |
+ fImpl->fDeduper.setCanvas(nullptr); |
} |