return fList[i].fRect;
}
- GrSetOp getOp(int i) const { return fList[i].fOp; }
+ SkRegion::Op getOp(int i) const { return fList[i].fOp; }
bool getDoAA(int i) const { return fList[i].fDoAA; }
bool isRect() const {
if (1 == fList.count() && kRect_ClipType == fList[0].fType &&
- (kIntersect_SetOp == fList[0].fOp ||
- kReplace_SetOp == fList[0].fOp)) {
+ (SkRegion::kIntersect_Op == fList[0].fOp ||
+ SkRegion::kReplace_Op == fList[0].fOp)) {
// if we determined that the clip is a single rect
// we ought to have also used that rect as the bounds.
GrAssert(fConservativeBoundsValid);
private:
struct Element {
- GrClipType fType;
- GrRect fRect;
- GrPath fPath;
- GrPathFill fPathFill;
- GrSetOp fOp;
- bool fDoAA;
+ GrClipType fType;
+ GrRect fRect;
+ GrPath fPath;
+ GrPathFill fPathFill;
+ SkRegion::Op fOp;
+ bool fDoAA;
bool operator ==(const Element& e) const {
if (e.fType != fType || e.fOp != fOp || e.fDoAA != fDoAA) {
return false;
#include "GrPath.h"
#include "GrRect.h"
+#include "SkRegion.h"
/**
* A clip is a list of paths and/or rects with set operations to combine them.
* Gets the operation used to apply the current item to previously iterated
* items. Iterators should not produce a Replace op.
*/
- virtual GrSetOp getOp() const = 0;
+ virtual SkRegion::Op getOp() const = 0;
/**
* Gets anti-aliasing setting desired for the current clip
int fSampleCnt;
};
-/**
- * Set Operations used to construct clips.
- */
-enum GrSetOp {
- kReplace_SetOp,
- kIntersect_SetOp,
- kUnion_SetOp,
- kXor_SetOp,
- kDifference_SetOp,
- kReverseDifference_SetOp,
-};
-
/**
* Clips are composed from these objects.
*/
virtual void rewind() SK_OVERRIDE { this->reset(*fClipStack); }
virtual GrClipType getType() const SK_OVERRIDE;
- virtual GrSetOp getOp() const SK_OVERRIDE;
+ virtual SkRegion::Op getOp() const SK_OVERRIDE;
virtual bool getDoAA() const SK_OVERRIDE;
fList.push_back();
fList.back().fRect = r;
fList.back().fType = kRect_ClipType;
- fList.back().fOp = kReplace_SetOp;
+ fList.back().fOp = SkRegion::kReplace_Op;
fList.back().fDoAA = false;
fConservativeBounds = r;
fConservativeBoundsValid = true;
fList.push_back();
fList.back().fRect.set(r);
fList.back().fType = kRect_ClipType;
- fList.back().fOp = kReplace_SetOp;
+ fList.back().fOp = SkRegion::kReplace_Op;
fList.back().fDoAA = false;
fConservativeBounds.set(r);
fConservativeBoundsValid = true;
fRequiresAA = true;
}
// iterators should not emit replace
- GrAssert(kReplace_SetOp != e.fOp);
+ GrAssert(SkRegion::kReplace_Op != e.fOp);
switch (e.fType) {
case kRect_ClipType:
iter->getRect(&e.fRect);
}
++rectCount;
if (isectRectValid) {
- if (kIntersect_SetOp == e.fOp) {
+ if (SkRegion::kIntersect_Op == e.fOp) {
GrAssert(fList.count() <= 2);
if (fList.count() > 1) {
GrAssert(2 == rectCount);
int process_initial_clip_elements(const GrClip& clip,
const GrRect& bounds,
bool* clearToInside,
- GrSetOp* startOp) {
+ SkRegion::Op* startOp) {
// logically before the first element of the clip stack is
// processed the clip is entirely open. However, depending on the
for (curr = 0; curr < count && !done; ++curr) {
switch (clip.getOp(curr)) {
- case kReplace_SetOp:
+ case SkRegion::kReplace_Op:
// replace ignores everything previous
- *startOp = kReplace_SetOp;
+ *startOp = SkRegion::kReplace_Op;
*clearToInside = false;
done = true;
break;
- case kIntersect_SetOp:
+ case SkRegion::kIntersect_Op:
// if this element contains the entire bounds then we
// can skip it.
if (kRect_ClipType == clip.getElementType(curr)
// same as clear to 0 and treat as a replace. Otherwise,
// set stays empty.
if (*clearToInside) {
- *startOp = kReplace_SetOp;
+ *startOp = SkRegion::kReplace_Op;
*clearToInside = false;
done = true;
}
break;
// we can skip a leading union.
- case kUnion_SetOp:
+ case SkRegion::kUnion_Op:
// if everything is initially outside then union is
// same as replace. Otherwise, every pixel is still
// clearToInside
if (!*clearToInside) {
- *startOp = kReplace_SetOp;
+ *startOp = SkRegion::kReplace_Op;
done = true;
}
break;
- case kXor_SetOp:
+ case SkRegion::kXOR_Op:
// xor is same as difference or replace both of which
// can be 1-pass instead of 2 for xor.
if (*clearToInside) {
- *startOp = kDifference_SetOp;
+ *startOp = SkRegion::kDifference_Op;
} else {
- *startOp = kReplace_SetOp;
+ *startOp = SkRegion::kReplace_Op;
}
done = true;
break;
- case kDifference_SetOp:
+ case SkRegion::kDifference_Op:
// if all pixels are clearToInside then we have to process the
// difference, otherwise it has no effect and all pixels
// remain outside.
if (*clearToInside) {
- *startOp = kDifference_SetOp;
+ *startOp = SkRegion::kDifference_Op;
done = true;
}
break;
- case kReverseDifference_SetOp:
+ case SkRegion::kReverseDifference_Op:
// if all pixels are clearToInside then reverse difference
// produces empty set. Otherise it is same as replace
if (*clearToInside) {
*clearToInside = false;
} else {
- *startOp = kReplace_SetOp;
+ *startOp = SkRegion::kReplace_Op;
done = true;
}
break;
GrIntToScalar(rt->width()), GrIntToScalar(rt->height()));
bool clearToInside;
- GrSetOp startOp = kReplace_SetOp; // suppress warning
+ SkRegion::Op startOp = SkRegion::kReplace_Op; // suppress warning
int start = process_initial_clip_elements(clipCopy,
rtRect,
&clearToInside,
fillInverted = false;
// there is no point in intersecting a screen filling
// rectangle.
- if (kIntersect_SetOp == clipCopy.getOp(c) &&
+ if (SkRegion::kIntersect_Op == clipCopy.getOp(c) &&
clipCopy.getRect(c).contains(rtRect)) {
continue;
}
!pr->requiresStencilPass(*clipPath, fill, gpu);
}
- GrSetOp op = (c == start) ? startOp : clipCopy.getOp(c);
+ SkRegion::Op op = (c == start) ? startOp : clipCopy.getOp(c);
int passes;
GrStencilSettings stencilSettings[GrStencilSettings::kMaxStencilClipPasses];
0x0000 // set clip bit
);
-bool GrStencilSettings::GetClipPasses(GrSetOp op,
+bool GrStencilSettings::GetClipPasses(SkRegion::Op op,
bool canBeDirect,
unsigned int stencilClipMask,
bool invertedFill,
if (canBeDirect && !invertedFill) {
*numPasses = 0;
switch (op) {
- case kReplace_SetOp:
+ case SkRegion::kReplace_Op:
*numPasses = 1;
settings[0] = gReplaceClip;
break;
- case kUnion_SetOp:
+ case SkRegion::kUnion_Op:
*numPasses = 1;
settings[0] = gUnionClip;
break;
- case kXor_SetOp:
+ case SkRegion::kXOR_Op:
*numPasses = 1;
settings[0] = gXorClip;
break;
- case kDifference_SetOp:
+ case SkRegion::kDifference_Op:
*numPasses = 1;
settings[0] = gDiffClip;
break;
// if we make the path renderer go to stencil we always give it a
// non-inverted fill and we use the stencil rules on the client->clipbit
// pass to select either the zeros or nonzeros.
- case kReplace_SetOp:
+ case SkRegion::kReplace_Op:
*numPasses= 1;
settings[0] = invertedFill ? gInvUserToClipReplace : gUserToClipReplace;
settings[0].fFrontFuncMask &= ~stencilClipMask;
settings[0].fBackFuncMask = settings[0].fFrontFuncMask;
settings[0].fBackFuncRef = settings[0].fFrontFuncRef;
break;
- case kIntersect_SetOp:
+ case SkRegion::kIntersect_Op:
*numPasses = 1;
settings[0] = invertedFill ? gInvUserToClipIsect : gUserToClipIsect;
settings[0].fFrontFuncRef = stencilClipMask;
settings[0].fBackFuncRef = settings[0].fFrontFuncRef;
break;
- case kUnion_SetOp:
+ case SkRegion::kUnion_Op:
*numPasses = 2;
if (invertedFill) {
settings[0] = gInvUserToClipUnionPass0;
settings[1].fBackFuncRef = settings[1].fFrontFuncRef;
}
break;
- case kXor_SetOp:
+ case SkRegion::kXOR_Op:
*numPasses = 2;
if (invertedFill) {
settings[0] = gInvUserToClipXorPass0;
settings[1].fBackFuncRef = settings[1].fFrontFuncRef;
}
break;
- case kDifference_SetOp:
+ case SkRegion::kDifference_Op:
*numPasses = 1;
settings[0] = invertedFill ? gInvUserToClipDiff : gUserToClipDiff;
settings[0].fFrontFuncRef |= stencilClipMask;
settings[0].fBackFuncRef = settings[0].fFrontFuncRef;
break;
- case kReverseDifference_SetOp:
+ case SkRegion::kReverseDifference_Op:
if (invertedFill) {
*numPasses = 1;
settings[0] = gInvUserToClipRDiff;
#define GrStencil_DEFINED
#include "GrTypes.h"
+#include "SkRegion.h"
+
/**
* Gr uses the stencil buffer to implement complex clipping inside the
* GrDrawTarget class. The GrDrawTarget makes a subset of the stencil buffer
* stencil clip bit. Will only be true if canBeDirect is true.
* numPasses will be 1 if return value is true.
*/
- static bool GetClipPasses(GrSetOp op,
+ static bool GetClipPasses(SkRegion::Op op,
bool canBeDirect,
unsigned int stencilClipMask,
bool invertedFill,
}
}
-GrSetOp SkGrClipIterator::getOp() const {
+SkRegion::Op SkGrClipIterator::getOp() const {
// we skipped to the last "replace" op
// when this iter was reset.
// GrClip doesn't allow replace, so treat it as
// intersect.
- GrSetOp skToGrOps[] = {
- kDifference_SetOp, // kDifference_Op
- kIntersect_SetOp, // kIntersect_Op
- kUnion_SetOp, // kUnion_Op
- kXor_SetOp, // kXOR_Op
- kReverseDifference_SetOp, // kReverseDifference_Op
- kIntersect_SetOp // kReplace_op
- };
- GR_STATIC_ASSERT(0 == SkRegion::kDifference_Op);
- GR_STATIC_ASSERT(1 == SkRegion::kIntersect_Op);
- GR_STATIC_ASSERT(2 == SkRegion::kUnion_Op);
- GR_STATIC_ASSERT(3 == SkRegion::kXOR_Op);
- GR_STATIC_ASSERT(4 == SkRegion::kReverseDifference_Op);
- GR_STATIC_ASSERT(5 == SkRegion::kReplace_Op);
- return skToGrOps[fCurr->fOp];
+ if (SkRegion::kReplace_Op == fCurr->fOp) {
+ return SkRegion::kIntersect_Op;
+ }
+
+ return fCurr->fOp;
+
}
bool SkGrClipIterator::getDoAA() const {