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

Side by Side Diff: src/core/SkPicture.cpp

Issue 1233953004: Deduplicate typefaces across sub-pictures (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 4 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 | « include/core/SkPicture.h ('k') | src/core/SkPictureData.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 2007 The Android Open Source Project 2 * Copyright 2007 The Android Open Source Project
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 "SkAtomics.h" 8 #include "SkAtomics.h"
9 #include "SkMessageBus.h" 9 #include "SkMessageBus.h"
10 #include "SkPicture.h" 10 #include "SkPicture.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 if (!data) { 132 if (!data) {
133 return nullptr; 133 return nullptr;
134 } 134 }
135 SkPicturePlayback playback(data); 135 SkPicturePlayback playback(data);
136 SkPictureRecorder r; 136 SkPictureRecorder r;
137 playback.draw(r.beginRecording(info.fCullRect), nullptr/*no callback*/); 137 playback.draw(r.beginRecording(info.fCullRect), nullptr/*no callback*/);
138 return r.endRecording(); 138 return r.endRecording();
139 } 139 }
140 140
141 SkPicture* SkPicture::CreateFromStream(SkStream* stream, InstallPixelRefProc pro c) { 141 SkPicture* SkPicture::CreateFromStream(SkStream* stream, InstallPixelRefProc pro c) {
142 return CreateFromStream(stream, proc, nullptr);
143 }
144
145 SkPicture* SkPicture::CreateFromStream(SkStream* stream,
146 InstallPixelRefProc proc,
147 SkTypefacePlayback* typefaces) {
142 SkPictInfo info; 148 SkPictInfo info;
143 if (!InternalOnly_StreamIsSKP(stream, &info) || !stream->readBool()) { 149 if (!InternalOnly_StreamIsSKP(stream, &info) || !stream->readBool()) {
144 return nullptr; 150 return nullptr;
145 } 151 }
146 SkAutoTDelete<SkPictureData> data(SkPictureData::CreateFromStream(stream, in fo, proc)); 152 SkAutoTDelete<SkPictureData> data(
153 SkPictureData::CreateFromStream(stream, info, proc, typefaces));
147 return Forwardport(info, data); 154 return Forwardport(info, data);
148 } 155 }
149 156
150 SkPicture* SkPicture::CreateFromBuffer(SkReadBuffer& buffer) { 157 SkPicture* SkPicture::CreateFromBuffer(SkReadBuffer& buffer) {
151 SkPictInfo info; 158 SkPictInfo info;
152 if (!InternalOnly_BufferIsSKP(&buffer, &info) || !buffer.readBool()) { 159 if (!InternalOnly_BufferIsSKP(&buffer, &info) || !buffer.readBool()) {
153 return nullptr; 160 return nullptr;
154 } 161 }
155 SkAutoTDelete<SkPictureData> data(SkPictureData::CreateFromBuffer(buffer, in fo)); 162 SkAutoTDelete<SkPictureData> data(SkPictureData::CreateFromBuffer(buffer, in fo));
156 return Forwardport(info, data); 163 return Forwardport(info, data);
157 } 164 }
158 165
159 SkPictureData* SkPicture::backport() const { 166 SkPictureData* SkPicture::backport() const {
160 SkPictInfo info = this->createHeader(); 167 SkPictInfo info = this->createHeader();
161 SkPictureRecord rec(SkISize::Make(info.fCullRect.width(), info.fCullRect.hei ght()), 0/*flags*/); 168 SkPictureRecord rec(SkISize::Make(info.fCullRect.width(), info.fCullRect.hei ght()), 0/*flags*/);
162 rec.beginRecording(); 169 rec.beginRecording();
163 this->playback(&rec); 170 this->playback(&rec);
164 rec.endRecording(); 171 rec.endRecording();
165 return SkNEW_ARGS(SkPictureData, (rec, info, false/*deep copy ops?*/)); 172 return SkNEW_ARGS(SkPictureData, (rec, info, false/*deep copy ops?*/));
166 } 173 }
167 174
168 void SkPicture::serialize(SkWStream* stream, SkPixelSerializer* pixelSerializer) const { 175 void SkPicture::serialize(SkWStream* stream, SkPixelSerializer* pixelSerializer) const {
176 this->serialize(stream, pixelSerializer, nullptr);
177 }
178
179 void SkPicture::serialize(SkWStream* stream,
180 SkPixelSerializer* pixelSerializer,
181 SkRefCntSet* typefaceSet) const {
169 SkPictInfo info = this->createHeader(); 182 SkPictInfo info = this->createHeader();
170 SkAutoTDelete<SkPictureData> data(this->backport()); 183 SkAutoTDelete<SkPictureData> data(this->backport());
171 184
172 stream->write(&info, sizeof(info)); 185 stream->write(&info, sizeof(info));
173 if (data) { 186 if (data) {
174 stream->writeBool(true); 187 stream->writeBool(true);
175 data->serialize(stream, pixelSerializer); 188 data->serialize(stream, pixelSerializer, typefaceSet);
176 } else { 189 } else {
177 stream->writeBool(false); 190 stream->writeBool(false);
178 } 191 }
179 } 192 }
180 193
181 void SkPicture::flatten(SkWriteBuffer& buffer) const { 194 void SkPicture::flatten(SkWriteBuffer& buffer) const {
182 SkPictInfo info = this->createHeader(); 195 SkPictInfo info = this->createHeader();
183 SkAutoTDelete<SkPictureData> data(this->backport()); 196 SkAutoTDelete<SkPictureData> data(this->backport());
184 197
185 buffer.writeByteArray(&info.fMagic, sizeof(info.fMagic)); 198 buffer.writeByteArray(&info.fMagic, sizeof(info.fMagic));
(...skipping 17 matching lines...) Expand all
203 } 216 }
204 217
205 // Global setting to disable security precautions for serialization. 218 // Global setting to disable security precautions for serialization.
206 void SkPicture::SetPictureIOSecurityPrecautionsEnabled_Dangerous(bool set) { 219 void SkPicture::SetPictureIOSecurityPrecautionsEnabled_Dangerous(bool set) {
207 g_AllPictureIOSecurityPrecautionsEnabled = set; 220 g_AllPictureIOSecurityPrecautionsEnabled = set;
208 } 221 }
209 222
210 bool SkPicture::PictureIOSecurityPrecautionsEnabled() { 223 bool SkPicture::PictureIOSecurityPrecautionsEnabled() {
211 return g_AllPictureIOSecurityPrecautionsEnabled; 224 return g_AllPictureIOSecurityPrecautionsEnabled;
212 } 225 }
OLDNEW
« no previous file with comments | « include/core/SkPicture.h ('k') | src/core/SkPictureData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698