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 "GrInvariantOutput.h" | 10 #include "GrInvariantOutput.h" |
11 #include "GrSimpleTextureEffect.h" | 11 #include "GrSimpleTextureEffect.h" |
12 #include "SkMatrix.h" | 12 #include "SkMatrix.h" |
13 #include "gl/GrGLProcessor.h" | 13 #include "gl/GrGLProcessor.h" |
14 #include "gl/builders/GrGLProgramBuilder.h" | 14 #include "gl/builders/GrGLProgramBuilder.h" |
15 | 15 |
16 class GrGLConfigConversionEffect : public GrGLFragmentProcessor { | 16 class GrGLConfigConversionEffect : public GrGLFragmentProcessor { |
17 public: | 17 public: |
18 GrGLConfigConversionEffect(const GrProcessor& processor) { | 18 GrGLConfigConversionEffect(const GrProcessor& processor) { |
19 const GrConfigConversionEffect& configConversionEffect = | 19 const GrConfigConversionEffect& configConversionEffect = |
20 processor.cast<GrConfigConversionEffect>(); | 20 processor.cast<GrConfigConversionEffect>(); |
21 fSwapRedAndBlue = configConversionEffect.swapsRedAndBlue(); | 21 fSwapRedAndBlue = configConversionEffect.swapsRedAndBlue(); |
22 fPMConversion = configConversionEffect.pmConversion(); | 22 fPMConversion = configConversionEffect.pmConversion(); |
23 } | 23 } |
24 | 24 |
25 virtual void emitCode(GrGLFPBuilder* builder, | 25 virtual void emitCode(GrGLFPBuilder* builder, |
26 const GrFragmentProcessor&, | 26 const GrFragmentProcessor&, |
27 const char* outputColor, | 27 const char* outputColor, |
28 const char* inputColor, | 28 const char* inputColor, |
29 const TransformedCoordsArray& coords, | 29 const TransformedCoordsArray& coords, |
30 const TextureSamplerArray& samplers) SK_OVERRIDE { | 30 const TextureSamplerArray& samplers) override { |
31 // Using highp for GLES here in order to avoid some precision issues on
specific GPUs. | 31 // Using highp for GLES here in order to avoid some precision issues on
specific GPUs. |
32 GrGLShaderVar tmpVar("tmpColor", kVec4f_GrSLType, 0, kHigh_GrSLPrecision
); | 32 GrGLShaderVar tmpVar("tmpColor", kVec4f_GrSLType, 0, kHigh_GrSLPrecision
); |
33 SkString tmpDecl; | 33 SkString tmpDecl; |
34 tmpVar.appendDecl(builder->ctxInfo(), &tmpDecl); | 34 tmpVar.appendDecl(builder->ctxInfo(), &tmpDecl); |
35 | 35 |
36 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | 36 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
37 | 37 |
38 fsBuilder->codeAppendf("%s;", tmpDecl.c_str()); | 38 fsBuilder->codeAppendf("%s;", tmpDecl.c_str()); |
39 | 39 |
40 fsBuilder->codeAppendf("%s = ", tmpVar.c_str()); | 40 fsBuilder->codeAppendf("%s = ", tmpVar.c_str()); |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 kNone_PMConversion != pmConversion) { | 289 kNone_PMConversion != pmConversion) { |
290 // The PM conversions assume colors are 0..255 | 290 // The PM conversions assume colors are 0..255 |
291 return NULL; | 291 return NULL; |
292 } | 292 } |
293 return SkNEW_ARGS(GrConfigConversionEffect, (texture, | 293 return SkNEW_ARGS(GrConfigConversionEffect, (texture, |
294 swapRedAndBlue, | 294 swapRedAndBlue, |
295 pmConversion, | 295 pmConversion, |
296 matrix)); | 296 matrix)); |
297 } | 297 } |
298 } | 298 } |
OLD | NEW |