OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkGradientShaderPriv.h" | 8 #include "SkGradientShaderPriv.h" |
9 #include "SkLinearGradient.h" | 9 #include "SkLinearGradient.h" |
10 #include "SkRadialGradient.h" | 10 #include "SkRadialGradient.h" |
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 } | 973 } |
974 | 974 |
975 SkString output; | 975 SkString output; |
976 builder->fsCodeAppendf("\t%s = ", outputColor); | 976 builder->fsCodeAppendf("\t%s = ", outputColor); |
977 GrGLSLModulatef<4>(&output, inputColor, "colorTemp"); | 977 GrGLSLModulatef<4>(&output, inputColor, "colorTemp"); |
978 builder->fsCodeAppend(output.c_str()); | 978 builder->fsCodeAppend(output.c_str()); |
979 builder->fsCodeAppend(";\n"); | 979 builder->fsCodeAppend(";\n"); |
980 } else if (GrGradientEffect::kThree_ColorType == ColorTypeFromKey(key)){ | 980 } else if (GrGradientEffect::kThree_ColorType == ColorTypeFromKey(key)){ |
981 builder->fsCodeAppendf("\tfloat oneMinus2t = 1.0 - (2.0 * (%s));\n", | 981 builder->fsCodeAppendf("\tfloat oneMinus2t = 1.0 - (2.0 * (%s));\n", |
982 gradientTValue); | 982 gradientTValue); |
983 builder->fsCodeAppendf("\tvec4 colorTemp = clamp(oneMinus2t, 0.0, 1.0) *
%s +(1.0 - min(abs(oneMinus2t), 1.0)) * %s + clamp(-oneMinus2t, 0.0, 1.0) * %s;
\n", | 983 builder->fsCodeAppendf("\tvec4 colorTemp = clamp(oneMinus2t, 0.0, 1.0) *
%s;\n", |
984 builder->getUniformVariable(fColorStartUni).c_str
(), | 984 builder->getUniformVariable(fColorStartUni).c_str
()); |
985 builder->getUniformVariable(fColorMidUni).c_str()
, | 985 if (kTegra3_GrGLRenderer == builder->ctxInfo().renderer()) { |
| 986 // The Tegra3 compiler will sometimes never return if we have |
| 987 // min(abs(oneMinus2t), 1.0), or do the abs first in a separate expr
ession. |
| 988 builder->fsCodeAppend("\tfloat minAbs = abs(oneMinus2t);\n"); |
| 989 builder->fsCodeAppend("\tminAbs = minAbs > 1.0 ? 1.0 : minAbs;\n"); |
| 990 builder->fsCodeAppendf("\tcolorTemp += (1.0 - minAbs) * %s;\n", |
| 991 builder->getUniformVariable(fColorMidUni).c_s
tr()); |
| 992 } else { |
| 993 builder->fsCodeAppendf("\tcolorTemp += (1.0 - min(abs(oneMinus2t), 1
.0)) * %s;\n", |
| 994 builder->getUniformVariable(fColorMidUni).c_s
tr()); |
| 995 } |
| 996 builder->fsCodeAppendf("\tcolorTemp += clamp(-oneMinus2t, 0.0, 1.0) * %s
;\n", |
986 builder->getUniformVariable(fColorEndUni).c_str()
); | 997 builder->getUniformVariable(fColorEndUni).c_str()
); |
987 if (GrGradientEffect::kAfterInterp_PremulType == PremulTypeFromKey(key))
{ | 998 if (GrGradientEffect::kAfterInterp_PremulType == PremulTypeFromKey(key))
{ |
988 builder->fsCodeAppend("\tcolorTemp.rgb *= colorTemp.a;\n"); | 999 builder->fsCodeAppend("\tcolorTemp.rgb *= colorTemp.a;\n"); |
989 } | 1000 } |
990 | 1001 |
991 SkString output; | 1002 SkString output; |
992 builder->fsCodeAppendf("\t%s = ", outputColor); | 1003 builder->fsCodeAppendf("\t%s = ", outputColor); |
993 GrGLSLModulatef<4>(&output, inputColor, "colorTemp"); | 1004 GrGLSLModulatef<4>(&output, inputColor, "colorTemp"); |
994 builder->fsCodeAppend(output.c_str()); | 1005 builder->fsCodeAppend(output.c_str()); |
995 builder->fsCodeAppend(";\n"); | 1006 builder->fsCodeAppend(";\n"); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1145 (*stops)[i] = stop; | 1156 (*stops)[i] = stop; |
1146 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; | 1157 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; |
1147 } | 1158 } |
1148 } | 1159 } |
1149 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); | 1160 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); |
1150 | 1161 |
1151 return outColors; | 1162 return outColors; |
1152 } | 1163 } |
1153 | 1164 |
1154 #endif | 1165 #endif |
OLD | NEW |