| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 #ifndef SkPictureFlat_DEFINED | 8 #ifndef SkPictureFlat_DEFINED |
| 9 #define SkPictureFlat_DEFINED | 9 #define SkPictureFlat_DEFINED |
| 10 | 10 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 // implemented, or SkChunkFlatController can be used to use an SkChunkAllocator
and never do | 172 // implemented, or SkChunkFlatController can be used to use an SkChunkAllocator
and never do |
| 173 // replacements. | 173 // replacements. |
| 174 // | 174 // |
| 175 // | 175 // |
| 176 /////////////////////////////////////////////////////////////////////////////// | 176 /////////////////////////////////////////////////////////////////////////////// |
| 177 | 177 |
| 178 class SkFlatData; | 178 class SkFlatData; |
| 179 | 179 |
| 180 class SkFlatController : public SkRefCnt { | 180 class SkFlatController : public SkRefCnt { |
| 181 public: | 181 public: |
| 182 | 182 |
| 183 | 183 |
| 184 SkFlatController(uint32_t writeBufferFlags = 0); | 184 SkFlatController(uint32_t writeBufferFlags = 0); |
| 185 virtual ~SkFlatController(); | 185 virtual ~SkFlatController(); |
| 186 /** | 186 /** |
| 187 * Return a new block of memory for the SkFlatDictionary to use. | 187 * Return a new block of memory for the SkFlatDictionary to use. |
| 188 * This memory is owned by the controller and has the same lifetime unless y
ou | 188 * This memory is owned by the controller and has the same lifetime unless y
ou |
| 189 * call unalloc(), in which case it may be freed early. | 189 * call unalloc(), in which case it may be freed early. |
| 190 */ | 190 */ |
| 191 virtual void* allocThrow(size_t bytes) = 0; | 191 virtual void* allocThrow(size_t bytes) = 0; |
| 192 | 192 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 | 350 |
| 351 void setIndex(int index) { fIndex = index; } | 351 void setIndex(int index) { fIndex = index; } |
| 352 uint8_t* data() { return (uint8_t*)this + sizeof(*this); } | 352 uint8_t* data() { return (uint8_t*)this + sizeof(*this); } |
| 353 | 353 |
| 354 // This assumes the payload flat data has already been written and does not
modify it. | 354 // This assumes the payload flat data has already been written and does not
modify it. |
| 355 void stampHeader(int index, int32_t size) { | 355 void stampHeader(int index, int32_t size) { |
| 356 SkASSERT(SkIsAlign4(size)); | 356 SkASSERT(SkIsAlign4(size)); |
| 357 fIndex = index; | 357 fIndex = index; |
| 358 fFlatSize = size; | 358 fFlatSize = size; |
| 359 fTopBot[0] = SK_ScalarNaN; // Mark as unwritten. | 359 fTopBot[0] = SK_ScalarNaN; // Mark as unwritten. |
| 360 fChecksum = SkChecksum::Compute((uint32_t*)this->data(), size); | 360 fChecksum = SkChecksum::Murmur3(this->data(), size); |
| 361 } | 361 } |
| 362 | 362 |
| 363 int fIndex; | 363 int fIndex; |
| 364 int32_t fFlatSize; | 364 int32_t fFlatSize; |
| 365 uint32_t fChecksum; | 365 uint32_t fChecksum; |
| 366 mutable SkScalar fTopBot[2]; // Cache of FontMetrics fTop, fBottom. Starts
as [NaN,?]. | 366 mutable SkScalar fTopBot[2]; // Cache of FontMetrics fTop, fBottom. Starts
as [NaN,?]. |
| 367 // uint32_t flattenedData[] implicitly hangs off the end. | 367 // uint32_t flattenedData[] implicitly hangs off the end. |
| 368 | 368 |
| 369 template <typename T, typename Traits> friend class SkFlatDictionary; | 369 template <typename T, typename Traits> friend class SkFlatDictionary; |
| 370 }; | 370 }; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 bool fReady; | 553 bool fReady; |
| 554 | 554 |
| 555 // For index -> SkFlatData. 0-based, while all indices in the API are 1-bas
ed. Careful! | 555 // For index -> SkFlatData. 0-based, while all indices in the API are 1-bas
ed. Careful! |
| 556 SkTDArray<const SkFlatData*> fIndexedData; | 556 SkTDArray<const SkFlatData*> fIndexedData; |
| 557 | 557 |
| 558 // For SkFlatData -> cached SkFlatData, which has index(). | 558 // For SkFlatData -> cached SkFlatData, which has index(). |
| 559 SkTDynamicHash<SkFlatData, SkFlatData, SkFlatData::HashTraits> fHash; | 559 SkTDynamicHash<SkFlatData, SkFlatData, SkFlatData::HashTraits> fHash; |
| 560 }; | 560 }; |
| 561 | 561 |
| 562 #endif | 562 #endif |
| OLD | NEW |