| 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 #ifndef SkMaskGamma_DEFINED | 8 #ifndef SkMaskGamma_DEFINED |
| 9 #define SkMaskGamma_DEFINED | 9 #define SkMaskGamma_DEFINED |
| 10 | 10 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 * contains non-linear alpha values in an attempt to create gamma correct blits | 85 * contains non-linear alpha values in an attempt to create gamma correct blits |
| 86 * in the presence of a gamma incorrect (linear) blend in the blitter. | 86 * in the presence of a gamma incorrect (linear) blend in the blitter. |
| 87 * | 87 * |
| 88 * SkMaskGamma creates and maintains tables which convert linear alpha values | 88 * SkMaskGamma creates and maintains tables which convert linear alpha values |
| 89 * to gamma correcting alpha values. | 89 * to gamma correcting alpha values. |
| 90 * @param R The number of luminance bits to use [1, 8] from the red channel. | 90 * @param R The number of luminance bits to use [1, 8] from the red channel. |
| 91 * @param G The number of luminance bits to use [1, 8] from the green channel. | 91 * @param G The number of luminance bits to use [1, 8] from the green channel. |
| 92 * @param B The number of luminance bits to use [1, 8] from the blue channel. | 92 * @param B The number of luminance bits to use [1, 8] from the blue channel. |
| 93 */ | 93 */ |
| 94 template <int R_LUM_BITS, int G_LUM_BITS, int B_LUM_BITS> class SkTMaskGamma : p
ublic SkRefCnt { | 94 template <int R_LUM_BITS, int G_LUM_BITS, int B_LUM_BITS> class SkTMaskGamma : p
ublic SkRefCnt { |
| 95 SK_DECLARE_INST_COUNT(SkTMaskGamma) |
| 95 public: | 96 public: |
| 96 SK_DECLARE_INST_COUNT_TEMPLATE(SkTMaskGamma) | |
| 97 | 97 |
| 98 /** Creates a linear SkTMaskGamma. */ | 98 /** Creates a linear SkTMaskGamma. */ |
| 99 SkTMaskGamma() : fIsLinear(true) { } | 99 SkTMaskGamma() : fIsLinear(true) { } |
| 100 | 100 |
| 101 /** | 101 /** |
| 102 * Creates tables to convert linear alpha values to gamma correcting alpha | 102 * Creates tables to convert linear alpha values to gamma correcting alpha |
| 103 * values. | 103 * values. |
| 104 * | 104 * |
| 105 * @param contrast A value in the range [0.0, 1.0] which indicates the | 105 * @param contrast A value in the range [0.0, 1.0] which indicates the |
| 106 * amount of artificial contrast to add. | 106 * amount of artificial contrast to add. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 static const int MAX_LUM_BITS = | 140 static const int MAX_LUM_BITS = |
| 141 B_LUM_BITS > (R_LUM_BITS > G_LUM_BITS ? R_LUM_BITS : G_LUM_BITS) | 141 B_LUM_BITS > (R_LUM_BITS > G_LUM_BITS ? R_LUM_BITS : G_LUM_BITS) |
| 142 ? B_LUM_BITS : (R_LUM_BITS > G_LUM_BITS ? R_LUM_BITS : G_LUM_BITS); | 142 ? B_LUM_BITS : (R_LUM_BITS > G_LUM_BITS ? R_LUM_BITS : G_LUM_BITS); |
| 143 uint8_t fGammaTables[1 << MAX_LUM_BITS][256]; | 143 uint8_t fGammaTables[1 << MAX_LUM_BITS][256]; |
| 144 bool fIsLinear; | 144 bool fIsLinear; |
| 145 | 145 |
| 146 typedef SkRefCnt INHERITED; | 146 typedef SkRefCnt INHERITED; |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 | 149 |
| 150 #define MacroComma , | |
| 151 SK_DEFINE_INST_COUNT_TEMPLATE( | |
| 152 template <int R_LUM_BITS MacroComma int G_LUM_BITS MacroComma int B_LUM_BITS
>, | |
| 153 SkTMaskGamma<R_LUM_BITS MacroComma G_LUM_BITS MacroComma B_LUM_BITS>); | |
| 154 | |
| 155 /** | 150 /** |
| 156 * SkTMaskPreBlend is a tear-off of SkTMaskGamma. It provides the tables to | 151 * SkTMaskPreBlend is a tear-off of SkTMaskGamma. It provides the tables to |
| 157 * convert a linear alpha value for a given channel to a gamma correcting alpha | 152 * convert a linear alpha value for a given channel to a gamma correcting alpha |
| 158 * value for that channel. This class is immutable. | 153 * value for that channel. This class is immutable. |
| 159 * | 154 * |
| 160 * If fR, fG, or fB is NULL, all of them will be. This indicates that no mask | 155 * If fR, fG, or fB is NULL, all of them will be. This indicates that no mask |
| 161 * pre blend should be applied. SkTMaskPreBlend::isApplicable() is provided as | 156 * pre blend should be applied. SkTMaskPreBlend::isApplicable() is provided as |
| 162 * a convenience function to test for the absence of this case. | 157 * a convenience function to test for the absence of this case. |
| 163 */ | 158 */ |
| 164 template <int R_LUM_BITS, int G_LUM_BITS, int B_LUM_BITS> class SkTMaskPreBlend
{ | 159 template <int R_LUM_BITS, int G_LUM_BITS, int B_LUM_BITS> class SkTMaskPreBlend
{ |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 */ | 207 */ |
| 213 template<bool APPLY_LUT> static inline U8CPU sk_apply_lut_if(U8CPU component, co
nst uint8_t*) { | 208 template<bool APPLY_LUT> static inline U8CPU sk_apply_lut_if(U8CPU component, co
nst uint8_t*) { |
| 214 return component; | 209 return component; |
| 215 } | 210 } |
| 216 template<> /*static*/ inline U8CPU sk_apply_lut_if<true>(U8CPU component, const
uint8_t* lut) { | 211 template<> /*static*/ inline U8CPU sk_apply_lut_if<true>(U8CPU component, const
uint8_t* lut) { |
| 217 return lut[component]; | 212 return lut[component]; |
| 218 } | 213 } |
| 219 ///@} | 214 ///@} |
| 220 | 215 |
| 221 #endif | 216 #endif |
| OLD | NEW |