| 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 12 matching lines...) Expand all Loading... |
| 23 fSwapRedAndBlue = effect.swapsRedAndBlue(); | 23 fSwapRedAndBlue = effect.swapsRedAndBlue(); |
| 24 fPMConversion = effect.pmConversion(); | 24 fPMConversion = effect.pmConversion(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 virtual void emitCode(GrGLShaderBuilder* builder, | 27 virtual void emitCode(GrGLShaderBuilder* builder, |
| 28 const GrDrawEffect&, | 28 const GrDrawEffect&, |
| 29 EffectKey key, | 29 EffectKey key, |
| 30 const char* outputColor, | 30 const char* outputColor, |
| 31 const char* inputColor, | 31 const char* inputColor, |
| 32 const TextureSamplerArray& samplers) SK_OVERRIDE { | 32 const TextureSamplerArray& samplers) SK_OVERRIDE { |
| 33 const char* coords; | 33 SkString coords; |
| 34 GrSLType coordsType = fEffectMatrix.emitCode(builder, key, &coords); | 34 GrSLType coordsType = fEffectMatrix.emitCode(builder, key, &coords); |
| 35 builder->fsCodeAppendf("\t\t%s = ", outputColor); | 35 builder->fsCodeAppendf("\t\t%s = ", outputColor); |
| 36 builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, | 36 builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, |
| 37 samplers[0], | 37 samplers[0], |
| 38 coords, | 38 coords.c_str(), |
| 39 coordsType); | 39 coordsType); |
| 40 builder->fsCodeAppend(";\n"); | 40 builder->fsCodeAppend(";\n"); |
| 41 if (GrConfigConversionEffect::kNone_PMConversion == fPMConversion) { | 41 if (GrConfigConversionEffect::kNone_PMConversion == fPMConversion) { |
| 42 SkASSERT(fSwapRedAndBlue); | 42 SkASSERT(fSwapRedAndBlue); |
| 43 builder->fsCodeAppendf("\t%s = %s.bgra;\n", outputColor, outputColor
); | 43 builder->fsCodeAppendf("\t%s = %s.bgra;\n", outputColor, outputColor
); |
| 44 } else { | 44 } else { |
| 45 const char* swiz = fSwapRedAndBlue ? "bgr" : "rgb"; | 45 const char* swiz = fSwapRedAndBlue ? "bgr" : "rgb"; |
| 46 switch (fPMConversion) { | 46 switch (fPMConversion) { |
| 47 case GrConfigConversionEffect::kMulByAlpha_RoundUp_PMConversion: | 47 case GrConfigConversionEffect::kMulByAlpha_RoundUp_PMConversion: |
| 48 builder->fsCodeAppendf( | 48 builder->fsCodeAppendf( |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 // The PM conversions assume colors are 0..255 | 287 // The PM conversions assume colors are 0..255 |
| 288 return NULL; | 288 return NULL; |
| 289 } | 289 } |
| 290 AutoEffectUnref effect(SkNEW_ARGS(GrConfigConversionEffect, (texture, | 290 AutoEffectUnref effect(SkNEW_ARGS(GrConfigConversionEffect, (texture, |
| 291 swapRedAndB
lue, | 291 swapRedAndB
lue, |
| 292 pmConversio
n, | 292 pmConversio
n, |
| 293 matrix))); | 293 matrix))); |
| 294 return CreateEffectRef(effect); | 294 return CreateEffectRef(effect); |
| 295 } | 295 } |
| 296 } | 296 } |
| OLD | NEW |