OLD | NEW |
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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 "\t\t\t\tfloat scale = thresh / color.a;\n" | 154 "\t\t\t\tfloat scale = thresh / color.a;\n" |
155 "\t\t\t\tcolor.rgb *= scale;\n" | 155 "\t\t\t\tcolor.rgb *= scale;\n" |
156 "\t\t\t\tcolor.a = thresh;\n" | 156 "\t\t\t\tcolor.a = thresh;\n" |
157 "\t\t\t}\n" | 157 "\t\t\t}\n" |
158 "\t\t} else if (color.a < thresh) {\n" | 158 "\t\t} else if (color.a < thresh) {\n" |
159 "\t\t\tfloat scale = thresh / color.a;\n" | 159 "\t\t\tfloat scale = thresh / color.a;\n" |
160 "\t\t\tcolor.rgb *= scale;\n" | 160 "\t\t\tcolor.rgb *= scale;\n" |
161 "\t\t\tcolor.a = thresh;\n" | 161 "\t\t\tcolor.a = thresh;\n" |
162 "\t\t}\n"); | 162 "\t\t}\n"); |
163 | 163 |
164 builder->fsCodeAppend("color = "); | 164 builder->fsCodeAppendf("color = %s = %s;\n", outputColor, |
165 SkString outStr; | 165 (GrGLSLExpr<4>(inputColor) * GrGLSLExpr<4>("c
olor")).c_str()); |
166 outStr.appendf("\t\t%s = ", outputColor); | |
167 GrGLSLModulatef<4>(&outStr, inputColor, "color"); | |
168 outStr.append(";\n"); | |
169 builder->fsCodeAppend(outStr.c_str()); | |
170 } | 166 } |
171 | 167 |
172 virtual void setData(const GrGLUniformManager& uman, const GrDrawEffect&
e) SK_OVERRIDE { | 168 virtual void setData(const GrGLUniformManager& uman, const GrDrawEffect&
e) SK_OVERRIDE { |
173 const ThresholdEffect& effect = e.castEffect<ThresholdEffect>(); | 169 const ThresholdEffect& effect = e.castEffect<ThresholdEffect>(); |
174 fBmpMatrix.setData(uman, effect.fBmpMatrix, e, effect.fBmpAccess.get
Texture()); | 170 fBmpMatrix.setData(uman, effect.fBmpMatrix, e, effect.fBmpAccess.get
Texture()); |
175 fMaskMatrix.setData(uman, effect.fMaskMatrix, e, effect.fMaskAccess.
getTexture()); | 171 fMaskMatrix.setData(uman, effect.fMaskMatrix, e, effect.fMaskAccess.
getTexture()); |
176 if (fPrevThreshold != effect.fThreshold) { | 172 if (fPrevThreshold != effect.fThreshold) { |
177 uman.set1f(fThresholdUniHandle, effect.fThreshold); | 173 uman.set1f(fThresholdUniHandle, effect.fThreshold); |
178 } | 174 } |
179 } | 175 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 GrEffectRef* effect = ThresholdEffect::Create(bmpTexture, bmpMatrix, | 298 GrEffectRef* effect = ThresholdEffect::Create(bmpTexture, bmpMatrix, |
303 maskTexture, maskMatrix, | 299 maskTexture, maskMatrix, |
304 fThreshold); | 300 fThreshold); |
305 | 301 |
306 GrUnlockAndUnrefCachedBitmapTexture(bmpTexture); | 302 GrUnlockAndUnrefCachedBitmapTexture(bmpTexture); |
307 | 303 |
308 return effect; | 304 return effect; |
309 } | 305 } |
310 | 306 |
311 #endif | 307 #endif |
OLD | NEW |