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

Unified Diff: src/pipe/SkPipeCanvas.cpp

Issue 2335973003: change write-image to use pipeverbs like everyone else, and add test (Closed)
Patch Set: Created 4 years, 3 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/pipe/SkPipeCanvas.h ('k') | src/pipe/SkPipeFormat.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pipe/SkPipeCanvas.cpp
diff --git a/src/pipe/SkPipeCanvas.cpp b/src/pipe/SkPipeCanvas.cpp
index 062d416537e4fa7e8aabb72a4b6899d146118621..41e6b9ec62865766dc7e1f2ab934f517ede7d10e 100644
--- a/src/pipe/SkPipeCanvas.cpp
+++ b/src/pipe/SkPipeCanvas.cpp
@@ -1036,10 +1036,24 @@ void SkPipeSerializer::write(SkPicture* picture, SkWStream* stream) {
this->endWrite();
}
+/*
+ * This either writes
+ * kDefineImage + image_index [followed by contents]
+ * or
mtklein 2016/09/13 21:24:52 Might be simpler to think about if it's if (!defi
reed1 2016/09/13 23:11:34 Seems like it actually complicates the reader, whe
reed1 2016/09/13 23:36:29 I've uploaded your suggestion, and the reader is f
+ * kWriteImage + image_index (image_index == 0 means failure)
+ */
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 (index) {
+ stream->write32(pack_verb(SkPipeVerb::kWriteImage, index));
+ } else {
+ fImpl->fDeduper.setStream(stream);
+ index = fImpl->fDeduper.findOrDefineImage(image);
+ if (0 == index) {
+ // failed to define the image
+ stream->write32(pack_verb(SkPipeVerb::kWriteImage, index));
+ }
+ }
}
SkCanvas* SkPipeSerializer::beginWrite(const SkRect& cull, SkWStream* stream) {
@@ -1053,4 +1067,5 @@ SkCanvas* SkPipeSerializer::beginWrite(const SkRect& cull, SkWStream* stream) {
void SkPipeSerializer::endWrite() {
fImpl->fCanvas->restoreToCount(1);
fImpl->fCanvas.reset(nullptr);
+ fImpl->fDeduper.setCanvas(nullptr);
}
« no previous file with comments | « src/pipe/SkPipeCanvas.h ('k') | src/pipe/SkPipeFormat.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698