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 "GrDrawContext.h" | 10 #include "GrDrawContext.h" |
11 #include "GrInvariantOutput.h" | 11 #include "GrInvariantOutput.h" |
12 #include "GrSimpleTextureEffect.h" | 12 #include "GrSimpleTextureEffect.h" |
13 #include "SkMatrix.h" | 13 #include "SkMatrix.h" |
14 #include "glsl/GrGLSLFragmentProcessor.h" | 14 #include "glsl/GrGLSLFragmentProcessor.h" |
15 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 15 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
16 | 16 |
17 class GrGLConfigConversionEffect : public GrGLSLFragmentProcessor { | 17 class GrGLConfigConversionEffect : public GrGLSLFragmentProcessor { |
18 public: | 18 public: |
19 void emitCode(EmitArgs& args) override { | 19 void emitCode(EmitArgs& args) override { |
20 const GrConfigConversionEffect& cce = args.fFp.cast<GrConfigConversionEf
fect>(); | 20 const GrConfigConversionEffect& cce = args.fFp.cast<GrConfigConversionEf
fect>(); |
21 const GrSwizzle& swizzle = cce.swizzle(); | 21 const GrSwizzle& swizzle = cce.swizzle(); |
22 GrConfigConversionEffect::PMConversion pmConversion = cce.pmConversion()
; | 22 GrConfigConversionEffect::PMConversion pmConversion = cce.pmConversion()
; |
23 | 23 |
24 // Using highp for GLES here in order to avoid some precision issues on
specific GPUs. | 24 // Using highp for GLES here in order to avoid some precision issues on
specific GPUs. |
25 GrGLSLShaderVar tmpVar("tmpColor", kVec4f_GrSLType, 0, kHigh_GrSLPrecisi
on); | 25 GrGLSLShaderVar tmpVar("tmpColor", kVec4f_GrSLType, 0, kHigh_GrSLPrecisi
on); |
26 SkString tmpDecl; | 26 SkString tmpDecl; |
27 tmpVar.appendDecl(args.fGLSLCaps, &tmpDecl); | 27 tmpVar.appendDecl(args.fGLSLCaps, &tmpDecl); |
28 | 28 |
29 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; | 29 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
30 | 30 |
31 fragBuilder->codeAppendf("%s;", tmpDecl.c_str()); | 31 fragBuilder->codeAppendf("%s;", tmpDecl.c_str()); |
32 | 32 |
33 fragBuilder->codeAppendf("%s = ", tmpVar.c_str()); | 33 fragBuilder->codeAppendf("%s = ", tmpVar.c_str()); |
34 fragBuilder->appendTextureLookup(args.fSamplers[0], args.fCoords[0].c_st
r(), | 34 fragBuilder->appendTextureLookup(args.fSamplers[0], args.fCoords[0].c_st
r(), |
35 args.fCoords[0].getType()); | 35 args.fCoords[0].getType()); |
36 fragBuilder->codeAppend(";"); | 36 fragBuilder->codeAppend(";"); |
37 | 37 |
38 if (GrConfigConversionEffect::kNone_PMConversion == pmConversion) { | 38 if (GrConfigConversionEffect::kNone_PMConversion == pmConversion) { |
39 SkASSERT(GrSwizzle::RGBA() != swizzle); | 39 SkASSERT(GrSwizzle::RGBA() != swizzle); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 } else { | 296 } else { |
297 if (kRGBA_8888_GrPixelConfig != texture->config() && | 297 if (kRGBA_8888_GrPixelConfig != texture->config() && |
298 kBGRA_8888_GrPixelConfig != texture->config() && | 298 kBGRA_8888_GrPixelConfig != texture->config() && |
299 kNone_PMConversion != pmConversion) { | 299 kNone_PMConversion != pmConversion) { |
300 // The PM conversions assume colors are 0..255 | 300 // The PM conversions assume colors are 0..255 |
301 return nullptr; | 301 return nullptr; |
302 } | 302 } |
303 return new GrConfigConversionEffect(texture, swizzle, pmConversion, matr
ix); | 303 return new GrConfigConversionEffect(texture, swizzle, pmConversion, matr
ix); |
304 } | 304 } |
305 } | 305 } |
OLD | NEW |