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" |
11 #include "GrSimpleTextureEffect.h" | 11 #include "GrSimpleTextureEffect.h" |
12 #include "gl/GrGLEffect.h" | 12 #include "gl/GrGLEffect.h" |
13 #include "SkMatrix.h" | 13 #include "SkMatrix.h" |
14 | 14 |
15 class GrGLConfigConversionEffect : public GrGLEffect { | 15 class GrGLConfigConversionEffect : public GrGLEffect { |
16 public: | 16 public: |
17 GrGLConfigConversionEffect(const GrBackendEffectFactory& factory, | 17 GrGLConfigConversionEffect(const GrBackendEffectFactory& factory, |
18 const GrDrawEffect& drawEffect) | 18 const GrDrawEffect& drawEffect) |
19 : INHERITED (factory) { | 19 : INHERITED (factory) { |
20 const GrConfigConversionEffect& effect = drawEffect.castEffect<GrConfigC
onversionEffect>(); | 20 const GrConfigConversionEffect& effect = drawEffect.castEffect<GrConfigC
onversionEffect>(); |
21 fSwapRedAndBlue = effect.swapsRedAndBlue(); | 21 fSwapRedAndBlue = effect.swapsRedAndBlue(); |
22 fPMConversion = effect.pmConversion(); | 22 fPMConversion = effect.pmConversion(); |
23 } | 23 } |
24 | 24 |
25 virtual void emitCode(GrGLShaderBuilder* builder, | 25 virtual void emitCode(GrGLShaderBuilder* builder, |
26 const GrDrawEffect&, | 26 const GrDrawEffect&, |
27 EffectKey key, | 27 EffectKey key, |
28 const char* outputColor, | 28 const char* outputColor, |
29 const char* inputColor, | 29 const GrGLSLExpr4& inputColor, |
30 const TransformedCoordsArray& coords, | 30 const TransformedCoordsArray& coords, |
31 const TextureSamplerArray& samplers) SK_OVERRIDE { | 31 const TextureSamplerArray& samplers) SK_OVERRIDE { |
32 builder->fsCodeAppendf("\t\t%s = ", outputColor); | 32 builder->fsCodeAppendf("\t\t%s = ", outputColor); |
33 builder->fsAppendTextureLookup(samplers[0], coords[0].c_str(), coords[0]
.type()); | 33 builder->fsAppendTextureLookup(samplers[0], coords[0].c_str(), coords[0]
.type()); |
34 builder->fsCodeAppend(";\n"); | 34 builder->fsCodeAppend(";\n"); |
35 if (GrConfigConversionEffect::kNone_PMConversion == fPMConversion) { | 35 if (GrConfigConversionEffect::kNone_PMConversion == fPMConversion) { |
36 SkASSERT(fSwapRedAndBlue); | 36 SkASSERT(fSwapRedAndBlue); |
37 builder->fsCodeAppendf("\t%s = %s.bgra;\n", outputColor, outputColor
); | 37 builder->fsCodeAppendf("\t%s = %s.bgra;\n", outputColor, outputColor
); |
38 } else { | 38 } else { |
39 const char* swiz = fSwapRedAndBlue ? "bgr" : "rgb"; | 39 const char* swiz = fSwapRedAndBlue ? "bgr" : "rgb"; |
(...skipping 228 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 |