Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: tests/PathOpsBuilderTest.cpp

Issue 1129193006: fix winding for path ops builder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix compile bug Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pathops/SkPathOpsWinding.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 15 matching lines...) Expand all
26 26
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::kCW_Direction); 36 REPORTER_ASSERT(reporter, dir == SkPath::kCCW_Direction);
37 REPORTER_ASSERT(reporter, rectPath == result); 37 SkBitmap bitmap;
38 int pixelDiff = comparePaths(reporter, __FUNCTION__, rectPath, result, bitma p);
39 REPORTER_ASSERT(reporter, pixelDiff == 0);
38 40
39 rectPath.reset(); 41 rectPath.reset();
40 rectPath.setFillType(SkPath::kEvenOdd_FillType); 42 rectPath.setFillType(SkPath::kEvenOdd_FillType);
41 rectPath.addRect(0, 1, 2, 3, SkPath::kCCW_Direction); 43 rectPath.addRect(0, 1, 2, 3, SkPath::kCCW_Direction);
42 builder.add(rectPath, kUnion_SkPathOp); 44 builder.add(rectPath, kUnion_SkPathOp);
43 REPORTER_ASSERT(reporter, builder.resolve(&result)); 45 REPORTER_ASSERT(reporter, builder.resolve(&result));
44 REPORTER_ASSERT(reporter, result.isRect(NULL, &closed, &dir)); 46 REPORTER_ASSERT(reporter, result.isRect(NULL, &closed, &dir));
45 REPORTER_ASSERT(reporter, closed); 47 REPORTER_ASSERT(reporter, closed);
46 REPORTER_ASSERT(reporter, dir == SkPath::kCCW_Direction); 48 REPORTER_ASSERT(reporter, dir == SkPath::kCCW_Direction);
47 REPORTER_ASSERT(reporter, rectPath == result); 49 REPORTER_ASSERT(reporter, rectPath == result);
48 50
49 builder.add(rectPath, kDifference_SkPathOp); 51 builder.add(rectPath, kDifference_SkPathOp);
50 REPORTER_ASSERT(reporter, builder.resolve(&result)); 52 REPORTER_ASSERT(reporter, builder.resolve(&result));
51 REPORTER_ASSERT(reporter, result.isEmpty()); 53 REPORTER_ASSERT(reporter, result.isEmpty());
52 54
53 SkPath rect2, rect3; 55 SkPath rect2, rect3;
54 rect2.addRect(2, 1, 4, 3, SkPath::kCW_Direction); 56 rect2.addRect(2, 1, 4, 3, SkPath::kCW_Direction);
55 rect3.addRect(4, 1, 5, 3, SkPath::kCCW_Direction); 57 rect3.addRect(4, 1, 5, 3, SkPath::kCCW_Direction);
56 builder.add(rectPath, kUnion_SkPathOp); 58 builder.add(rectPath, kUnion_SkPathOp);
57 builder.add(rect2, kUnion_SkPathOp); 59 builder.add(rect2, kUnion_SkPathOp);
58 builder.add(rect3, kUnion_SkPathOp); 60 builder.add(rect3, kUnion_SkPathOp);
59 REPORTER_ASSERT(reporter, builder.resolve(&result)); 61 REPORTER_ASSERT(reporter, builder.resolve(&result));
60 REPORTER_ASSERT(reporter, result.isRect(NULL, &closed, &dir)); 62 REPORTER_ASSERT(reporter, result.isRect(NULL, &closed, &dir));
61 REPORTER_ASSERT(reporter, closed); 63 REPORTER_ASSERT(reporter, closed);
62 SkRect expected; 64 SkRect expected;
63 expected.set(0, 1, 5, 3); 65 expected.set(0, 1, 5, 3);
64 REPORTER_ASSERT(reporter, result.getBounds() == expected); 66 REPORTER_ASSERT(reporter, result.getBounds() == expected);
65 67
66 SkPath circle1, circle2, circle3; 68 SkPath circle1, circle2, circle3;
67 circle1.addCircle(5, 6, 4, SkPath::kCW_Direction); 69 circle1.addCircle(5, 6, 4, SkPath::kCW_Direction);
68 circle2.addCircle(7, 4, 8, SkPath::kCCW_Direction); 70 circle2.addCircle(7, 4, 8, SkPath::kCCW_Direction);
69 circle3.addCircle(6, 5, 6, SkPath::kCW_Direction); 71 circle3.addCircle(6, 5, 6, SkPath::kCW_Direction);
70 SkPath opCompare; 72 SkPath opCompare;
71 Op(circle1, circle2, kUnion_SkPathOp, &opCompare); 73 Op(circle1, circle2, kUnion_SkPathOp, &opCompare);
72 Op(opCompare, circle3, kDifference_SkPathOp, &opCompare); 74 Op(opCompare, circle3, kDifference_SkPathOp, &opCompare);
73 builder.add(circle1, kUnion_SkPathOp); 75 builder.add(circle1, kUnion_SkPathOp);
74 builder.add(circle2, kUnion_SkPathOp); 76 builder.add(circle2, kUnion_SkPathOp);
75 builder.add(circle3, kDifference_SkPathOp); 77 builder.add(circle3, kDifference_SkPathOp);
76 REPORTER_ASSERT(reporter, builder.resolve(&result)); 78 REPORTER_ASSERT(reporter, builder.resolve(&result));
77 SkBitmap bitmap; 79 pixelDiff = comparePaths(reporter, __FUNCTION__, opCompare, result, bitmap);
78 int pixelDiff = comparePaths(reporter, __FUNCTION__, opCompare, result, bitm ap);
79 REPORTER_ASSERT(reporter, pixelDiff == 0); 80 REPORTER_ASSERT(reporter, pixelDiff == 0);
80 } 81 }
81 82
82 DEF_TEST(Issue3838, reporter) { 83 DEF_TEST(BuilderIssue3838, reporter) {
83 SkPath path; 84 SkPath path;
84 path.moveTo(200, 170); 85 path.moveTo(200, 170);
85 path.lineTo(220, 170); 86 path.lineTo(220, 170);
86 path.lineTo(220, 230); 87 path.lineTo(220, 230);
87 path.lineTo(240, 230); 88 path.lineTo(240, 230);
88 path.lineTo(240, 210); 89 path.lineTo(240, 210);
89 path.lineTo(180, 210); 90 path.lineTo(180, 210);
90 path.lineTo(180, 190); 91 path.lineTo(180, 190);
91 path.lineTo(260, 190); 92 path.lineTo(260, 190);
92 path.lineTo(260, 250); 93 path.lineTo(260, 250);
93 path.lineTo(200, 250); 94 path.lineTo(200, 250);
94 path.lineTo(200, 170); 95 path.lineTo(200, 170);
95 path.close(); 96 path.close();
96 testSimplify(reporter, path, __FUNCTION__);
97 SkPath path3;
98 Simplify(path, &path3);
99 SkPath path2; 97 SkPath path2;
100 SkOpBuilder builder; 98 SkOpBuilder builder;
101 builder.add(path, kUnion_SkPathOp); 99 builder.add(path, kUnion_SkPathOp);
102 builder.resolve(&path2); 100 builder.resolve(&path2);
103 SkBitmap bitmap; 101 SkBitmap bitmap;
104 int pixelDiff = comparePaths(reporter, __FUNCTION__, path, path2, bitmap); 102 int pixelDiff = comparePaths(reporter, __FUNCTION__, path, path2, bitmap);
105 REPORTER_ASSERT(reporter, pixelDiff == 0); 103 REPORTER_ASSERT(reporter, pixelDiff == 0);
106 } 104 }
105
106 DEF_TEST(BuilderIssue3838_2, reporter) {
107 SkPath path;
108 path.addCircle(100, 100, 50);
109
110 SkOpBuilder builder;
111 builder.add(path, kUnion_SkPathOp);
112 builder.add(path, kUnion_SkPathOp);
113
114 SkPath result;
115 SkBitmap bitmap;
116 builder.resolve(&result);
117 int pixelDiff = comparePaths(reporter, __FUNCTION__, path, result, bitmap);
118 REPORTER_ASSERT(reporter, pixelDiff == 0);
119 }
OLDNEW
« no previous file with comments | « src/pathops/SkPathOpsWinding.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698