blob: ceae56a84efc48fe00a8b08a31801697b9dfb112 [file] [log] [blame]
Leon Scroggins III1252ec42017-01-11 12:59:43 -05001/*
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
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "tests/Test.h"
Leon Scroggins III1252ec42017-01-11 12:59:43 -05009
Mike Kleinc0bd9f92019-04-23 12:05:21 -050010#include "include/core/SkColor.h"
Leon Scroggins III1252ec42017-01-11 12:59:43 -050011
12DEF_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++) {
Cary Clark6cdb7d32018-04-24 14:47:16 -040017 SkColor color = SkColorSetRGB(r, g, b);
Leon Scroggins III1252ec42017-01-11 12:59:43 -050018 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}