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 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 | 825 |
826 GrGLGradientEffect::GrGLGradientEffect(const GrBackendEffectFactory& factory) | 826 GrGLGradientEffect::GrGLGradientEffect(const GrBackendEffectFactory& factory) |
827 : INHERITED(factory) | 827 : INHERITED(factory) |
828 , fCachedYCoord(SK_ScalarMax) | 828 , fCachedYCoord(SK_ScalarMax) |
829 , fEffectMatrix(kCoordsType) { | 829 , fEffectMatrix(kCoordsType) { |
830 } | 830 } |
831 | 831 |
832 GrGLGradientEffect::~GrGLGradientEffect() { } | 832 GrGLGradientEffect::~GrGLGradientEffect() { } |
833 | 833 |
834 void GrGLGradientEffect::emitYCoordUniform(GrGLShaderBuilder* builder) { | 834 void GrGLGradientEffect::emitYCoordUniform(GrGLShaderBuilder* builder) { |
835 fFSYUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, | 835 fFSYUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, |
836 kFloat_GrSLType, "GradientYCoordFS"); | 836 kFloat_GrSLType, "GradientYCoordFS"); |
837 } | 837 } |
838 | 838 |
839 void GrGLGradientEffect::setData(const GrGLUniformManager& uman, | 839 void GrGLGradientEffect::setData(const GrGLUniformManager& uman, |
840 const GrDrawEffect& drawEffect) { | 840 const GrDrawEffect& drawEffect) { |
841 const GrGradientEffect& e = drawEffect.castEffect<GrGradientEffect>(); | 841 const GrGradientEffect& e = drawEffect.castEffect<GrGradientEffect>(); |
842 const GrTexture* texture = e.texture(0); | 842 const GrTexture* texture = e.texture(0); |
843 fEffectMatrix.setData(uman, e.getMatrix(), drawEffect, texture); | 843 fEffectMatrix.setData(uman, e.getMatrix(), drawEffect, texture); |
844 | 844 |
845 SkScalar yCoord = e.getYCoord(); | 845 SkScalar yCoord = e.getYCoord(); |
(...skipping 24 matching lines...) Expand all Loading... |
870 void GrGLGradientEffect::emitColorLookup(GrGLShaderBuilder* builder, | 870 void GrGLGradientEffect::emitColorLookup(GrGLShaderBuilder* builder, |
871 const char* gradientTValue, | 871 const char* gradientTValue, |
872 const char* outputColor, | 872 const char* outputColor, |
873 const char* inputColor, | 873 const char* inputColor, |
874 const GrGLShaderBuilder::TextureSampler
& sampler) { | 874 const GrGLShaderBuilder::TextureSampler
& sampler) { |
875 | 875 |
876 builder->fsCodeAppendf("\tvec2 coord = vec2(%s, %s);\n", | 876 builder->fsCodeAppendf("\tvec2 coord = vec2(%s, %s);\n", |
877 gradientTValue, | 877 gradientTValue, |
878 builder->getUniformVariable(fFSYUni).c_str()); | 878 builder->getUniformVariable(fFSYUni).c_str()); |
879 builder->fsCodeAppendf("\t%s = ", outputColor); | 879 builder->fsCodeAppendf("\t%s = ", outputColor); |
880 builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment_ShaderT
ype, | 880 builder->fsAppendTextureLookupAndModulate(inputColor, sampler, "coord"); |
881 inputColor, | |
882 sampler, | |
883 "coord"); | |
884 builder->fsCodeAppend(";\n"); | 881 builder->fsCodeAppend(";\n"); |
885 } | 882 } |
886 | 883 |
887 ///////////////////////////////////////////////////////////////////// | 884 ///////////////////////////////////////////////////////////////////// |
888 | 885 |
889 GrGradientEffect::GrGradientEffect(GrContext* ctx, | 886 GrGradientEffect::GrGradientEffect(GrContext* ctx, |
890 const SkGradientShaderBase& shader, | 887 const SkGradientShaderBase& shader, |
891 const SkMatrix& matrix, | 888 const SkMatrix& matrix, |
892 SkShader::TileMode tileMode) { | 889 SkShader::TileMode tileMode) { |
893 // TODO: check for simple cases where we don't need a texture: | 890 // TODO: check for simple cases where we don't need a texture: |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 (*stops)[i] = stop; | 973 (*stops)[i] = stop; |
977 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; | 974 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; |
978 } | 975 } |
979 } | 976 } |
980 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); | 977 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); |
981 | 978 |
982 return outColors; | 979 return outColors; |
983 } | 980 } |
984 | 981 |
985 #endif | 982 #endif |
OLD | NEW |