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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 111 |
112 void GrConfigConversionEffect::getConstantColorComponents(GrColor* color, | 112 void GrConfigConversionEffect::getConstantColorComponents(GrColor* color, |
113 uint32_t* validFlags)
const { | 113 uint32_t* validFlags)
const { |
114 this->updateConstantColorComponentsForModulation(color, validFlags); | 114 this->updateConstantColorComponentsForModulation(color, validFlags); |
115 } | 115 } |
116 | 116 |
117 /////////////////////////////////////////////////////////////////////////////// | 117 /////////////////////////////////////////////////////////////////////////////// |
118 | 118 |
119 GR_DEFINE_EFFECT_TEST(GrConfigConversionEffect); | 119 GR_DEFINE_EFFECT_TEST(GrConfigConversionEffect); |
120 | 120 |
121 GrEffectRef* GrConfigConversionEffect::TestCreate(SkRandom* random, | 121 GrEffect* GrConfigConversionEffect::TestCreate(SkRandom* random, |
122 GrContext*, | 122 GrContext*, |
123 const GrDrawTargetCaps&, | 123 const GrDrawTargetCaps&, |
124 GrTexture* textures[]) { | 124 GrTexture* textures[]) { |
125 PMConversion pmConv = static_cast<PMConversion>(random->nextULessThan(kPMCon
versionCnt)); | 125 PMConversion pmConv = static_cast<PMConversion>(random->nextULessThan(kPMCon
versionCnt)); |
126 bool swapRB; | 126 bool swapRB; |
127 if (kNone_PMConversion == pmConv) { | 127 if (kNone_PMConversion == pmConv) { |
128 swapRB = true; | 128 swapRB = true; |
129 } else { | 129 } else { |
130 swapRB = random->nextBool(); | 130 swapRB = random->nextBool(); |
131 } | 131 } |
132 return SkNEW_ARGS(GrConfigConversionEffect, | 132 return SkNEW_ARGS(GrConfigConversionEffect, |
133 (textures[GrEffectUnitTest::kSkiaPMTexture
Idx], | 133 (textures[GrEffectUnitTest::kSkiaPMTexture
Idx], |
134 swapRB, | 134 swapRB, |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 } | 240 } |
241 } | 241 } |
242 } | 242 } |
243 } | 243 } |
244 if (failed) { | 244 if (failed) { |
245 *pmToUPMRule = kNone_PMConversion; | 245 *pmToUPMRule = kNone_PMConversion; |
246 *upmToPMRule = kNone_PMConversion; | 246 *upmToPMRule = kNone_PMConversion; |
247 } | 247 } |
248 } | 248 } |
249 | 249 |
250 const GrEffectRef* GrConfigConversionEffect::Create(GrTexture* texture, | 250 const GrEffect* GrConfigConversionEffect::Create(GrTexture* texture, |
251 bool swapRedAndBlue, | 251 bool swapRedAndBlue, |
252 PMConversion pmConversion, | 252 PMConversion pmConversion, |
253 const SkMatrix& matrix) { | 253 const SkMatrix& matrix) { |
254 if (!swapRedAndBlue && kNone_PMConversion == pmConversion) { | 254 if (!swapRedAndBlue && kNone_PMConversion == pmConversion) { |
255 // If we returned a GrConfigConversionEffect that was equivalent to a Gr
SimpleTextureEffect | 255 // If we returned a GrConfigConversionEffect that was equivalent to a Gr
SimpleTextureEffect |
256 // then we may pollute our texture cache with redundant shaders. So in t
he case that no | 256 // then we may pollute our texture cache with redundant shaders. So in t
he case that no |
257 // conversions were requested we instead return a GrSimpleTextureEffect. | 257 // conversions were requested we instead return a GrSimpleTextureEffect. |
258 return GrSimpleTextureEffect::Create(texture, matrix); | 258 return GrSimpleTextureEffect::Create(texture, matrix); |
259 } else { | 259 } else { |
260 if (kRGBA_8888_GrPixelConfig != texture->config() && | 260 if (kRGBA_8888_GrPixelConfig != texture->config() && |
261 kBGRA_8888_GrPixelConfig != texture->config() && | 261 kBGRA_8888_GrPixelConfig != texture->config() && |
262 kNone_PMConversion != pmConversion) { | 262 kNone_PMConversion != pmConversion) { |
263 // The PM conversions assume colors are 0..255 | 263 // The PM conversions assume colors are 0..255 |
264 return NULL; | 264 return NULL; |
265 } | 265 } |
266 return SkNEW_ARGS(GrConfigConversionEffect, (texture, | 266 return SkNEW_ARGS(GrConfigConversionEffect, (texture, |
267 swapRedAndBlue, | 267 swapRedAndBlue, |
268 pmConversion, | 268 pmConversion, |
269 matrix)); | 269 matrix)); |
270 } | 270 } |
271 } | 271 } |
OLD | NEW |