2013-04-18 19:36:09 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GrGLSL_impl_DEFINED
|
|
|
|
#define GrGLSL_impl_DEFINED
|
|
|
|
|
2013-10-23 05:42:03 +00:00
|
|
|
template<typename Self>
|
|
|
|
template<typename T>
|
|
|
|
inline Self GrGLSLExpr<Self>::VectorCastImpl(const T& expr) {
|
|
|
|
if (expr.isZeros()) {
|
|
|
|
return Self(0);
|
|
|
|
}
|
|
|
|
if (expr.isOnes()) {
|
|
|
|
return Self(1);
|
|
|
|
}
|
|
|
|
return Self(Self::CastStr(), expr.c_str());
|
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
2013-10-10 06:30:18 +00:00
|
|
|
}
|
|
|
|
|
2013-10-23 05:42:03 +00:00
|
|
|
template<typename Self>
|
|
|
|
template<typename T0, typename T1>
|
|
|
|
inline Self GrGLSLExpr<Self>::Mul(T0 in0, T1 in1) {
|
|
|
|
if (in0.isZeros() || in1.isZeros()) {
|
|
|
|
return Self(0);
|
|
|
|
}
|
|
|
|
if (in0.isOnes()) {
|
|
|
|
return Self::VectorCast(in1);
|
|
|
|
}
|
|
|
|
if (in1.isOnes()) {
|
|
|
|
return Self::VectorCast(in0);
|
|
|
|
}
|
|
|
|
return Self("(%s * %s)", in0.c_str(), in1.c_str());
|
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
2013-10-10 06:30:18 +00:00
|
|
|
}
|
|
|
|
|
2013-10-23 05:42:03 +00:00
|
|
|
template<typename Self>
|
|
|
|
template<typename T0, typename T1>
|
|
|
|
inline Self GrGLSLExpr<Self>::Add(T0 in0, T1 in1) {
|
|
|
|
if (in1.isZeros()) {
|
|
|
|
return Self::VectorCast(in0);
|
|
|
|
}
|
|
|
|
if (in0.isZeros()) {
|
|
|
|
return Self::VectorCast(in1);
|
|
|
|
}
|
|
|
|
if (in0.isOnes() && in1.isOnes()) {
|
|
|
|
return Self(2);
|
|
|
|
}
|
|
|
|
return Self("(%s + %s)", in0.c_str(), in1.c_str());
|
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
2013-10-10 06:30:18 +00:00
|
|
|
}
|
|
|
|
|
2013-10-23 05:42:03 +00:00
|
|
|
template<typename Self>
|
|
|
|
template<typename T0, typename T1>
|
|
|
|
inline Self GrGLSLExpr<Self>::Sub(T0 in0, T1 in1) {
|
|
|
|
if (in1.isZeros()) {
|
|
|
|
return Self::VectorCast(in0);
|
|
|
|
}
|
|
|
|
if (in1.isOnes()) {
|
|
|
|
if (in0.isOnes()) {
|
|
|
|
return Self(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Self("(%s - %s)", in0.c_str(), in1.c_str());
|
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
2013-10-10 06:30:18 +00:00
|
|
|
}
|
2013-10-23 05:42:03 +00:00
|
|
|
|
|
|
|
template <typename Self>
|
|
|
|
template <typename T>
|
|
|
|
T GrGLSLExpr<Self>::extractComponents(const char format[]) const {
|
|
|
|
if (this->isZeros()) {
|
|
|
|
return T(0);
|
|
|
|
}
|
|
|
|
if (this->isOnes()) {
|
|
|
|
return T(1);
|
|
|
|
}
|
|
|
|
return T(format, this->c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
inline GrGLSLExpr1 GrGLSLExpr1::VectorCast(const GrGLSLExpr1& expr) {
|
|
|
|
return expr;
|
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
2013-10-10 06:30:18 +00:00
|
|
|
}
|
|
|
|
|
2013-10-23 05:42:03 +00:00
|
|
|
inline const char* GrGLSLExpr1::ZerosStr() {
|
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
2013-10-10 06:30:18 +00:00
|
|
|
return "0";
|
|
|
|
}
|
|
|
|
|
2013-10-23 05:42:03 +00:00
|
|
|
inline const char* GrGLSLExpr1::OnesStr() {
|
|
|
|
return "1.0";
|
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
2013-10-10 06:30:18 +00:00
|
|
|
}
|
|
|
|
|
2013-10-23 05:42:03 +00:00
|
|
|
// GrGLSLExpr1::CastStr() is unimplemented because using them is likely an
|
|
|
|
// error. This is now caught compile-time.
|
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
2013-10-10 06:30:18 +00:00
|
|
|
|
2013-10-23 05:42:03 +00:00
|
|
|
inline const char* GrGLSLExpr1::CastIntStr() {
|
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
2013-10-10 06:30:18 +00:00
|
|
|
return "%d";
|
|
|
|
}
|
|
|
|
|
2013-10-23 05:42:03 +00:00
|
|
|
inline GrGLSLExpr1 operator*(const GrGLSLExpr1& in0, const GrGLSLExpr1& in1) {
|
|
|
|
return GrGLSLExpr1::Mul(in0, in1);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline GrGLSLExpr1 operator+(const GrGLSLExpr1& in0, const GrGLSLExpr1& in1) {
|
|
|
|
return GrGLSLExpr1::Add(in0, in1);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline GrGLSLExpr1 operator-(const GrGLSLExpr1& in0, const GrGLSLExpr1& in1) {
|
|
|
|
return GrGLSLExpr1::Sub(in0, in1);
|
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
2013-10-10 06:30:18 +00:00
|
|
|
}
|
|
|
|
|
2013-10-23 05:42:03 +00:00
|
|
|
inline const char* GrGLSLExpr4::ZerosStr() {
|
|
|
|
return "vec4(0)";
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const char* GrGLSLExpr4::OnesStr() {
|
|
|
|
return "vec4(1)";
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const char* GrGLSLExpr4::CastStr() {
|
|
|
|
return "vec4(%s)";
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const char* GrGLSLExpr4::CastIntStr() {
|
|
|
|
return "vec4(%d)";
|
|
|
|
}
|
|
|
|
|
|
|
|
inline GrGLSLExpr4 GrGLSLExpr4::VectorCast(const GrGLSLExpr1& expr) {
|
|
|
|
return INHERITED::VectorCastImpl(expr);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline GrGLSLExpr4 GrGLSLExpr4::VectorCast(const GrGLSLExpr4& expr) {
|
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
2013-10-10 06:30:18 +00:00
|
|
|
return expr;
|
|
|
|
}
|
2013-04-18 19:36:09 +00:00
|
|
|
|
2013-10-23 05:42:03 +00:00
|
|
|
inline GrGLSLExpr4::AExpr GrGLSLExpr4::a() const {
|
|
|
|
return this->extractComponents<GrGLSLExpr4::AExpr>("%s.a");
|
2013-04-18 19:36:09 +00:00
|
|
|
}
|
|
|
|
|
2013-10-23 05:42:03 +00:00
|
|
|
inline GrGLSLExpr4 operator*(const GrGLSLExpr1& in0, const GrGLSLExpr4& in1) {
|
|
|
|
return GrGLSLExpr4::Mul(in0, in1);
|
2013-04-18 19:36:09 +00:00
|
|
|
}
|
|
|
|
|
2013-10-23 05:42:03 +00:00
|
|
|
inline GrGLSLExpr4 operator+(const GrGLSLExpr1& in0, const GrGLSLExpr4& in1) {
|
|
|
|
return GrGLSLExpr4::Add(in0, in1);
|
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
2013-10-10 06:30:18 +00:00
|
|
|
}
|
|
|
|
|
2013-10-23 05:42:03 +00:00
|
|
|
inline GrGLSLExpr4 operator-(const GrGLSLExpr1& in0, const GrGLSLExpr4& in1) {
|
|
|
|
return GrGLSLExpr4::Sub(in0, in1);
|
|
|
|
}
|
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
2013-10-10 06:30:18 +00:00
|
|
|
|
2013-10-23 05:42:03 +00:00
|
|
|
inline GrGLSLExpr4 operator*(const GrGLSLExpr4& in0, const GrGLSLExpr1& in1) {
|
|
|
|
return GrGLSLExpr4::Mul(in0, in1);
|
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
2013-10-10 06:30:18 +00:00
|
|
|
}
|
|
|
|
|
2013-10-23 05:42:03 +00:00
|
|
|
inline GrGLSLExpr4 operator+(const GrGLSLExpr4& in0, const GrGLSLExpr1& in1) {
|
|
|
|
return GrGLSLExpr4::Add(in0, in1);
|
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
2013-10-10 06:30:18 +00:00
|
|
|
}
|
|
|
|
|
2013-10-23 05:42:03 +00:00
|
|
|
inline GrGLSLExpr4 operator-(const GrGLSLExpr4& in0, const GrGLSLExpr1& in1) {
|
|
|
|
return GrGLSLExpr4::Sub(in0, in1);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline GrGLSLExpr4 operator*(const GrGLSLExpr4& in0, const GrGLSLExpr4& in1) {
|
|
|
|
return GrGLSLExpr4::Mul(in0, in1);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline GrGLSLExpr4 operator+(const GrGLSLExpr4& in0, const GrGLSLExpr4& in1) {
|
|
|
|
return GrGLSLExpr4::Add(in0, in1);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline GrGLSLExpr4 operator-(const GrGLSLExpr4& in0, const GrGLSLExpr4& in1) {
|
|
|
|
return GrGLSLExpr4::Sub(in0, in1);
|
2013-04-18 19:36:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|