OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 #include "PathOpsTestCommon.h" | 7 #include "PathOpsTestCommon.h" |
| 8 #include "SkPath.h" |
8 #include "SkPathOpsQuad.h" | 9 #include "SkPathOpsQuad.h" |
| 10 #include "SkRRect.h" |
9 #include "Test.h" | 11 #include "Test.h" |
10 | 12 |
11 static const SkDQuad tests[] = { | 13 static const SkDQuad tests[] = { |
12 {{{1, 1}, {2, 1}, {0, 2}}}, | 14 {{{1, 1}, {2, 1}, {0, 2}}}, |
13 {{{0, 0}, {1, 1}, {3, 1}}}, | 15 {{{0, 0}, {1, 1}, {3, 1}}}, |
14 {{{2, 0}, {1, 1}, {2, 2}}}, | 16 {{{2, 0}, {1, 1}, {2, 2}}}, |
15 {{{4, 0}, {0, 1}, {4, 2}}}, | 17 {{{4, 0}, {0, 1}, {4, 2}}}, |
16 {{{0, 0}, {0, 1}, {1, 1}}}, | 18 {{{0, 0}, {0, 1}, {1, 1}}}, |
17 }; | 19 }; |
18 | 20 |
19 static const SkDPoint inPoint[]= { | 21 static const SkDPoint inPoint[]= { |
20 {1, 1.2}, | 22 {1, 1.2}, |
21 {1, 0.8}, | 23 {1, 0.8}, |
22 {1.8, 1}, | 24 {1.8, 1}, |
23 {1.5, 1}, | 25 {1.5, 1}, |
24 {0.5, 0.5}, | 26 {0.4999, 0.5}, // was 0.5, 0.5; points on the hull are considered outside |
25 }; | 27 }; |
26 | 28 |
27 static const SkDPoint outPoint[]= { | 29 static const SkDPoint outPoint[]= { |
28 {1, 1.6}, | 30 {1, 1.6}, |
29 {1, 1.5}, | 31 {1, 1.5}, |
30 {2.2, 1}, | 32 {2.2, 1}, |
31 {1.5, 1.5}, | 33 {1.5, 1.5}, |
32 {1.1, 0.5}, | 34 {1.1, 0.5}, |
33 }; | 35 }; |
34 | 36 |
35 static const size_t tests_count = SK_ARRAY_COUNT(tests); | 37 static const size_t tests_count = SK_ARRAY_COUNT(tests); |
36 | 38 |
37 static void PathOpsDQuadTest(skiatest::Reporter* reporter) { | 39 static void PathOpsDQuadTest(skiatest::Reporter* reporter) { |
38 for (size_t index = 0; index < tests_count; ++index) { | 40 for (size_t index = 0; index < tests_count; ++index) { |
39 const SkDQuad& quad = tests[index]; | 41 const SkDQuad& quad = tests[index]; |
40 SkASSERT(ValidQuad(quad)); | 42 SkASSERT(ValidQuad(quad)); |
41 bool result = quad.pointInHull(inPoint[index]); | 43 bool result = quad.pointInHull(inPoint[index]); |
42 if (!result) { | 44 if (!result) { |
43 SkDebugf("%s [%d] expected in hull\n", __FUNCTION__, index); | 45 SkDebugf("%s [%d] expected in hull\n", __FUNCTION__, index); |
44 REPORTER_ASSERT(reporter, 0); | 46 REPORTER_ASSERT(reporter, 0); |
45 } | 47 } |
46 result = quad.pointInHull(outPoint[index]); | 48 result = quad.pointInHull(outPoint[index]); |
47 if (result) { | 49 if (result) { |
48 SkDebugf("%s [%d] expected outside hull\n", __FUNCTION__, index); | 50 SkDebugf("%s [%d] expected outside hull\n", __FUNCTION__, index); |
49 REPORTER_ASSERT(reporter, 0); | 51 REPORTER_ASSERT(reporter, 0); |
50 } | 52 } |
51 } | 53 } |
52 } | 54 } |
53 | 55 |
| 56 static void PathOpsRRectTest(skiatest::Reporter* reporter) { |
| 57 SkPath path; |
| 58 SkRRect rRect; |
| 59 SkRect rect = {135, 143, 250, 177}; |
| 60 SkVector radii[4] = {{8, 8}, {8, 8}, {0, 0}, {0, 0}}; |
| 61 rRect.setRectRadii(rect, radii); |
| 62 path.addRRect(rRect); |
| 63 } |
| 64 |
54 #include "TestClassDef.h" | 65 #include "TestClassDef.h" |
55 DEFINE_TESTCLASS_SHORT(PathOpsDQuadTest) | 66 DEFINE_TESTCLASS_SHORT(PathOpsDQuadTest) |
| 67 |
| 68 DEFINE_TESTCLASS_SHORT(PathOpsRRectTest) |
OLD | NEW |