Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: src/core/SkPictureFlat.h

Issue 723593002: Start stripping out complicated parts of SkPicture{Record,Data}. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 SkWriteBuffer fScratch; 563 SkWriteBuffer fScratch;
564 bool fReady; 564 bool fReady;
565 565
566 // For index -> SkFlatData. 0-based, while all indices in the API are 1-bas ed. Careful! 566 // For index -> SkFlatData. 0-based, while all indices in the API are 1-bas ed. Careful!
567 SkTDArray<const SkFlatData*> fIndexedData; 567 SkTDArray<const SkFlatData*> fIndexedData;
568 568
569 // For SkFlatData -> cached SkFlatData, which has index(). 569 // For SkFlatData -> cached SkFlatData, which has index().
570 SkTDynamicHash<SkFlatData, SkFlatData, SkFlatData::HashTraits> fHash; 570 SkTDynamicHash<SkFlatData, SkFlatData, SkFlatData::HashTraits> fHash;
571 }; 571 };
572 572
573 struct SkPaintFlatteningTraits {
574 static void Flatten(SkWriteBuffer& buffer, const SkPaint& paint) { paint.fla tten(buffer); }
575 static void Unflatten(SkReadBuffer& buffer, SkPaint* paint) { paint->unflatt en(buffer); }
576 };
577
578 typedef SkFlatDictionary<SkPaint, SkPaintFlatteningTraits> SkPaintDictionary;
579
580 class SkChunkFlatController : public SkFlatController {
581 public:
582 SkChunkFlatController(size_t minSize)
583 : fHeap(minSize)
584 , fTypefaceSet(SkNEW(SkRefCntSet))
585 , fLastAllocated(NULL) {
586 this->setTypefaceSet(fTypefaceSet);
587 this->setTypefacePlayback(&fTypefacePlayback);
588 }
589
590 virtual void* allocThrow(size_t bytes) SK_OVERRIDE {
591 fLastAllocated = fHeap.allocThrow(bytes);
592 return fLastAllocated;
593 }
594
595 virtual void unalloc(void* ptr) SK_OVERRIDE {
596 // fHeap can only free a pointer if it was the last one allocated. Othe rwise, we'll just
597 // have to wait until fHeap is destroyed.
598 if (ptr == fLastAllocated) (void)fHeap.unalloc(ptr);
599 }
600
601 void setupPlaybacks() const {
602 fTypefacePlayback.reset(fTypefaceSet.get());
603 }
604
605 void setBitmapStorage(SkBitmapHeap* heap) {
606 this->setBitmapHeap(heap);
607 }
608
609 private:
610 SkChunkAlloc fHeap;
611 SkAutoTUnref<SkRefCntSet> fTypefaceSet;
612 void* fLastAllocated;
613 mutable SkTypefacePlayback fTypefacePlayback;
614 };
615
616 #endif 573 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698