Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Unified Diff: src/gpu/effects/GrRRectEffect.cpp

Issue 204463007: Remove the now-unnecessary enum in the elliptical clipping effect. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/effects/GrRRectEffect.cpp
diff --git a/src/gpu/effects/GrRRectEffect.cpp b/src/gpu/effects/GrRRectEffect.cpp
index 61652c17452e74033d8ed407e3c2535b77120caf..e4120c956ae5156a8680a4e3f621cc36ec6b6031 100644
--- a/src/gpu/effects/GrRRectEffect.cpp
+++ b/src/gpu/effects/GrRRectEffect.cpp
@@ -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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698