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

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

Issue 340403003: SaveFlags be-gone (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: One more baseurl attempt Created 6 years, 5 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/SkCanvas.cpp ('k') | 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 // The CTM in effect when this clip call was issued 175 // The CTM in effect when this clip call was issued
176 int fMatrixID; 176 int fMatrixID;
177 }; 177 };
178 178
179 SkTDArray<ClipOp> fClips; 179 SkTDArray<ClipOp> fClips;
180 180
181 typedef SkNoncopyable INHERITED; 181 typedef SkNoncopyable INHERITED;
182 }; 182 };
183 183
184 MatrixClipState(MatrixClipState* prev, int flags) 184 MatrixClipState(MatrixClipState* prev)
185 : fPrev(prev) 185 : fPrev(prev)
186 { 186 {
187 fHasOpen = false; 187 fHasOpen = false;
188 188
189 if (NULL == prev) { 189 if (NULL == prev) {
190 fLayerID = 0; 190 fLayerID = 0;
191 191
192 fMatrixInfoStorage.reset(); 192 fMatrixInfoStorage.reset();
193 fMatrixInfo = &fMatrixInfoStorage; 193 fMatrixInfo = &fMatrixInfoStorage;
194 fClipInfo = &fClipInfoStorage; // ctor handles init of fClipInf oStorage 194 fClipInfo = &fClipInfoStorage; // ctor handles init of fClipInf oStorage
195 195
196 // The identity/wide-open-clip state is current by default 196 // The identity/wide-open-clip state is current by default
197 fMCStateID = kIdentityWideOpenStateID; 197 fMCStateID = kIdentityWideOpenStateID;
198 #ifdef SK_DEBUG 198 #ifdef SK_DEBUG
199 fExpectedDepth = 1; 199 fExpectedDepth = 1;
200 #endif 200 #endif
201 } 201 }
202 else { 202 else {
203 fLayerID = prev->fLayerID; 203 fLayerID = prev->fLayerID;
204 204
205 if (flags & SkCanvas::kMatrix_SaveFlag) { 205 fMatrixInfoStorage = *prev->fMatrixInfo;
206 fMatrixInfoStorage = *prev->fMatrixInfo; 206 fMatrixInfo = &fMatrixInfoStorage;
207 fMatrixInfo = &fMatrixInfoStorage;
208 } else {
209 fMatrixInfo = prev->fMatrixInfo;
210 }
211 207
212 if (flags & SkCanvas::kClip_SaveFlag) { 208 // We don't copy the ClipOps of the previous clip states
213 // We don't copy the ClipOps of the previous clip states 209 fClipInfo = &fClipInfoStorage;
214 fClipInfo = &fClipInfoStorage;
215 } else {
216 fClipInfo = prev->fClipInfo;
217 }
218 210
219 // Initially a new save/saveLayer represents the same MC state 211 // Initially a new save/saveLayer represents the same MC state
220 // as its predecessor. 212 // as its predecessor.
221 fMCStateID = prev->fMCStateID; 213 fMCStateID = prev->fMCStateID;
222 #ifdef SK_DEBUG 214 #ifdef SK_DEBUG
223 fExpectedDepth = prev->fExpectedDepth; 215 fExpectedDepth = prev->fExpectedDepth;
224 #endif 216 #endif
225 } 217 }
226 218
227 fIsSaveLayer = false; 219 fIsSaveLayer = false;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 fPicRecord = picRecord; 260 fPicRecord = picRecord;
269 } 261 }
270 262
271 SkPictureRecord* getPicRecord() { return fPicRecord; } 263 SkPictureRecord* getPicRecord() { return fPicRecord; }
272 264
273 // TODO: need to override canvas' getSaveCount. Right now we pass the 265 // TODO: need to override canvas' getSaveCount. Right now we pass the
274 // save* and restore calls on to the base SkCanvas in SkPictureRecord but 266 // save* and restore calls on to the base SkCanvas in SkPictureRecord but
275 // this duplicates effort. 267 // this duplicates effort.
276 int getSaveCount() const { return fMatrixClipStack.count(); } 268 int getSaveCount() const { return fMatrixClipStack.count(); }
277 269
278 int save(SkCanvas::SaveFlags flags); 270 int save();
279 271
280 int saveLayer(const SkRect* bounds, const SkPaint* paint, SkCanvas::SaveFlag s flags); 272 int saveLayer(const SkRect* bounds, const SkPaint* paint, SkCanvas::SaveFlag s flags);
281 273
282 bool isDrawingToLayer() const { 274 bool isDrawingToLayer() const {
283 return fCurMCState->fLayerID > 0; 275 return fCurMCState->fLayerID > 0;
284 } 276 }
285 277
286 void restore(); 278 void restore();
287 279
288 void translate(SkScalar dx, SkScalar dy) { 280 void translate(SkScalar dx, SkScalar dy) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 // The MCStateID of the state currently in effect in the byte stream. 0 if n one. 357 // The MCStateID of the state currently in effect in the byte stream. 0 if n one.
366 int32_t fCurOpenStateID; 358 int32_t fCurOpenStateID;
367 // The skip offsets for the current open state. These are the locations in t he 359 // The skip offsets for the current open state. These are the locations in t he
368 // skp that must be filled in when the current open state is closed. These a re 360 // skp that must be filled in when the current open state is closed. These a re
369 // here rather then distributed across the MatrixClipState's because saveLay ers 361 // here rather then distributed across the MatrixClipState's because saveLay ers
370 // can cause MC states to be nested. 362 // can cause MC states to be nested.
371 SkTDArray<int32_t> *fSkipOffsets; // TODO: should we store u32 or size_t i nstead? 363 SkTDArray<int32_t> *fSkipOffsets; // TODO: should we store u32 or size_t i nstead?
372 364
373 SkDEBUGCODE(void validate();) 365 SkDEBUGCODE(void validate();)
374 366
375 int MCStackPush(SkCanvas::SaveFlags flags); 367 int MCStackPush();
376 368
377 void addClipOffset(size_t offset) { 369 void addClipOffset(size_t offset) {
378 SkASSERT(NULL != fSkipOffsets); 370 SkASSERT(NULL != fSkipOffsets);
379 SkASSERT(kIdentityWideOpenStateID != fCurOpenStateID); 371 SkASSERT(kIdentityWideOpenStateID != fCurOpenStateID);
380 SkASSERT(fCurMCState->fHasOpen); 372 SkASSERT(fCurMCState->fHasOpen);
381 SkASSERT(!fCurMCState->fIsSaveLayer); 373 SkASSERT(!fCurMCState->fIsSaveLayer);
382 374
383 *fSkipOffsets->append() = SkToS32(offset); 375 *fSkipOffsets->append() = SkToS32(offset);
384 } 376 }
385 377
(...skipping 19 matching lines...) Expand all
405 #ifdef SK_DEBUG 397 #ifdef SK_DEBUG
406 int fActualDepth; 398 int fActualDepth;
407 #endif 399 #endif
408 400
409 // save layers are nested within a specific MC state. This stack tracks 401 // 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. 402 // the nesting MC state's ID as save layers are pushed and popped.
411 SkTDArray<int> fStateIDStack; 403 SkTDArray<int> fStateIDStack;
412 }; 404 };
413 405
414 #endif 406 #endif
OLDNEW
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkMatrixClipStateMgr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698