Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1842)

Side by Side Diff: src/animator/SkDrawColor.cpp

Issue 1138263002: Revert of stop calling SkScalarDiv (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/animator/SkDisplayable.cpp ('k') | src/animator/SkScript.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 12 matching lines...) Expand all
23 23
24 static SkScalar RGB_to_HSV(SkColor color, HSV_Choice choice) { 24 static SkScalar RGB_to_HSV(SkColor color, HSV_Choice choice) {
25 SkScalar red = SkIntToScalar(SkColorGetR(color)); 25 SkScalar red = SkIntToScalar(SkColorGetR(color));
26 SkScalar green = SkIntToScalar(SkColorGetG(color)); 26 SkScalar green = SkIntToScalar(SkColorGetG(color));
27 SkScalar blue = SkIntToScalar(SkColorGetB(color)); 27 SkScalar blue = SkIntToScalar(SkColorGetB(color));
28 SkScalar min = SkMinScalar(SkMinScalar(red, green), blue); 28 SkScalar min = SkMinScalar(SkMinScalar(red, green), blue);
29 SkScalar value = SkMaxScalar(SkMaxScalar(red, green), blue); 29 SkScalar value = SkMaxScalar(SkMaxScalar(red, green), blue);
30 if (choice == kGetValue) 30 if (choice == kGetValue)
31 return value/255; 31 return value/255;
32 SkScalar delta = value - min; 32 SkScalar delta = value - min;
33 SkScalar saturation = value == 0 ? 0 : delta / value; 33 SkScalar saturation = value == 0 ? 0 : SkScalarDiv(delta, value);
34 if (choice == kGetSaturation) 34 if (choice == kGetSaturation)
35 return saturation; 35 return saturation;
36 SkScalar hue; 36 SkScalar hue;
37 if (saturation == 0) 37 if (saturation == 0)
38 hue = 0; 38 hue = 0;
39 else { 39 else {
40 SkScalar part60 = 60 / delta; 40 SkScalar part60 = SkScalarDiv(60 * SK_Scalar1, delta);
41 if (red == value) { 41 if (red == value) {
42 hue = SkScalarMul(green - blue, part60); 42 hue = SkScalarMul(green - blue, part60);
43 if (hue < 0) 43 if (hue < 0)
44 hue += 360 * SK_Scalar1; 44 hue += 360 * SK_Scalar1;
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 }
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « src/animator/SkDisplayable.cpp ('k') | src/animator/SkScript.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698