OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |