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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 /** The type of the mask pre-blend which will be returned from preBlend(SkCo
lor). */ | 129 /** The type of the mask pre-blend which will be returned from preBlend(SkCo
lor). */ |
130 typedef SkTMaskPreBlend<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS> PreBlend; | 130 typedef SkTMaskPreBlend<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS> PreBlend; |
131 | 131 |
132 /** | 132 /** |
133 * Provides access to the tables appropriate for converting linear alpha | 133 * Provides access to the tables appropriate for converting linear alpha |
134 * values into gamma correcting alpha values when drawing the given color | 134 * values into gamma correcting alpha values when drawing the given color |
135 * through the mask. The destination color will be approximated. | 135 * through the mask. The destination color will be approximated. |
136 */ | 136 */ |
137 PreBlend preBlend(SkColor color) const; | 137 PreBlend preBlend(SkColor color) const; |
138 | 138 |
| 139 /** |
| 140 * Get dimensions for the full table set, so it can be allocated as a block. |
| 141 */ |
| 142 void getGammaTableDimensions(int* tableWidth, int* numTables) const { |
| 143 *tableWidth = 256; |
| 144 *numTables = (1 << MAX_LUM_BITS); |
| 145 } |
| 146 |
| 147 /** |
| 148 * Provides direct access to the full table set, so it can be uploaded |
| 149 * into a texture. |
| 150 */ |
| 151 const uint8_t* getGammaTables() const { |
| 152 return (const uint8_t*) fGammaTables; |
| 153 } |
| 154 |
139 private: | 155 private: |
140 static const int MAX_LUM_BITS = | 156 static const int MAX_LUM_BITS = |
141 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) |
142 ? 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); |
143 uint8_t fGammaTables[1 << MAX_LUM_BITS][256]; | 159 uint8_t fGammaTables[1 << MAX_LUM_BITS][256]; |
144 bool fIsLinear; | 160 bool fIsLinear; |
145 | 161 |
146 typedef SkRefCnt INHERITED; | 162 typedef SkRefCnt INHERITED; |
147 }; | 163 }; |
148 | 164 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 */ | 223 */ |
208 template<bool APPLY_LUT> static inline U8CPU sk_apply_lut_if(U8CPU component, co
nst uint8_t*) { | 224 template<bool APPLY_LUT> static inline U8CPU sk_apply_lut_if(U8CPU component, co
nst uint8_t*) { |
209 return component; | 225 return component; |
210 } | 226 } |
211 template<> /*static*/ inline U8CPU sk_apply_lut_if<true>(U8CPU component, const
uint8_t* lut) { | 227 template<> /*static*/ inline U8CPU sk_apply_lut_if<true>(U8CPU component, const
uint8_t* lut) { |
212 return lut[component]; | 228 return lut[component]; |
213 } | 229 } |
214 ///@} | 230 ///@} |
215 | 231 |
216 #endif | 232 #endif |
OLD | NEW |