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

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

Issue 491673002: Initial refactor of shaderbuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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 | « src/gpu/GrOvalRenderer.cpp ('k') | src/gpu/effects/GrBicubicEffect.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/effects/GrBezierEffect.cpp
diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp
index 6f3772d7987a1b39f9ebf2a82074c07dc60d61ca..7384f62856c91378014f114d3fdee8c026a8e02a 100644
--- a/src/gpu/effects/GrBezierEffect.cpp
+++ b/src/gpu/effects/GrBezierEffect.cpp
@@ -5,10 +5,10 @@
* found in the LICENSE file.
*/
+#include "gl/builders/GrGLProgramBuilder.h"
#include "GrBezierEffect.h"
#include "gl/GrGLEffect.h"
-#include "gl/GrGLShaderBuilder.h"
#include "gl/GrGLSL.h"
#include "gl/GrGLVertexEffect.h"
#include "GrTBackendEffectFactory.h"
@@ -17,7 +17,7 @@ class GrGLConicEffect : public GrGLVertexEffect {
public:
GrGLConicEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
- virtual void emitCode(GrGLFullShaderBuilder* builder,
+ virtual void emitCode(GrGLFullProgramBuilder* builder,
const GrDrawEffect& drawEffect,
const GrEffectKey& key,
const char* outputColor,
@@ -42,7 +42,7 @@ GrGLConicEffect::GrGLConicEffect(const GrBackendEffectFactory& factory,
fEdgeType = ce.getEdgeType();
}
-void GrGLConicEffect::emitCode(GrGLFullShaderBuilder* builder,
+void GrGLConicEffect::emitCode(GrGLFullProgramBuilder* builder,
const GrDrawEffect& drawEffect,
const GrEffectKey& key,
const char* outputColor,
@@ -53,67 +53,70 @@ void GrGLConicEffect::emitCode(GrGLFullShaderBuilder* builder,
builder->addVarying(kVec4f_GrSLType, "ConicCoeffs",
&vsName, &fsName);
+
+ GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();
const SkString* attr0Name =
- builder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0]);
- builder->vsCodeAppendf("\t%s = %s;\n", vsName, attr0Name->c_str());
+ vsBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0]);
+ vsBuilder->codeAppendf("\t%s = %s;\n", vsName, attr0Name->c_str());
- builder->fsCodeAppend("\t\tfloat edgeAlpha;\n");
+ GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
+ fsBuilder->codeAppend("\t\tfloat edgeAlpha;\n");
switch (fEdgeType) {
case kHairlineAA_GrEffectEdgeType: {
- SkAssertResult(builder->enableFeature(
- GrGLShaderBuilder::kStandardDerivatives_GLSLFeature));
- builder->fsCodeAppendf("\t\tvec3 dklmdx = dFdx(%s.xyz);\n", fsName);
- builder->fsCodeAppendf("\t\tvec3 dklmdy = dFdy(%s.xyz);\n", fsName);
- builder->fsCodeAppendf("\t\tfloat dfdx =\n"
+ SkAssertResult(fsBuilder->enableFeature(
+ GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
+ fsBuilder->codeAppendf("\t\tvec3 dklmdx = dFdx(%s.xyz);\n", fsName);
+ fsBuilder->codeAppendf("\t\tvec3 dklmdy = dFdy(%s.xyz);\n", fsName);
+ fsBuilder->codeAppendf("\t\tfloat dfdx =\n"
"\t\t\t2.0*%s.x*dklmdx.x - %s.y*dklmdx.z - %s.z*dklmdx.y;\n",
fsName, fsName, fsName);
- builder->fsCodeAppendf("\t\tfloat dfdy =\n"
+ fsBuilder->codeAppendf("\t\tfloat dfdy =\n"
"\t\t\t2.0*%s.x*dklmdy.x - %s.y*dklmdy.z - %s.z*dklmdy.y;\n",
fsName, fsName, fsName);
- builder->fsCodeAppend("\t\tvec2 gF = vec2(dfdx, dfdy);\n");
- builder->fsCodeAppend("\t\tfloat gFM = sqrt(dot(gF, gF));\n");
- builder->fsCodeAppendf("\t\tfloat func = %s.x*%s.x - %s.y*%s.z;\n", fsName, fsName,
+ fsBuilder->codeAppend("\t\tvec2 gF = vec2(dfdx, dfdy);\n");
+ fsBuilder->codeAppend("\t\tfloat gFM = sqrt(dot(gF, gF));\n");
+ fsBuilder->codeAppendf("\t\tfloat func = %s.x*%s.x - %s.y*%s.z;\n", fsName, fsName,
fsName, fsName);
- builder->fsCodeAppend("\t\tfunc = abs(func);\n");
- builder->fsCodeAppend("\t\tedgeAlpha = func / gFM;\n");
- builder->fsCodeAppend("\t\tedgeAlpha = max(1.0 - edgeAlpha, 0.0);\n");
+ fsBuilder->codeAppend("\t\tfunc = abs(func);\n");
+ fsBuilder->codeAppend("\t\tedgeAlpha = func / gFM;\n");
+ fsBuilder->codeAppend("\t\tedgeAlpha = max(1.0 - edgeAlpha, 0.0);\n");
// Add line below for smooth cubic ramp
- // builder->fsCodeAppend("\t\tedgeAlpha = edgeAlpha*edgeAlpha*(3.0-2.0*edgeAlpha);\n");
+ // fsBuilder->codeAppend("\t\tedgeAlpha = edgeAlpha*edgeAlpha*(3.0-2.0*edgeAlpha);\n");
break;
}
case kFillAA_GrEffectEdgeType: {
- SkAssertResult(builder->enableFeature(
- GrGLShaderBuilder::kStandardDerivatives_GLSLFeature));
- builder->fsCodeAppendf("\t\tvec3 dklmdx = dFdx(%s.xyz);\n", fsName);
- builder->fsCodeAppendf("\t\tvec3 dklmdy = dFdy(%s.xyz);\n", fsName);
- builder->fsCodeAppendf("\t\tfloat dfdx =\n"
+ SkAssertResult(fsBuilder->enableFeature(
+ GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
+ fsBuilder->codeAppendf("\t\tvec3 dklmdx = dFdx(%s.xyz);\n", fsName);
+ fsBuilder->codeAppendf("\t\tvec3 dklmdy = dFdy(%s.xyz);\n", fsName);
+ fsBuilder->codeAppendf("\t\tfloat dfdx =\n"
"\t\t\t2.0*%s.x*dklmdx.x - %s.y*dklmdx.z - %s.z*dklmdx.y;\n",
fsName, fsName, fsName);
- builder->fsCodeAppendf("\t\tfloat dfdy =\n"
+ fsBuilder->codeAppendf("\t\tfloat dfdy =\n"
"\t\t\t2.0*%s.x*dklmdy.x - %s.y*dklmdy.z - %s.z*dklmdy.y;\n",
fsName, fsName, fsName);
- builder->fsCodeAppend("\t\tvec2 gF = vec2(dfdx, dfdy);\n");
- builder->fsCodeAppend("\t\tfloat gFM = sqrt(dot(gF, gF));\n");
- builder->fsCodeAppendf("\t\tfloat func = %s.x*%s.x - %s.y*%s.z;\n", fsName, fsName,
+ fsBuilder->codeAppend("\t\tvec2 gF = vec2(dfdx, dfdy);\n");
+ fsBuilder->codeAppend("\t\tfloat gFM = sqrt(dot(gF, gF));\n");
+ fsBuilder->codeAppendf("\t\tfloat func = %s.x*%s.x - %s.y*%s.z;\n", fsName, fsName,
fsName, fsName);
- builder->fsCodeAppend("\t\tedgeAlpha = func / gFM;\n");
- builder->fsCodeAppend("\t\tedgeAlpha = clamp(1.0 - edgeAlpha, 0.0, 1.0);\n");
+ fsBuilder->codeAppend("\t\tedgeAlpha = func / gFM;\n");
+ fsBuilder->codeAppend("\t\tedgeAlpha = clamp(1.0 - edgeAlpha, 0.0, 1.0);\n");
// Add line below for smooth cubic ramp
- // builder->fsCodeAppend("\t\tedgeAlpha = edgeAlpha*edgeAlpha*(3.0-2.0*edgeAlpha);\n");
+ // fsBuilder->codeAppend("\t\tedgeAlpha = edgeAlpha*edgeAlpha*(3.0-2.0*edgeAlpha);\n");
break;
}
case kFillBW_GrEffectEdgeType: {
- builder->fsCodeAppendf("\t\tedgeAlpha = %s.x*%s.x - %s.y*%s.z;\n", fsName, fsName,
+ fsBuilder->codeAppendf("\t\tedgeAlpha = %s.x*%s.x - %s.y*%s.z;\n", fsName, fsName,
fsName, fsName);
- builder->fsCodeAppend("\t\tedgeAlpha = float(edgeAlpha < 0.0);\n");
+ fsBuilder->codeAppend("\t\tedgeAlpha = float(edgeAlpha < 0.0);\n");
break;
}
default:
SkFAIL("Shouldn't get here");
}
- builder->fsCodeAppendf("\t%s = %s;\n", outputColor,
+ fsBuilder->codeAppendf("\t%s = %s;\n", outputColor,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
}
@@ -167,7 +170,7 @@ class GrGLQuadEffect : public GrGLVertexEffect {
public:
GrGLQuadEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
- virtual void emitCode(GrGLFullShaderBuilder* builder,
+ virtual void emitCode(GrGLFullProgramBuilder* builder,
const GrDrawEffect& drawEffect,
const GrEffectKey& key,
const char* outputColor,
@@ -192,7 +195,7 @@ GrGLQuadEffect::GrGLQuadEffect(const GrBackendEffectFactory& factory,
fEdgeType = ce.getEdgeType();
}
-void GrGLQuadEffect::emitCode(GrGLFullShaderBuilder* builder,
+void GrGLQuadEffect::emitCode(GrGLFullProgramBuilder* builder,
const GrDrawEffect& drawEffect,
const GrEffectKey& key,
const char* outputColor,
@@ -200,61 +203,61 @@ void GrGLQuadEffect::emitCode(GrGLFullShaderBuilder* builder,
const TransformedCoordsArray&,
const TextureSamplerArray& samplers) {
const char *vsName, *fsName;
+ builder->addVarying(kVec4f_GrSLType, "HairQuadEdge", &vsName, &fsName);
+ GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();
const SkString* attrName =
- builder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0]);
- builder->fsCodeAppendf("\t\tfloat edgeAlpha;\n");
+ vsBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0]);
+ vsBuilder->codeAppendf("\t%s = %s;\n", vsName, attrName->c_str());
- builder->addVarying(kVec4f_GrSLType, "HairQuadEdge", &vsName, &fsName);
+ GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
+ fsBuilder->codeAppendf("\t\tfloat edgeAlpha;\n");
switch (fEdgeType) {
case kHairlineAA_GrEffectEdgeType: {
- SkAssertResult(builder->enableFeature(
- GrGLShaderBuilder::kStandardDerivatives_GLSLFeature));
- builder->fsCodeAppendf("\t\tvec2 duvdx = dFdx(%s.xy);\n", fsName);
- builder->fsCodeAppendf("\t\tvec2 duvdy = dFdy(%s.xy);\n", fsName);
- builder->fsCodeAppendf("\t\tvec2 gF = vec2(2.0*%s.x*duvdx.x - duvdx.y,\n"
+ SkAssertResult(fsBuilder->enableFeature(
+ GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
+ fsBuilder->codeAppendf("\t\tvec2 duvdx = dFdx(%s.xy);\n", fsName);
+ fsBuilder->codeAppendf("\t\tvec2 duvdy = dFdy(%s.xy);\n", fsName);
+ fsBuilder->codeAppendf("\t\tvec2 gF = vec2(2.0*%s.x*duvdx.x - duvdx.y,\n"
"\t\t 2.0*%s.x*duvdy.x - duvdy.y);\n",
fsName, fsName);
- builder->fsCodeAppendf("\t\tedgeAlpha = (%s.x*%s.x - %s.y);\n", fsName, fsName,
+ fsBuilder->codeAppendf("\t\tedgeAlpha = (%s.x*%s.x - %s.y);\n", fsName, fsName,
fsName);
- builder->fsCodeAppend("\t\tedgeAlpha = sqrt(edgeAlpha*edgeAlpha / dot(gF, gF));\n");
- builder->fsCodeAppend("\t\tedgeAlpha = max(1.0 - edgeAlpha, 0.0);\n");
+ fsBuilder->codeAppend("\t\tedgeAlpha = sqrt(edgeAlpha*edgeAlpha / dot(gF, gF));\n");
+ fsBuilder->codeAppend("\t\tedgeAlpha = max(1.0 - edgeAlpha, 0.0);\n");
// Add line below for smooth cubic ramp
- // builder->fsCodeAppend("\t\tedgeAlpha = edgeAlpha*edgeAlpha*(3.0-2.0*edgeAlpha);\n");
+ // fsBuilder->codeAppend("\t\tedgeAlpha = edgeAlpha*edgeAlpha*(3.0-2.0*edgeAlpha);\n");
break;
}
case kFillAA_GrEffectEdgeType: {
- SkAssertResult(builder->enableFeature(
- GrGLShaderBuilder::kStandardDerivatives_GLSLFeature));
- builder->fsCodeAppendf("\t\tvec2 duvdx = dFdx(%s.xy);\n", fsName);
- builder->fsCodeAppendf("\t\tvec2 duvdy = dFdy(%s.xy);\n", fsName);
- builder->fsCodeAppendf("\t\tvec2 gF = vec2(2.0*%s.x*duvdx.x - duvdx.y,\n"
+ SkAssertResult(fsBuilder->enableFeature(
+ GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
+ fsBuilder->codeAppendf("\t\tvec2 duvdx = dFdx(%s.xy);\n", fsName);
+ fsBuilder->codeAppendf("\t\tvec2 duvdy = dFdy(%s.xy);\n", fsName);
+ fsBuilder->codeAppendf("\t\tvec2 gF = vec2(2.0*%s.x*duvdx.x - duvdx.y,\n"
"\t\t 2.0*%s.x*duvdy.x - duvdy.y);\n",
fsName, fsName);
- builder->fsCodeAppendf("\t\tedgeAlpha = (%s.x*%s.x - %s.y);\n", fsName, fsName,
+ fsBuilder->codeAppendf("\t\tedgeAlpha = (%s.x*%s.x - %s.y);\n", fsName, fsName,
fsName);
- builder->fsCodeAppend("\t\tedgeAlpha = edgeAlpha / sqrt(dot(gF, gF));\n");
- builder->fsCodeAppend("\t\tedgeAlpha = clamp(1.0 - edgeAlpha, 0.0, 1.0);\n");
+ fsBuilder->codeAppend("\t\tedgeAlpha = edgeAlpha / sqrt(dot(gF, gF));\n");
+ fsBuilder->codeAppend("\t\tedgeAlpha = clamp(1.0 - edgeAlpha, 0.0, 1.0);\n");
// Add line below for smooth cubic ramp
- // builder->fsCodeAppend("\t\tedgeAlpha = edgeAlpha*edgeAlpha*(3.0-2.0*edgeAlpha);\n");
+ // fsBuilder->codeAppend("\t\tedgeAlpha = edgeAlpha*edgeAlpha*(3.0-2.0*edgeAlpha);\n");
break;
}
case kFillBW_GrEffectEdgeType: {
- builder->fsCodeAppendf("\t\tedgeAlpha = (%s.x*%s.x - %s.y);\n", fsName, fsName,
+ fsBuilder->codeAppendf("\t\tedgeAlpha = (%s.x*%s.x - %s.y);\n", fsName, fsName,
fsName);
- builder->fsCodeAppend("\t\tedgeAlpha = float(edgeAlpha < 0.0);\n");
+ fsBuilder->codeAppend("\t\tedgeAlpha = float(edgeAlpha < 0.0);\n");
break;
}
default:
SkFAIL("Shouldn't get here");
}
- builder->fsCodeAppendf("\t%s = %s;\n", outputColor,
+ fsBuilder->codeAppendf("\t%s = %s;\n", outputColor,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
-
-
- builder->vsCodeAppendf("\t%s = %s;\n", vsName, attrName->c_str());
}
void GrGLQuadEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
@@ -307,7 +310,7 @@ class GrGLCubicEffect : public GrGLVertexEffect {
public:
GrGLCubicEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
- virtual void emitCode(GrGLFullShaderBuilder* builder,
+ virtual void emitCode(GrGLFullProgramBuilder* builder,
const GrDrawEffect& drawEffect,
const GrEffectKey& key,
const char* outputColor,
@@ -332,7 +335,7 @@ GrGLCubicEffect::GrGLCubicEffect(const GrBackendEffectFactory& factory,
fEdgeType = ce.getEdgeType();
}
-void GrGLCubicEffect::emitCode(GrGLFullShaderBuilder* builder,
+void GrGLCubicEffect::emitCode(GrGLFullProgramBuilder* builder,
const GrDrawEffect& drawEffect,
const GrEffectKey& key,
const char* outputColor,
@@ -343,67 +346,70 @@ void GrGLCubicEffect::emitCode(GrGLFullShaderBuilder* builder,
builder->addVarying(kVec4f_GrSLType, "CubicCoeffs",
&vsName, &fsName);
+
+ GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();
const SkString* attr0Name =
- builder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0]);
- builder->vsCodeAppendf("\t%s = %s;\n", vsName, attr0Name->c_str());
+ vsBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0]);
+ vsBuilder->codeAppendf("\t%s = %s;\n", vsName, attr0Name->c_str());
- builder->fsCodeAppend("\t\tfloat edgeAlpha;\n");
+ GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
+ fsBuilder->codeAppend("\t\tfloat edgeAlpha;\n");
switch (fEdgeType) {
case kHairlineAA_GrEffectEdgeType: {
- SkAssertResult(builder->enableFeature(
- GrGLShaderBuilder::kStandardDerivatives_GLSLFeature));
- builder->fsCodeAppendf("\t\tvec3 dklmdx = dFdx(%s.xyz);\n", fsName);
- builder->fsCodeAppendf("\t\tvec3 dklmdy = dFdy(%s.xyz);\n", fsName);
- builder->fsCodeAppendf("\t\tfloat dfdx =\n"
+ SkAssertResult(fsBuilder->enableFeature(
+ GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
+ fsBuilder->codeAppendf("\t\tvec3 dklmdx = dFdx(%s.xyz);\n", fsName);
+ fsBuilder->codeAppendf("\t\tvec3 dklmdy = dFdy(%s.xyz);\n", fsName);
+ fsBuilder->codeAppendf("\t\tfloat dfdx =\n"
"\t\t3.0*%s.x*%s.x*dklmdx.x - %s.y*dklmdx.z - %s.z*dklmdx.y;\n",
fsName, fsName, fsName, fsName);
- builder->fsCodeAppendf("\t\tfloat dfdy =\n"
+ fsBuilder->codeAppendf("\t\tfloat dfdy =\n"
"\t\t3.0*%s.x*%s.x*dklmdy.x - %s.y*dklmdy.z - %s.z*dklmdy.y;\n",
fsName, fsName, fsName, fsName);
- builder->fsCodeAppend("\t\tvec2 gF = vec2(dfdx, dfdy);\n");
- builder->fsCodeAppend("\t\tfloat gFM = sqrt(dot(gF, gF));\n");
- builder->fsCodeAppendf("\t\tfloat func = %s.x*%s.x*%s.x - %s.y*%s.z;\n",
+ fsBuilder->codeAppend("\t\tvec2 gF = vec2(dfdx, dfdy);\n");
+ fsBuilder->codeAppend("\t\tfloat gFM = sqrt(dot(gF, gF));\n");
+ fsBuilder->codeAppendf("\t\tfloat func = %s.x*%s.x*%s.x - %s.y*%s.z;\n",
fsName, fsName, fsName, fsName, fsName);
- builder->fsCodeAppend("\t\tfunc = abs(func);\n");
- builder->fsCodeAppend("\t\tedgeAlpha = func / gFM;\n");
- builder->fsCodeAppend("\t\tedgeAlpha = max(1.0 - edgeAlpha, 0.0);\n");
+ fsBuilder->codeAppend("\t\tfunc = abs(func);\n");
+ fsBuilder->codeAppend("\t\tedgeAlpha = func / gFM;\n");
+ fsBuilder->codeAppend("\t\tedgeAlpha = max(1.0 - edgeAlpha, 0.0);\n");
// Add line below for smooth cubic ramp
- // builder->fsCodeAppend("\t\tedgeAlpha = edgeAlpha*edgeAlpha*(3.0-2.0*edgeAlpha);\n");
+ // fsBuilder->codeAppend("\t\tedgeAlpha = edgeAlpha*edgeAlpha*(3.0-2.0*edgeAlpha);\n");
break;
}
case kFillAA_GrEffectEdgeType: {
- SkAssertResult(builder->enableFeature(
- GrGLShaderBuilder::kStandardDerivatives_GLSLFeature));
- builder->fsCodeAppendf("\t\tvec3 dklmdx = dFdx(%s.xyz);\n", fsName);
- builder->fsCodeAppendf("\t\tvec3 dklmdy = dFdy(%s.xyz);\n", fsName);
- builder->fsCodeAppendf("\t\tfloat dfdx =\n"
+ SkAssertResult(fsBuilder->enableFeature(
+ GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
+ fsBuilder->codeAppendf("\t\tvec3 dklmdx = dFdx(%s.xyz);\n", fsName);
+ fsBuilder->codeAppendf("\t\tvec3 dklmdy = dFdy(%s.xyz);\n", fsName);
+ fsBuilder->codeAppendf("\t\tfloat dfdx =\n"
"\t\t3.0*%s.x*%s.x*dklmdx.x - %s.y*dklmdx.z - %s.z*dklmdx.y;\n",
fsName, fsName, fsName, fsName);
- builder->fsCodeAppendf("\t\tfloat dfdy =\n"
+ fsBuilder->codeAppendf("\t\tfloat dfdy =\n"
"\t\t3.0*%s.x*%s.x*dklmdy.x - %s.y*dklmdy.z - %s.z*dklmdy.y;\n",
fsName, fsName, fsName, fsName);
- builder->fsCodeAppend("\t\tvec2 gF = vec2(dfdx, dfdy);\n");
- builder->fsCodeAppend("\t\tfloat gFM = sqrt(dot(gF, gF));\n");
- builder->fsCodeAppendf("\t\tfloat func = %s.x*%s.x*%s.x - %s.y*%s.z;\n",
+ fsBuilder->codeAppend("\t\tvec2 gF = vec2(dfdx, dfdy);\n");
+ fsBuilder->codeAppend("\t\tfloat gFM = sqrt(dot(gF, gF));\n");
+ fsBuilder->codeAppendf("\t\tfloat func = %s.x*%s.x*%s.x - %s.y*%s.z;\n",
fsName, fsName, fsName, fsName, fsName);
- builder->fsCodeAppend("\t\tedgeAlpha = func / gFM;\n");
- builder->fsCodeAppend("\t\tedgeAlpha = clamp(1.0 - edgeAlpha, 0.0, 1.0);\n");
+ fsBuilder->codeAppend("\t\tedgeAlpha = func / gFM;\n");
+ fsBuilder->codeAppend("\t\tedgeAlpha = clamp(1.0 - edgeAlpha, 0.0, 1.0);\n");
// Add line below for smooth cubic ramp
- // builder->fsCodeAppend("\t\tedgeAlpha = edgeAlpha*edgeAlpha*(3.0-2.0*edgeAlpha);\n");
+ // fsBuilder->codeAppend("\t\tedgeAlpha = edgeAlpha*edgeAlpha*(3.0-2.0*edgeAlpha);\n");
break;
}
case kFillBW_GrEffectEdgeType: {
- builder->fsCodeAppendf("\t\tedgeAlpha = %s.x*%s.x*%s.x - %s.y*%s.z;\n",
+ fsBuilder->codeAppendf("\t\tedgeAlpha = %s.x*%s.x*%s.x - %s.y*%s.z;\n",
fsName, fsName, fsName, fsName, fsName);
- builder->fsCodeAppend("\t\tedgeAlpha = float(edgeAlpha < 0.0);\n");
+ fsBuilder->codeAppend("\t\tedgeAlpha = float(edgeAlpha < 0.0);\n");
break;
}
default:
SkFAIL("Shouldn't get here");
}
- builder->fsCodeAppendf("\t%s = %s;\n", outputColor,
+ fsBuilder->codeAppendf("\t%s = %s;\n", outputColor,
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
}
« no previous file with comments | « src/gpu/GrOvalRenderer.cpp ('k') | src/gpu/effects/GrBicubicEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698