| 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 #include "glsl/GrGLSLUniformHandler.h" |
| 16 | 17 |
| 17 class GrGLConfigConversionEffect : public GrGLSLFragmentProcessor { | 18 class GrGLConfigConversionEffect : public GrGLSLFragmentProcessor { |
| 18 public: | 19 public: |
| 19 void emitCode(EmitArgs& args) override { | 20 void emitCode(EmitArgs& args) override { |
| 20 const GrConfigConversionEffect& cce = args.fFp.cast<GrConfigConversionEf
fect>(); | 21 const GrConfigConversionEffect& cce = args.fFp.cast<GrConfigConversionEf
fect>(); |
| 21 const GrSwizzle& swizzle = cce.swizzle(); | 22 const GrSwizzle& swizzle = cce.swizzle(); |
| 22 GrConfigConversionEffect::PMConversion pmConversion = cce.pmConversion()
; | 23 GrConfigConversionEffect::PMConversion pmConversion = cce.pmConversion()
; |
| 23 | 24 |
| 24 // Using highp for GLES here in order to avoid some precision issues on
specific GPUs. | 25 // 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); | 26 GrGLSLShaderVar tmpVar("tmpColor", kVec4f_GrSLType, 0, kHigh_GrSLPrecisi
on); |
| 26 SkString tmpDecl; | 27 SkString tmpDecl; |
| 27 tmpVar.appendDecl(args.fGLSLCaps, &tmpDecl); | 28 tmpVar.appendDecl(args.fGLSLCaps, &tmpDecl); |
| 28 | 29 |
| 29 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; | 30 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
| 30 | 31 |
| 31 fragBuilder->codeAppendf("%s;", tmpDecl.c_str()); | 32 fragBuilder->codeAppendf("%s;", tmpDecl.c_str()); |
| 32 | 33 |
| 33 fragBuilder->codeAppendf("%s = ", tmpVar.c_str()); | 34 fragBuilder->codeAppendf("%s = ", tmpVar.c_str()); |
| 34 fragBuilder->appendTextureLookup(args.fTexSamplers[0], args.fCoords[0].c
_str(), | 35 fragBuilder->appendTextureLookup(args.fUniformHandler->getSampler(args.f
TexSamplers[0]), |
| 35 args.fCoords[0].getType()); | 36 args.fCoords[0].c_str(), |
| 37 args.fCoords[0].getType()); |
| 36 fragBuilder->codeAppend(";"); | 38 fragBuilder->codeAppend(";"); |
| 37 | 39 |
| 38 if (GrConfigConversionEffect::kNone_PMConversion == pmConversion) { | 40 if (GrConfigConversionEffect::kNone_PMConversion == pmConversion) { |
| 39 SkASSERT(GrSwizzle::RGBA() != swizzle); | 41 SkASSERT(GrSwizzle::RGBA() != swizzle); |
| 40 fragBuilder->codeAppendf("%s = %s.%s;", args.fOutputColor, tmpVar.c_
str(), | 42 fragBuilder->codeAppendf("%s = %s.%s;", args.fOutputColor, tmpVar.c_
str(), |
| 41 swizzle.c_str()); | 43 swizzle.c_str()); |
| 42 } else { | 44 } else { |
| 43 switch (pmConversion) { | 45 switch (pmConversion) { |
| 44 case GrConfigConversionEffect::kMulByAlpha_RoundUp_PMConversion: | 46 case GrConfigConversionEffect::kMulByAlpha_RoundUp_PMConversion: |
| 45 fragBuilder->codeAppendf( | 47 fragBuilder->codeAppendf( |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 } else { | 303 } else { |
| 302 if (kRGBA_8888_GrPixelConfig != texture->config() && | 304 if (kRGBA_8888_GrPixelConfig != texture->config() && |
| 303 kBGRA_8888_GrPixelConfig != texture->config() && | 305 kBGRA_8888_GrPixelConfig != texture->config() && |
| 304 kNone_PMConversion != pmConversion) { | 306 kNone_PMConversion != pmConversion) { |
| 305 // The PM conversions assume colors are 0..255 | 307 // The PM conversions assume colors are 0..255 |
| 306 return nullptr; | 308 return nullptr; |
| 307 } | 309 } |
| 308 return new GrConfigConversionEffect(texture, swizzle, pmConversion, matr
ix); | 310 return new GrConfigConversionEffect(texture, swizzle, pmConversion, matr
ix); |
| 309 } | 311 } |
| 310 } | 312 } |
| OLD | NEW |