OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 | 7 |
8 #include "PathOpsExtendedTest.h" | 8 #include "PathOpsExtendedTest.h" |
9 #include "PathOpsTestCommon.h" | 9 #include "PathOpsTestCommon.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 SkPath rectPath; | 27 SkPath rectPath; |
28 rectPath.setFillType(SkPath::kEvenOdd_FillType); | 28 rectPath.setFillType(SkPath::kEvenOdd_FillType); |
29 rectPath.addRect(0, 1, 2, 3, SkPath::kCW_Direction); | 29 rectPath.addRect(0, 1, 2, 3, SkPath::kCW_Direction); |
30 builder.add(rectPath, kUnion_SkPathOp); | 30 builder.add(rectPath, kUnion_SkPathOp); |
31 REPORTER_ASSERT(reporter, builder.resolve(&result)); | 31 REPORTER_ASSERT(reporter, builder.resolve(&result)); |
32 bool closed; | 32 bool closed; |
33 SkPath::Direction dir; | 33 SkPath::Direction dir; |
34 REPORTER_ASSERT(reporter, result.isRect(NULL, &closed, &dir)); | 34 REPORTER_ASSERT(reporter, result.isRect(NULL, &closed, &dir)); |
35 REPORTER_ASSERT(reporter, closed); | 35 REPORTER_ASSERT(reporter, closed); |
36 REPORTER_ASSERT(reporter, dir == SkPath::kCCW_Direction); | 36 REPORTER_ASSERT(reporter, dir == SkPath::kCCW_Direction); |
37 SkBitmap bitmap; | 37 int pixelDiff = comparePaths(reporter, __FUNCTION__, rectPath, result); |
38 int pixelDiff = comparePaths(reporter, __FUNCTION__, rectPath, result, bitma
p); | |
39 REPORTER_ASSERT(reporter, pixelDiff == 0); | 38 REPORTER_ASSERT(reporter, pixelDiff == 0); |
40 | 39 |
41 rectPath.reset(); | 40 rectPath.reset(); |
42 rectPath.setFillType(SkPath::kEvenOdd_FillType); | 41 rectPath.setFillType(SkPath::kEvenOdd_FillType); |
43 rectPath.addRect(0, 1, 2, 3, SkPath::kCCW_Direction); | 42 rectPath.addRect(0, 1, 2, 3, SkPath::kCCW_Direction); |
44 builder.add(rectPath, kUnion_SkPathOp); | 43 builder.add(rectPath, kUnion_SkPathOp); |
45 REPORTER_ASSERT(reporter, builder.resolve(&result)); | 44 REPORTER_ASSERT(reporter, builder.resolve(&result)); |
46 REPORTER_ASSERT(reporter, result.isRect(NULL, &closed, &dir)); | 45 REPORTER_ASSERT(reporter, result.isRect(NULL, &closed, &dir)); |
47 REPORTER_ASSERT(reporter, closed); | 46 REPORTER_ASSERT(reporter, closed); |
48 REPORTER_ASSERT(reporter, dir == SkPath::kCCW_Direction); | 47 REPORTER_ASSERT(reporter, dir == SkPath::kCCW_Direction); |
(...skipping 20 matching lines...) Expand all Loading... |
69 circle1.addCircle(5, 6, 4, SkPath::kCW_Direction); | 68 circle1.addCircle(5, 6, 4, SkPath::kCW_Direction); |
70 circle2.addCircle(7, 4, 8, SkPath::kCCW_Direction); | 69 circle2.addCircle(7, 4, 8, SkPath::kCCW_Direction); |
71 circle3.addCircle(6, 5, 6, SkPath::kCW_Direction); | 70 circle3.addCircle(6, 5, 6, SkPath::kCW_Direction); |
72 SkPath opCompare; | 71 SkPath opCompare; |
73 Op(circle1, circle2, kUnion_SkPathOp, &opCompare); | 72 Op(circle1, circle2, kUnion_SkPathOp, &opCompare); |
74 Op(opCompare, circle3, kDifference_SkPathOp, &opCompare); | 73 Op(opCompare, circle3, kDifference_SkPathOp, &opCompare); |
75 builder.add(circle1, kUnion_SkPathOp); | 74 builder.add(circle1, kUnion_SkPathOp); |
76 builder.add(circle2, kUnion_SkPathOp); | 75 builder.add(circle2, kUnion_SkPathOp); |
77 builder.add(circle3, kDifference_SkPathOp); | 76 builder.add(circle3, kDifference_SkPathOp); |
78 REPORTER_ASSERT(reporter, builder.resolve(&result)); | 77 REPORTER_ASSERT(reporter, builder.resolve(&result)); |
79 pixelDiff = comparePaths(reporter, __FUNCTION__, opCompare, result, bitmap); | 78 pixelDiff = comparePaths(reporter, __FUNCTION__, opCompare, result); |
80 REPORTER_ASSERT(reporter, pixelDiff == 0); | 79 REPORTER_ASSERT(reporter, pixelDiff == 0); |
81 } | 80 } |
82 | 81 |
83 DEF_TEST(BuilderIssue3838, reporter) { | 82 DEF_TEST(BuilderIssue3838, reporter) { |
84 SkPath path; | 83 SkPath path; |
85 path.moveTo(200, 170); | 84 path.moveTo(200, 170); |
86 path.lineTo(220, 170); | 85 path.lineTo(220, 170); |
87 path.lineTo(220, 230); | 86 path.lineTo(220, 230); |
88 path.lineTo(240, 230); | 87 path.lineTo(240, 230); |
89 path.lineTo(240, 210); | 88 path.lineTo(240, 210); |
90 path.lineTo(180, 210); | 89 path.lineTo(180, 210); |
91 path.lineTo(180, 190); | 90 path.lineTo(180, 190); |
92 path.lineTo(260, 190); | 91 path.lineTo(260, 190); |
93 path.lineTo(260, 250); | 92 path.lineTo(260, 250); |
94 path.lineTo(200, 250); | 93 path.lineTo(200, 250); |
95 path.lineTo(200, 170); | 94 path.lineTo(200, 170); |
96 path.close(); | 95 path.close(); |
97 SkPath path2; | 96 SkPath path2; |
98 SkOpBuilder builder; | 97 SkOpBuilder builder; |
99 builder.add(path, kUnion_SkPathOp); | 98 builder.add(path, kUnion_SkPathOp); |
100 builder.resolve(&path2); | 99 builder.resolve(&path2); |
101 SkBitmap bitmap; | 100 int pixelDiff = comparePaths(reporter, __FUNCTION__, path, path2); |
102 int pixelDiff = comparePaths(reporter, __FUNCTION__, path, path2, bitmap); | |
103 REPORTER_ASSERT(reporter, pixelDiff == 0); | 101 REPORTER_ASSERT(reporter, pixelDiff == 0); |
104 } | 102 } |
105 | 103 |
106 DEF_TEST(BuilderIssue3838_2, reporter) { | 104 DEF_TEST(BuilderIssue3838_2, reporter) { |
107 SkPath path; | 105 SkPath path; |
108 path.addCircle(100, 100, 50); | 106 path.addCircle(100, 100, 50); |
109 | 107 |
110 SkOpBuilder builder; | 108 SkOpBuilder builder; |
111 builder.add(path, kUnion_SkPathOp); | 109 builder.add(path, kUnion_SkPathOp); |
112 builder.add(path, kUnion_SkPathOp); | 110 builder.add(path, kUnion_SkPathOp); |
113 | 111 |
114 SkPath result; | 112 SkPath result; |
115 SkBitmap bitmap; | |
116 builder.resolve(&result); | 113 builder.resolve(&result); |
117 int pixelDiff = comparePaths(reporter, __FUNCTION__, path, result, bitmap); | 114 int pixelDiff = comparePaths(reporter, __FUNCTION__, path, result); |
118 REPORTER_ASSERT(reporter, pixelDiff == 0); | 115 REPORTER_ASSERT(reporter, pixelDiff == 0); |
119 } | 116 } |
| 117 |
| 118 DEF_TEST(BuilderIssue3838_3, reporter) { |
| 119 SkPath path; |
| 120 path.moveTo(40, 10); |
| 121 path.lineTo(60, 10); |
| 122 path.lineTo(60, 30); |
| 123 path.lineTo(40, 30); |
| 124 path.lineTo(40, 10); |
| 125 path.moveTo(41, 11); |
| 126 path.lineTo(41, 29); |
| 127 path.lineTo(59, 29); |
| 128 path.lineTo(59, 11); |
| 129 path.lineTo(41, 11); |
| 130 |
| 131 SkOpBuilder builder; |
| 132 builder.add(path, kUnion_SkPathOp); |
| 133 SkPath result; |
| 134 builder.resolve(&result); |
| 135 int pixelDiff = comparePaths(reporter, __FUNCTION__, path, result); |
| 136 REPORTER_ASSERT(reporter, pixelDiff == 0); |
| 137 } |
OLD | NEW |