diff options
Diffstat (limited to 'src/gpu/GrOvalRenderer.cpp')
-rw-r--r-- | src/gpu/GrOvalRenderer.cpp | 58 |
1 files changed, 25 insertions, 33 deletions
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp index 2c923f8f81..785126560a 100644 --- a/src/gpu/GrOvalRenderer.cpp +++ b/src/gpu/GrOvalRenderer.cpp @@ -10,6 +10,7 @@ #include "GrEffect.h" #include "gl/GrGLEffect.h" #include "gl/GrGLSL.h" +#include "gl/GrGLVertexEffect.h" #include "GrTBackendEffectFactory.h" #include "GrDrawState.h" @@ -88,28 +89,25 @@ public: inline bool isStroked() const { return fStroke; } - class GLEffect : public GrGLEffect { + class GLEffect : public GrGLVertexEffect { public: GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&) : INHERITED (factory) {} - virtual void emitCode(GrGLShaderBuilder* builder, + virtual void emitCode(GrGLFullShaderBuilder* builder, const GrDrawEffect& drawEffect, EffectKey key, const char* outputColor, const char* inputColor, const TransformedCoordsArray&, const TextureSamplerArray& samplers) SK_OVERRIDE { - GrGLShaderBuilder::VertexBuilder* vertexBuilder = builder->getVertexBuilder(); - SkASSERT(NULL != vertexBuilder); - const CircleEdgeEffect& circleEffect = drawEffect.castEffect<CircleEdgeEffect>(); const char *vsName, *fsName; - vertexBuilder->addVarying(kVec4f_GrSLType, "CircleEdge", &vsName, &fsName); + builder->addVarying(kVec4f_GrSLType, "CircleEdge", &vsName, &fsName); const SkString* attrName = - vertexBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0]); - vertexBuilder->vsCodeAppendf("\t%s = %s;\n", vsName, attrName->c_str()); + builder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0]); + builder->vsCodeAppendf("\t%s = %s;\n", vsName, attrName->c_str()); builder->fsCodeAppendf("\tfloat d = length(%s.xy);\n", fsName); builder->fsCodeAppendf("\tfloat edgeAlpha = clamp(%s.z - d, 0.0, 1.0);\n", fsName); @@ -132,7 +130,7 @@ public: virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE {} private: - typedef GrGLEffect INHERITED; + typedef GrGLVertexEffect INHERITED; }; @@ -203,35 +201,32 @@ public: inline bool isStroked() const { return fStroke; } - class GLEffect : public GrGLEffect { + class GLEffect : public GrGLVertexEffect { public: GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&) : INHERITED (factory) {} - virtual void emitCode(GrGLShaderBuilder* builder, + virtual void emitCode(GrGLFullShaderBuilder* builder, const GrDrawEffect& drawEffect, EffectKey key, const char* outputColor, const char* inputColor, const TransformedCoordsArray&, const TextureSamplerArray& samplers) SK_OVERRIDE { - GrGLShaderBuilder::VertexBuilder* vertexBuilder = builder->getVertexBuilder(); - SkASSERT(NULL != vertexBuilder); - const EllipseEdgeEffect& ellipseEffect = drawEffect.castEffect<EllipseEdgeEffect>(); const char *vsOffsetName, *fsOffsetName; const char *vsRadiiName, *fsRadiiName; - vertexBuilder->addVarying(kVec2f_GrSLType, "EllipseOffsets", &vsOffsetName, &fsOffsetName); + builder->addVarying(kVec2f_GrSLType, "EllipseOffsets", &vsOffsetName, &fsOffsetName); const SkString* attr0Name = - vertexBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0]); - vertexBuilder->vsCodeAppendf("\t%s = %s;\n", vsOffsetName, attr0Name->c_str()); + builder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0]); + builder->vsCodeAppendf("\t%s = %s;\n", vsOffsetName, attr0Name->c_str()); - vertexBuilder->addVarying(kVec4f_GrSLType, "EllipseRadii", &vsRadiiName, &fsRadiiName); + builder->addVarying(kVec4f_GrSLType, "EllipseRadii", &vsRadiiName, &fsRadiiName); const SkString* attr1Name = - vertexBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[1]); - vertexBuilder->vsCodeAppendf("\t%s = %s;\n", vsRadiiName, attr1Name->c_str()); + builder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[1]); + builder->vsCodeAppendf("\t%s = %s;\n", vsRadiiName, attr1Name->c_str()); // for outer curve builder->fsCodeAppendf("\tvec2 scaledOffset = %s*%s.xy;\n", fsOffsetName, fsRadiiName); @@ -269,7 +264,7 @@ public: } private: - typedef GrGLEffect INHERITED; + typedef GrGLVertexEffect INHERITED; }; private: @@ -347,38 +342,35 @@ public: inline Mode getMode() const { return fMode; } - class GLEffect : public GrGLEffect { + class GLEffect : public GrGLVertexEffect { public: GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&) : INHERITED (factory) {} - virtual void emitCode(GrGLShaderBuilder* builder, + virtual void emitCode(GrGLFullShaderBuilder* builder, const GrDrawEffect& drawEffect, EffectKey key, const char* outputColor, const char* inputColor, const TransformedCoordsArray&, const TextureSamplerArray& samplers) SK_OVERRIDE { - GrGLShaderBuilder::VertexBuilder* vertexBuilder = builder->getVertexBuilder(); - SkASSERT(NULL != vertexBuilder); - const DIEllipseEdgeEffect& ellipseEffect = drawEffect.castEffect<DIEllipseEdgeEffect>(); SkAssertResult(builder->enableFeature( GrGLShaderBuilder::kStandardDerivatives_GLSLFeature)); const char *vsOffsetName0, *fsOffsetName0; - vertexBuilder->addVarying(kVec2f_GrSLType, "EllipseOffsets0", + builder->addVarying(kVec2f_GrSLType, "EllipseOffsets0", &vsOffsetName0, &fsOffsetName0); const SkString* attr0Name = - vertexBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0]); - vertexBuilder->vsCodeAppendf("\t%s = %s;\n", vsOffsetName0, attr0Name->c_str()); + builder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0]); + builder->vsCodeAppendf("\t%s = %s;\n", vsOffsetName0, attr0Name->c_str()); const char *vsOffsetName1, *fsOffsetName1; - vertexBuilder->addVarying(kVec2f_GrSLType, "EllipseOffsets1", + builder->addVarying(kVec2f_GrSLType, "EllipseOffsets1", &vsOffsetName1, &fsOffsetName1); const SkString* attr1Name = - vertexBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[1]); - vertexBuilder->vsCodeAppendf("\t%s = %s;\n", vsOffsetName1, attr1Name->c_str()); + builder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[1]); + builder->vsCodeAppendf("\t%s = %s;\n", vsOffsetName1, attr1Name->c_str()); // for outer curve builder->fsCodeAppendf("\tvec2 scaledOffset = %s.xy;\n", fsOffsetName0); @@ -431,7 +423,7 @@ public: } private: - typedef GrGLEffect INHERITED; + typedef GrGLVertexEffect INHERITED; }; private: |