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

Unified Diff: src/gpu/GrOvalRenderer.cpp

Issue 675193002: Revert of Added varying struct (Closed) Base URL: https://skia.googlesource.com/skia.git@gp_emit_struct
Patch Set: Created 6 years, 2 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/GrAARectRenderer.cpp ('k') | src/gpu/effects/GrBezierEffect.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrOvalRenderer.cpp
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index 72a01813b4028e0edc010d51b93e4d9885787c36..8c3b99c6e39ebf52f80066a41717b0469a26dc43 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -94,22 +94,21 @@
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
const CircleEdgeEffect& circleEffect = args.fGP.cast<CircleEdgeEffect>();
- GrGLVertToFrag v(kVec4f_GrSLType);
- args.fPB->addVarying("CircleEdge", &v);
+ const char *vsName, *fsName;
+ args.fPB->addVarying(kVec4f_GrSLType, "CircleEdge", &vsName, &fsName);
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();;
- vsBuilder->codeAppendf("%s = %s;", v.vsOut(), circleEffect.inCircleEdge().c_str());
+ vsBuilder->codeAppendf("\t%s = %s;\n", vsName, circleEffect.inCircleEdge().c_str());
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
- fsBuilder->codeAppendf("float d = length(%s.xy);", v.fsIn());
- fsBuilder->codeAppendf("float edgeAlpha = clamp(%s.z - d, 0.0, 1.0);", v.fsIn());
+ fsBuilder->codeAppendf("\tfloat d = length(%s.xy);\n", fsName);
+ fsBuilder->codeAppendf("\tfloat edgeAlpha = clamp(%s.z - d, 0.0, 1.0);\n", fsName);
if (circleEffect.isStroked()) {
- fsBuilder->codeAppendf("float innerAlpha = clamp(d - %s.w, 0.0, 1.0);",
- v.fsIn());
- fsBuilder->codeAppend("edgeAlpha *= innerAlpha;");
+ fsBuilder->codeAppendf("\tfloat innerAlpha = clamp(d - %s.w, 0.0, 1.0);\n", fsName);
+ fsBuilder->codeAppend("\tedgeAlpha *= innerAlpha;\n");
}
- fsBuilder->codeAppendf("%s = %s;\n", args.fOutput,
+ fsBuilder->codeAppendf("\t%s = %s;\n", args.fOutput,
(GrGLSLExpr4(args.fInput) * GrGLSLExpr1("edgeAlpha")).c_str());
}
@@ -207,43 +206,39 @@
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
const EllipseEdgeEffect& ellipseEffect = args.fGP.cast<EllipseEdgeEffect>();
- GrGLVertToFrag ellipseOffsets(kVec2f_GrSLType);
- args.fPB->addVarying("EllipseOffsets", &ellipseOffsets);
+ const char *vsOffsetName, *fsOffsetName;
+ const char *vsRadiiName, *fsRadiiName;
+
+ args.fPB->addVarying(kVec2f_GrSLType, "EllipseOffsets", &vsOffsetName, &fsOffsetName);
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
- vsBuilder->codeAppendf("%s = %s;", ellipseOffsets.vsOut(),
+ vsBuilder->codeAppendf("%s = %s;", vsOffsetName,
ellipseEffect.inEllipseOffset().c_str());
- GrGLVertToFrag ellipseRadii(kVec4f_GrSLType);
- args.fPB->addVarying("EllipseRadii", &ellipseRadii);
- vsBuilder->codeAppendf("%s = %s;", ellipseRadii.vsOut(),
- ellipseEffect.inEllipseRadii().c_str());
+ args.fPB->addVarying(kVec4f_GrSLType, "EllipseRadii", &vsRadiiName, &fsRadiiName);
+ vsBuilder->codeAppendf("%s = %s;", vsRadiiName, ellipseEffect.inEllipseRadii().c_str());
// for outer curve
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
- fsBuilder->codeAppendf("vec2 scaledOffset = %s*%s.xy;", ellipseOffsets.fsIn(),
- ellipseRadii.fsIn());
- fsBuilder->codeAppend("float test = dot(scaledOffset, scaledOffset) - 1.0;");
- fsBuilder->codeAppendf("vec2 grad = 2.0*scaledOffset*%s.xy;", ellipseRadii.fsIn());
- fsBuilder->codeAppend("float grad_dot = dot(grad, grad);");
-
+ fsBuilder->codeAppendf("\tvec2 scaledOffset = %s*%s.xy;\n", fsOffsetName, fsRadiiName);
+ fsBuilder->codeAppend("\tfloat test = dot(scaledOffset, scaledOffset) - 1.0;\n");
+ fsBuilder->codeAppendf("\tvec2 grad = 2.0*scaledOffset*%s.xy;\n", fsRadiiName);
+ fsBuilder->codeAppend("\tfloat grad_dot = dot(grad, grad);\n");
// avoid calling inversesqrt on zero.
- fsBuilder->codeAppend("grad_dot = max(grad_dot, 1.0e-4);");
- fsBuilder->codeAppend("float invlen = inversesqrt(grad_dot);");
- fsBuilder->codeAppend("float edgeAlpha = clamp(0.5-test*invlen, 0.0, 1.0);");
+ fsBuilder->codeAppend("\tgrad_dot = max(grad_dot, 1.0e-4);\n");
+ fsBuilder->codeAppend("\tfloat invlen = inversesqrt(grad_dot);\n");
+ fsBuilder->codeAppend("\tfloat edgeAlpha = clamp(0.5-test*invlen, 0.0, 1.0);\n");
// for inner curve
if (ellipseEffect.isStroked()) {
- fsBuilder->codeAppendf("scaledOffset = %s*%s.zw;",
- ellipseOffsets.fsIn(), ellipseRadii.fsIn());
- fsBuilder->codeAppend("test = dot(scaledOffset, scaledOffset) - 1.0;");
- fsBuilder->codeAppendf("grad = 2.0*scaledOffset*%s.zw;",
- ellipseRadii.fsIn());
- fsBuilder->codeAppend("invlen = inversesqrt(dot(grad, grad));");
- fsBuilder->codeAppend("edgeAlpha *= clamp(0.5+test*invlen, 0.0, 1.0);");
+ fsBuilder->codeAppendf("\tscaledOffset = %s*%s.zw;\n", fsOffsetName, fsRadiiName);
+ fsBuilder->codeAppend("\ttest = dot(scaledOffset, scaledOffset) - 1.0;\n");
+ fsBuilder->codeAppendf("\tgrad = 2.0*scaledOffset*%s.zw;\n", fsRadiiName);
+ fsBuilder->codeAppend("\tinvlen = inversesqrt(dot(grad, grad));\n");
+ fsBuilder->codeAppend("\tedgeAlpha *= clamp(0.5+test*invlen, 0.0, 1.0);\n");
}
- fsBuilder->codeAppendf("%s = %s;", args.fOutput,
+ fsBuilder->codeAppendf("\t%s = %s;\n", args.fOutput,
(GrGLSLExpr4(args.fInput) * GrGLSLExpr1("edgeAlpha")).c_str());
}
@@ -353,57 +348,57 @@
virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
const DIEllipseEdgeEffect& ellipseEffect = args.fGP.cast<DIEllipseEdgeEffect>();
- GrGLVertToFrag offsets0(kVec2f_GrSLType);
- args.fPB->addVarying("EllipseOffsets0", &offsets0);
+ const char *vsOffsetName0, *fsOffsetName0;
+ args.fPB->addVarying(kVec2f_GrSLType, "EllipseOffsets0",
+ &vsOffsetName0, &fsOffsetName0);
GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
- vsBuilder->codeAppendf("%s = %s;", offsets0.vsOut(),
+ vsBuilder->codeAppendf("%s = %s;", vsOffsetName0,
ellipseEffect.inEllipseOffsets0().c_str());
-
- GrGLVertToFrag offsets1(kVec2f_GrSLType);
- args.fPB->addVarying("EllipseOffsets1", &offsets1);
- vsBuilder->codeAppendf("%s = %s;", offsets1.vsOut(),
+ const char *vsOffsetName1, *fsOffsetName1;
+ args.fPB->addVarying(kVec2f_GrSLType, "EllipseOffsets1",
+ &vsOffsetName1, &fsOffsetName1);
+ vsBuilder->codeAppendf("\t%s = %s;\n", vsOffsetName1,
ellipseEffect.inEllipseOffsets1().c_str());
GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
SkAssertResult(fsBuilder->enableFeature(
GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
// for outer curve
- fsBuilder->codeAppendf("vec2 scaledOffset = %s.xy;", offsets0.fsIn());
- fsBuilder->codeAppend("float test = dot(scaledOffset, scaledOffset) - 1.0;");
- fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s);", offsets0.fsIn());
- fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s);", offsets0.fsIn());
- fsBuilder->codeAppendf("vec2 grad = vec2(2.0*%s.x*duvdx.x + 2.0*%s.y*duvdx.y,"
- " 2.0*%s.x*duvdy.x + 2.0*%s.y*duvdy.y);",
- offsets0.fsIn(), offsets0.fsIn(), offsets0.fsIn(), offsets0.fsIn());
-
- fsBuilder->codeAppend("float grad_dot = dot(grad, grad);");
+ fsBuilder->codeAppendf("\tvec2 scaledOffset = %s.xy;\n", fsOffsetName0);
+ fsBuilder->codeAppend("\tfloat test = dot(scaledOffset, scaledOffset) - 1.0;\n");
+ fsBuilder->codeAppendf("\tvec2 duvdx = dFdx(%s);\n", fsOffsetName0);
+ fsBuilder->codeAppendf("\tvec2 duvdy = dFdy(%s);\n", fsOffsetName0);
+ fsBuilder->codeAppendf("\tvec2 grad = vec2(2.0*%s.x*duvdx.x + 2.0*%s.y*duvdx.y,\n"
+ "\t 2.0*%s.x*duvdy.x + 2.0*%s.y*duvdy.y);\n",
+ fsOffsetName0, fsOffsetName0, fsOffsetName0, fsOffsetName0);
+
+ fsBuilder->codeAppend("\tfloat grad_dot = dot(grad, grad);\n");
// avoid calling inversesqrt on zero.
- fsBuilder->codeAppend("grad_dot = max(grad_dot, 1.0e-4);");
- fsBuilder->codeAppend("float invlen = inversesqrt(grad_dot);");
+ fsBuilder->codeAppend("\tgrad_dot = max(grad_dot, 1.0e-4);\n");
+ fsBuilder->codeAppend("\tfloat invlen = inversesqrt(grad_dot);\n");
if (kHairline == ellipseEffect.getMode()) {
// can probably do this with one step
- fsBuilder->codeAppend("float edgeAlpha = clamp(1.0-test*invlen, 0.0, 1.0);");
- fsBuilder->codeAppend("edgeAlpha *= clamp(1.0+test*invlen, 0.0, 1.0);");
+ fsBuilder->codeAppend("\tfloat edgeAlpha = clamp(1.0-test*invlen, 0.0, 1.0);\n");
+ fsBuilder->codeAppend("\tedgeAlpha *= clamp(1.0+test*invlen, 0.0, 1.0);\n");
} else {
- fsBuilder->codeAppend("float edgeAlpha = clamp(0.5-test*invlen, 0.0, 1.0);");
+ fsBuilder->codeAppend("\tfloat edgeAlpha = clamp(0.5-test*invlen, 0.0, 1.0);\n");
}
// for inner curve
if (kStroke == ellipseEffect.getMode()) {
- fsBuilder->codeAppendf("scaledOffset = %s.xy;", offsets1.fsIn());
- fsBuilder->codeAppend("test = dot(scaledOffset, scaledOffset) - 1.0;");
- fsBuilder->codeAppendf("duvdx = dFdx(%s);", offsets1.fsIn());
- fsBuilder->codeAppendf("duvdy = dFdy(%s);", offsets1.fsIn());
- fsBuilder->codeAppendf("grad = vec2(2.0*%s.x*duvdx.x + 2.0*%s.y*duvdx.y,"
- " 2.0*%s.x*duvdy.x + 2.0*%s.y*duvdy.y);",
- offsets1.fsIn(), offsets1.fsIn(), offsets1.fsIn(),
- offsets1.fsIn());
- fsBuilder->codeAppend("invlen = inversesqrt(dot(grad, grad));");
- fsBuilder->codeAppend("edgeAlpha *= clamp(0.5+test*invlen, 0.0, 1.0);");
+ fsBuilder->codeAppendf("\tscaledOffset = %s.xy;\n", fsOffsetName1);
+ fsBuilder->codeAppend("\ttest = dot(scaledOffset, scaledOffset) - 1.0;\n");
+ fsBuilder->codeAppendf("\tduvdx = dFdx(%s);\n", fsOffsetName1);
+ fsBuilder->codeAppendf("\tduvdy = dFdy(%s);\n", fsOffsetName1);
+ fsBuilder->codeAppendf("\tgrad = vec2(2.0*%s.x*duvdx.x + 2.0*%s.y*duvdx.y,\n"
+ "\t 2.0*%s.x*duvdy.x + 2.0*%s.y*duvdy.y);\n",
+ fsOffsetName1, fsOffsetName1, fsOffsetName1, fsOffsetName1);
+ fsBuilder->codeAppend("\tinvlen = inversesqrt(dot(grad, grad));\n");
+ fsBuilder->codeAppend("\tedgeAlpha *= clamp(0.5+test*invlen, 0.0, 1.0);\n");
}
- fsBuilder->codeAppendf("%s = %s;", args.fOutput,
+ fsBuilder->codeAppendf("\t%s = %s;\n", args.fOutput,
(GrGLSLExpr4(args.fInput) * GrGLSLExpr1("edgeAlpha")).c_str());
}
« no previous file with comments | « src/gpu/GrAARectRenderer.cpp ('k') | src/gpu/effects/GrBezierEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698