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

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

Issue 176413002: Simplify storage of MC State stack (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/core/SkMatrixClipStateMgr.cpp » ('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 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 #ifndef SkMatrixClipStateMgr_DEFINED 7 #ifndef SkMatrixClipStateMgr_DEFINED
8 #define SkMatrixClipStateMgr_DEFINED 8 #define SkMatrixClipStateMgr_DEFINED
9 9
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 // The SkMatrixClipStateMgr works by intercepting all the save*, restore, clip*, 47 // The SkMatrixClipStateMgr works by intercepting all the save*, restore, clip*,
48 // and matrix calls sent to SkCanvas in order to track the current matrix/clip 48 // and matrix calls sent to SkCanvas in order to track the current matrix/clip
49 // state. All the other canvas calls get funnelled into a generic "call" entry 49 // state. All the other canvas calls get funnelled into a generic "call" entry
50 // point that signals that a state block is required. 50 // point that signals that a state block is required.
51 class SkMatrixClipStateMgr { 51 class SkMatrixClipStateMgr {
52 public: 52 public:
53 static const int32_t kIdentityWideOpenStateID = 0; 53 static const int32_t kIdentityWideOpenStateID = 0;
54 static const int kIdentityMatID = 0; 54 static const int kIdentityMatID = 0;
55 55
56 class MatrixClipState { 56 class MatrixClipState : public SkNoncopyable {
57 public: 57 public:
58 class MatrixInfo { 58 class MatrixInfo {
59 public: 59 public:
60 void reset() { 60 void reset() {
61 fMatrixID = kIdentityMatID; 61 fMatrixID = kIdentityMatID;
62 fMatrix.reset(); 62 fMatrix.reset();
63 } 63 }
64 64
65 bool preTranslate(SkScalar dx, SkScalar dy) { 65 bool preTranslate(SkScalar dx, SkScalar dy) {
66 fMatrixID = -1; 66 fMatrixID = -1;
(...skipping 30 matching lines...) Expand all
97 return fMatrixID; 97 return fMatrixID;
98 } 98 }
99 99
100 fMatrixID = mgr->addMatToDict(fMatrix); 100 fMatrixID = mgr->addMatToDict(fMatrix);
101 return fMatrixID; 101 return fMatrixID;
102 } 102 }
103 103
104 private: 104 private:
105 SkMatrix fMatrix; 105 SkMatrix fMatrix;
106 int fMatrixID; 106 int fMatrixID;
107
108 typedef SkNoncopyable INHERITED;
107 }; 109 };
108 110
109 class ClipInfo : public SkNoncopyable { 111 class ClipInfo : public SkNoncopyable {
110 public: 112 public:
111 ClipInfo() {} 113 ClipInfo() {}
112 114
113 bool clipRect(const SkRect& rect, 115 bool clipRect(const SkRect& rect,
114 SkRegion::Op op, 116 SkRegion::Op op,
115 bool doAA, 117 bool doAA,
116 int matrixID) { 118 int matrixID) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 kRRect_ClipType, 157 kRRect_ClipType,
156 kPath_ClipType, 158 kPath_ClipType,
157 kRegion_ClipType 159 kRegion_ClipType
158 }; 160 };
159 161
160 class ClipOp { 162 class ClipOp {
161 public: 163 public:
162 ClipType fClipType; 164 ClipType fClipType;
163 165
164 union { 166 union {
165 SkRRect fRRect; // also stores clipRect 167 SkRRect fRRect; // also stores clip rect
166 int fPathID; 168 int fPathID;
167 int fRegionID; 169 int fRegionID;
168 } fGeom; 170 } fGeom;
169 171
170 bool fDoAA; 172 bool fDoAA;
171 SkRegion::Op fOp; 173 SkRegion::Op fOp;
172 174
173 // The CTM in effect when this clip call was issued 175 // The CTM in effect when this clip call was issued
174 int fMatrixID; 176 int fMatrixID;
175 }; 177 };
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 MatrixInfo fMatrixInfoStorage; 231 MatrixInfo fMatrixInfoStorage;
230 232
231 ClipInfo* fClipInfo; 233 ClipInfo* fClipInfo;
232 ClipInfo fClipInfoStorage; 234 ClipInfo fClipInfoStorage;
233 235
234 // Tracks the current depth of saveLayers to support the isDrawingToLaye r call 236 // Tracks the current depth of saveLayers to support the isDrawingToLaye r call
235 int fLayerID; 237 int fLayerID;
236 // Does this MC state represent a saveLayer call? 238 // Does this MC state represent a saveLayer call?
237 bool fIsSaveLayer; 239 bool fIsSaveLayer;
238 240
239 // The next two fields are only valid when fIsSaveLayer is set. 241 // The next field is only valid when fIsSaveLayer is set.
240 int32_t fSaveLayerBaseStateID;
241 SkTDArray<int>* fSavedSkipOffsets; 242 SkTDArray<int>* fSavedSkipOffsets;
242 243
243 // Does the MC state have an open block in the skp? 244 // Does the MC state have an open block in the skp?
244 bool fHasOpen; 245 bool fHasOpen;
245 246
246 MatrixClipState* fPrev; 247 MatrixClipState* fPrev;
247 248
248 #ifdef SK_DEBUG 249 #ifdef SK_DEBUG
249 int fExpectedDepth; // debugging aid 250 int fExpectedDepth; // debugging aid
250 #endif 251 #endif
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 } 393 }
393 394
394 // TODO: add stats to check if the dictionary really does 395 // TODO: add stats to check if the dictionary really does
395 // reduce the size of the SkPicture. 396 // reduce the size of the SkPicture.
396 int addMatToDict(const SkMatrix& mat); 397 int addMatToDict(const SkMatrix& mat);
397 const SkMatrix& lookupMat(int index) { 398 const SkMatrix& lookupMat(int index) {
398 SkASSERT(index >= 0 && index < fMatrixDict.count()); 399 SkASSERT(index >= 0 && index < fMatrixDict.count());
399 return fMatrixDict[index]; 400 return fMatrixDict[index];
400 } 401 }
401 402
402 bool isCurrentlyOpen(int32_t stateID); 403 bool isNestingMCState(int stateID);
403 404
404 #ifdef SK_DEBUG 405 #ifdef SK_DEBUG
405 int fActualDepth; 406 int fActualDepth;
406 #endif 407 #endif
408
409 // save layers are nested within a specific MC state. This stack tracks
410 // the nesting MC state's ID as save layers are pushed and popped.
411 SkTDArray<int> fStateIDStack;
407 }; 412 };
408 413
409 #endif 414 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkMatrixClipStateMgr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698