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" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 SkFAIL("Unknown conversion op."); | 75 SkFAIL("Unknown conversion op."); |
76 break; | 76 break; |
77 } | 77 } |
78 fsBuilder->codeAppendf("%s = %s;", outputColor, tmpVar.c_str()); | 78 fsBuilder->codeAppendf("%s = %s;", outputColor, tmpVar.c_str()); |
79 } | 79 } |
80 SkString modulate; | 80 SkString modulate; |
81 GrGLSLMulVarBy4f(&modulate, outputColor, inputColor); | 81 GrGLSLMulVarBy4f(&modulate, outputColor, inputColor); |
82 fsBuilder->codeAppend(modulate.c_str()); | 82 fsBuilder->codeAppend(modulate.c_str()); |
83 } | 83 } |
84 | 84 |
85 static inline void GenKey(const GrProcessor& processor, const GrGLCaps&, | 85 static inline void GenKey(const GrProcessor& processor, const GrGLSLCaps&, |
86 GrProcessorKeyBuilder* b) { | 86 GrProcessorKeyBuilder* b) { |
87 const GrConfigConversionEffect& conv = processor.cast<GrConfigConversion
Effect>(); | 87 const GrConfigConversionEffect& conv = processor.cast<GrConfigConversion
Effect>(); |
88 uint32_t key = (conv.swapsRedAndBlue() ? 0 : 1) | (conv.pmConversion() <
< 1); | 88 uint32_t key = (conv.swapsRedAndBlue() ? 0 : 1) | (conv.pmConversion() <
< 1); |
89 b->add32(key); | 89 b->add32(key); |
90 } | 90 } |
91 | 91 |
92 private: | 92 private: |
93 bool fSwapRedAndBlue; | 93 bool fSwapRedAndBlue; |
94 GrConfigConversionEffect::PMConversion fPMConversion; | 94 GrConfigConversionEffect::PMConversion fPMConversion; |
95 | 95 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 } | 140 } |
141 return SkNEW_ARGS(GrConfigConversionEffect, | 141 return SkNEW_ARGS(GrConfigConversionEffect, |
142 (textures[GrProcessorUnitTest::kSkiaPMText
ureIdx], | 142 (textures[GrProcessorUnitTest::kSkiaPMText
ureIdx], |
143 swapRB, | 143 swapRB, |
144 pmConv, | 144 pmConv, |
145 GrProcessorUnitTest::TestMatrix(random)))
; | 145 GrProcessorUnitTest::TestMatrix(random)))
; |
146 } | 146 } |
147 | 147 |
148 /////////////////////////////////////////////////////////////////////////////// | 148 /////////////////////////////////////////////////////////////////////////////// |
149 | 149 |
150 void GrConfigConversionEffect::getGLProcessorKey(const GrGLCaps& caps, | 150 void GrConfigConversionEffect::getGLProcessorKey(const GrGLSLCaps& caps, |
151 GrProcessorKeyBuilder* b) const
{ | 151 GrProcessorKeyBuilder* b) const
{ |
152 GrGLConfigConversionEffect::GenKey(*this, caps, b); | 152 GrGLConfigConversionEffect::GenKey(*this, caps, b); |
153 } | 153 } |
154 | 154 |
155 GrGLFragmentProcessor* GrConfigConversionEffect::createGLInstance() const { | 155 GrGLFragmentProcessor* GrConfigConversionEffect::createGLInstance() const { |
156 return SkNEW_ARGS(GrGLConfigConversionEffect, (*this)); | 156 return SkNEW_ARGS(GrGLConfigConversionEffect, (*this)); |
157 } | 157 } |
158 | 158 |
159 | 159 |
160 | 160 |
(...skipping 128 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 |