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

Side by Side Diff: tests/PathOpsSimplifyRectThreadedTest.cpp

Issue 13094010: Add implementation of path ops (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « tests/PathOpsSimplifyQuadralateralsThreadedTest.cpp ('k') | tests/PathOpsSimplifyTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "PathOpsExtendedTest.h"
8
9 // four rects, of four sizes
10 // for 3 smaller sizes, tall, wide
11 // top upper mid lower bottom aligned (3 bits, 5 values)
12 // same with x (3 bits, 5 values)
13 // not included, square, tall, wide (2 bits)
14 // cw or ccw (1 bit)
15
16 static void* testSimplify4x4RectsMain(void* data)
17 {
18 SkASSERT(data);
19 State4& state = *(State4*) data;
20 char pathStr[1024]; // gdb: set print elements 400
21 bzero(pathStr, sizeof(pathStr));
22 do {
23 int aShape = state.a & 0x03;
24 SkPath::Direction aCW = state.a >> 2 ? SkPath::kCCW_Direction : SkPath:: kCW_Direction;
25 int bShape = state.b & 0x03;
26 SkPath::Direction bCW = state.b >> 2 ? SkPath::kCCW_Direction : SkPath:: kCW_Direction;
27 int cShape = state.c & 0x03;
28 SkPath::Direction cCW = state.c >> 2 ? SkPath::kCCW_Direction : SkPath:: kCW_Direction;
29 int dShape = state.d & 0x03;
30 SkPath::Direction dCW = state.d >> 2 ? SkPath::kCCW_Direction : SkPath:: kCW_Direction;
31 for (int aXAlign = 0 ; aXAlign < 5; ++aXAlign) {
32 for (int aYAlign = 0 ; aYAlign < 5; ++aYAlign) {
33 for (int bXAlign = 0 ; bXAlign < 5; ++bXAlign) {
34 for (int bYAlign = 0 ; bYAlign < 5; ++bYAlign) {
35 for (int cXAlign = 0 ; cXAlign < 5; ++cXAlign) {
36 for (int cYAlign = 0 ; cYAlign < 5; ++cYAlign) {
37 for (int dXAlign = 0 ; dXAlign < 5; ++dXAlign) {
38 for (int dYAlign = 0 ; dYAlign < 5; ++dYAlign) {
39 SkPath path, out;
40 char* str = pathStr;
41 path.setFillType(SkPath::kWinding_FillType);
42 int l, t, r, b;
43 if (aShape) {
44 switch (aShape) {
45 case 1: // square
46 l = 0; r = 60;
47 t = 0; b = 60;
48 aXAlign = 5;
49 aYAlign = 5;
50 break;
51 case 2:
52 l = aXAlign * 12;
53 r = l + 30;
54 t = 0; b = 60;
55 aYAlign = 5;
56 break;
57 case 3:
58 l = 0; r = 60;
59 t = aYAlign * 12;
60 b = l + 30;
61 aXAlign = 5;
62 break;
63 }
64 path.addRect(l, t, r, b, aCW);
65 str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
66 " SkPath::kC%sW_Direction);\n", l, t, r, b, aCW ? "C" : "");
67 } else {
68 aXAlign = 5;
69 aYAlign = 5;
70 }
71 if (bShape) {
72 switch (bShape) {
73 case 1: // square
74 l = bXAlign * 10;
75 r = l + 20;
76 t = bYAlign * 10;
77 b = l + 20;
78 break;
79 case 2:
80 l = bXAlign * 10;
81 r = l + 20;
82 t = 10; b = 40;
83 bYAlign = 5;
84 break;
85 case 3:
86 l = 10; r = 40;
87 t = bYAlign * 10;
88 b = l + 20;
89 bXAlign = 5;
90 break;
91 }
92 path.addRect(l, t, r, b, bCW);
93 str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
94 " SkPath::kC%sW_Direction);\n", l, t, r, b, bCW ? "C" : "");
95 } else {
96 bXAlign = 5;
97 bYAlign = 5;
98 }
99 if (cShape) {
100 switch (cShape) {
101 case 1: // square
102 l = cXAlign * 6;
103 r = l + 12;
104 t = cYAlign * 6;
105 b = l + 12;
106 break;
107 case 2:
108 l = cXAlign * 6;
109 r = l + 12;
110 t = 20; b = 30;
111 cYAlign = 5;
112 break;
113 case 3:
114 l = 20; r = 30;
115 t = cYAlign * 6;
116 b = l + 20;
117 cXAlign = 5;
118 break;
119 }
120 path.addRect(l, t, r, b, cCW);
121 str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
122 " SkPath::kC%sW_Direction);\n", l, t, r, b, cCW ? "C" : "");
123 } else {
124 cXAlign = 5;
125 cYAlign = 5;
126 }
127 if (dShape) {
128 switch (dShape) {
129 case 1: // square
130 l = dXAlign * 4;
131 r = l + 9;
132 t = dYAlign * 4;
133 b = l + 9;
134 break;
135 case 2:
136 l = dXAlign * 6;
137 r = l + 9;
138 t = 32; b = 36;
139 dYAlign = 5;
140 break;
141 case 3:
142 l = 32; r = 36;
143 t = dYAlign * 6;
144 b = l + 9;
145 dXAlign = 5;
146 break;
147 }
148 path.addRect(l, t, r, b, dCW);
149 str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
150 " SkPath::kC%sW_Direction);\n", l, t, r, b, dCW ? "C" : "");
151 } else {
152 dXAlign = 5;
153 dYAlign = 5;
154 }
155 path.close();
156 outputProgress(state, pathStr, SkPath::kWinding_FillType);
157 testSimplify(path, false, out, state, pathStr);
158 state.testsRun++;
159 outputProgress(state, pathStr, SkPath::kEvenOdd_FillType);
160 testSimplify(path, true, out, state, pathStr);
161 state.testsRun++;
162 }
163 }
164 }
165 }
166 }
167 }
168 }
169 }
170 } while (runNextTestSet(state));
171 return NULL;
172 }
173
174 static void TestSimplifyRectsThreaded(skiatest::Reporter* reporter)
175 {
176 int testsRun = 0;
177 if (gShowTestProgress) SkDebugf("%s\n", __FUNCTION__);
178 #ifdef SK_DEBUG
179 gDebugMaxWindSum = 4;
180 gDebugMaxWindValue = 4;
181 #endif
182 const char testLineStr[] = "testLine";
183 initializeTests(reporter, testLineStr, sizeof(testLineStr));
184 for (int a = 0; a < 8; ++a) { // outermost
185 for (int b = a ; b < 8; ++b) {
186 for (int c = b ; c < 8; ++c) {
187 for (int d = c; d < 8; ++d) {
188 testsRun += dispatchTest4(testSimplify4x4RectsMain, a, b, c, d);
189 }
190 if (!gAllowExtendedTest) goto finish;
191 if (gShowTestProgress) SkDebugf(".");
192 }
193 if (gShowTestProgress) SkDebugf("%d", b);
194 }
195 if (gShowTestProgress) SkDebugf("\n%d", a);
196 }
197 finish:
198 testsRun += waitForCompletion();
199 if (gShowTestProgress) SkDebugf("%s tests=%d\n", __FUNCTION__, testsRun);
200 }
201
202 #include "TestClassDef.h"
203 DEFINE_TESTCLASS("PathOpsSimplifyRectsThreaded",SimplifyRectsThreadedTestClass, \
204 TestSimplifyRectsThreaded)
OLDNEW
« no previous file with comments | « tests/PathOpsSimplifyQuadralateralsThreadedTest.cpp ('k') | tests/PathOpsSimplifyTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698