8 #ifndef SkClipStack_DEFINED
9 #define SkClipStack_DEFINED
51 kLastType = kPath_Type
53 static const int kTypeCnt = kLastType + 1;
60 Element(
const Element&);
63 this->initRect(0, rect, op, doAA);
67 this->initRRect(0, rrect, op, doAA);
71 this->initPath(0, path, op, doAA);
74 bool operator== (
const Element& element)
const;
75 bool operator!= (
const Element& element)
const {
return !(*
this == element); }
84 const SkPath&
getPath()
const { SkASSERT(kPath_Type == fType);
return *fPath.get(); }
87 const SkRRect&
getRRect()
const { SkASSERT(kRRect_Type == fType);
return fRRect; }
91 SkASSERT(kRect_Type == fType && (fRRect.isRect() || fRRect.isEmpty()));
92 return fRRect.getBounds();
99 void asPath(
SkPath* path)
const;
102 const SkRRect& asRRect()
const { SkASSERT(kPath_Type != fType);
return fRRect; }
106 bool isAA()
const {
return fDoAA; }
109 void invertShapeFillType();
119 int32_t
getGenID()
const { SkASSERT(kInvalidGenID != fGenID);
return fGenID; }
126 static const SkRect kEmpty = { 0, 0, 0, 0 };
130 return fRRect.getBounds();
132 return fPath.get()->getBounds();
136 SkDEBUGFAIL(
"Unexpected type.");
148 return this->getRect().contains(rect);
150 return fRRect.contains(rect);
152 return fPath.get()->conservativelyContainsRect(rect);
156 SkDEBUGFAIL(
"Unexpected type.");
161 bool contains(
const SkRRect& rrect)
const {
164 return this->getRect().contains(rrect.getBounds());
167 return fRRect.contains(rrect.getBounds()) || rrect == fRRect;
169 return fPath.get()->conservativelyContainsRect(rrect.getBounds());
173 SkDEBUGFAIL(
"Unexpected type.");
182 return kPath_Type == fType && fPath.get()->isInverseFillType();
218 SkClipStack::BoundsType fFiniteBoundType;
223 bool fIsIntersectionOfRects;
233 this->initRRect(saveCount, rrect, op, doAA);
237 this->initRect(saveCount, rect, op, doAA);
241 this->initPath(saveCount, path, op, doAA);
244 void initCommon(
int saveCount,
SkRegion::Op op,
bool doAA) {
245 fSaveCount = saveCount;
250 fFiniteBoundType = kInsideOut_BoundsType;
251 fFiniteBound.setEmpty();
252 fIsIntersectionOfRects =
false;
257 fRRect.setRect(rect);
259 this->initCommon(saveCount, op, doAA);
270 this->initCommon(saveCount, op, doAA);
278 inline void checkEmpty()
const;
279 inline bool canBeIntersectedInPlace(
int saveCount,
SkRegion::Op op)
const;
283 bool rectRectIntersectAllowed(
const SkRect& newR,
bool newAA)
const;
286 void updateBoundAndGenID(
const Element* prior);
290 kPrev_InvCur_FillCombo,
291 kInvPrev_Cur_FillCombo,
292 kInvPrev_InvCur_FillCombo
295 inline void combineBoundsDiff(FillCombo combination,
const SkRect& prevFinite);
296 inline void combineBoundsXOR(
int combination,
const SkRect& prevFinite);
297 inline void combineBoundsUnion(
int combination,
const SkRect& prevFinite);
298 inline void combineBoundsIntersection(
int combination,
const SkRect& prevFinite);
299 inline void combineBoundsRevDiff(
int combination,
const SkRect& prevFinite);
310 bool operator!=(
const SkClipStack& b)
const {
return !(*
this == b); }
314 int getSaveCount()
const {
return fSaveCount; }
328 BoundsType* boundType,
329 bool* isIntersectionOfRects = NULL)
const;
337 return this->
isWideOpen() || this->internalQuickContains(devRect);
341 return this->
isWideOpen() || this->internalQuickContains(devRRect);
353 this->clipDevRect(r, op,
false);
365 bool isWideOpen()
const {
return this->getTopmostGenID() == kWideOpenGenID; }
372 static const int32_t kEmptyGenID = 1;
375 static const int32_t kWideOpenGenID = 2;
377 int32_t getTopmostGenID()
const;
391 kBottom_IterStart = SkDeque::Iter::kFront_IterStart,
392 kTop_IterStart = SkDeque::Iter::kBack_IterStart
418 void reset(
const SkClipStack& stack, IterStart startLoc);
448 this->INHERITED::reset(stack, kBottom_IterStart);
453 typedef Iter INHERITED;
469 void getConservativeBounds(
int offsetX,
474 bool* isIntersectionOfRects = NULL)
const;
485 static int32_t gGenID;
487 bool internalQuickContains(
const SkRect& devRect)
const;
488 bool internalQuickContains(
const SkRRect& devRRect)
const;
493 void pushElement(
const Element& element);
498 void restoreTo(
int saveCount);
503 static int32_t GetNextGenID();
const SkPath & getPath() const
Call if getType() is kRRect to get the round-rect.
Definition: SkClipStack.h:84
The SkRRect class represents a rounded rect with a potentially different radii for each corner...
Definition: SkRRect.h:48
The SkPath class encapsulates compound (multiple contour) geometric paths consisting of straight line...
Definition: SkPath.h:27
SkRegion::Op getOp() const
Call to get the element as a path, regardless of its type.
Definition: SkClipStack.h:96
const SkRect & getBounds() const
Gets the bounds of the clip element, either the rect or path bounds.
Definition: SkClipStack.h:125
void reset(const SkClipStack &stack)
Wrap Iter::reset to force initialization to the beginning of the deque/bottom of the stack...
Definition: SkClipStack.h:447
Type
Enum to capture the various possible subtypes of RR.
Definition: SkRRect.h:58
bool isAA() const
If getType() is not kEmpty this indicates whether the clip shape should be anti-aliased when it is ra...
Definition: SkClipStack.h:106
bool isInverseFilled() const
Is the clip shape inverse filled.
Definition: SkClipStack.h:181
bool quickContains(const SkRect &devRect) const
Returns true if the input (r)rect in device space is entirely contained by the clip.
Definition: SkClipStack.h:336
Definition: SkClipStack.h:388
int32_t getGenID() const
The GenID can be used by clip stack clients to cache representations of the clip. ...
Definition: SkClipStack.h:119
Type getType() const
Call to get the save count associated with this clip element.
Definition: SkClipStack.h:78
static const int32_t kInvalidGenID
The generation ID has three reserved values to indicate special (potentially ignorable) cases...
Definition: SkClipStack.h:371
The RR is actually a (non-empty) oval (i.e., all x radii are equal and >= width/2 and all the y radii...
Definition: SkRRect.h:64
const SkRect & getRect() const
Call if getType() is not kEmpty to get the set operation used to combine this element.
Definition: SkClipStack.h:90
Type
Definition: SkClipStack.h:41
void dump() const
Dumps the contents of the clip stack to SkDebugf.
bool contains(const SkRect &rect) const
Conservatively checks whether the clip shape contains the rect param.
Definition: SkClipStack.h:145
bool isWideOpen() const
isWideOpen returns true if the clip state corresponds to the infinite plane (i.e., draws are not limited at all)
Definition: SkClipStack.h:365
replace the dst region with the op region
Definition: SkRegion.h:246
Type getType() const
Returns the RR's sub type.
Definition: SkRRect.h:92
The RR is actually a (non-empty) rect (i.e., at least one radius at each corner is zero) ...
Definition: SkRRect.h:60
const SkRRect & getRRect() const
Call if getType() is kRect to get the rect.
Definition: SkClipStack.h:87
Definition: SkClipStack.h:39
The B2TIter iterates from the bottom of the stack to the top.
Definition: SkClipStack.h:429
SkIRect holds four 32 bit integer coordinates for a rectangle.
Definition: SkRect.h:20
B2TIter(const SkClipStack &stack)
Wrap Iter's 2 parameter ctor to force initialization to the beginning of the deque/bottom of the stac...
Definition: SkClipStack.h:437
Definition: SkRefCnt.h:221
Definition: SkClipStack.h:26
Op
The logical operations that can be performed when combining two regions.
Definition: SkRegion.h:239
int getSaveCount() const
Call if getType() is kPath to get the path.
Definition: SkClipStack.h:81
Definition: SkCanvas.h:1687
void getBounds(SkRect *canvFiniteBound, BoundsType *boundType, bool *isIntersectionOfRects=NULL) const
getBounds places the current finite bound in its first parameter.
bool asPath(SkPath *path) const
Flattens the clip stack into a single SkPath.