| 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 | |
| 155 private: | 139 private: |
| 156 static const int MAX_LUM_BITS = | 140 static const int MAX_LUM_BITS = |
| 157 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) |
| 158 ? 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); |
| 159 uint8_t fGammaTables[1 << MAX_LUM_BITS][256]; | 143 uint8_t fGammaTables[1 << MAX_LUM_BITS][256]; |
| 160 bool fIsLinear; | 144 bool fIsLinear; |
| 161 | 145 |
| 162 typedef SkRefCnt INHERITED; | 146 typedef SkRefCnt INHERITED; |
| 163 }; | 147 }; |
| 164 | 148 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 */ | 207 */ |
| 224 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*) { |
| 225 return component; | 209 return component; |
| 226 } | 210 } |
| 227 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) { |
| 228 return lut[component]; | 212 return lut[component]; |
| 229 } | 213 } |
| 230 ///@} | 214 ///@} |
| 231 | 215 |
| 232 #endif | 216 #endif |
| OLD | NEW |