OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 | 10 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 /** Converts a GrColor to an rgba array of GrGLfloat */ | 82 /** Converts a GrColor to an rgba array of GrGLfloat */ |
83 static inline void GrColorToRGBAFloat(GrColor color, float rgba[4]) { | 83 static inline void GrColorToRGBAFloat(GrColor color, float rgba[4]) { |
84 static const float ONE_OVER_255 = 1.f / 255.f; | 84 static const float ONE_OVER_255 = 1.f / 255.f; |
85 rgba[0] = GrColorUnpackR(color) * ONE_OVER_255; | 85 rgba[0] = GrColorUnpackR(color) * ONE_OVER_255; |
86 rgba[1] = GrColorUnpackG(color) * ONE_OVER_255; | 86 rgba[1] = GrColorUnpackG(color) * ONE_OVER_255; |
87 rgba[2] = GrColorUnpackB(color) * ONE_OVER_255; | 87 rgba[2] = GrColorUnpackB(color) * ONE_OVER_255; |
88 rgba[3] = GrColorUnpackA(color) * ONE_OVER_255; | 88 rgba[3] = GrColorUnpackA(color) * ONE_OVER_255; |
89 } | 89 } |
90 | 90 |
| 91 /** Normalizes and coverts an uint8_t to a float. [0, 255] -> [0.0, 1.0] */ |
| 92 static inline float GrNormalizeByteToFloat(uint8_t value) { |
| 93 static const float ONE_OVER_255 = 1.f / 255.f; |
| 94 return value * ONE_OVER_255; |
| 95 } |
| 96 |
91 /** Determines whether the color is opaque or not. */ | 97 /** Determines whether the color is opaque or not. */ |
92 static inline bool GrColorIsOpaque(GrColor color) { | 98 static inline bool GrColorIsOpaque(GrColor color) { |
93 return (color & (0xFFU << GrColor_SHIFT_A)) == (0xFFU << GrColor_SHIFT_A); | 99 return (color & (0xFFU << GrColor_SHIFT_A)) == (0xFFU << GrColor_SHIFT_A); |
94 } | 100 } |
95 | 101 |
96 /** | 102 /** |
97 * Flags used for bitfields of color components. They are defined so that the bi
t order reflects the | 103 * Flags used for bitfields of color components. They are defined so that the bi
t order reflects the |
98 * GrColor shift order. | 104 * GrColor shift order. |
99 */ | 105 */ |
100 enum GrColorComponentFlags { | 106 enum GrColorComponentFlags { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 GR_STATIC_ASSERT(6 == kBGRA_8888_GrPixelConfig); | 160 GR_STATIC_ASSERT(6 == kBGRA_8888_GrPixelConfig); |
155 GR_STATIC_ASSERT(7 == kETC1_GrPixelConfig); | 161 GR_STATIC_ASSERT(7 == kETC1_GrPixelConfig); |
156 GR_STATIC_ASSERT(8 == kLATC_GrPixelConfig); | 162 GR_STATIC_ASSERT(8 == kLATC_GrPixelConfig); |
157 GR_STATIC_ASSERT(9 == kR11_EAC_GrPixelConfig); | 163 GR_STATIC_ASSERT(9 == kR11_EAC_GrPixelConfig); |
158 GR_STATIC_ASSERT(10 == kASTC_12x12_GrPixelConfig); | 164 GR_STATIC_ASSERT(10 == kASTC_12x12_GrPixelConfig); |
159 GR_STATIC_ASSERT(11 == kRGBA_float_GrPixelConfig); | 165 GR_STATIC_ASSERT(11 == kRGBA_float_GrPixelConfig); |
160 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kFlags) == kGrPixelConfigCnt); | 166 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kFlags) == kGrPixelConfigCnt); |
161 } | 167 } |
162 | 168 |
163 #endif | 169 #endif |
OLD | NEW |