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 | 7 |
8 #ifndef SkPictureRecord_DEFINED | 8 #ifndef SkPictureRecord_DEFINED |
9 #define SkPictureRecord_DEFINED | 9 #define SkPictureRecord_DEFINED |
10 | 10 |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkFlattenable.h" | 12 #include "SkFlattenable.h" |
| 13 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE |
| 14 #include "SkMatrixClipStateMgr.h" |
| 15 #endif |
13 #include "SkPathHeap.h" | 16 #include "SkPathHeap.h" |
14 #include "SkPicture.h" | 17 #include "SkPicture.h" |
15 #include "SkPictureFlat.h" | 18 #include "SkPictureFlat.h" |
16 #include "SkTemplates.h" | 19 #include "SkTemplates.h" |
17 #include "SkWriter32.h" | 20 #include "SkWriter32.h" |
18 | 21 |
19 class SkPictureStateTree; | 22 class SkPictureStateTree; |
20 class SkBBoxHierarchy; | 23 class SkBBoxHierarchy; |
21 | 24 |
22 // These macros help with packing and unpacking a single byte value and | 25 // These macros help with packing and unpacking a single byte value and |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 } | 107 } |
105 | 108 |
106 void beginRecording(); | 109 void beginRecording(); |
107 void endRecording(); | 110 void endRecording(); |
108 | 111 |
109 private: | 112 private: |
110 void handleOptimization(int opt); | 113 void handleOptimization(int opt); |
111 int recordRestoreOffsetPlaceholder(SkRegion::Op); | 114 int recordRestoreOffsetPlaceholder(SkRegion::Op); |
112 void fillRestoreOffsetPlaceholdersForCurrentStackLevel(uint32_t restoreOffse
t); | 115 void fillRestoreOffsetPlaceholdersForCurrentStackLevel(uint32_t restoreOffse
t); |
113 | 116 |
| 117 #ifndef SK_COLLAPSE_MATRIX_CLIP_STATE |
114 SkTDArray<int32_t> fRestoreOffsetStack; | 118 SkTDArray<int32_t> fRestoreOffsetStack; |
115 int fFirstSavedLayerIndex; | 119 int fFirstSavedLayerIndex; |
116 enum { | 120 enum { |
117 kNoSavedLayerIndex = -1 | 121 kNoSavedLayerIndex = -1 |
118 }; | 122 }; |
| 123 #endif |
119 | 124 |
120 /* | 125 /* |
121 * Write the 'drawType' operation and chunk size to the skp. 'size' | 126 * Write the 'drawType' operation and chunk size to the skp. 'size' |
122 * can potentially be increased if the chunk size needs its own storage | 127 * can potentially be increased if the chunk size needs its own storage |
123 * location (i.e., it overflows 24 bits). | 128 * location (i.e., it overflows 24 bits). |
124 * Returns the start offset of the chunk. This is the location at which | 129 * Returns the start offset of the chunk. This is the location at which |
125 * the opcode & size are stored. | 130 * the opcode & size are stored. |
126 * TODO: since we are handing the size into here we could call reserve | 131 * TODO: since we are handing the size into here we could call reserve |
127 * and then return a pointer to the memory storage. This could decrease | 132 * and then return a pointer to the memory storage. This could decrease |
128 * allocation overhead but could lead to more wasted space (the tail | 133 * allocation overhead but could lead to more wasted space (the tail |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 // These entry points allow the writing of matrices, clips, saves & | 248 // These entry points allow the writing of matrices, clips, saves & |
244 // restores to be deferred (e.g., if the MC state is being collapsed and | 249 // restores to be deferred (e.g., if the MC state is being collapsed and |
245 // only written out as needed). | 250 // only written out as needed). |
246 void recordConcat(const SkMatrix& matrix); | 251 void recordConcat(const SkMatrix& matrix); |
247 int recordClipRect(const SkRect& rect, SkRegion::Op op, bool doAA); | 252 int recordClipRect(const SkRect& rect, SkRegion::Op op, bool doAA); |
248 int recordClipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA); | 253 int recordClipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA); |
249 int recordClipPath(int pathID, SkRegion::Op op, bool doAA); | 254 int recordClipPath(int pathID, SkRegion::Op op, bool doAA); |
250 int recordClipRegion(const SkRegion& region, SkRegion::Op op); | 255 int recordClipRegion(const SkRegion& region, SkRegion::Op op); |
251 void recordSave(SaveFlags flags); | 256 void recordSave(SaveFlags flags); |
252 void recordSaveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags f
lags); | 257 void recordSaveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags f
lags); |
253 void recordRestore(); | 258 void recordRestore(bool fillInSkips = true); |
254 | 259 |
255 // These are set to NULL in our constructor, but may be changed by | 260 // These are set to NULL in our constructor, but may be changed by |
256 // subclasses, in which case they will be SkSafeUnref'd in our destructor. | 261 // subclasses, in which case they will be SkSafeUnref'd in our destructor. |
257 SkBBoxHierarchy* fBoundingHierarchy; | 262 SkBBoxHierarchy* fBoundingHierarchy; |
258 SkPictureStateTree* fStateTree; | 263 SkPictureStateTree* fStateTree; |
259 | 264 |
260 // Allocated in the constructor and managed by this class. | 265 // Allocated in the constructor and managed by this class. |
261 SkBitmapHeap* fBitmapHeap; | 266 SkBitmapHeap* fBitmapHeap; |
262 | 267 |
263 private: | 268 private: |
| 269 friend class MatrixClipState; // for access to *Impl methods |
| 270 friend class SkMatrixClipStateMgr; // for access to *Impl methods |
| 271 |
264 SkChunkFlatController fFlattenableHeap; | 272 SkChunkFlatController fFlattenableHeap; |
265 | 273 |
266 SkPaintDictionary fPaints; | 274 SkPaintDictionary fPaints; |
267 | 275 |
268 SkPathHeap* fPathHeap; // reference counted | 276 SkPathHeap* fPathHeap; // reference counted |
269 SkWriter32 fWriter; | 277 SkWriter32 fWriter; |
270 | 278 |
271 // we ref each item in these arrays | 279 // we ref each item in these arrays |
272 SkTDArray<SkPicture*> fPictureRefs; | 280 SkTDArray<SkPicture*> fPictureRefs; |
273 | 281 |
274 uint32_t fRecordFlags; | 282 uint32_t fRecordFlags; |
275 int fInitialSaveCount; | 283 int fInitialSaveCount; |
276 | 284 |
277 friend class SkPicturePlayback; | 285 friend class SkPicturePlayback; |
278 friend class SkPictureTester; // for unit testing | 286 friend class SkPictureTester; // for unit testing |
279 | 287 |
| 288 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE |
| 289 SkMatrixClipStateMgr fMCMgr; |
| 290 #endif |
| 291 |
280 typedef SkCanvas INHERITED; | 292 typedef SkCanvas INHERITED; |
281 }; | 293 }; |
282 | 294 |
283 #endif | 295 #endif |
OLD | NEW |