OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #include <new> | 7 #include <new> |
8 #include "SkImageGenerator.h" | 8 #include "SkImageGenerator.h" |
9 #include "SkPictureData.h" | 9 #include "SkPictureData.h" |
10 #include "SkPictureRecord.h" | 10 #include "SkPictureRecord.h" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 | 261 |
262 // We serialize all typefaces into the typeface section of the top-level pic
ture. | 262 // We serialize all typefaces into the typeface section of the top-level pic
ture. |
263 SkRefCntSet localTypefaceSet; | 263 SkRefCntSet localTypefaceSet; |
264 SkRefCntSet* typefaceSet = topLevelTypeFaceSet ? topLevelTypeFaceSet : &loca
lTypefaceSet; | 264 SkRefCntSet* typefaceSet = topLevelTypeFaceSet ? topLevelTypeFaceSet : &loca
lTypefaceSet; |
265 | 265 |
266 // We delay serializing the bulk of our data until after we've serialized | 266 // We delay serializing the bulk of our data until after we've serialized |
267 // factories and typefaces by first serializing to an in-memory write buffer
. | 267 // factories and typefaces by first serializing to an in-memory write buffer
. |
268 SkFactorySet factSet; // buffer refs factSet, so factSet must come first. | 268 SkFactorySet factSet; // buffer refs factSet, so factSet must come first. |
269 SkBinaryWriteBuffer buffer(SkBinaryWriteBuffer::kCrossProcess_Flag); | 269 SkBinaryWriteBuffer buffer(SkBinaryWriteBuffer::kCrossProcess_Flag); |
270 buffer.setFactoryRecorder(&factSet); | 270 buffer.setFactoryRecorder(&factSet); |
271 buffer.setPixelSerializer(pixelSerializer); | 271 buffer.setPixelSerializer(sk_ref_sp(pixelSerializer)); |
272 buffer.setTypefaceRecorder(typefaceSet); | 272 buffer.setTypefaceRecorder(typefaceSet); |
273 this->flattenToBuffer(buffer); | 273 this->flattenToBuffer(buffer); |
274 | 274 |
275 // Dummy serialize our sub-pictures for the side effect of filling | 275 // Dummy serialize our sub-pictures for the side effect of filling |
276 // typefaceSet with typefaces from sub-pictures. | 276 // typefaceSet with typefaces from sub-pictures. |
277 struct DevNull: public SkWStream { | 277 struct DevNull: public SkWStream { |
278 DevNull() : fBytesWritten(0) {} | 278 DevNull() : fBytesWritten(0) {} |
279 size_t fBytesWritten; | 279 size_t fBytesWritten; |
280 bool write(const void*, size_t size) override { fBytesWritten += size; r
eturn true; } | 280 bool write(const void*, size_t size) override { fBytesWritten += size; r
eturn true; } |
281 size_t bytesWritten() const override { return fBytesWritten; } | 281 size_t bytesWritten() const override { return fBytesWritten; } |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 } else { | 649 } else { |
650 return this->suitableForGpuRasterization(nullptr, reason); | 650 return this->suitableForGpuRasterization(nullptr, reason); |
651 } | 651 } |
652 } | 652 } |
653 | 653 |
654 bool SkPictureData::suitableForLayerOptimization() const { | 654 bool SkPictureData::suitableForLayerOptimization() const { |
655 return fContentInfo.numLayers() > 0; | 655 return fContentInfo.numLayers() > 0; |
656 } | 656 } |
657 #endif | 657 #endif |
658 /////////////////////////////////////////////////////////////////////////////// | 658 /////////////////////////////////////////////////////////////////////////////// |
OLD | NEW |