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