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, GrTextureParams::ClampNoFilterForceAllowSRGB()) | 101 : INHERITED(texture, 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 const GrFragmentProcessor* GrConfigConversionEffect::Create(GrTexture* texture, | 291 const GrFragmentProcessor* GrConfigConversionEffect::Create(GrTexture* texture, |
292 const GrSwizzle& swi
zzle, | 292 const GrSwizzle& swi
zzle, |
293 PMConversion pmConve
rsion, | 293 PMConversion pmConve
rsion, |
294 const SkMatrix& matr
ix) { | 294 const SkMatrix& matr
ix) { |
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::Create(texture, matrix, | 299 return GrSimpleTextureEffect::Create(texture, matrix); |
300 GrTextureParams::ClampNoFilterForce
AllowSRGB()); | |
301 } else { | 300 } else { |
302 if (kRGBA_8888_GrPixelConfig != texture->config() && | 301 if (kRGBA_8888_GrPixelConfig != texture->config() && |
303 kBGRA_8888_GrPixelConfig != texture->config() && | 302 kBGRA_8888_GrPixelConfig != texture->config() && |
304 kNone_PMConversion != pmConversion) { | 303 kNone_PMConversion != pmConversion) { |
305 // The PM conversions assume colors are 0..255 | 304 // The PM conversions assume colors are 0..255 |
306 return nullptr; | 305 return nullptr; |
307 } | 306 } |
308 return new GrConfigConversionEffect(texture, swizzle, pmConversion, matr
ix); | 307 return new GrConfigConversionEffect(texture, swizzle, pmConversion, matr
ix); |
309 } | 308 } |
310 } | 309 } |
OLD | NEW |