Minor refactoring to remove duplicate enum from Ganesh (_SetOp -> SkRegion::Op)
http://codereview.appspot.com/6116047/
git-svn-id: http://skia.googlecode.com/svn/trunk@3763 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/gpu/GrClip.h b/include/gpu/GrClip.h
index a23f99c..c94755d 100644
--- a/include/gpu/GrClip.h
+++ b/include/gpu/GrClip.h
@@ -60,14 +60,14 @@
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);
@@ -111,12 +111,12 @@
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;
diff --git a/include/gpu/GrClipIterator.h b/include/gpu/GrClipIterator.h
index a540bb4..4f98c5c 100644
--- a/include/gpu/GrClipIterator.h
+++ b/include/gpu/GrClipIterator.h
@@ -13,6 +13,7 @@
#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.
@@ -58,7 +59,7 @@
* 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
diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h
index 0ab7773..e3e5357 100644
--- a/include/gpu/GrTypes.h
+++ b/include/gpu/GrTypes.h
@@ -482,18 +482,6 @@
};
/**
- * 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.
*/
enum GrClipType {
diff --git a/include/gpu/SkGr.h b/include/gpu/SkGr.h
index 6bc6549..5ad90f4 100644
--- a/include/gpu/SkGr.h
+++ b/include/gpu/SkGr.h
@@ -108,7 +108,7 @@
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;
diff --git a/src/gpu/GrClip.cpp b/src/gpu/GrClip.cpp
index 87d58c4..a5120d4 100644
--- a/src/gpu/GrClip.cpp
+++ b/src/gpu/GrClip.cpp
@@ -59,7 +59,7 @@
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;
@@ -75,7 +75,7 @@
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;
@@ -108,7 +108,7 @@
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);
@@ -117,7 +117,7 @@
}
++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);
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index cdcc741..a6c1705 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -91,7 +91,7 @@
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
@@ -105,13 +105,13 @@
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)
@@ -122,47 +122,47 @@
// 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;
@@ -226,7 +226,7 @@
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,
@@ -256,7 +256,7 @@
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;
}
@@ -275,7 +275,7 @@
!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];
diff --git a/src/gpu/GrStencil.cpp b/src/gpu/GrStencil.cpp
index 6624942..ab0e78c 100644
--- a/src/gpu/GrStencil.cpp
+++ b/src/gpu/GrStencil.cpp
@@ -220,7 +220,7 @@
0x0000 // set clip bit
);
-bool GrStencilSettings::GetClipPasses(GrSetOp op,
+bool GrStencilSettings::GetClipPasses(SkRegion::Op op,
bool canBeDirect,
unsigned int stencilClipMask,
bool invertedFill,
@@ -229,19 +229,19 @@
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;
@@ -260,7 +260,7 @@
// 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;
@@ -268,13 +268,13 @@
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;
@@ -301,7 +301,7 @@
settings[1].fBackFuncRef = settings[1].fFrontFuncRef;
}
break;
- case kXor_SetOp:
+ case SkRegion::kXOR_Op:
*numPasses = 2;
if (invertedFill) {
settings[0] = gInvUserToClipXorPass0;
@@ -321,13 +321,13 @@
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;
diff --git a/src/gpu/GrStencil.h b/src/gpu/GrStencil.h
index 39700fe..bba5aa6 100644
--- a/src/gpu/GrStencil.h
+++ b/src/gpu/GrStencil.h
@@ -11,6 +11,8 @@
#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
@@ -319,7 +321,7 @@
* 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,
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index c832b20..12967e2 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -159,26 +159,17 @@
}
}
-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 {