Remove the now-unnecessary enum in the elliptical clipping effect.

BUG=skia:2181
R=robertphillips@google.com

Author: bsalomon@google.com

Review URL: https://codereview.chromium.org/204463007

git-svn-id: http://skia.googlecode.com/svn/trunk@13886 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2014-03-20 21:39:03 +00:00
parent 520cf8b33e
commit 9615d5fc04

View File

@ -377,24 +377,16 @@ class GLEllipticalRRectEffect;
class EllipticalRRectEffect : public GrEffect {
public:
// This effect currently works for these two classifications of SkRRects
enum RRectType {
kSimple_RRectType, // SkRRect::kSimple_Type
kNinePatch_RRectType, // The two left x radii are the same, the two
// top y radii are the same, etc.
};
// This effect only supports rrects where the radii are >= kRadiusMin.
static const SkScalar kRadiusMin;
static GrEffectRef* Create(GrEffectEdgeType, RRectType, const SkRRect&);
static GrEffectRef* Create(GrEffectEdgeType, const SkRRect&);
virtual ~EllipticalRRectEffect() {};
static const char* Name() { return "EllipticalRRect"; }
const SkRRect& getRRect() const { return fRRect; }
RRectType getRRectType() const { return fRRectType; }
GrEffectEdgeType getEdgeType() const { return fEdgeType; }
@ -405,12 +397,11 @@ public:
virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
private:
EllipticalRRectEffect(GrEffectEdgeType, RRectType, const SkRRect&);
EllipticalRRectEffect(GrEffectEdgeType, const SkRRect&);
virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
SkRRect fRRect;
RRectType fRRectType;
GrEffectEdgeType fEdgeType;
GR_DECLARE_EFFECT_TEST;
@ -420,12 +411,9 @@ private:
const SkScalar EllipticalRRectEffect::kRadiusMin = 0.5f;
GrEffectRef* EllipticalRRectEffect::Create(GrEffectEdgeType edgeType,
RRectType rrType,
const SkRRect& rrect) {
GrEffectRef* EllipticalRRectEffect::Create(GrEffectEdgeType edgeType, const SkRRect& rrect) {
SkASSERT(kFillAA_GrEffectEdgeType == edgeType || kInverseFillAA_GrEffectEdgeType == edgeType);
return CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(EllipticalRRectEffect, (edgeType, rrType,
rrect))));
return CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(EllipticalRRectEffect, (edgeType, rrect))));
}
void EllipticalRRectEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const {
@ -436,17 +424,14 @@ const GrBackendEffectFactory& EllipticalRRectEffect::getFactory() const {
return GrTBackendEffectFactory<EllipticalRRectEffect>::getInstance();
}
EllipticalRRectEffect::EllipticalRRectEffect(GrEffectEdgeType edgeType, RRectType rrType,
const SkRRect& rrect)
EllipticalRRectEffect::EllipticalRRectEffect(GrEffectEdgeType edgeType, const SkRRect& rrect)
: fRRect(rrect)
, fRRectType(rrType)
, fEdgeType(edgeType){
this->setWillReadFragmentPosition();
}
bool EllipticalRRectEffect::onIsEqual(const GrEffect& other) const {
const EllipticalRRectEffect& erre = CastEffect<EllipticalRRectEffect>(other);
// No need to check fRRectType as it is derived from fRRect.
return fEdgeType == erre.fEdgeType && fRRect == erre.fRRect;
}
@ -551,8 +536,8 @@ void GLEllipticalRRectEffect::emitCode(GrGLShaderBuilder* builder,
// need be computed to determine the min alpha.
builder->fsCodeAppendf("\t\tvec2 dxy0 = %s.xy - %s.xy;\n", rectName, fragmentPos);
builder->fsCodeAppendf("\t\tvec2 dxy1 = %s.xy - %s.zw;\n", fragmentPos, rectName);
switch (erre.getRRectType()) {
case EllipticalRRectEffect::kSimple_RRectType: {
switch (erre.getRRect().getType()) {
case SkRRect::kSimple_Type: {
const char *invRadiiXYSqdName;
fInvRadiiSqdUniform = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility,
kVec2f_GrSLType,
@ -563,7 +548,7 @@ void GLEllipticalRRectEffect::emitCode(GrGLShaderBuilder* builder,
builder->fsCodeAppendf("\t\tvec2 Z = dxy * %s;\n", invRadiiXYSqdName);
break;
}
case EllipticalRRectEffect::kNinePatch_RRectType: {
case SkRRect::kNinePatch_Type: {
const char *invRadiiLTRBSqdName;
fInvRadiiSqdUniform = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility,
kVec4f_GrSLType,
@ -576,7 +561,9 @@ void GLEllipticalRRectEffect::emitCode(GrGLShaderBuilder* builder,
builder->fsCodeAppendf("\t\tvec2 Z = max(max(dxy0 * %s.xy, dxy1 * %s.zw), 0.0);\n",
invRadiiLTRBSqdName, invRadiiLTRBSqdName);
break;
}
}
default:
GrCrash("RRect should always be simple or nine-patch.");
}
// implicit is the evaluation of (x/a)^2 + (y/b)^2 - 1.
builder->fsCodeAppend("\t\tfloat implicit = dot(Z, dxy) - 1.0;\n");
@ -599,7 +586,7 @@ GrGLEffect::EffectKey GLEllipticalRRectEffect::GenKey(const GrDrawEffect& drawEf
const GrGLCaps&) {
const EllipticalRRectEffect& erre = drawEffect.castEffect<EllipticalRRectEffect>();
GR_STATIC_ASSERT(kLast_GrEffectEdgeType < (1 << 3));
return erre.getRRectType() | erre.getEdgeType() << 3;
return erre.getRRect().getType() | erre.getEdgeType() << 3;
}
void GLEllipticalRRectEffect::setData(const GrGLUniformManager& uman,
@ -611,13 +598,13 @@ void GLEllipticalRRectEffect::setData(const GrGLUniformManager& uman,
const SkVector& r0 = rrect.radii(SkRRect::kUpperLeft_Corner);
SkASSERT(r0.fX >= EllipticalRRectEffect::kRadiusMin);
SkASSERT(r0.fY >= EllipticalRRectEffect::kRadiusMin);
switch (erre.getRRectType()) {
case EllipticalRRectEffect::kSimple_RRectType:
switch (erre.getRRect().getType()) {
case SkRRect::kSimple_Type:
rect.inset(r0.fX, r0.fY);
uman.set2f(fInvRadiiSqdUniform, 1.f / (r0.fX * r0.fX),
1.f / (r0.fY * r0.fY));
break;
case EllipticalRRectEffect::kNinePatch_RRectType: {
case SkRRect::kNinePatch_Type: {
const SkVector& r1 = rrect.radii(SkRRect::kLowerRight_Corner);
SkASSERT(r1.fX >= EllipticalRRectEffect::kRadiusMin);
SkASSERT(r1.fY >= EllipticalRRectEffect::kRadiusMin);
@ -631,6 +618,8 @@ void GLEllipticalRRectEffect::setData(const GrGLUniformManager& uman,
1.f / (r1.fY * r1.fY));
break;
}
default:
GrCrash("RRect should always be simple or nine-patch.");
}
uman.set4f(fInnerRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
fPrevRRect = rrect;
@ -655,8 +644,7 @@ GrEffectRef* GrRRectEffect::Create(GrEffectEdgeType edgeType, const SkRRect& rre
rrect.getSimpleRadii().fY < EllipticalRRectEffect::kRadiusMin) {
return NULL;
}
return EllipticalRRectEffect::Create(edgeType,
EllipticalRRectEffect::kSimple_RRectType, rrect);
return EllipticalRRectEffect::Create(edgeType, rrect);
}
} else if (rrect.isComplex() || rrect.isNinePatch()) {
// Check for the "tab" cases - two adjacent circular corners and two square corners.
@ -707,9 +695,7 @@ GrEffectRef* GrRRectEffect::Create(GrEffectEdgeType edgeType, const SkRRect& rre
r0.fY >= EllipticalRRectEffect::kRadiusMin &&
r1.fX >= EllipticalRRectEffect::kRadiusMin &&
r1.fY >= EllipticalRRectEffect::kRadiusMin) {
return EllipticalRRectEffect::Create(edgeType,
EllipticalRRectEffect::kNinePatch_RRectType,
rrect);
return EllipticalRRectEffect::Create(edgeType, rrect);
}
}
return NULL;