Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 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 SkColor_DEFINED | 8 #ifndef SkColor_DEFINED |
| 9 #define SkColor_DEFINED | 9 #define SkColor_DEFINED |
| 10 | 10 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 */ | 103 */ |
| 104 SK_API void SkRGBToHSV(U8CPU red, U8CPU green, U8CPU blue, SkScalar hsv[3]); | 104 SK_API void SkRGBToHSV(U8CPU red, U8CPU green, U8CPU blue, SkScalar hsv[3]); |
| 105 | 105 |
| 106 /** Convert the argb color to its HSV components. | 106 /** Convert the argb color to its HSV components. |
| 107 hsv[0] is Hue [0 .. 360) | 107 hsv[0] is Hue [0 .. 360) |
| 108 hsv[1] is Saturation [0...1] | 108 hsv[1] is Saturation [0...1] |
| 109 hsv[2] is Value [0...1] | 109 hsv[2] is Value [0...1] |
| 110 @param color the argb color to convert. Note: the alpha component is ignored . | 110 @param color the argb color to convert. Note: the alpha component is ignored . |
| 111 @param hsv 3 element array which holds the resulting HSV components. | 111 @param hsv 3 element array which holds the resulting HSV components. |
| 112 */ | 112 */ |
| 113 static inline void SkColorToHSV(SkColor color, SkScalar hsv[3]) | 113 static inline void SkColorToHSV(SkColor color, SkScalar hsv[3]) { |
| 114 { | |
| 115 SkRGBToHSV(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color), hsv); | 114 SkRGBToHSV(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color), hsv); |
| 116 } | 115 } |
| 117 | 116 |
| 118 /** Convert HSV components to an ARGB color. The alpha component is passed throu gh unchanged. | 117 /** Convert HSV components to an ARGB color. The alpha component is passed throu gh unchanged. |
| 119 hsv[0] is Hue [0 .. 360) | 118 hsv[0] is Hue [0 .. 360) |
| 120 hsv[1] is Saturation [0...1] | 119 hsv[1] is Saturation [0...1] |
| 121 hsv[2] is Value [0...1] | 120 hsv[2] is Value [0...1] |
| 122 If hsv values are out of range, they are pinned. | 121 If hsv values are out of range, they are pinned. |
| 123 @param alpha the alpha component of the returned argb color. | 122 @param alpha the alpha component of the returned argb color. |
| 124 @param hsv 3 element array which holds the input HSV components. | 123 @param hsv 3 element array which holds the input HSV components. |
| 125 @return the resulting argb color | 124 @return the resulting argb color |
| 126 */ | 125 */ |
| 127 SK_API SkColor SkHSVToColor(U8CPU alpha, const SkScalar hsv[3]); | 126 SK_API SkColor SkHSVToColor(U8CPU alpha, const SkScalar hsv[3]); |
| 128 | 127 |
| 129 /** Convert HSV components to an ARGB color. The alpha component set to 0xFF. | 128 /** Convert HSV components to an ARGB color. The alpha component set to 0xFF. |
| 130 hsv[0] is Hue [0 .. 360) | 129 hsv[0] is Hue [0 .. 360) |
| 131 hsv[1] is Saturation [0...1] | 130 hsv[1] is Saturation [0...1] |
| 132 hsv[2] is Value [0...1] | 131 hsv[2] is Value [0...1] |
| 133 If hsv values are out of range, they are pinned. | 132 If hsv values are out of range, they are pinned. |
| 134 @param hsv 3 element array which holds the input HSV components. | 133 @param hsv 3 element array which holds the input HSV components. |
| 135 @return the resulting argb color | 134 @return the resulting argb color |
| 136 */ | 135 */ |
| 137 static inline SkColor SkHSVToColor(const SkScalar hsv[3]) | 136 static inline SkColor SkHSVToColor(const SkScalar hsv[3]) { |
| 138 { | |
| 139 return SkHSVToColor(0xFF, hsv); | 137 return SkHSVToColor(0xFF, hsv); |
| 140 } | 138 } |
| 141 | 139 |
| 142 //////////////////////////////////////////////////////////////////////// | 140 //////////////////////////////////////////////////////////////////////// |
| 143 | 141 |
| 144 /** 32 bit ARGB color value, premultiplied. The byte order for this value is | 142 /** 32 bit ARGB color value, premultiplied. The byte order for this value is |
| 145 configuration dependent, matching the format of kARGB32 bitmaps. This is dif ferent | 143 configuration dependent, matching the format of kARGB32 bitmaps. This is dif ferent |
| 146 from SkColor, which is nonpremultiplied, and is always in the same byte orde r. | 144 from SkColor, which is nonpremultiplied, and is always in the same byte orde r. |
| 147 */ | 145 */ |
| 148 typedef uint32_t SkPMColor; | 146 typedef uint32_t SkPMColor; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 159 /** Define a function pointer type for combining two premultiplied colors | 157 /** Define a function pointer type for combining two premultiplied colors |
| 160 */ | 158 */ |
| 161 typedef SkPMColor (*SkXfermodeProc)(SkPMColor src, SkPMColor dst); | 159 typedef SkPMColor (*SkXfermodeProc)(SkPMColor src, SkPMColor dst); |
| 162 | 160 |
| 163 //////////////////////////////////////////////////////////////////////////////// /////////////////// | 161 //////////////////////////////////////////////////////////////////////////////// /////////////////// |
| 164 | 162 |
| 165 /* | 163 /* |
| 166 * The float values are 0...1 premultiplied | 164 * The float values are 0...1 premultiplied |
| 167 */ | 165 */ |
| 168 struct SkPM4f { | 166 struct SkPM4f { |
| 167 enum { | |
| 168 A = SK_A32_SHIFT/8, | |
| 169 R = SK_R32_SHIFT/8, | |
| 170 G = SK_G32_SHIFT/8, | |
| 171 B = SK_B32_SHIFT/8, | |
| 172 }; | |
|
mtklein
2016/01/29 15:23:00
+1
| |
| 169 float fVec[4]; | 173 float fVec[4]; |
| 170 | 174 |
| 171 float a() const { return fVec[SK_A32_SHIFT/8]; } | 175 float a() const { return fVec[3]; } |
|
mtklein
2016/01/29 15:23:00
Ahem, fVec[A];
reed1
2016/01/29 22:35:27
Doh
| |
| 172 | 176 |
| 173 static SkPM4f FromPMColor(SkPMColor); | 177 static SkPM4f FromPMColor(SkPMColor); |
| 178 | |
| 179 bool isUnit() const; | |
| 174 }; | 180 }; |
| 175 | 181 |
| 176 /* | 182 /* |
| 177 * The float values are 0...1 unpremultiplied | 183 * The float values are 0...1 unpremultiplied |
| 178 */ | 184 */ |
| 179 struct SkColor4f { | 185 struct SkColor4f { |
| 180 float fA; | 186 float fA; |
| 181 float fR; | 187 float fR; |
| 182 float fG; | 188 float fG; |
| 183 float fB; | 189 float fB; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 196 static SkColor4f FromColor(SkColor); | 202 static SkColor4f FromColor(SkColor); |
| 197 | 203 |
| 198 SkColor4f pin() const { | 204 SkColor4f pin() const { |
| 199 return Pin(fA, fR, fG, fB); | 205 return Pin(fA, fR, fG, fB); |
| 200 } | 206 } |
| 201 | 207 |
| 202 SkPM4f premul() const; | 208 SkPM4f premul() const; |
| 203 }; | 209 }; |
| 204 | 210 |
| 205 #endif | 211 #endif |
| OLD | NEW |