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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 return fTopBot; | 328 return fTopBot; |
329 } | 329 } |
330 | 330 |
331 // Return the topbot[] after it has been recorded. | 331 // Return the topbot[] after it has been recorded. |
332 const SkScalar* topBot() const { | 332 const SkScalar* topBot() const { |
333 SkASSERT(this->isTopBotWritten()); | 333 SkASSERT(this->isTopBotWritten()); |
334 return fTopBot; | 334 return fTopBot; |
335 } | 335 } |
336 | 336 |
337 private: | 337 private: |
338 // For SkTDynamicHash. | 338 struct HashTraits { |
339 static const SkFlatData& Identity(const SkFlatData& flat) { return flat; } | 339 static const SkFlatData& GetKey(const SkFlatData& flat) { return flat; } |
340 static uint32_t Hash(const SkFlatData& flat) { return flat.checksum(); } | 340 static uint32_t Hash(const SkFlatData& flat) { return flat.checksum(); } |
| 341 }; |
341 | 342 |
342 void setIndex(int index) { fIndex = index; } | 343 void setIndex(int index) { fIndex = index; } |
343 uint8_t* data() { return (uint8_t*)this + sizeof(*this); } | 344 uint8_t* data() { return (uint8_t*)this + sizeof(*this); } |
344 | 345 |
345 // This assumes the payload flat data has already been written and does not
modify it. | 346 // This assumes the payload flat data has already been written and does not
modify it. |
346 void stampHeader(int index, int32_t size) { | 347 void stampHeader(int index, int32_t size) { |
347 SkASSERT(SkIsAlign4(size)); | 348 SkASSERT(SkIsAlign4(size)); |
348 fIndex = index; | 349 fIndex = index; |
349 fFlatSize = size; | 350 fFlatSize = size; |
350 fTopBot[0] = SK_ScalarNaN; // Mark as unwritten. | 351 fTopBot[0] = SK_ScalarNaN; // Mark as unwritten. |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 | 557 |
557 // All SkFlatData* stored in fIndexedData and fHash are owned by the control
ler. | 558 // All SkFlatData* stored in fIndexedData and fHash are owned by the control
ler. |
558 SkAutoTUnref<SkFlatController> fController; | 559 SkAutoTUnref<SkFlatController> fController; |
559 SkWriteBuffer fScratch; | 560 SkWriteBuffer fScratch; |
560 bool fReady; | 561 bool fReady; |
561 | 562 |
562 // For index -> SkFlatData. 0-based, while all indices in the API are 1-bas
ed. Careful! | 563 // For index -> SkFlatData. 0-based, while all indices in the API are 1-bas
ed. Careful! |
563 SkTDArray<const SkFlatData*> fIndexedData; | 564 SkTDArray<const SkFlatData*> fIndexedData; |
564 | 565 |
565 // For SkFlatData -> cached SkFlatData, which has index(). | 566 // For SkFlatData -> cached SkFlatData, which has index(). |
566 SkTDynamicHash<SkFlatData, SkFlatData, SkFlatData::Identity, SkFlatData::Has
h> fHash; | 567 SkTDynamicHash<SkFlatData, SkFlatData, SkFlatData::HashTraits> fHash; |
567 }; | 568 }; |
568 | 569 |
569 typedef SkFlatDictionary<SkPaint, SkPaint::FlatteningTraits> SkPaintDictionary; | 570 typedef SkFlatDictionary<SkPaint, SkPaint::FlatteningTraits> SkPaintDictionary; |
570 | 571 |
571 class SkChunkFlatController : public SkFlatController { | 572 class SkChunkFlatController : public SkFlatController { |
572 public: | 573 public: |
573 SkChunkFlatController(size_t minSize) | 574 SkChunkFlatController(size_t minSize) |
574 : fHeap(minSize) | 575 : fHeap(minSize) |
575 , fTypefaceSet(SkNEW(SkRefCntSet)) | 576 , fTypefaceSet(SkNEW(SkRefCntSet)) |
576 , fLastAllocated(NULL) { | 577 , fLastAllocated(NULL) { |
(...skipping 21 matching lines...) Expand all Loading... |
598 } | 599 } |
599 | 600 |
600 private: | 601 private: |
601 SkChunkAlloc fHeap; | 602 SkChunkAlloc fHeap; |
602 SkAutoTUnref<SkRefCntSet> fTypefaceSet; | 603 SkAutoTUnref<SkRefCntSet> fTypefaceSet; |
603 void* fLastAllocated; | 604 void* fLastAllocated; |
604 mutable SkTypefacePlayback fTypefacePlayback; | 605 mutable SkTypefacePlayback fTypefacePlayback; |
605 }; | 606 }; |
606 | 607 |
607 #endif | 608 #endif |
OLD | NEW |