| 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 "Sk4fLinearGradient.h" | 8 #include "Sk4fLinearGradient.h" | 
| 9 #include "SkGradientShaderPriv.h" | 9 #include "SkGradientShaderPriv.h" | 
| 10 #include "SkLinearGradient.h" | 10 #include "SkLinearGradient.h" | 
| (...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1024     return key; | 1024     return key; | 
| 1025 } | 1025 } | 
| 1026 | 1026 | 
| 1027 void GrGLGradientEffect::emitColor(GrGLSLFPFragmentBuilder* fragBuilder, | 1027 void GrGLGradientEffect::emitColor(GrGLSLFPFragmentBuilder* fragBuilder, | 
| 1028                                    GrGLSLUniformHandler* uniformHandler, | 1028                                    GrGLSLUniformHandler* uniformHandler, | 
| 1029                                    const GrGLSLCaps* glslCaps, | 1029                                    const GrGLSLCaps* glslCaps, | 
| 1030                                    const GrGradientEffect& ge, | 1030                                    const GrGradientEffect& ge, | 
| 1031                                    const char* gradientTValue, | 1031                                    const char* gradientTValue, | 
| 1032                                    const char* outputColor, | 1032                                    const char* outputColor, | 
| 1033                                    const char* inputColor, | 1033                                    const char* inputColor, | 
| 1034                                    const SamplerArray& texSamplers) { | 1034                                    const SamplerHandle* texSampler) { | 
| 1035     if (SkGradientShaderBase::kTwo_GpuColorType == ge.getColorType()){ | 1035     if (SkGradientShaderBase::kTwo_GpuColorType == ge.getColorType()){ | 
| 1036         fragBuilder->codeAppendf("\tvec4 colorTemp = mix(%s, %s, clamp(%s, 0.0, 
      1.0));\n", | 1036         fragBuilder->codeAppendf("\tvec4 colorTemp = mix(%s, %s, clamp(%s, 0.0, 
      1.0));\n", | 
| 1037                                  uniformHandler->getUniformVariable(fColorStartU
      ni).c_str(), | 1037                                  uniformHandler->getUniformVariable(fColorStartU
      ni).c_str(), | 
| 1038                                  uniformHandler->getUniformVariable(fColorEndUni
      ).c_str(), | 1038                                  uniformHandler->getUniformVariable(fColorEndUni
      ).c_str(), | 
| 1039                                  gradientTValue); | 1039                                  gradientTValue); | 
| 1040         // Note that we could skip this step if both colors are known to be opaq
      ue. Two | 1040         // Note that we could skip this step if both colors are known to be opaq
      ue. Two | 
| 1041         // considerations: | 1041         // considerations: | 
| 1042         // The gradient SkShader reporting opaque is more restrictive than neces
      sary in the two pt | 1042         // The gradient SkShader reporting opaque is more restrictive than neces
      sary in the two pt | 
| 1043         // case. Make sure the key reflects this optimization (and note that it 
      can use the same | 1043         // case. Make sure the key reflects this optimization (and note that it 
      can use the same | 
| 1044         // shader as thekBeforeIterp case). This same optimization applies to th
      e 3 color case | 1044         // shader as thekBeforeIterp case). This same optimization applies to th
      e 3 color case | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 1072         } | 1072         } | 
| 1073 | 1073 | 
| 1074         fragBuilder->codeAppendf("\t%s = %s;\n", outputColor, | 1074         fragBuilder->codeAppendf("\t%s = %s;\n", outputColor, | 
| 1075                                  (GrGLSLExpr4(inputColor) * GrGLSLExpr4("colorTe
      mp")).c_str()); | 1075                                  (GrGLSLExpr4(inputColor) * GrGLSLExpr4("colorTe
      mp")).c_str()); | 
| 1076     } else { | 1076     } else { | 
| 1077         fragBuilder->codeAppendf("\tvec2 coord = vec2(%s, %s);\n", | 1077         fragBuilder->codeAppendf("\tvec2 coord = vec2(%s, %s);\n", | 
| 1078                                  gradientTValue, | 1078                                  gradientTValue, | 
| 1079                                  uniformHandler->getUniformVariable(fFSYUni).c_s
      tr()); | 1079                                  uniformHandler->getUniformVariable(fFSYUni).c_s
      tr()); | 
| 1080         fragBuilder->codeAppendf("\t%s = ", outputColor); | 1080         fragBuilder->codeAppendf("\t%s = ", outputColor); | 
| 1081         fragBuilder->appendTextureLookupAndModulate(inputColor, | 1081         fragBuilder->appendTextureLookupAndModulate(inputColor, | 
| 1082                                                     texSamplers[0], | 1082                                                     uniformHandler->getSampler(t
      exSampler[0]), | 
| 1083                                                     "coord"); | 1083                                                     "coord"); | 
| 1084         fragBuilder->codeAppend(";\n"); | 1084         fragBuilder->codeAppend(";\n"); | 
| 1085     } | 1085     } | 
| 1086 } | 1086 } | 
| 1087 | 1087 | 
| 1088 ///////////////////////////////////////////////////////////////////// | 1088 ///////////////////////////////////////////////////////////////////// | 
| 1089 | 1089 | 
| 1090 GrGradientEffect::GrGradientEffect(GrContext* ctx, | 1090 GrGradientEffect::GrGradientEffect(GrContext* ctx, | 
| 1091                                    const SkGradientShaderBase& shader, | 1091                                    const SkGradientShaderBase& shader, | 
| 1092                                    const SkMatrix& matrix, | 1092                                    const SkMatrix& matrix, | 
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1207             (*stops)[i] = stop; | 1207             (*stops)[i] = stop; | 
| 1208             stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
      op) : 1.f; | 1208             stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
      op) : 1.f; | 
| 1209         } | 1209         } | 
| 1210     } | 1210     } | 
| 1211     *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
      odeCount)); | 1211     *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
      odeCount)); | 
| 1212 | 1212 | 
| 1213     return outColors; | 1213     return outColors; | 
| 1214 } | 1214 } | 
| 1215 | 1215 | 
| 1216 #endif | 1216 #endif | 
| OLD | NEW | 
|---|