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 | 95 |
96 public: | 96 public: |
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 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 *numTables = (1 << MAX_LUM_BITS); | 144 *numTables = (1 << MAX_LUM_BITS); |
145 } | 145 } |
146 | 146 |
147 /** | 147 /** |
148 * Provides direct access to the full table set, so it can be uploaded | 148 * Provides direct access to the full table set, so it can be uploaded |
149 * into a texture. | 149 * into a texture. |
150 */ | 150 */ |
151 const uint8_t* getGammaTables() const { | 151 const uint8_t* getGammaTables() const { |
152 return (const uint8_t*) fGammaTables; | 152 return (const uint8_t*) fGammaTables; |
153 } | 153 } |
154 | 154 |
155 private: | 155 private: |
156 static const int MAX_LUM_BITS = | 156 static const int MAX_LUM_BITS = |
157 B_LUM_BITS > (R_LUM_BITS > G_LUM_BITS ? R_LUM_BITS : G_LUM_BITS) | 157 B_LUM_BITS > (R_LUM_BITS > G_LUM_BITS ? R_LUM_BITS : G_LUM_BITS) |
158 ? B_LUM_BITS : (R_LUM_BITS > G_LUM_BITS ? R_LUM_BITS : G_LUM_BITS); | 158 ? B_LUM_BITS : (R_LUM_BITS > G_LUM_BITS ? R_LUM_BITS : G_LUM_BITS); |
159 uint8_t fGammaTables[1 << MAX_LUM_BITS][256]; | 159 uint8_t fGammaTables[1 << MAX_LUM_BITS][256]; |
160 bool fIsLinear; | 160 bool fIsLinear; |
161 | 161 |
162 typedef SkRefCnt INHERITED; | 162 typedef SkRefCnt INHERITED; |
163 }; | 163 }; |
164 | 164 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 */ | 221 */ |
222 template<bool APPLY_LUT> static inline U8CPU sk_apply_lut_if(U8CPU component, co
nst uint8_t*) { | 222 template<bool APPLY_LUT> static inline U8CPU sk_apply_lut_if(U8CPU component, co
nst uint8_t*) { |
223 return component; | 223 return component; |
224 } | 224 } |
225 template<> /*static*/ inline U8CPU sk_apply_lut_if<true>(U8CPU component, const
uint8_t* lut) { | 225 template<> /*static*/ inline U8CPU sk_apply_lut_if<true>(U8CPU component, const
uint8_t* lut) { |
226 return lut[component]; | 226 return lut[component]; |
227 } | 227 } |
228 ///@} | 228 ///@} |
229 | 229 |
230 #endif | 230 #endif |
OLD | NEW |