blob: 4159ce48fd2929b53d908ec8b161000c684d2821 [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
herb5e0883c2016-01-22 08:34:35 -080010#include <algorithm>
herb7cf12dd2016-01-11 08:08:56 -080011#include "Test.h"
12
13DEF_TEST(ScaleToSides, reporter) {
herb5e0883c2016-01-22 08:34:35 -080014 double interestingValues[] = {
15 // From skp bitbucket
16 111.60000228881836,
17 55.800003051757813,
18 0.99999996581812677920,
19 0.0,
20 0.5,
21 1.0,
22 2.0,
23 3.0,
24 33.0,
25 33554430.0,
26 33554431.0,
27 33554464.0,
28 333333332.0,
29 333333333.0,
30 333333334.0,
herb7cf12dd2016-01-11 08:08:56 -080031 FLT_MAX,
32 FLT_EPSILON,
33 FLT_MIN
34 };
35
36 int numInterestingValues = (int)SK_ARRAY_COUNT(interestingValues);
37
herb5e0883c2016-01-22 08:34:35 -080038 for (int s = 0; s <= numInterestingValues; s++) {
39 for (int i = 0; i < numInterestingValues; i++) {
40 for (int j = 0; j < numInterestingValues; j++) {
41 for (int k = 0; k < numInterestingValues; k++) {
42 float radius1 = (float)interestingValues[i];
43 float radius2 = (float)interestingValues[j];
44 double width = interestingValues[k];
45 double scale = width / ((double)radius1 + (double)radius2);
46 if (width > 0.0) {
47 if (s != 0) {
48 scale = std::min(scale, interestingValues[s-1]);
49 }
50 if (scale < 1.0 && scale > 0.0) {
herb97293c62016-01-22 11:58:55 -080051 SkScaleToSides::AdjustRadii(width, scale, &radius1, &radius2);
herb5e0883c2016-01-22 08:34:35 -080052 }
herb7cf12dd2016-01-11 08:08:56 -080053 }
54 }
55 }
56 }
57 }
58}