• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "Test.h"
9 
10 #include "SkColor.h"
11 
DEF_TEST(ColorToHSVRoundTrip,reporter)12 DEF_TEST(ColorToHSVRoundTrip, reporter) {
13     SkScalar hsv[3];
14     for (U8CPU r = 0; r <= 255; r++) {
15         for (U8CPU g = 0; g <= 255; g++) {
16             for (U8CPU b = 0; b <= 255; b++) {
17                 SkColor color = SkColorSetRGB(r, g, b);
18                 SkColorToHSV(color, hsv);
19                 SkColor result = SkHSVToColor(0xFF, hsv);
20                 if (result != color) {
21                     ERRORF(reporter, "HSV roundtrip mismatch!\n"
22                                      "\toriginal: %X\n"
23                                      "\tHSV: %f, %f, %f\n"
24                                      "\tresult: %X\n",
25                            color, hsv[0], hsv[1], hsv[2], result);
26                 }
27             }
28         }
29     }
30 }
31