| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrConfigConversionEffect.h" | 8 #include "GrConfigConversionEffect.h" |
| 9 #include "GrContext.h" | 9 #include "GrContext.h" |
| 10 #include "GrTBackendEffectFactory.h" | 10 #include "GrTBackendEffectFactory.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 break; | 54 break; |
| 55 case GrConfigConversionEffect::kDivByAlpha_RoundUp_PMConversion: | 55 case GrConfigConversionEffect::kDivByAlpha_RoundUp_PMConversion: |
| 56 builder->fsCodeAppendf("\t\t%s = %s.a <= 0.0 ? vec4(0,0,0,0)
: vec4(ceil(%s.%s / %s.a * 255.0) / 255.0, %s.a);\n", | 56 builder->fsCodeAppendf("\t\t%s = %s.a <= 0.0 ? vec4(0,0,0,0)
: vec4(ceil(%s.%s / %s.a * 255.0) / 255.0, %s.a);\n", |
| 57 outputColor, outputColor, outputColor, swiz, outputColor
, outputColor); | 57 outputColor, outputColor, outputColor, swiz, outputColor
, outputColor); |
| 58 break; | 58 break; |
| 59 case GrConfigConversionEffect::kDivByAlpha_RoundDown_PMConversio
n: | 59 case GrConfigConversionEffect::kDivByAlpha_RoundDown_PMConversio
n: |
| 60 builder->fsCodeAppendf("\t\t%s = %s.a <= 0.0 ? vec4(0,0,0,0)
: vec4(floor(%s.%s / %s.a * 255.0) / 255.0, %s.a);\n", | 60 builder->fsCodeAppendf("\t\t%s = %s.a <= 0.0 ? vec4(0,0,0,0)
: vec4(floor(%s.%s / %s.a * 255.0) / 255.0, %s.a);\n", |
| 61 outputColor, outputColor, outputColor, swiz, outputColor
, outputColor); | 61 outputColor, outputColor, outputColor, swiz, outputColor
, outputColor); |
| 62 break; | 62 break; |
| 63 default: | 63 default: |
| 64 GrCrash("Unknown conversion op."); | 64 SkFAIL("Unknown conversion op."); |
| 65 break; | 65 break; |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 SkString modulate; | 68 SkString modulate; |
| 69 GrGLSLMulVarBy4f(&modulate, 2, outputColor, inputColor); | 69 GrGLSLMulVarBy4f(&modulate, 2, outputColor, inputColor); |
| 70 builder->fsCodeAppend(modulate.c_str()); | 70 builder->fsCodeAppend(modulate.c_str()); |
| 71 } | 71 } |
| 72 | 72 |
| 73 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCap
s&) { | 73 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCap
s&) { |
| 74 const GrConfigConversionEffect& conv = drawEffect.castEffect<GrConfigCon
versionEffect>(); | 74 const GrConfigConversionEffect& conv = drawEffect.castEffect<GrConfigCon
versionEffect>(); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 // The PM conversions assume colors are 0..255 | 268 // The PM conversions assume colors are 0..255 |
| 269 return NULL; | 269 return NULL; |
| 270 } | 270 } |
| 271 AutoEffectUnref effect(SkNEW_ARGS(GrConfigConversionEffect, (texture, | 271 AutoEffectUnref effect(SkNEW_ARGS(GrConfigConversionEffect, (texture, |
| 272 swapRedAndB
lue, | 272 swapRedAndB
lue, |
| 273 pmConversio
n, | 273 pmConversio
n, |
| 274 matrix))); | 274 matrix))); |
| 275 return CreateEffectRef(effect); | 275 return CreateEffectRef(effect); |
| 276 } | 276 } |
| 277 } | 277 } |
| OLD | NEW |