зеркало из https://github.com/mozilla/moz-skia.git
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
This commit is contained in:
Родитель
69afee1c8f
Коммит
0f191f30af
|
@ -60,14 +60,14 @@ public:
|
|||
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 @@ public:
|
|||
|
||||
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;
|
||||
|
|
|
@ -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 @@ public:
|
|||
* 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
|
||||
|
|
|
@ -481,18 +481,6 @@ struct GrTextureDesc {
|
|||
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.
|
||||
*/
|
||||
|
|
|
@ -108,7 +108,7 @@ public:
|
|||
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;
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ void GrClip::setFromRect(const GrRect& r) {
|
|||
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 @@ void GrClip::setFromIRect(const GrIRect& r) {
|
|||
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 @@ void GrClip::setFromIterator(GrClipIterator* iter, GrScalar tx, GrScalar ty,
|
|||
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 @@ void GrClip::setFromIterator(GrClipIterator* iter, GrScalar tx, GrScalar ty,
|
|||
}
|
||||
++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);
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace {
|
|||
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 @@ int process_initial_clip_elements(const GrClip& clip,
|
|||
|
||||
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 @@ int process_initial_clip_elements(const GrClip& clip,
|
|||
// 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 @@ bool GrClipMaskManager::createStencilClipMask(GrGpu* gpu,
|
|||
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 @@ bool GrClipMaskManager::createStencilClipMask(GrGpu* gpu,
|
|||
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 @@ bool GrClipMaskManager::createStencilClipMask(GrGpu* gpu,
|
|||
!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];
|
||||
|
||||
|
|
|
@ -220,7 +220,7 @@ GR_STATIC_CONST_SAME_STENCIL(gDiffClip,
|
|||
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 @@ bool GrStencilSettings::GetClipPasses(GrSetOp op,
|
|||
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 @@ bool GrStencilSettings::GetClipPasses(GrSetOp op,
|
|||
// 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 @@ bool GrStencilSettings::GetClipPasses(GrSetOp op,
|
|||
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 @@ bool GrStencilSettings::GetClipPasses(GrSetOp op,
|
|||
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 @@ bool GrStencilSettings::GetClipPasses(GrSetOp op,
|
|||
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;
|
||||
|
|
|
@ -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 @@ private:
|
|||
* 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,
|
||||
|
|
|
@ -159,26 +159,17 @@ GrClipType SkGrClipIterator::getType() const {
|
|||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
|
|
Загрузка…
Ссылка в новой задаче