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 "SkBBoxHierarchy.h" | 8 #include "SkBBoxHierarchy.h" |
9 #include "SkDrawPictureCallback.h" | 9 #include "SkDrawPictureCallback.h" |
10 #include "SkPictureData.h" | 10 #include "SkPictureData.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 | 211 |
212 if (fTextBlobCount > 0) { | 212 if (fTextBlobCount > 0) { |
213 write_tag_size(buffer, SK_PICT_TEXTBLOB_BUFFER_TAG, fTextBlobCount); | 213 write_tag_size(buffer, SK_PICT_TEXTBLOB_BUFFER_TAG, fTextBlobCount); |
214 for (i = 0; i < fTextBlobCount; ++i) { | 214 for (i = 0; i < fTextBlobCount; ++i) { |
215 fTextBlobRefs[i]->flatten(buffer); | 215 fTextBlobRefs[i]->flatten(buffer); |
216 } | 216 } |
217 } | 217 } |
218 } | 218 } |
219 | 219 |
220 void SkPictureData::serialize(SkWStream* stream, | 220 void SkPictureData::serialize(SkWStream* stream, |
221 SkPixelSerializer* pixelSerializer) const { | 221 SkPicture::EncodeBitmap encoder) const { |
222 write_tag_size(stream, SK_PICT_READER_TAG, fOpData->size()); | 222 write_tag_size(stream, SK_PICT_READER_TAG, fOpData->size()); |
223 stream->write(fOpData->bytes(), fOpData->size()); | 223 stream->write(fOpData->bytes(), fOpData->size()); |
224 | 224 |
225 if (fPictureCount > 0) { | 225 if (fPictureCount > 0) { |
226 write_tag_size(stream, SK_PICT_PICTURE_TAG, fPictureCount); | 226 write_tag_size(stream, SK_PICT_PICTURE_TAG, fPictureCount); |
227 for (int i = 0; i < fPictureCount; i++) { | 227 for (int i = 0; i < fPictureCount; i++) { |
228 fPictureRefs[i]->serialize(stream, pixelSerializer); | 228 fPictureRefs[i]->serialize(stream, encoder); |
229 } | 229 } |
230 } | 230 } |
231 | 231 |
232 // Write some of our data into a writebuffer, and then serialize that | 232 // Write some of our data into a writebuffer, and then serialize that |
233 // into our stream | 233 // into our stream |
234 { | 234 { |
235 SkRefCntSet typefaceSet; | 235 SkRefCntSet typefaceSet; |
236 SkFactorySet factSet; | 236 SkFactorySet factSet; |
237 | 237 |
238 SkWriteBuffer buffer(SkWriteBuffer::kCrossProcess_Flag); | 238 SkWriteBuffer buffer(SkWriteBuffer::kCrossProcess_Flag); |
239 buffer.setTypefaceRecorder(&typefaceSet); | 239 buffer.setTypefaceRecorder(&typefaceSet); |
240 buffer.setFactoryRecorder(&factSet); | 240 buffer.setFactoryRecorder(&factSet); |
241 buffer.setPixelSerializer(pixelSerializer); | 241 buffer.setBitmapEncoder(encoder); |
242 | 242 |
243 this->flattenToBuffer(buffer); | 243 this->flattenToBuffer(buffer); |
244 | 244 |
245 // We have to write these two sets into the stream *before* we write | 245 // We have to write these two sets into the stream *before* we write |
246 // the buffer, since parsing that buffer will require that we already | 246 // the buffer, since parsing that buffer will require that we already |
247 // have these sets available to use. | 247 // have these sets available to use. |
248 WriteFactories(stream, factSet); | 248 WriteFactories(stream, factSet); |
249 WriteTypefaces(stream, typefaceSet); | 249 WriteTypefaces(stream, typefaceSet); |
250 | 250 |
251 write_tag_size(stream, SK_PICT_BUFFER_SIZE_TAG, buffer.bytesWritten()); | 251 write_tag_size(stream, SK_PICT_BUFFER_SIZE_TAG, buffer.bytesWritten()); |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 } | 573 } |
574 } | 574 } |
575 | 575 |
576 bool SkPictureData::suitableForLayerOptimization() const { | 576 bool SkPictureData::suitableForLayerOptimization() const { |
577 return fContentInfo.numLayers() > 0; | 577 return fContentInfo.numLayers() > 0; |
578 } | 578 } |
579 #endif | 579 #endif |
580 /////////////////////////////////////////////////////////////////////////////// | 580 /////////////////////////////////////////////////////////////////////////////// |
581 | 581 |
582 | 582 |
OLD | NEW |