1 /*
2 * Copyright 2017 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "include/core/SkColor.h"
9 #include "include/core/SkScalar.h"
10 #include "include/core/SkTypes.h"
11 #include "include/private/base/SkCPUTypes.h"
12 #include "tests/Test.h"
13
DEF_TEST(ColorToHSVRoundTrip,reporter)14 DEF_TEST(ColorToHSVRoundTrip, reporter) {
15 SkScalar hsv[3];
16 for (U8CPU r = 0; r <= 255; r++) {
17 for (U8CPU g = 0; g <= 255; g++) {
18 for (U8CPU b = 0; b <= 255; b++) {
19 SkColor color = SkColorSetRGB(r, g, b);
20 SkColorToHSV(color, hsv);
21 SkColor result = SkHSVToColor(0xFF, hsv);
22 if (result != color) {
23 ERRORF(reporter, "HSV roundtrip mismatch!\n"
24 "\toriginal: %X\n"
25 "\tHSV: %f, %f, %f\n"
26 "\tresult: %X\n",
27 color, hsv[0], hsv[1], hsv[2], result);
28 }
29 }
30 }
31 }
32 }
33