Index: src/gpu/effects/GrOvalEffect.cpp |
diff --git a/src/gpu/effects/GrOvalEffect.cpp b/src/gpu/effects/GrOvalEffect.cpp |
index 65f188e9083caf29f575469e2eecff57007878d6..10fd8a6bf41768bf3b63e0929eb3e2ecb40ba052 100644 |
--- a/src/gpu/effects/GrOvalEffect.cpp |
+++ b/src/gpu/effects/GrOvalEffect.cpp |
@@ -8,9 +8,9 @@ |
#include "gl/builders/GrGLProgramBuilder.h" |
#include "GrOvalEffect.h" |
-#include "gl/GrGLEffect.h" |
+#include "gl/GrGLProcessor.h" |
#include "gl/GrGLSL.h" |
-#include "GrTBackendEffectFactory.h" |
+#include "GrTBackendProcessorFactory.h" |
#include "SkRect.h" |
@@ -18,9 +18,9 @@ |
class GLCircleEffect; |
-class CircleEffect : public GrEffect { |
+class CircleEffect : public GrFragmentProcessor { |
public: |
- static GrEffect* Create(GrEffectEdgeType, const SkPoint& center, SkScalar radius); |
+ static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkPoint& center, SkScalar radius); |
virtual ~CircleEffect() {}; |
static const char* Name() { return "Circle"; } |
@@ -28,29 +28,30 @@ public: |
const SkPoint& getCenter() const { return fCenter; } |
SkScalar getRadius() const { return fRadius; } |
- GrEffectEdgeType getEdgeType() const { return fEdgeType; } |
+ GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
- typedef GLCircleEffect GLEffect; |
+ typedef GLCircleEffect GLProcessor; |
virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE; |
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; |
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE; |
private: |
- CircleEffect(GrEffectEdgeType, const SkPoint& center, SkScalar radius); |
+ CircleEffect(GrPrimitiveEdgeType, const SkPoint& center, SkScalar radius); |
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE; |
+ virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; |
SkPoint fCenter; |
SkScalar fRadius; |
- GrEffectEdgeType fEdgeType; |
+ GrPrimitiveEdgeType fEdgeType; |
- GR_DECLARE_EFFECT_TEST; |
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
- typedef GrEffect INHERITED; |
+ typedef GrFragmentProcessor INHERITED; |
}; |
-GrEffect* CircleEffect::Create(GrEffectEdgeType edgeType, const SkPoint& center, SkScalar radius) { |
+GrFragmentProcessor* CircleEffect::Create(GrPrimitiveEdgeType edgeType, const SkPoint& center, |
+ SkScalar radius) { |
SkASSERT(radius >= 0); |
return SkNEW_ARGS(CircleEffect, (edgeType, center, radius)); |
} |
@@ -59,81 +60,81 @@ void CircleEffect::getConstantColorComponents(GrColor* color, uint32_t* validFla |
*validFlags = 0; |
} |
-const GrBackendEffectFactory& CircleEffect::getFactory() const { |
- return GrTBackendEffectFactory<CircleEffect>::getInstance(); |
+const GrBackendFragmentProcessorFactory& CircleEffect::getFactory() const { |
+ return GrTBackendFragmentProcessorFactory<CircleEffect>::getInstance(); |
} |
-CircleEffect::CircleEffect(GrEffectEdgeType edgeType, const SkPoint& c, SkScalar r) |
+CircleEffect::CircleEffect(GrPrimitiveEdgeType edgeType, const SkPoint& c, SkScalar r) |
: fCenter(c) |
, fRadius(r) |
, fEdgeType(edgeType) { |
this->setWillReadFragmentPosition(); |
} |
-bool CircleEffect::onIsEqual(const GrEffect& other) const { |
+bool CircleEffect::onIsEqual(const GrProcessor& other) const { |
const CircleEffect& ce = other.cast<CircleEffect>(); |
return fEdgeType == ce.fEdgeType && fCenter == ce.fCenter && fRadius == ce.fRadius; |
} |
////////////////////////////////////////////////////////////////////////////// |
-GR_DEFINE_EFFECT_TEST(CircleEffect); |
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleEffect); |
-GrEffect* CircleEffect::TestCreate(SkRandom* random, |
- GrContext*, |
- const GrDrawTargetCaps& caps, |
- GrTexture*[]) { |
+GrFragmentProcessor* CircleEffect::TestCreate(SkRandom* random, |
+ GrContext*, |
+ const GrDrawTargetCaps& caps, |
+ GrTexture*[]) { |
SkPoint center; |
center.fX = random->nextRangeScalar(0.f, 1000.f); |
center.fY = random->nextRangeScalar(0.f, 1000.f); |
SkScalar radius = random->nextRangeF(0.f, 1000.f); |
- GrEffectEdgeType et; |
+ GrPrimitiveEdgeType et; |
do { |
- et = (GrEffectEdgeType)random->nextULessThan(kGrEffectEdgeTypeCnt); |
- } while (kHairlineAA_GrEffectEdgeType == et); |
+ et = (GrPrimitiveEdgeType)random->nextULessThan(kGrProcessorEdgeTypeCnt); |
+ } while (kHairlineAA_GrProcessorEdgeType == et); |
return CircleEffect::Create(et, center, radius); |
} |
////////////////////////////////////////////////////////////////////////////// |
-class GLCircleEffect : public GrGLEffect { |
+class GLCircleEffect : public GrGLFragmentProcessor { |
public: |
- GLCircleEffect(const GrBackendEffectFactory&, const GrEffect&); |
+ GLCircleEffect(const GrBackendProcessorFactory&, const GrProcessor&); |
virtual void emitCode(GrGLProgramBuilder* builder, |
- const GrEffect& effect, |
- const GrEffectKey& key, |
+ const GrFragmentProcessor& fp, |
+ const GrProcessorKey& key, |
const char* outputColor, |
const char* inputColor, |
const TransformedCoordsArray&, |
const TextureSamplerArray&) SK_OVERRIDE; |
- static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*); |
+ static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*); |
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE; |
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE; |
private: |
GrGLProgramDataManager::UniformHandle fCircleUniform; |
SkPoint fPrevCenter; |
SkScalar fPrevRadius; |
- typedef GrGLEffect INHERITED; |
+ typedef GrGLFragmentProcessor INHERITED; |
}; |
-GLCircleEffect::GLCircleEffect(const GrBackendEffectFactory& factory, |
- const GrEffect& effect) |
+GLCircleEffect::GLCircleEffect(const GrBackendProcessorFactory& factory, |
+ const GrProcessor&) |
: INHERITED (factory) { |
fPrevRadius = -1.f; |
} |
void GLCircleEffect::emitCode(GrGLProgramBuilder* builder, |
- const GrEffect& effect, |
- const GrEffectKey& key, |
+ const GrFragmentProcessor& fp, |
+ const GrProcessorKey& key, |
const char* outputColor, |
const char* inputColor, |
const TransformedCoordsArray&, |
const TextureSamplerArray& samplers) { |
- const CircleEffect& ce = effect.cast<CircleEffect>(); |
+ const CircleEffect& ce = fp.cast<CircleEffect>(); |
const char *circleName; |
// The circle uniform is (center.x, center.y, radius + 0.5) for regular fills and |
// (... ,radius - 0.5) for inverse fills. |
@@ -145,15 +146,15 @@ void GLCircleEffect::emitCode(GrGLProgramBuilder* builder, |
GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
const char* fragmentPos = fsBuilder->fragmentPosition(); |
- SkASSERT(kHairlineAA_GrEffectEdgeType != ce.getEdgeType()); |
- if (GrEffectEdgeTypeIsInverseFill(ce.getEdgeType())) { |
+ SkASSERT(kHairlineAA_GrProcessorEdgeType != ce.getEdgeType()); |
+ if (GrProcessorEdgeTypeIsInverseFill(ce.getEdgeType())) { |
fsBuilder->codeAppendf("\t\tfloat d = length(%s.xy - %s.xy) - %s.z;\n", |
circleName, fragmentPos, circleName); |
} else { |
fsBuilder->codeAppendf("\t\tfloat d = %s.z - length(%s.xy - %s.xy);\n", |
circleName, fragmentPos, circleName); |
} |
- if (GrEffectEdgeTypeIsAA(ce.getEdgeType())) { |
+ if (GrProcessorEdgeTypeIsAA(ce.getEdgeType())) { |
fsBuilder->codeAppend("\t\td = clamp(d, 0.0, 1.0);\n"); |
} else { |
fsBuilder->codeAppend("\t\td = d > 0.5 ? 1.0 : 0.0;\n"); |
@@ -163,17 +164,17 @@ void GLCircleEffect::emitCode(GrGLProgramBuilder* builder, |
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("d")).c_str()); |
} |
-void GLCircleEffect::GenKey(const GrEffect& effect, const GrGLCaps&, |
- GrEffectKeyBuilder* b) { |
- const CircleEffect& ce = effect.cast<CircleEffect>(); |
+void GLCircleEffect::GenKey(const GrProcessor& processor, const GrGLCaps&, |
+ GrProcessorKeyBuilder* b) { |
+ const CircleEffect& ce = processor.cast<CircleEffect>(); |
b->add32(ce.getEdgeType()); |
} |
-void GLCircleEffect::setData(const GrGLProgramDataManager& pdman, const GrEffect& effect) { |
- const CircleEffect& ce = effect.cast<CircleEffect>(); |
+void GLCircleEffect::setData(const GrGLProgramDataManager& pdman, const GrProcessor& processor) { |
+ const CircleEffect& ce = processor.cast<CircleEffect>(); |
if (ce.getRadius() != fPrevRadius || ce.getCenter() != fPrevCenter) { |
SkScalar radius = ce.getRadius(); |
- if (GrEffectEdgeTypeIsInverseFill(ce.getEdgeType())) { |
+ if (GrProcessorEdgeTypeIsInverseFill(ce.getEdgeType())) { |
radius -= 0.5f; |
} else { |
radius += 0.5f; |
@@ -188,9 +189,10 @@ void GLCircleEffect::setData(const GrGLProgramDataManager& pdman, const GrEffect |
class GLEllipseEffect; |
-class EllipseEffect : public GrEffect { |
+class EllipseEffect : public GrFragmentProcessor { |
public: |
- static GrEffect* Create(GrEffectEdgeType, const SkPoint& center, SkScalar rx, SkScalar ry); |
+ static GrFragmentProcessor* Create(GrPrimitiveEdgeType, const SkPoint& center, SkScalar rx, |
+ SkScalar ry); |
virtual ~EllipseEffect() {}; |
static const char* Name() { return "Ellipse"; } |
@@ -198,32 +200,32 @@ public: |
const SkPoint& getCenter() const { return fCenter; } |
SkVector getRadii() const { return fRadii; } |
- GrEffectEdgeType getEdgeType() const { return fEdgeType; } |
+ GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
- typedef GLEllipseEffect GLEffect; |
+ typedef GLEllipseEffect GLProcessor; |
virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE; |
- virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; |
+ virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERRIDE; |
private: |
- EllipseEffect(GrEffectEdgeType, const SkPoint& center, SkScalar rx, SkScalar ry); |
+ EllipseEffect(GrPrimitiveEdgeType, const SkPoint& center, SkScalar rx, SkScalar ry); |
- virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE; |
+ virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; |
SkPoint fCenter; |
SkVector fRadii; |
- GrEffectEdgeType fEdgeType; |
+ GrPrimitiveEdgeType fEdgeType; |
- GR_DECLARE_EFFECT_TEST; |
+ GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
- typedef GrEffect INHERITED; |
+ typedef GrFragmentProcessor INHERITED; |
}; |
-GrEffect* EllipseEffect::Create(GrEffectEdgeType edgeType, |
- const SkPoint& center, |
- SkScalar rx, |
- SkScalar ry) { |
+GrFragmentProcessor* EllipseEffect::Create(GrPrimitiveEdgeType edgeType, |
+ const SkPoint& center, |
+ SkScalar rx, |
+ SkScalar ry) { |
SkASSERT(rx >= 0 && ry >= 0); |
return SkNEW_ARGS(EllipseEffect, (edgeType, center, rx, ry)); |
} |
@@ -232,82 +234,82 @@ void EllipseEffect::getConstantColorComponents(GrColor* color, uint32_t* validFl |
*validFlags = 0; |
} |
-const GrBackendEffectFactory& EllipseEffect::getFactory() const { |
- return GrTBackendEffectFactory<EllipseEffect>::getInstance(); |
+const GrBackendFragmentProcessorFactory& EllipseEffect::getFactory() const { |
+ return GrTBackendFragmentProcessorFactory<EllipseEffect>::getInstance(); |
} |
-EllipseEffect::EllipseEffect(GrEffectEdgeType edgeType, const SkPoint& c, SkScalar rx, SkScalar ry) |
+EllipseEffect::EllipseEffect(GrPrimitiveEdgeType edgeType, const SkPoint& c, SkScalar rx, SkScalar ry) |
: fCenter(c) |
, fRadii(SkVector::Make(rx, ry)) |
, fEdgeType(edgeType) { |
this->setWillReadFragmentPosition(); |
} |
-bool EllipseEffect::onIsEqual(const GrEffect& other) const { |
+bool EllipseEffect::onIsEqual(const GrProcessor& other) const { |
const EllipseEffect& ee = other.cast<EllipseEffect>(); |
return fEdgeType == ee.fEdgeType && fCenter == ee.fCenter && fRadii == ee.fRadii; |
} |
////////////////////////////////////////////////////////////////////////////// |
-GR_DEFINE_EFFECT_TEST(EllipseEffect); |
+GR_DEFINE_FRAGMENT_PROCESSOR_TEST(EllipseEffect); |
-GrEffect* EllipseEffect::TestCreate(SkRandom* random, |
- GrContext*, |
- const GrDrawTargetCaps& caps, |
- GrTexture*[]) { |
+GrFragmentProcessor* EllipseEffect::TestCreate(SkRandom* random, |
+ GrContext*, |
+ const GrDrawTargetCaps& caps, |
+ GrTexture*[]) { |
SkPoint center; |
center.fX = random->nextRangeScalar(0.f, 1000.f); |
center.fY = random->nextRangeScalar(0.f, 1000.f); |
SkScalar rx = random->nextRangeF(0.f, 1000.f); |
SkScalar ry = random->nextRangeF(0.f, 1000.f); |
- GrEffectEdgeType et; |
+ GrPrimitiveEdgeType et; |
do { |
- et = (GrEffectEdgeType)random->nextULessThan(kGrEffectEdgeTypeCnt); |
- } while (kHairlineAA_GrEffectEdgeType == et); |
+ et = (GrPrimitiveEdgeType)random->nextULessThan(kGrProcessorEdgeTypeCnt); |
+ } while (kHairlineAA_GrProcessorEdgeType == et); |
return EllipseEffect::Create(et, center, rx, ry); |
} |
////////////////////////////////////////////////////////////////////////////// |
-class GLEllipseEffect : public GrGLEffect { |
+class GLEllipseEffect : public GrGLFragmentProcessor { |
public: |
- GLEllipseEffect(const GrBackendEffectFactory&, const GrEffect&); |
+ GLEllipseEffect(const GrBackendProcessorFactory&, const GrProcessor&); |
virtual void emitCode(GrGLProgramBuilder* builder, |
- const GrEffect& effect, |
- const GrEffectKey& key, |
+ const GrFragmentProcessor& fp, |
+ const GrProcessorKey& key, |
const char* outputColor, |
const char* inputColor, |
const TransformedCoordsArray&, |
const TextureSamplerArray&) SK_OVERRIDE; |
- static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*); |
+ static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKeyBuilder*); |
- virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE; |
+ virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE; |
private: |
GrGLProgramDataManager::UniformHandle fEllipseUniform; |
SkPoint fPrevCenter; |
SkVector fPrevRadii; |
- typedef GrGLEffect INHERITED; |
+ typedef GrGLFragmentProcessor INHERITED; |
}; |
-GLEllipseEffect::GLEllipseEffect(const GrBackendEffectFactory& factory, |
- const GrEffect& effect) |
+GLEllipseEffect::GLEllipseEffect(const GrBackendProcessorFactory& factory, |
+ const GrProcessor& effect) |
: INHERITED (factory) { |
fPrevRadii.fX = -1.f; |
} |
void GLEllipseEffect::emitCode(GrGLProgramBuilder* builder, |
- const GrEffect& effect, |
- const GrEffectKey& key, |
+ const GrFragmentProcessor& fp, |
+ const GrProcessorKey& key, |
const char* outputColor, |
const char* inputColor, |
const TransformedCoordsArray&, |
const TextureSamplerArray& samplers) { |
- const EllipseEffect& ee = effect.cast<EllipseEffect>(); |
+ const EllipseEffect& ee = fp.cast<EllipseEffect>(); |
const char *ellipseName; |
// The ellipse uniform is (center.x, center.y, 1 / rx^2, 1 / ry^2) |
fEllipseUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility, |
@@ -330,19 +332,19 @@ void GLEllipseEffect::emitCode(GrGLProgramBuilder* builder, |
fsBuilder->codeAppendf("\t\tfloat approx_dist = implicit * inversesqrt(grad_dot);\n"); |
switch (ee.getEdgeType()) { |
- case kFillAA_GrEffectEdgeType: |
+ case kFillAA_GrProcessorEdgeType: |
fsBuilder->codeAppend("\t\tfloat alpha = clamp(0.5 - approx_dist, 0.0, 1.0);\n"); |
break; |
- case kInverseFillAA_GrEffectEdgeType: |
+ case kInverseFillAA_GrProcessorEdgeType: |
fsBuilder->codeAppend("\t\tfloat alpha = clamp(0.5 + approx_dist, 0.0, 1.0);\n"); |
break; |
- case kFillBW_GrEffectEdgeType: |
+ case kFillBW_GrProcessorEdgeType: |
fsBuilder->codeAppend("\t\tfloat alpha = approx_dist > 0.0 ? 0.0 : 1.0;\n"); |
break; |
- case kInverseFillBW_GrEffectEdgeType: |
+ case kInverseFillBW_GrProcessorEdgeType: |
fsBuilder->codeAppend("\t\tfloat alpha = approx_dist > 0.0 ? 1.0 : 0.0;\n"); |
break; |
- case kHairlineAA_GrEffectEdgeType: |
+ case kHairlineAA_GrProcessorEdgeType: |
SkFAIL("Hairline not expected here."); |
} |
@@ -350,13 +352,13 @@ void GLEllipseEffect::emitCode(GrGLProgramBuilder* builder, |
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_str()); |
} |
-void GLEllipseEffect::GenKey(const GrEffect& effect, const GrGLCaps&, |
- GrEffectKeyBuilder* b) { |
+void GLEllipseEffect::GenKey(const GrProcessor& effect, const GrGLCaps&, |
+ GrProcessorKeyBuilder* b) { |
const EllipseEffect& ee = effect.cast<EllipseEffect>(); |
b->add32(ee.getEdgeType()); |
} |
-void GLEllipseEffect::setData(const GrGLProgramDataManager& pdman, const GrEffect& effect) { |
+void GLEllipseEffect::setData(const GrGLProgramDataManager& pdman, const GrProcessor& effect) { |
const EllipseEffect& ee = effect.cast<EllipseEffect>(); |
if (ee.getRadii() != fPrevRadii || ee.getCenter() != fPrevCenter) { |
SkScalar invRXSqd = 1.f / (ee.getRadii().fX * ee.getRadii().fX); |
@@ -369,8 +371,8 @@ void GLEllipseEffect::setData(const GrGLProgramDataManager& pdman, const GrEffec |
////////////////////////////////////////////////////////////////////////////// |
-GrEffect* GrOvalEffect::Create(GrEffectEdgeType edgeType, const SkRect& oval) { |
- if (kHairlineAA_GrEffectEdgeType == edgeType) { |
+GrFragmentProcessor* GrOvalEffect::Create(GrPrimitiveEdgeType edgeType, const SkRect& oval) { |
+ if (kHairlineAA_GrProcessorEdgeType == edgeType) { |
return NULL; |
} |
SkScalar w = oval.width(); |