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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/pipe/SkPipeCanvas.h ('k') | src/pipe/SkPipeFormat.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkPathEffect.h" 8 #include "SkPathEffect.h"
9 #include "SkColorFilter.h" 9 #include "SkColorFilter.h"
10 #include "SkDrawLooper.h" 10 #include "SkDrawLooper.h"
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 } 1029 }
1030 1030
1031 void SkPipeSerializer::write(SkPicture* picture, SkWStream* stream) { 1031 void SkPipeSerializer::write(SkPicture* picture, SkWStream* stream) {
1032 stream->write32(kDefinePicture_ExtPipeVerb); 1032 stream->write32(kDefinePicture_ExtPipeVerb);
1033 SkRect cull = picture->cullRect(); 1033 SkRect cull = picture->cullRect();
1034 stream->write(&cull.fLeft, sizeof(SkRect)); 1034 stream->write(&cull.fLeft, sizeof(SkRect));
1035 picture->playback(this->beginWrite(cull, stream)); 1035 picture->playback(this->beginWrite(cull, stream));
1036 this->endWrite(); 1036 this->endWrite();
1037 } 1037 }
1038 1038
1039 /*
1040 * This either writes
1041 * kDefineImage + image_index [followed by contents]
1042 * 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
1043 * kWriteImage + image_index (image_index == 0 means failure)
1044 */
1039 void SkPipeSerializer::write(SkImage* image, SkWStream* stream) { 1045 void SkPipeSerializer::write(SkImage* image, SkWStream* stream) {
1040 stream->write32(kDefineImage_ExtPipeVerb); 1046 int index = fImpl->fDeduper.findImage(image);
1041 SkPipeWriter writer(stream, &fImpl->fDeduper); 1047 if (index) {
1042 writer.writeImage(image); 1048 stream->write32(pack_verb(SkPipeVerb::kWriteImage, index));
1049 } else {
1050 fImpl->fDeduper.setStream(stream);
1051 index = fImpl->fDeduper.findOrDefineImage(image);
1052 if (0 == index) {
1053 // failed to define the image
1054 stream->write32(pack_verb(SkPipeVerb::kWriteImage, index));
1055 }
1056 }
1043 } 1057 }
1044 1058
1045 SkCanvas* SkPipeSerializer::beginWrite(const SkRect& cull, SkWStream* stream) { 1059 SkCanvas* SkPipeSerializer::beginWrite(const SkRect& cull, SkWStream* stream) {
1046 SkASSERT(nullptr == fImpl->fCanvas); 1060 SkASSERT(nullptr == fImpl->fCanvas);
1047 fImpl->fCanvas.reset(new SkPipeCanvas(cull, &fImpl->fDeduper, stream)); 1061 fImpl->fCanvas.reset(new SkPipeCanvas(cull, &fImpl->fDeduper, stream));
1048 fImpl->fDeduper.setStream(stream); 1062 fImpl->fDeduper.setStream(stream);
1049 fImpl->fDeduper.setCanvas(fImpl->fCanvas.get()); 1063 fImpl->fDeduper.setCanvas(fImpl->fCanvas.get());
1050 return fImpl->fCanvas.get(); 1064 return fImpl->fCanvas.get();
1051 } 1065 }
1052 1066
1053 void SkPipeSerializer::endWrite() { 1067 void SkPipeSerializer::endWrite() {
1054 fImpl->fCanvas->restoreToCount(1); 1068 fImpl->fCanvas->restoreToCount(1);
1055 fImpl->fCanvas.reset(nullptr); 1069 fImpl->fCanvas.reset(nullptr);
1070 fImpl->fDeduper.setCanvas(nullptr);
1056 } 1071 }
OLDNEW
« 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