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

Unified Diff: src/pipe/SkPipeCanvas.cpp

Issue 2347593004: test/fix/tweak writePicture/readPicture (Closed)
Patch Set: remove dead code 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 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
« 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