aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/effects
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-10 06:30:18 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-10 06:30:18 +0000
commit824c346b6e0e114063c1a8ad4ba7c3a669ee2cff (patch)
tree746fca51437b25e3a6e851a42ec40ec3d5ac6ee0 /src/gpu/effects
parentab9d30cb01d0c8401537dc115aba2842b0f4f27f (diff)
Express (GLSL expression, possibly known value) pairs as a class
Express (GLSL expression, possibly known value) pairs as a class instead of two variables Introduces GrGLSLExpr<N> to encapsulate the expression and possibly constant-folded value of the expression. This simplifies passing of the expressions to functions. Changes the shaders with following patterns: { // Stage 0: Linear Gradient vec4 colorTemp = mix(uGradientStartColor_Stage0, uGradientEndColor_Stage0, clamp(vMatrixCoord_Stage0.x, 0.0, 1 colorTemp.rgb *= colorTemp.a; - output_Stage0 = vec4((vColor) * (colorTemp)); + output_Stage0 = (vColor * colorTemp); + } Previously the vector cast was always added if constant folding was effective, regardless of the term dimensions. Now the vector upcast is not inserted in places where it is not needed, ie. when the binary operator term is of the target dimension. Also, some parentheses can be omitted. It is assumed that GrGLSLExpr<N>("string") constructors construct a simple expression or parenthesized expression. Otherwise the shader code remains identical. R=jvanverth@google.com, bsalomon@google.com, robertphillips@google.com Author: kkinnunen@nvidia.com Review URL: https://codereview.chromium.org/25048002 git-svn-id: http://skia.googlecode.com/svn/trunk@11690 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/effects')
-rw-r--r--src/gpu/effects/GrBezierEffect.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp
index 4dca884734..9cca054a40 100644
--- a/src/gpu/effects/GrBezierEffect.cpp
+++ b/src/gpu/effects/GrBezierEffect.cpp
@@ -110,9 +110,8 @@ void GrGLConicEffect::emitCode(GrGLFullShaderBuilder* builder,
}
}
- SkString modulate;
- GrGLSLModulatef<4>(&modulate, inputColor, "edgeAlpha");
- builder->fsCodeAppendf("\t%s = %s;\n", outputColor, modulate.c_str());
+ builder->fsCodeAppendf("\t%s = %s;\n", outputColor,
+ (GrGLSLExpr<4>(inputColor) * GrGLSLExpr<1>("edgeAlpha")).c_str());
}
GrGLEffect::EffectKey GrGLConicEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
@@ -239,9 +238,9 @@ void GrGLQuadEffect::emitCode(GrGLFullShaderBuilder* builder,
}
}
- SkString modulate;
- GrGLSLModulatef<4>(&modulate, inputColor, "edgeAlpha");
- builder->fsCodeAppendf("\t%s = %s;\n", outputColor, modulate.c_str());
+ builder->fsCodeAppendf("\t%s = %s;\n", outputColor,
+ (GrGLSLExpr<4>(inputColor) * GrGLSLExpr<1>("edgeAlpha")).c_str());
+
builder->vsCodeAppendf("\t%s = %s;\n", vsName, attrName->c_str());
}
@@ -383,9 +382,8 @@ void GrGLCubicEffect::emitCode(GrGLFullShaderBuilder* builder,
}
}
- SkString modulate;
- GrGLSLModulatef<4>(&modulate, inputColor, "edgeAlpha");
- builder->fsCodeAppendf("\t%s = %s;\n", outputColor, modulate.c_str());
+ builder->fsCodeAppendf("\t%s = %s;\n", outputColor,
+ (GrGLSLExpr<4>(inputColor) * GrGLSLExpr<1>("edgeAlpha")).c_str());
}
GrGLEffect::EffectKey GrGLCubicEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {