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 22 matching lines...) Expand all Loading... |
33 // Using highp for GLES here in order to avoid some precision issues on
specific GPUs. | 33 // Using highp for GLES here in order to avoid some precision issues on
specific GPUs. |
34 GrGLShaderVar tmpVar("tmpColor", kVec4f_GrSLType, 0, GrGLShaderVar::kHig
h_Precision); | 34 GrGLShaderVar tmpVar("tmpColor", kVec4f_GrSLType, 0, GrGLShaderVar::kHig
h_Precision); |
35 SkString tmpDecl; | 35 SkString tmpDecl; |
36 tmpVar.appendDecl(builder->ctxInfo(), &tmpDecl); | 36 tmpVar.appendDecl(builder->ctxInfo(), &tmpDecl); |
37 | 37 |
38 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder
(); | 38 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder
(); |
39 | 39 |
40 fsBuilder->codeAppendf("%s;", tmpDecl.c_str()); | 40 fsBuilder->codeAppendf("%s;", tmpDecl.c_str()); |
41 | 41 |
42 fsBuilder->codeAppendf("%s = ", tmpVar.c_str()); | 42 fsBuilder->codeAppendf("%s = ", tmpVar.c_str()); |
43 fsBuilder->appendTextureLookup(samplers[0], coords[0].c_str(), coords[0]
.type()); | 43 fsBuilder->appendTextureLookup(samplers[0], coords[0].c_str(), coords[0]
.getType()); |
44 fsBuilder->codeAppend(";"); | 44 fsBuilder->codeAppend(";"); |
45 | 45 |
46 if (GrConfigConversionEffect::kNone_PMConversion == fPMConversion) { | 46 if (GrConfigConversionEffect::kNone_PMConversion == fPMConversion) { |
47 SkASSERT(fSwapRedAndBlue); | 47 SkASSERT(fSwapRedAndBlue); |
48 fsBuilder->codeAppendf("%s = %s.bgra;", outputColor, tmpVar.c_str())
; | 48 fsBuilder->codeAppendf("%s = %s.bgra;", outputColor, tmpVar.c_str())
; |
49 } else { | 49 } else { |
50 const char* swiz = fSwapRedAndBlue ? "bgr" : "rgb"; | 50 const char* swiz = fSwapRedAndBlue ? "bgr" : "rgb"; |
51 switch (fPMConversion) { | 51 switch (fPMConversion) { |
52 case GrConfigConversionEffect::kMulByAlpha_RoundUp_PMConversion: | 52 case GrConfigConversionEffect::kMulByAlpha_RoundUp_PMConversion: |
53 fsBuilder->codeAppendf( | 53 fsBuilder->codeAppendf( |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 kNone_PMConversion != pmConversion) { | 278 kNone_PMConversion != pmConversion) { |
279 // The PM conversions assume colors are 0..255 | 279 // The PM conversions assume colors are 0..255 |
280 return NULL; | 280 return NULL; |
281 } | 281 } |
282 return SkNEW_ARGS(GrConfigConversionEffect, (texture, | 282 return SkNEW_ARGS(GrConfigConversionEffect, (texture, |
283 swapRedAndBlue, | 283 swapRedAndBlue, |
284 pmConversion, | 284 pmConversion, |
285 matrix)); | 285 matrix)); |
286 } | 286 } |
287 } | 287 } |
OLD | NEW |