Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: src/effects/gradients/SkGradientShader.cpp

Issue 1428543003: Create GLSL base class for ProgramDataManager (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add space Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/effects/SkTableColorFilter.cpp ('k') | src/effects/gradients/SkGradientShaderPriv.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 903 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
904 904
905 /////////////////////////////////////////////////////////////////////////////// 905 ///////////////////////////////////////////////////////////////////////////////
906 906
907 #if SK_SUPPORT_GPU 907 #if SK_SUPPORT_GPU
908 908
909 #include "effects/GrTextureStripAtlas.h" 909 #include "effects/GrTextureStripAtlas.h"
910 #include "GrInvariantOutput.h" 910 #include "GrInvariantOutput.h"
911 #include "gl/GrGLContext.h" 911 #include "gl/GrGLContext.h"
912 #include "gl/builders/GrGLProgramBuilder.h" 912 #include "gl/builders/GrGLProgramBuilder.h"
913 #include "glsl/GrGLSLProgramDataManager.h"
913 #include "SkGr.h" 914 #include "SkGr.h"
914 915
915 GrGLGradientEffect::GrGLGradientEffect() 916 GrGLGradientEffect::GrGLGradientEffect()
916 : fCachedYCoord(SK_ScalarMax) { 917 : fCachedYCoord(SK_ScalarMax) {
917 } 918 }
918 919
919 GrGLGradientEffect::~GrGLGradientEffect() { } 920 GrGLGradientEffect::~GrGLGradientEffect() { }
920 921
921 void GrGLGradientEffect::emitUniforms(GrGLFPBuilder* builder, const GrGradientEf fect& ge) { 922 void GrGLGradientEffect::emitUniforms(GrGLFPBuilder* builder, const GrGradientEf fect& ge) {
922 923
(...skipping 16 matching lines...) Expand all
939 kVec4f_GrSLType, kDefault_GrSLPrecisi on, 940 kVec4f_GrSLType, kDefault_GrSLPrecisi on,
940 "GradientEndColor"); 941 "GradientEndColor");
941 942
942 } else { // if not a fast case 943 } else { // if not a fast case
943 fFSYUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility, 944 fFSYUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
944 kFloat_GrSLType, kDefault_GrSLPrecision, 945 kFloat_GrSLType, kDefault_GrSLPrecision,
945 "GradientYCoordFS"); 946 "GradientYCoordFS");
946 } 947 }
947 } 948 }
948 949
949 static inline void set_color_uni(const GrGLProgramDataManager& pdman, 950 static inline void set_color_uni(const GrGLSLProgramDataManager& pdman,
950 const GrGLProgramDataManager::UniformHandle uni , 951 const GrGLSLProgramDataManager::UniformHandle u ni,
951 const SkColor* color) { 952 const SkColor* color) {
952 pdman.set4f(uni, 953 pdman.set4f(uni,
953 SkColorGetR(*color) / 255.f, 954 SkColorGetR(*color) / 255.f,
954 SkColorGetG(*color) / 255.f, 955 SkColorGetG(*color) / 255.f,
955 SkColorGetB(*color) / 255.f, 956 SkColorGetB(*color) / 255.f,
956 SkColorGetA(*color) / 255.f); 957 SkColorGetA(*color) / 255.f);
957 } 958 }
958 959
959 static inline void set_mul_color_uni(const GrGLProgramDataManager& pdman, 960 static inline void set_mul_color_uni(const GrGLSLProgramDataManager& pdman,
960 const GrGLProgramDataManager::UniformHandle uni, 961 const GrGLSLProgramDataManager::UniformHand le uni,
961 const SkColor* color){ 962 const SkColor* color){
962 float a = SkColorGetA(*color) / 255.f; 963 float a = SkColorGetA(*color) / 255.f;
963 float aDiv255 = a / 255.f; 964 float aDiv255 = a / 255.f;
964 pdman.set4f(uni, 965 pdman.set4f(uni,
965 SkColorGetR(*color) * aDiv255, 966 SkColorGetR(*color) * aDiv255,
966 SkColorGetG(*color) * aDiv255, 967 SkColorGetG(*color) * aDiv255,
967 SkColorGetB(*color) * aDiv255, 968 SkColorGetB(*color) * aDiv255,
968 a); 969 a);
969 } 970 }
970 971
971 void GrGLGradientEffect::onSetData(const GrGLProgramDataManager& pdman, 972 void GrGLGradientEffect::onSetData(const GrGLSLProgramDataManager& pdman,
972 const GrProcessor& processor) { 973 const GrProcessor& processor) {
973 974
974 const GrGradientEffect& e = processor.cast<GrGradientEffect>(); 975 const GrGradientEffect& e = processor.cast<GrGradientEffect>();
975 976
976 977
977 if (SkGradientShaderBase::kTwo_GpuColorType == e.getColorType()){ 978 if (SkGradientShaderBase::kTwo_GpuColorType == e.getColorType()){
978 979
979 if (GrGradientEffect::kBeforeInterp_PremulType == e.getPremulType()) { 980 if (GrGradientEffect::kBeforeInterp_PremulType == e.getPremulType()) {
980 set_mul_color_uni(pdman, fColorStartUni, e.getColors(0)); 981 set_mul_color_uni(pdman, fColorStartUni, e.getColors(0));
981 set_mul_color_uni(pdman, fColorEndUni, e.getColors(1)); 982 set_mul_color_uni(pdman, fColorEndUni, e.getColors(1));
982 } else { 983 } else {
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 (*stops)[i] = stop; 1206 (*stops)[i] = stop;
1206 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f; 1207 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f;
1207 } 1208 }
1208 } 1209 }
1209 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount)); 1210 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount));
1210 1211
1211 return outColors; 1212 return outColors;
1212 } 1213 }
1213 1214
1214 #endif 1215 #endif
OLDNEW
« no previous file with comments | « src/effects/SkTableColorFilter.cpp ('k') | src/effects/gradients/SkGradientShaderPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698