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" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 typedef GrGLSLFragmentProcessor INHERITED; | 91 typedef GrGLSLFragmentProcessor INHERITED; |
92 | 92 |
93 }; | 93 }; |
94 | 94 |
95 /////////////////////////////////////////////////////////////////////////////// | 95 /////////////////////////////////////////////////////////////////////////////// |
96 | 96 |
97 GrConfigConversionEffect::GrConfigConversionEffect(GrTexture* texture, | 97 GrConfigConversionEffect::GrConfigConversionEffect(GrTexture* texture, |
98 const GrSwizzle& swizzle, | 98 const GrSwizzle& swizzle, |
99 PMConversion pmConversion, | 99 PMConversion pmConversion, |
100 const SkMatrix& matrix) | 100 const SkMatrix& matrix) |
101 : INHERITED(texture, matrix) | 101 : INHERITED(texture, nullptr, matrix) |
102 , fSwizzle(swizzle) | 102 , fSwizzle(swizzle) |
103 , fPMConversion(pmConversion) { | 103 , fPMConversion(pmConversion) { |
104 this->initClassID<GrConfigConversionEffect>(); | 104 this->initClassID<GrConfigConversionEffect>(); |
105 // We expect to get here with non-BGRA/RGBA only if we're doing not doing a
premul/unpremul | 105 // We expect to get here with non-BGRA/RGBA only if we're doing not doing a
premul/unpremul |
106 // conversion. | 106 // conversion. |
107 SkASSERT((kRGBA_8888_GrPixelConfig == texture->config() || | 107 SkASSERT((kRGBA_8888_GrPixelConfig == texture->config() || |
108 kBGRA_8888_GrPixelConfig == texture->config()) || | 108 kBGRA_8888_GrPixelConfig == texture->config()) || |
109 kNone_PMConversion == pmConversion); | 109 kNone_PMConversion == pmConversion); |
110 // Why did we pollute our texture cache instead of using a GrSingleTextureEf
fect? | 110 // Why did we pollute our texture cache instead of using a GrSingleTextureEf
fect? |
111 SkASSERT(swizzle != GrSwizzle::RGBA() || kNone_PMConversion != pmConversion)
; | 111 SkASSERT(swizzle != GrSwizzle::RGBA() || kNone_PMConversion != pmConversion)
; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 } | 289 } |
290 | 290 |
291 sk_sp<GrFragmentProcessor> GrConfigConversionEffect::Make(GrTexture* texture, | 291 sk_sp<GrFragmentProcessor> GrConfigConversionEffect::Make(GrTexture* texture, |
292 const GrSwizzle& swizz
le, | 292 const GrSwizzle& swizz
le, |
293 PMConversion pmConvers
ion, | 293 PMConversion pmConvers
ion, |
294 const SkMatrix& matrix
) { | 294 const SkMatrix& matrix
) { |
295 if (swizzle == GrSwizzle::RGBA() && kNone_PMConversion == pmConversion) { | 295 if (swizzle == GrSwizzle::RGBA() && kNone_PMConversion == pmConversion) { |
296 // If we returned a GrConfigConversionEffect that was equivalent to a Gr
SimpleTextureEffect | 296 // If we returned a GrConfigConversionEffect that was equivalent to a Gr
SimpleTextureEffect |
297 // then we may pollute our texture cache with redundant shaders. So in t
he case that no | 297 // then we may pollute our texture cache with redundant shaders. So in t
he case that no |
298 // conversions were requested we instead return a GrSimpleTextureEffect. | 298 // conversions were requested we instead return a GrSimpleTextureEffect. |
299 return GrSimpleTextureEffect::Make(texture, matrix); | 299 return GrSimpleTextureEffect::Make(texture, nullptr, matrix); |
300 } else { | 300 } else { |
301 if (kRGBA_8888_GrPixelConfig != texture->config() && | 301 if (kRGBA_8888_GrPixelConfig != texture->config() && |
302 kBGRA_8888_GrPixelConfig != texture->config() && | 302 kBGRA_8888_GrPixelConfig != texture->config() && |
303 kNone_PMConversion != pmConversion) { | 303 kNone_PMConversion != pmConversion) { |
304 // The PM conversions assume colors are 0..255 | 304 // The PM conversions assume colors are 0..255 |
305 return nullptr; | 305 return nullptr; |
306 } | 306 } |
307 return sk_sp<GrFragmentProcessor>( | 307 return sk_sp<GrFragmentProcessor>( |
308 new GrConfigConversionEffect(texture, swizzle, pmConversion, matrix)
); | 308 new GrConfigConversionEffect(texture, swizzle, pmConversion, matrix)
); |
309 } | 309 } |
310 } | 310 } |
OLD | NEW |