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

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: 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 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 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 void SkPipeSerializer::write(SkImage* image, SkWStream* stream) { 1039 void SkPipeSerializer::write(SkImage* image, SkWStream* stream) {
1040 stream->write32(kDefineImage_ExtPipeVerb); 1040 int index = fImpl->fDeduper.findImage(image);
1041 SkPipeWriter writer(stream, &fImpl->fDeduper); 1041 if (0 == index) {
1042 writer.writeImage(image); 1042 // Try to define the image
1043 fImpl->fDeduper.setStream(stream);
1044 index = fImpl->fDeduper.findOrDefineImage(image);
1045 }
1046 stream->write32(pack_verb(SkPipeVerb::kWriteImage, index));
1043 } 1047 }
1044 1048
1045 SkCanvas* SkPipeSerializer::beginWrite(const SkRect& cull, SkWStream* stream) { 1049 SkCanvas* SkPipeSerializer::beginWrite(const SkRect& cull, SkWStream* stream) {
1046 SkASSERT(nullptr == fImpl->fCanvas); 1050 SkASSERT(nullptr == fImpl->fCanvas);
1047 fImpl->fCanvas.reset(new SkPipeCanvas(cull, &fImpl->fDeduper, stream)); 1051 fImpl->fCanvas.reset(new SkPipeCanvas(cull, &fImpl->fDeduper, stream));
1048 fImpl->fDeduper.setStream(stream); 1052 fImpl->fDeduper.setStream(stream);
1049 fImpl->fDeduper.setCanvas(fImpl->fCanvas.get()); 1053 fImpl->fDeduper.setCanvas(fImpl->fCanvas.get());
1050 return fImpl->fCanvas.get(); 1054 return fImpl->fCanvas.get();
1051 } 1055 }
1052 1056
1053 void SkPipeSerializer::endWrite() { 1057 void SkPipeSerializer::endWrite() {
1054 fImpl->fCanvas->restoreToCount(1); 1058 fImpl->fCanvas->restoreToCount(1);
1055 fImpl->fCanvas.reset(nullptr); 1059 fImpl->fCanvas.reset(nullptr);
1060 fImpl->fDeduper.setCanvas(nullptr);
1056 } 1061 }
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