blob: 79391c1ad0695ac5bc72c4b3b9bc2da463228eb6 [file] [log] [blame]
herb7cf12dd2016-01-11 08:08:56 -08001/*
2 * Copyright 2016 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 "SkScaleToSides.h"
9
herb7cf12dd2016-01-11 08:08:56 -080010#include "Test.h"
11
Hal Canary8a001442018-09-19 11:31:27 -040012#include <algorithm>
13
herb7cf12dd2016-01-11 08:08:56 -080014DEF_TEST(ScaleToSides, reporter) {
herb5e0883c2016-01-22 08:34:35 -080015 double interestingValues[] = {
herbf5d47462016-02-19 16:54:12 -080016 // From sample app - PathFuzzer
17 260.01662826538085938,
18 63.61007690429687500,
19 795.98901367187500000,
20 217.71697616577148438,
21 686.15960693359375000,
22 556.57641601562500000,
herb5e0883c2016-01-22 08:34:35 -080023 // From skp bitbucket
24 111.60000228881836,
25 55.800003051757813,
26 0.99999996581812677920,
27 0.0,
28 0.5,
29 1.0,
30 2.0,
31 3.0,
32 33.0,
33 33554430.0,
34 33554431.0,
35 33554464.0,
36 333333332.0,
37 333333333.0,
38 333333334.0,
herb7cf12dd2016-01-11 08:08:56 -080039 FLT_MAX,
40 FLT_EPSILON,
41 FLT_MIN
42 };
43
44 int numInterestingValues = (int)SK_ARRAY_COUNT(interestingValues);
45
herb5e0883c2016-01-22 08:34:35 -080046 for (int s = 0; s <= numInterestingValues; s++) {
47 for (int i = 0; i < numInterestingValues; i++) {
48 for (int j = 0; j < numInterestingValues; j++) {
49 for (int k = 0; k < numInterestingValues; k++) {
50 float radius1 = (float)interestingValues[i];
51 float radius2 = (float)interestingValues[j];
52 double width = interestingValues[k];
53 double scale = width / ((double)radius1 + (double)radius2);
54 if (width > 0.0) {
55 if (s != 0) {
56 scale = std::min(scale, interestingValues[s-1]);
57 }
58 if (scale < 1.0 && scale > 0.0) {
herb97293c62016-01-22 11:58:55 -080059 SkScaleToSides::AdjustRadii(width, scale, &radius1, &radius2);
herb5e0883c2016-01-22 08:34:35 -080060 }
herb7cf12dd2016-01-11 08:08:56 -080061 }
62 }
63 }
64 }
65 }
66}