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

Unified Diff: src/pipe/SkPipeCanvas.cpp

Issue 2335973003: change write-image to use pipeverbs like everyone else, and add test (Closed)
Patch Set: switch to [define_image] write_image 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..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);
}
« 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