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

Side by Side Diff: src/effects/SkBitmapAlphaThresholdShader.cpp

Issue 25048002: Express (GLSL expression, possibly known value) pairs as a class (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: addressing review comments Created 7 years, 2 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/SkArithmeticMode.cpp ('k') | src/effects/SkColorMatrixFilter.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 2013 Google Inc. 2 * Copyright 2013 Google Inc.
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 "SkBitmapAlphaThresholdShader.h" 8 #include "SkBitmapAlphaThresholdShader.h"
9 9
10 class BATShader : public SkShader { 10 class BATShader : public SkShader {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 "\t\t\t\tfloat scale = thresh / color.a;\n" 142 "\t\t\t\tfloat scale = thresh / color.a;\n"
143 "\t\t\t\tcolor.rgb *= scale;\n" 143 "\t\t\t\tcolor.rgb *= scale;\n"
144 "\t\t\t\tcolor.a = thresh;\n" 144 "\t\t\t\tcolor.a = thresh;\n"
145 "\t\t\t}\n" 145 "\t\t\t}\n"
146 "\t\t} else if (color.a < thresh) {\n" 146 "\t\t} else if (color.a < thresh) {\n"
147 "\t\t\tfloat scale = thresh / color.a;\n" 147 "\t\t\tfloat scale = thresh / color.a;\n"
148 "\t\t\tcolor.rgb *= scale;\n" 148 "\t\t\tcolor.rgb *= scale;\n"
149 "\t\t\tcolor.a = thresh;\n" 149 "\t\t\tcolor.a = thresh;\n"
150 "\t\t}\n"); 150 "\t\t}\n");
151 151
152 builder->fsCodeAppend("color = "); 152 builder->fsCodeAppendf("color = %s = %s;\n", outputColor,
153 SkString outStr; 153 (GrGLSLExpr<4>(inputColor) * GrGLSLExpr<4>("c olor")).c_str());
154 outStr.appendf("\t\t%s = ", outputColor);
155 GrGLSLModulatef<4>(&outStr, inputColor, "color");
156 outStr.append(";\n");
157 builder->fsCodeAppend(outStr.c_str());
158 } 154 }
159 155
160 virtual void setData(const GrGLUniformManager& uman, const GrDrawEffect& e) SK_OVERRIDE { 156 virtual void setData(const GrGLUniformManager& uman, const GrDrawEffect& e) SK_OVERRIDE {
161 const ThresholdEffect& effect = e.castEffect<ThresholdEffect>(); 157 const ThresholdEffect& effect = e.castEffect<ThresholdEffect>();
162 if (fPrevThreshold != effect.fThreshold) { 158 if (fPrevThreshold != effect.fThreshold) {
163 uman.set1f(fThresholdUniHandle, effect.fThreshold); 159 uman.set1f(fThresholdUniHandle, effect.fThreshold);
164 } 160 }
165 } 161 }
166 162
167 private: 163 private:
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 GrEffectRef* effect = ThresholdEffect::Create(bmpTexture, bmpMatrix, 268 GrEffectRef* effect = ThresholdEffect::Create(bmpTexture, bmpMatrix,
273 maskTexture, maskMatrix, 269 maskTexture, maskMatrix,
274 fThreshold); 270 fThreshold);
275 271
276 GrUnlockAndUnrefCachedBitmapTexture(bmpTexture); 272 GrUnlockAndUnrefCachedBitmapTexture(bmpTexture);
277 273
278 return effect; 274 return effect;
279 } 275 }
280 276
281 #endif 277 #endif
OLDNEW
« no previous file with comments | « src/effects/SkArithmeticMode.cpp ('k') | src/effects/SkColorMatrixFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698