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

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

Issue 12547012: Make GrGLEffects use an interface to append their code. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 months 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 | Annotate | Revision Log
« no previous file with comments | « src/effects/SkTableColorFilter.cpp ('k') | src/effects/gradients/SkTwoPointConicalGradient.cpp » ('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 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 vsVaryingName, 780 vsVaryingName,
781 vsVaryingType); 781 vsVaryingType);
782 } 782 }
783 783
784 void GrGLGradientEffect::emitColorLookup(GrGLShaderBuilder* builder, 784 void GrGLGradientEffect::emitColorLookup(GrGLShaderBuilder* builder,
785 const char* gradientTValue, 785 const char* gradientTValue,
786 const char* outputColor, 786 const char* outputColor,
787 const char* inputColor, 787 const char* inputColor,
788 const GrGLShaderBuilder::TextureSampler & sampler) { 788 const GrGLShaderBuilder::TextureSampler & sampler) {
789 789
790 SkString* code = &builder->fFSCode; 790 builder->fsCodeAppendf("\tvec2 coord = vec2(%s, %s);\n",
791 code->appendf("\tvec2 coord = vec2(%s, %s);\n", 791 gradientTValue,
792 gradientTValue, 792 builder->getUniformVariable(fFSYUni).c_str());
793 builder->getUniformVariable(fFSYUni).c_str()); 793 builder->fsCodeAppendf("\t%s = ", outputColor);
794 code->appendf("\t%s = ", outputColor); 794 builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment_ShaderT ype,
795 builder->appendTextureLookupAndModulate(code, inputColor, sampler, "coord"); 795 inputColor,
796 code->append(";\n"); 796 sampler,
797 "coord");
798 builder->fsCodeAppend(";\n");
797 } 799 }
798 800
799 ///////////////////////////////////////////////////////////////////// 801 /////////////////////////////////////////////////////////////////////
800 802
801 GrGradientEffect::GrGradientEffect(GrContext* ctx, 803 GrGradientEffect::GrGradientEffect(GrContext* ctx,
802 const SkGradientShaderBase& shader, 804 const SkGradientShaderBase& shader,
803 const SkMatrix& matrix, 805 const SkMatrix& matrix,
804 SkShader::TileMode tileMode) { 806 SkShader::TileMode tileMode) {
805 // TODO: check for simple cases where we don't need a texture: 807 // TODO: check for simple cases where we don't need a texture:
806 //GradientInfo info; 808 //GradientInfo info;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 (*stops)[i] = stop; 890 (*stops)[i] = stop;
889 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f; 891 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f;
890 } 892 }
891 } 893 }
892 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount)); 894 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount));
893 895
894 return outColors; 896 return outColors;
895 } 897 }
896 898
897 #endif 899 #endif
OLDNEW
« no previous file with comments | « src/effects/SkTableColorFilter.cpp ('k') | src/effects/gradients/SkTwoPointConicalGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698