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 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSweepGradient) | 727 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSweepGradient) |
728 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTwoPointRadialGradient) | 728 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTwoPointRadialGradient) |
729 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTwoPointConicalGradient) | 729 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTwoPointConicalGradient) |
730 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 730 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
731 | 731 |
732 /////////////////////////////////////////////////////////////////////////////// | 732 /////////////////////////////////////////////////////////////////////////////// |
733 | 733 |
734 #if SK_SUPPORT_GPU | 734 #if SK_SUPPORT_GPU |
735 | 735 |
736 #include "effects/GrTextureStripAtlas.h" | 736 #include "effects/GrTextureStripAtlas.h" |
| 737 #include "GrTBackendEffectFactory.h" |
737 #include "SkGr.h" | 738 #include "SkGr.h" |
738 | 739 |
739 GrGLGradientEffect::GrGLGradientEffect(const GrBackendEffectFactory& factory) | 740 GrGLGradientEffect::GrGLGradientEffect(const GrBackendEffectFactory& factory) |
740 : INHERITED(factory) | 741 : INHERITED(factory) |
741 , fCachedYCoord(SK_ScalarMax) | 742 , fCachedYCoord(SK_ScalarMax) |
742 , fFSYUni(GrGLUniformManager::kInvalidUniformHandle) { | 743 , fFSYUni(GrGLUniformManager::kInvalidUniformHandle) |
| 744 , fEffectMatrix(kCoordsType) { |
743 } | 745 } |
744 | 746 |
745 GrGLGradientEffect::~GrGLGradientEffect() { } | 747 GrGLGradientEffect::~GrGLGradientEffect() { } |
746 | 748 |
747 void GrGLGradientEffect::emitYCoordUniform(GrGLShaderBuilder* builder) { | 749 void GrGLGradientEffect::emitYCoordUniform(GrGLShaderBuilder* builder) { |
748 fFSYUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, | 750 fFSYUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, |
749 kFloat_GrSLType, "GradientYCoordFS"); | 751 kFloat_GrSLType, "GradientYCoordFS"); |
750 } | 752 } |
751 | 753 |
752 void GrGLGradientEffect::setData(const GrGLUniformManager& uman, const GrEffectS
tage& stage) { | 754 void GrGLGradientEffect::setData(const GrGLUniformManager& uman, |
753 const GrGradientEffect& e = GetEffectFromStage<GrGradientEffect>(stage); | 755 const GrDrawEffect& drawEffect) { |
| 756 const GrGradientEffect& e = drawEffect.castEffect<GrGradientEffect>(); |
754 const GrTexture* texture = e.texture(0); | 757 const GrTexture* texture = e.texture(0); |
755 fEffectMatrix.setData(uman, e.getMatrix(), stage.getCoordChangeMatrix(), tex
ture); | 758 fEffectMatrix.setData(uman, e.getMatrix(), drawEffect, texture); |
756 | 759 |
757 SkScalar yCoord = e.getYCoord(); | 760 SkScalar yCoord = e.getYCoord(); |
758 if (yCoord != fCachedYCoord) { | 761 if (yCoord != fCachedYCoord) { |
759 uman.set1f(fFSYUni, yCoord); | 762 uman.set1f(fFSYUni, yCoord); |
760 fCachedYCoord = yCoord; | 763 fCachedYCoord = yCoord; |
761 } | 764 } |
762 } | 765 } |
763 | 766 |
764 GrGLEffect::EffectKey GrGLGradientEffect::GenMatrixKey(const GrEffectStage& s) { | 767 GrGLEffect::EffectKey GrGLGradientEffect::GenMatrixKey(const GrDrawEffect& drawE
ffect) { |
765 const GrGradientEffect& e = GetEffectFromStage<GrGradientEffect>(s); | 768 const GrGradientEffect& e = drawEffect.castEffect<GrGradientEffect>(); |
766 const GrTexture* texture = e.texture(0); | 769 const GrTexture* texture = e.texture(0); |
767 return GrGLEffectMatrix::GenKey(e.getMatrix(), s.getCoordChangeMatrix(), tex
ture); | 770 return GrGLEffectMatrix::GenKey(e.getMatrix(), drawEffect, kCoordsType, text
ure); |
768 } | 771 } |
769 | 772 |
770 void GrGLGradientEffect::setupMatrix(GrGLShaderBuilder* builder, | 773 void GrGLGradientEffect::setupMatrix(GrGLShaderBuilder* builder, |
771 EffectKey key, | 774 EffectKey key, |
772 const char* vertexCoords, | |
773 const char** fsCoordName, | 775 const char** fsCoordName, |
774 const char** vsVaryingName, | 776 const char** vsVaryingName, |
775 GrSLType* vsVaryingType) { | 777 GrSLType* vsVaryingType) { |
776 fEffectMatrix.emitCodeMakeFSCoords2D(builder, | 778 fEffectMatrix.emitCodeMakeFSCoords2D(builder, |
777 key & kMatrixKeyMask, | 779 key & kMatrixKeyMask, |
778 vertexCoords, | |
779 fsCoordName, | 780 fsCoordName, |
780 vsVaryingName, | 781 vsVaryingName, |
781 vsVaryingType); | 782 vsVaryingType); |
782 } | 783 } |
783 | 784 |
784 void GrGLGradientEffect::emitColorLookup(GrGLShaderBuilder* builder, | 785 void GrGLGradientEffect::emitColorLookup(GrGLShaderBuilder* builder, |
785 const char* gradientTValue, | 786 const char* gradientTValue, |
786 const char* outputColor, | 787 const char* outputColor, |
787 const char* inputColor, | 788 const char* inputColor, |
788 const GrGLShaderBuilder::TextureSampler
& sampler) { | 789 const GrGLShaderBuilder::TextureSampler
& sampler) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 (*stops)[i] = stop; | 891 (*stops)[i] = stop; |
891 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; | 892 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; |
892 } | 893 } |
893 } | 894 } |
894 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); | 895 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); |
895 | 896 |
896 return outColors; | 897 return outColors; |
897 } | 898 } |
898 | 899 |
899 #endif | 900 #endif |
OLD | NEW |