| 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 #ifndef SkPictureFlat_DEFINED | 7 #ifndef SkPictureFlat_DEFINED |
| 8 #define SkPictureFlat_DEFINED | 8 #define SkPictureFlat_DEFINED |
| 9 | 9 |
| 10 | 10 |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 typedef SkRefCnt INHERITED; | 264 typedef SkRefCnt INHERITED; |
| 265 }; | 265 }; |
| 266 | 266 |
| 267 class SkFlatData { | 267 class SkFlatData { |
| 268 public: | 268 public: |
| 269 // Flatten obj into an SkFlatData with this index. controller owns the SkFl
atData*. | 269 // Flatten obj into an SkFlatData with this index. controller owns the SkFl
atData*. |
| 270 template <typename Traits, typename T> | 270 template <typename Traits, typename T> |
| 271 static SkFlatData* Create(SkFlatController* controller, const T& obj, int in
dex) { | 271 static SkFlatData* Create(SkFlatController* controller, const T& obj, int in
dex) { |
| 272 // A buffer of 256 bytes should fit most paints, regions, and matrices. | 272 // A buffer of 256 bytes should fit most paints, regions, and matrices. |
| 273 uint32_t storage[64]; | 273 uint32_t storage[64]; |
| 274 SkWriteBuffer buffer(storage, sizeof(storage), controller->getWriteBuffe
rFlags()); | 274 SkBinaryWriteBuffer buffer(storage, sizeof(storage), controller->getWrit
eBufferFlags()); |
| 275 | 275 |
| 276 buffer.setBitmapHeap(controller->getBitmapHeap()); | 276 buffer.setBitmapHeap(controller->getBitmapHeap()); |
| 277 buffer.setTypefaceRecorder(controller->getTypefaceSet()); | 277 buffer.setTypefaceRecorder(controller->getTypefaceSet()); |
| 278 | 278 |
| 279 Traits::Flatten(buffer, obj); | 279 Traits::Flatten(buffer, obj); |
| 280 size_t size = buffer.bytesWritten(); | 280 size_t size = buffer.bytesWritten(); |
| 281 SkASSERT(SkIsAlign4(size)); | 281 SkASSERT(SkIsAlign4(size)); |
| 282 | 282 |
| 283 // Allocate enough memory to hold SkFlatData struct and the flat data it
self. | 283 // Allocate enough memory to hold SkFlatData struct and the flat data it
self. |
| 284 size_t allocSize = sizeof(SkFlatData) + size; | 284 size_t allocSize = sizeof(SkFlatData) + size; |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 } | 539 } |
| 540 | 540 |
| 541 void unflatten(T* dst, const SkFlatData* element) const { | 541 void unflatten(T* dst, const SkFlatData* element) const { |
| 542 element->unflatten<Traits>(dst, | 542 element->unflatten<Traits>(dst, |
| 543 fController->getBitmapHeap(), | 543 fController->getBitmapHeap(), |
| 544 fController->getTypefacePlayback()); | 544 fController->getTypefacePlayback()); |
| 545 } | 545 } |
| 546 | 546 |
| 547 // All SkFlatData* stored in fIndexedData and fHash are owned by the control
ler. | 547 // All SkFlatData* stored in fIndexedData and fHash are owned by the control
ler. |
| 548 SkAutoTUnref<SkFlatController> fController; | 548 SkAutoTUnref<SkFlatController> fController; |
| 549 SkWriteBuffer fScratch; | 549 SkBinaryWriteBuffer fScratch; |
| 550 bool fReady; | 550 bool fReady; |
| 551 | 551 |
| 552 // For index -> SkFlatData. 0-based, while all indices in the API are 1-bas
ed. Careful! | 552 // For index -> SkFlatData. 0-based, while all indices in the API are 1-bas
ed. Careful! |
| 553 SkTDArray<const SkFlatData*> fIndexedData; | 553 SkTDArray<const SkFlatData*> fIndexedData; |
| 554 | 554 |
| 555 // For SkFlatData -> cached SkFlatData, which has index(). | 555 // For SkFlatData -> cached SkFlatData, which has index(). |
| 556 SkTDynamicHash<SkFlatData, SkFlatData, SkFlatData::HashTraits> fHash; | 556 SkTDynamicHash<SkFlatData, SkFlatData, SkFlatData::HashTraits> fHash; |
| 557 }; | 557 }; |
| 558 | 558 |
| 559 #endif | 559 #endif |
| OLD | NEW |