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 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 | 1021 |
1022 return key; | 1022 return key; |
1023 } | 1023 } |
1024 | 1024 |
1025 void GrGLGradientEffect::emitColor(GrGLFPBuilder* builder, | 1025 void GrGLGradientEffect::emitColor(GrGLFPBuilder* builder, |
1026 const GrGradientEffect& ge, | 1026 const GrGradientEffect& ge, |
1027 const char* gradientTValue, | 1027 const char* gradientTValue, |
1028 const char* outputColor, | 1028 const char* outputColor, |
1029 const char* inputColor, | 1029 const char* inputColor, |
1030 const TextureSamplerArray& samplers) { | 1030 const TextureSamplerArray& samplers) { |
1031 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | 1031 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
1032 if (SkGradientShaderBase::kTwo_GpuColorType == ge.getColorType()){ | 1032 if (SkGradientShaderBase::kTwo_GpuColorType == ge.getColorType()){ |
1033 fsBuilder->codeAppendf("\tvec4 colorTemp = mix(%s, %s, clamp(%s, 0.0, 1.
0));\n", | 1033 fsBuilder->codeAppendf("\tvec4 colorTemp = mix(%s, %s, clamp(%s, 0.0, 1.
0));\n", |
1034 builder->getUniformVariable(fColorStartUni).c_str
(), | 1034 builder->getUniformVariable(fColorStartUni).c_str
(), |
1035 builder->getUniformVariable(fColorEndUni).c_str()
, | 1035 builder->getUniformVariable(fColorEndUni).c_str()
, |
1036 gradientTValue); | 1036 gradientTValue); |
1037 // Note that we could skip this step if both colors are known to be opaq
ue. Two | 1037 // Note that we could skip this step if both colors are known to be opaq
ue. Two |
1038 // considerations: | 1038 // considerations: |
1039 // The gradient SkShader reporting opaque is more restrictive than neces
sary in the two pt | 1039 // The gradient SkShader reporting opaque is more restrictive than neces
sary in the two pt |
1040 // case. Make sure the key reflects this optimization (and note that it
can use the same | 1040 // case. Make sure the key reflects this optimization (and note that it
can use the same |
1041 // shader as thekBeforeIterp case). This same optimization applies to th
e 3 color case below. | 1041 // shader as thekBeforeIterp case). This same optimization applies to th
e 3 color case below. |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 (*stops)[i] = stop; | 1203 (*stops)[i] = stop; |
1204 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; | 1204 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; |
1205 } | 1205 } |
1206 } | 1206 } |
1207 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); | 1207 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); |
1208 | 1208 |
1209 return outColors; | 1209 return outColors; |
1210 } | 1210 } |
1211 | 1211 |
1212 #endif | 1212 #endif |
OLD | NEW |