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

Side by Side Diff: experimental/Intersection/SimplifyFindNext_Test.cpp

Issue 867213004: remove prototype pathops code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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
OLDNEW
(Empty)
1 /*
2 * Copyright 2012 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 #define DEBUG_TEST 1
9
10 #include "Simplify.h"
11
12 namespace SimplifyFindNextTest {
13
14 #include "Simplify.cpp"
15
16 } // end of SimplifyFindNextTest namespace
17
18 #include "Intersection_Tests.h"
19
20 static const SimplifyFindNextTest::Segment* testCommon(
21 int contourWinding, int spanWinding, int startIndex, int endIndex,
22 SkTArray<SimplifyFindNextTest::Contour>& contours) {
23 SkTDArray<SimplifyFindNextTest::Contour*> contourList;
24 makeContourList(contours, contourList, false, false);
25 addIntersectTs(contourList[0], contourList[0]);
26 if (contours.count() > 1) {
27 SkASSERT(contours.count() == 2);
28 addIntersectTs(contourList[0], contourList[1]);
29 addIntersectTs(contourList[1], contourList[1]);
30 }
31 fixOtherTIndex(contourList);
32 SimplifyFindNextTest::Segment& segment = contours[0].debugSegments()[0];
33 SkPoint pts[2];
34 pts[0] = segment.xyAtT(&segment.span(endIndex));
35 int nextStart = startIndex;
36 int nextEnd = endIndex;
37 SkTDArray<SimplifyFindNextTest::Span*> chaseArray;
38 bool unsortable = false;
39 SimplifyFindNextTest::Segment* next = segment.findNextWinding(chaseArray,
40 nextStart, nextEnd, unsortable);
41 pts[1] = next->xyAtT(&next->span(nextStart));
42 SkASSERT(pts[0] == pts[1]);
43 return next;
44 }
45
46 static void test(const SkPath& path) {
47 SkTArray<SimplifyFindNextTest::Contour> contours;
48 SimplifyFindNextTest::EdgeBuilder builder(path, contours);
49 int contourWinding = 0;
50 int spanWinding = 1;
51 int start = 0;
52 int end = 1;
53 testCommon(contourWinding, spanWinding, start, end, contours);
54 }
55
56 static void test(const SkPath& path, int start, int end) {
57 SkTArray<SimplifyFindNextTest::Contour> contours;
58 SimplifyFindNextTest::EdgeBuilder builder(path, contours);
59 int contourWinding = 0;
60 int spanWinding = 1;
61 testCommon(contourWinding, spanWinding, start, end, contours);
62 }
63
64 static void testLine1() {
65 SkPath path;
66 path.moveTo(2,0);
67 path.lineTo(1,1);
68 path.lineTo(0,0);
69 path.close();
70 test(path);
71 }
72
73 static void addInnerCWTriangle(SkPath& path) {
74 path.moveTo(3,0);
75 path.lineTo(4,1);
76 path.lineTo(2,1);
77 path.close();
78 }
79
80 #if DEBUG_UNUSED
81 static void addInnerCCWTriangle(SkPath& path) {
82 path.moveTo(3,0);
83 path.lineTo(2,1);
84 path.lineTo(4,1);
85 path.close();
86 }
87 #endif
88
89 static void addOuterCWTriangle(SkPath& path) {
90 path.moveTo(3,0);
91 path.lineTo(6,2);
92 path.lineTo(0,2);
93 path.close();
94 }
95
96 #if DEBUG_UNUSED
97 static void addOuterCCWTriangle(SkPath& path) {
98 path.moveTo(3,0);
99 path.lineTo(0,2);
100 path.lineTo(6,2);
101 path.close();
102 }
103 #endif
104
105 static void testLine2() {
106 SkPath path;
107 addInnerCWTriangle(path);
108 addOuterCWTriangle(path);
109 test(path, 0, 3);
110 }
111
112 static void testLine3() {
113 SkPath path;
114 addInnerCWTriangle(path);
115 addOuterCWTriangle(path);
116 test(path, 3, 0);
117 }
118
119 static void testLine4() {
120 SkPath path;
121 addInnerCWTriangle(path);
122 addOuterCWTriangle(path);
123 test(path, 3, 2);
124 }
125
126 static void (*tests[])() = {
127 testLine1,
128 testLine2,
129 testLine3,
130 testLine4,
131 };
132
133 static const size_t testCount = sizeof(tests) / sizeof(tests[0]);
134
135 static void (*firstTest)() = 0;
136 static bool skipAll = false;
137
138 void SimplifyFindNext_Test() {
139 if (skipAll) {
140 return;
141 }
142 size_t index = 0;
143 if (firstTest) {
144 while (index < testCount && tests[index] != firstTest) {
145 ++index;
146 }
147 }
148 bool firstTestComplete = false;
149 for ( ; index < testCount; ++index) {
150 (*tests[index])();
151 firstTestComplete = true;
152 }
153 }
OLDNEW
« no previous file with comments | « experimental/Intersection/SimplifyAngle_Test.cpp ('k') | experimental/Intersection/SimplifyFindTop_Test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698