Express (GLSL expression, possibly known value) pairs as a class
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 10 Oct 2013 06:30:18 +0000 (06:30 +0000)
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 10 Oct 2013 06:30:18 +0000 (06:30 +0000)
commit824c346b6e0e114063c1a8ad4ba7c3a669ee2cff
tree746fca51437b25e3a6e851a42ec40ec3d5ac6ee0
parentab9d30cb01d0c8401537dc115aba2842b0f4f27f
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
18 files changed:
src/core/SkXfermode.cpp
src/effects/SkArithmeticMode.cpp
src/effects/SkBitmapAlphaThresholdShader.cpp
src/effects/SkColorMatrixFilter.cpp
src/effects/SkLumaColorFilter.cpp
src/effects/SkLumaXfermode.cpp
src/effects/gradients/SkGradientShader.cpp
src/gpu/GrAAConvexPathRenderer.cpp
src/gpu/GrAARectRenderer.cpp
src/gpu/GrOvalRenderer.cpp
src/gpu/effects/GrBezierEffect.cpp
src/gpu/gl/GrGLProgram.cpp
src/gpu/gl/GrGLProgramDesc.h
src/gpu/gl/GrGLSL.cpp
src/gpu/gl/GrGLSL.h
src/gpu/gl/GrGLSL_impl.h
src/gpu/gl/GrGLShaderBuilder.cpp
src/gpu/gl/GrGLShaderBuilder.h