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 "SkArithmeticMode.h" | 8 #include "SkArithmeticMode.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 virtual ~GrGLArithmeticEffect(); | 241 virtual ~GrGLArithmeticEffect(); |
242 | 242 |
243 virtual void emitCode(GrGLShaderBuilder*, | 243 virtual void emitCode(GrGLShaderBuilder*, |
244 const GrDrawEffect&, | 244 const GrDrawEffect&, |
245 const GrEffectKey&, | 245 const GrEffectKey&, |
246 const char* outputColor, | 246 const char* outputColor, |
247 const char* inputColor, | 247 const char* inputColor, |
248 const TransformedCoordsArray&, | 248 const TransformedCoordsArray&, |
249 const TextureSamplerArray&) SK_OVERRIDE; | 249 const TextureSamplerArray&) SK_OVERRIDE; |
250 | 250 |
251 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER
RIDE; | 251 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_
OVERRIDE; |
252 | 252 |
253 static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBui
lder* b); | 253 static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBui
lder* b); |
254 | 254 |
255 private: | 255 private: |
256 GrGLUniformManager::UniformHandle fKUni; | 256 GrGLProgramDataManager::UniformHandle fKUni; |
257 bool fEnforcePMColor; | 257 bool fEnforcePMColor; |
258 | 258 |
259 typedef GrGLEffect INHERITED; | 259 typedef GrGLEffect INHERITED; |
260 }; | 260 }; |
261 | 261 |
262 /////////////////////////////////////////////////////////////////////////////// | 262 /////////////////////////////////////////////////////////////////////////////// |
263 | 263 |
264 class GrArithmeticEffect : public GrEffect { | 264 class GrArithmeticEffect : public GrEffect { |
265 public: | 265 public: |
266 static GrEffect* Create(float k1, float k2, float k3, float k4, bool enforce
PMColor, | 266 static GrEffect* Create(float k1, float k2, float k3, float k4, bool enforce
PMColor, |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 | 388 |
389 builder->fsCodeAppendf("\t\t%s = %s.x * src * dst + %s.y * src + %s.z * dst
+ %s.w;\n", outputColor, kUni, kUni, kUni, kUni); | 389 builder->fsCodeAppendf("\t\t%s = %s.x * src * dst + %s.y * src + %s.z * dst
+ %s.w;\n", outputColor, kUni, kUni, kUni, kUni); |
390 builder->fsCodeAppendf("\t\t%s = clamp(%s, 0.0, 1.0);\n", outputColor, outpu
tColor); | 390 builder->fsCodeAppendf("\t\t%s = clamp(%s, 0.0, 1.0);\n", outputColor, outpu
tColor); |
391 if (gUseUnpremul) { | 391 if (gUseUnpremul) { |
392 builder->fsCodeAppendf("\t\t%s.rgb *= %s.a;\n", outputColor, outputColor
); | 392 builder->fsCodeAppendf("\t\t%s.rgb *= %s.a;\n", outputColor, outputColor
); |
393 } else if (fEnforcePMColor) { | 393 } else if (fEnforcePMColor) { |
394 builder->fsCodeAppendf("\t\t%s.rgb = min(%s.rgb, %s.a);\n", outputColor,
outputColor, outputColor); | 394 builder->fsCodeAppendf("\t\t%s.rgb = min(%s.rgb, %s.a);\n", outputColor,
outputColor, outputColor); |
395 } | 395 } |
396 } | 396 } |
397 | 397 |
398 void GrGLArithmeticEffect::setData(const GrGLUniformManager& uman, const GrDrawE
ffect& drawEffect) { | 398 void GrGLArithmeticEffect::setData(const GrGLProgramDataManager& pdman, const Gr
DrawEffect& drawEffect) { |
399 const GrArithmeticEffect& arith = drawEffect.castEffect<GrArithmeticEffect>(
); | 399 const GrArithmeticEffect& arith = drawEffect.castEffect<GrArithmeticEffect>(
); |
400 uman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4()); | 400 pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4()); |
401 fEnforcePMColor = arith.enforcePMColor(); | 401 fEnforcePMColor = arith.enforcePMColor(); |
402 } | 402 } |
403 | 403 |
404 void GrGLArithmeticEffect::GenKey(const GrDrawEffect& drawEffect, | 404 void GrGLArithmeticEffect::GenKey(const GrDrawEffect& drawEffect, |
405 const GrGLCaps&, GrEffectKeyBuilder* b) { | 405 const GrGLCaps&, GrEffectKeyBuilder* b) { |
406 const GrArithmeticEffect& arith = drawEffect.castEffect<GrArithmeticEffect>(
); | 406 const GrArithmeticEffect& arith = drawEffect.castEffect<GrArithmeticEffect>(
); |
407 uint32_t key = arith.enforcePMColor() ? 1 : 0; | 407 uint32_t key = arith.enforcePMColor() ? 1 : 0; |
408 if (arith.backgroundTexture()) { | 408 if (arith.backgroundTexture()) { |
409 key |= 2; | 409 key |= 2; |
410 } | 410 } |
(...skipping 25 matching lines...) Expand all Loading... |
436 background); | 436 background); |
437 } | 437 } |
438 return true; | 438 return true; |
439 } | 439 } |
440 | 440 |
441 #endif | 441 #endif |
442 | 442 |
443 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode) | 443 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode) |
444 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar) | 444 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar) |
445 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 445 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |