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

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

Issue 143883006: No deduping dictionaries for matrices and regions. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: bump picture version Created 6 years, 11 months 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
« no previous file with comments | « src/core/SkPicture.cpp ('k') | src/core/SkPicturePlayback.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 //#define SK_DEBUG_SIZE 11 //#define SK_DEBUG_SIZE
12 12
13 #include "SkBitmap.h"
14 #include "SkBitmapHeap.h" 13 #include "SkBitmapHeap.h"
15 #include "SkChecksum.h" 14 #include "SkChecksum.h"
16 #include "SkChunkAlloc.h" 15 #include "SkChunkAlloc.h"
17 #include "SkMatrix.h"
18 #include "SkOrderedReadBuffer.h" 16 #include "SkOrderedReadBuffer.h"
19 #include "SkOrderedWriteBuffer.h" 17 #include "SkOrderedWriteBuffer.h"
20 #include "SkPaint.h" 18 #include "SkPaint.h"
21 #include "SkPath.h"
22 #include "SkPicture.h" 19 #include "SkPicture.h"
23 #include "SkPtrRecorder.h" 20 #include "SkPtrRecorder.h"
24 #include "SkRegion.h"
25 #include "SkTDynamicHash.h" 21 #include "SkTDynamicHash.h"
26 #include "SkTRefArray.h" 22 #include "SkTRefArray.h"
27 #include "SkTSearch.h"
28 23
29 enum DrawType { 24 enum DrawType {
30 UNUSED, 25 UNUSED,
31 CLIP_PATH, 26 CLIP_PATH,
32 CLIP_REGION, 27 CLIP_REGION,
33 CLIP_RECT, 28 CLIP_RECT,
34 CLIP_RRECT, 29 CLIP_RRECT,
35 CONCAT, 30 CONCAT,
36 DRAW_BITMAP, 31 DRAW_BITMAP,
37 DRAW_BITMAP_MATRIX, 32 DRAW_BITMAP_MATRIX,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 /////////////////////////////////////////////////////////////////////////////// 140 ///////////////////////////////////////////////////////////////////////////////
146 // 141 //
147 // 142 //
148 // The following templated classes provide an efficient way to store and compare 143 // The following templated classes provide an efficient way to store and compare
149 // objects that have been flattened (i.e. serialized in an ordered binary 144 // objects that have been flattened (i.e. serialized in an ordered binary
150 // format). 145 // format).
151 // 146 //
152 // SkFlatData: is a simple indexable container for the flattened data 147 // SkFlatData: is a simple indexable container for the flattened data
153 // which is agnostic to the type of data is is indexing. It is 148 // which is agnostic to the type of data is is indexing. It is
154 // also responsible for flattening/unflattening objects but 149 // also responsible for flattening/unflattening objects but
155 // details of that operation are hidden in the provided procs 150 // details of that operation are hidden in the provided traits
156 // SkFlatDictionary: is an abstract templated dictionary that maintains a 151 // SkFlatDictionary: is an abstract templated dictionary that maintains a
157 // searchable set of SkFlatData objects of type T. 152 // searchable set of SkFlatData objects of type T.
158 // SkFlatController: is an interface provided to SkFlatDictionary which handles 153 // SkFlatController: is an interface provided to SkFlatDictionary which handles
159 // allocation (and unallocation in some cases). It also holds 154 // allocation (and unallocation in some cases). It also holds
160 // ref count recorders and the like. 155 // ref count recorders and the like.
161 // 156 //
162 // NOTE: any class that wishes to be used in conjunction with SkFlatDictionary 157 // NOTE: any class that wishes to be used in conjunction with SkFlatDictionary m ust subclass the
163 // must subclass the dictionary and provide the necessary flattening procs. 158 // dictionary and provide the necessary flattening traits. SkFlatController mus t also be
164 // The end of this header contains dictionary subclasses for some common classes 159 // implemented, or SkChunkFlatController can be used to use an SkChunkAllocator and never do
165 // like SkBitmap, SkMatrix, SkPaint, and SkRegion. SkFlatController must also 160 // replacements.
166 // be implemented, or SkChunkFlatController can be used to use an
167 // SkChunkAllocator and never do replacements.
168 // 161 //
169 // 162 //
170 /////////////////////////////////////////////////////////////////////////////// 163 ///////////////////////////////////////////////////////////////////////////////
171 164
172 class SkFlatData; 165 class SkFlatData;
173 166
174 class SkFlatController : public SkRefCnt { 167 class SkFlatController : public SkRefCnt {
175 public: 168 public:
176 SK_DECLARE_INST_COUNT(SkFlatController) 169 SK_DECLARE_INST_COUNT(SkFlatController)
177 170
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 bool fReady; 560 bool fReady;
568 561
569 // For index -> SkFlatData. 0-based, while all indices in the API are 1-bas ed. Careful! 562 // For index -> SkFlatData. 0-based, while all indices in the API are 1-bas ed. Careful!
570 SkTDArray<const SkFlatData*> fIndexedData; 563 SkTDArray<const SkFlatData*> fIndexedData;
571 564
572 // For SkFlatData -> cached SkFlatData, which has index(). 565 // For SkFlatData -> cached SkFlatData, which has index().
573 SkTDynamicHash<SkFlatData, SkFlatData, 566 SkTDynamicHash<SkFlatData, SkFlatData,
574 SkFlatData::Identity, SkFlatData::Hash, SkFlatData::Equal> fH ash; 567 SkFlatData::Identity, SkFlatData::Hash, SkFlatData::Equal> fH ash;
575 }; 568 };
576 569
577 ///////////////////////////////////////////////////////////////////////////////
578 // Some common dictionaries are defined here for both reference and convenience
579 ///////////////////////////////////////////////////////////////////////////////
580
581 struct SkMatrixTraits {
582 static void flatten(SkOrderedWriteBuffer& buffer, const SkMatrix& matrix) {
583 buffer.getWriter32()->writeMatrix(matrix);
584 }
585 static void unflatten(SkOrderedReadBuffer& buffer, SkMatrix* matrix) {
586 buffer.getReader32()->readMatrix(matrix);
587 }
588 };
589 typedef SkFlatDictionary<SkMatrix, SkMatrixTraits> SkMatrixDictionary;
590
591
592 struct SkRegionTraits {
593 static void flatten(SkOrderedWriteBuffer& buffer, const SkRegion& region) {
594 buffer.getWriter32()->writeRegion(region);
595 }
596 static void unflatten(SkOrderedReadBuffer& buffer, SkRegion* region) {
597 buffer.getReader32()->readRegion(region);
598 }
599 };
600 typedef SkFlatDictionary<SkRegion, SkRegionTraits> SkRegionDictionary;
601
602
603 struct SkPaintTraits { 570 struct SkPaintTraits {
604 static void flatten(SkOrderedWriteBuffer& buffer, const SkPaint& paint) { 571 static void flatten(SkOrderedWriteBuffer& buffer, const SkPaint& paint) {
605 paint.flatten(buffer); 572 paint.flatten(buffer);
606 } 573 }
607 static void unflatten(SkOrderedReadBuffer& buffer, SkPaint* paint) { 574 static void unflatten(SkOrderedReadBuffer& buffer, SkPaint* paint) {
608 paint->unflatten(buffer); 575 paint->unflatten(buffer);
609 } 576 }
610 }; 577 };
611 typedef SkFlatDictionary<SkPaint, SkPaintTraits> SkPaintDictionary; 578 typedef SkFlatDictionary<SkPaint, SkPaintTraits> SkPaintDictionary;
612 579
(...skipping 27 matching lines...) Expand all
640 } 607 }
641 608
642 private: 609 private:
643 SkChunkAlloc fHeap; 610 SkChunkAlloc fHeap;
644 SkAutoTUnref<SkRefCntSet> fTypefaceSet; 611 SkAutoTUnref<SkRefCntSet> fTypefaceSet;
645 void* fLastAllocated; 612 void* fLastAllocated;
646 mutable SkTypefacePlayback fTypefacePlayback; 613 mutable SkTypefacePlayback fTypefacePlayback;
647 }; 614 };
648 615
649 #endif 616 #endif
OLDNEW
« no previous file with comments | « src/core/SkPicture.cpp ('k') | src/core/SkPicturePlayback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698