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

Side by Side Diff: include/core/SkClipStack.h

Issue 54543008: Revert "Avoid re-rendering stencil clip for every draw with reducable clip stack" (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/core/SkClipStack.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 /* 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 SkClipStack_DEFINED 8 #ifndef SkClipStack_DEFINED
9 #define SkClipStack_DEFINED 9 #define SkClipStack_DEFINED
10 10
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 void invertShapeFillType(); 102 void invertShapeFillType();
103 103
104 //!< Sets the set operation represented by the element. 104 //!< Sets the set operation represented by the element.
105 void setOp(SkRegion::Op op) { fOp = op; } 105 void setOp(SkRegion::Op op) { fOp = op; }
106 106
107 /** The GenID can be used by clip stack clients to cache representations of the clip. The 107 /** The GenID can be used by clip stack clients to cache representations of the clip. The
108 ID corresponds to the set of clip elements up to and including this element within the 108 ID corresponds to the set of clip elements up to and including this element within the
109 stack not to the element itself. That is the same clip path in diffe rent stacks will 109 stack not to the element itself. That is the same clip path in diffe rent stacks will
110 have a different ID since the elements produce different clip result in the context of 110 have a different ID since the elements produce different clip result in the context of
111 their stacks. */ 111 their stacks. */
112 int32_t getGenID() const { SkASSERT(kInvalidGenID != fGenID); return fGe nID; } 112 int32_t getGenID() const { return fGenID; }
113 113
114 /** 114 /**
115 * Gets the bounds of the clip element, either the rect or path bounds. (Whether the shape 115 * Gets the bounds of the clip element, either the rect or path bounds. (Whether the shape
116 * is inverse filled is not considered.) 116 * is inverse filled is not considered.)
117 */ 117 */
118 const SkRect& getBounds() const { 118 const SkRect& getBounds() const {
119 static const SkRect kEmpty = { 0, 0, 0, 0 }; 119 static const SkRect kEmpty = { 0, 0, 0, 0 };
120 switch (fType) { 120 switch (fType) {
121 case kRect_Type: 121 case kRect_Type:
122 return fRect; 122 return fRect;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 // An optimized version of clipDevRect(emptyRect, kIntersect, ...) 309 // An optimized version of clipDevRect(emptyRect, kIntersect, ...)
310 void clipEmpty(); 310 void clipEmpty();
311 311
312 /** 312 /**
313 * isWideOpen returns true if the clip state corresponds to the infinite 313 * isWideOpen returns true if the clip state corresponds to the infinite
314 * plane (i.e., draws are not limited at all) 314 * plane (i.e., draws are not limited at all)
315 */ 315 */
316 bool isWideOpen() const; 316 bool isWideOpen() const;
317 317
318 /** 318 /**
319 * Add a callback function that will be called whenever a clip state
320 * is no longer viable. This will occur whenever restore
321 * is called or when a clipDevRect or clipDevPath call updates the
322 * clip within an existing save/restore state. Each clip state is
323 * represented by a unique generation ID.
324 */
325 typedef void (*PFPurgeClipCB)(int genID, void* data);
326 void addPurgeClipCallback(PFPurgeClipCB callback, void* data) const;
327
328 /**
329 * Remove a callback added earlier via addPurgeClipCallback
330 */
331 void removePurgeClipCallback(PFPurgeClipCB callback, void* data) const;
332
333 /**
319 * The generation ID has three reserved values to indicate special 334 * The generation ID has three reserved values to indicate special
320 * (potentially ignorable) cases 335 * (potentially ignorable) cases
321 */ 336 */
322 static const int32_t kInvalidGenID = 0; //!< Invalid id that is never re turned by 337 static const int32_t kInvalidGenID = 0;
323 //!< SkClipStack. Useful when ca ching clips
324 //!< based on GenID.
325 static const int32_t kEmptyGenID = 1; // no pixels writeable 338 static const int32_t kEmptyGenID = 1; // no pixels writeable
326 static const int32_t kWideOpenGenID = 2; // all pixels writeable 339 static const int32_t kWideOpenGenID = 2; // all pixels writeable
327 340
328 int32_t getTopmostGenID() const; 341 int32_t getTopmostGenID() const;
329 342
330 public: 343 public:
331 class Iter { 344 class Iter {
332 public: 345 public:
333 enum IterStart { 346 enum IterStart {
334 kBottom_IterStart = SkDeque::Iter::kFront_IterStart, 347 kBottom_IterStart = SkDeque::Iter::kFront_IterStart,
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 friend class Iter; 433 friend class Iter;
421 434
422 SkDeque fDeque; 435 SkDeque fDeque;
423 int fSaveCount; 436 int fSaveCount;
424 437
425 // Generation ID for the clip stack. This is incremented for each 438 // Generation ID for the clip stack. This is incremented for each
426 // clipDevRect and clipDevPath call. 0 is reserved to indicate an 439 // clipDevRect and clipDevPath call. 0 is reserved to indicate an
427 // invalid ID. 440 // invalid ID.
428 static int32_t gGenID; 441 static int32_t gGenID;
429 442
443 struct ClipCallbackData {
444 PFPurgeClipCB fCallback;
445 void* fData;
446
447 friend bool operator==(const ClipCallbackData& a,
448 const ClipCallbackData& b) {
449 return a.fCallback == b.fCallback && a.fData == b.fData;
450 }
451 };
452
453 mutable SkTDArray<ClipCallbackData> fCallbackData;
454
430 /** 455 /**
431 * Restore the stack back to the specified save count. 456 * Restore the stack back to the specified save count.
432 */ 457 */
433 void restoreTo(int saveCount); 458 void restoreTo(int saveCount);
434 459
435 /** 460 /**
461 * Invoke all the purge callbacks passing in element's generation ID.
462 */
463 void purgeClip(Element* element);
464
465 /**
436 * Return the next unique generation ID. 466 * Return the next unique generation ID.
437 */ 467 */
438 static int32_t GetNextGenID(); 468 static int32_t GetNextGenID();
439 }; 469 };
440 470
441 #endif 471 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkClipStack.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698