OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
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 #include "SkDrawColor.h" | 10 #include "SkDrawColor.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 } | 45 } |
46 else if (green == value) | 46 else if (green == value) |
47 hue = 120 * SK_Scalar1 + SkScalarMul(blue - red, part60); | 47 hue = 120 * SK_Scalar1 + SkScalarMul(blue - red, part60); |
48 else // blue == value | 48 else // blue == value |
49 hue = 240 * SK_Scalar1 + SkScalarMul(red - green, part60); | 49 hue = 240 * SK_Scalar1 + SkScalarMul(red - green, part60); |
50 } | 50 } |
51 SkASSERT(choice == kGetHue); | 51 SkASSERT(choice == kGetHue); |
52 return hue; | 52 return hue; |
53 } | 53 } |
54 | 54 |
55 #if defined _WIN32 && _MSC_VER >= 1300 // disable 'red', etc. may be used witho
ut having been initialized | 55 #if defined _WIN32 // disable 'red', etc. may be used without having been initi
alized |
56 #pragma warning ( push ) | 56 #pragma warning ( push ) |
57 #pragma warning ( disable : 4701 ) | 57 #pragma warning ( disable : 4701 ) |
58 #endif | 58 #endif |
59 | 59 |
60 static SkColor HSV_to_RGB(SkColor color, HSV_Choice choice, SkScalar hsv) { | 60 static SkColor HSV_to_RGB(SkColor color, HSV_Choice choice, SkScalar hsv) { |
61 SkScalar hue = choice == kGetHue ? hsv : RGB_to_HSV(color, kGetHue); | 61 SkScalar hue = choice == kGetHue ? hsv : RGB_to_HSV(color, kGetHue); |
62 SkScalar saturation = choice == kGetSaturation ? hsv : RGB_to_HSV(color, kGe
tSaturation); | 62 SkScalar saturation = choice == kGetSaturation ? hsv : RGB_to_HSV(color, kGe
tSaturation); |
63 SkScalar value = choice == kGetValue ? hsv : RGB_to_HSV(color, kGetValue); | 63 SkScalar value = choice == kGetValue ? hsv : RGB_to_HSV(color, kGetValue); |
64 value *= 255; | 64 value *= 255; |
65 SkScalar red SK_INIT_TO_AVOID_WARNING; | 65 SkScalar red SK_INIT_TO_AVOID_WARNING; |
(...skipping 16 matching lines...) Expand all Loading... |
82 case 3: red = p; green = q; blue = value; break; | 82 case 3: red = p; green = q; blue = value; break; |
83 case 4: red = t; green = p; blue = value; break; | 83 case 4: red = t; green = p; blue = value; break; |
84 case 5: red = value; green = p; blue = q; break; | 84 case 5: red = value; green = p; blue = q; break; |
85 } | 85 } |
86 } | 86 } |
87 //used to say SkToU8((U8CPU) red) etc | 87 //used to say SkToU8((U8CPU) red) etc |
88 return SkColorSetARGB(SkColorGetA(color), SkScalarRoundToInt(red), | 88 return SkColorSetARGB(SkColorGetA(color), SkScalarRoundToInt(red), |
89 SkScalarRoundToInt(green), SkScalarRoundToInt(blue)); | 89 SkScalarRoundToInt(green), SkScalarRoundToInt(blue)); |
90 } | 90 } |
91 | 91 |
92 #if defined _WIN32 && _MSC_VER >= 1300 | 92 #if defined _WIN32 |
93 #pragma warning ( pop ) | 93 #pragma warning ( pop ) |
94 #endif | 94 #endif |
95 | 95 |
96 enum SkDrawColor_Properties { | 96 enum SkDrawColor_Properties { |
97 SK_PROPERTY(alpha), | 97 SK_PROPERTY(alpha), |
98 SK_PROPERTY(blue), | 98 SK_PROPERTY(blue), |
99 SK_PROPERTY(green), | 99 SK_PROPERTY(green), |
100 SK_PROPERTY(hue), | 100 SK_PROPERTY(hue), |
101 SK_PROPERTY(red), | 101 SK_PROPERTY(red), |
102 SK_PROPERTY(saturation), | 102 SK_PROPERTY(saturation), |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 case SK_PROPERTY(value): | 256 case SK_PROPERTY(value): |
257 fValue = scalar;//RGB_to_HSV(color, kGetValue); | 257 fValue = scalar;//RGB_to_HSV(color, kGetValue); |
258 fDirty = true; | 258 fDirty = true; |
259 break; | 259 break; |
260 default: | 260 default: |
261 SkASSERT(0); | 261 SkASSERT(0); |
262 return false; | 262 return false; |
263 } | 263 } |
264 return true; | 264 return true; |
265 } | 265 } |
OLD | NEW |