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

Side by Side Diff: tests/PathOpsSimplifyTrianglesThreadedTest.cpp

Issue 13094010: Add implementation of path ops (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 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/PathOpsSimplifyTest.cpp ('k') | tests/PathOpsTestCommon.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:executable
+ *
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 static void* testSimplifyTrianglesMain(void* data) {
10 SkASSERT(data);
11 State4& state = *(State4*) data;
12 char pathStr[1024];
13 bzero(pathStr, sizeof(pathStr));
14 do {
15 int ax = state.a & 0x03;
16 int ay = state.a >> 2;
17 int bx = state.b & 0x03;
18 int by = state.b >> 2;
19 int cx = state.c & 0x03;
20 int cy = state.c >> 2;
21 for (int d = 0; d < 15; ++d) {
22 int dx = d & 0x03;
23 int dy = d >> 2;
24 for (int e = d + 1; e < 16; ++e) {
25 int ex = e & 0x03;
26 int ey = e >> 2;
27 for (int f = d + 1; f < 16; ++f) {
28 if (e == f) {
29 continue;
30 }
31 int fx = f & 0x03;
32 int fy = f >> 2;
33 if ((ex - dx) * (fy - dy) == (ey - dy) * (fx - dx)) {
34 continue;
35 }
36 SkPath path, out;
37 path.setFillType(SkPath::kWinding_FillType);
38 path.moveTo(ax, ay);
39 path.lineTo(bx, by);
40 path.lineTo(cx, cy);
41 path.close();
42 path.moveTo(dx, dy);
43 path.lineTo(ex, ey);
44 path.lineTo(fx, fy);
45 path.close();
46 if (1) {
47 char* str = pathStr;
48 str += sprintf(str, " path.moveTo(%d, %d);\n", ax, ay );
49 str += sprintf(str, " path.lineTo(%d, %d);\n", bx, by );
50 str += sprintf(str, " path.lineTo(%d, %d);\n", cx, cy );
51 str += sprintf(str, " path.close();\n");
52 str += sprintf(str, " path.moveTo(%d, %d);\n", dx, dy );
53 str += sprintf(str, " path.lineTo(%d, %d);\n", ex, ey );
54 str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy );
55 str += sprintf(str, " path.close();\n");
56 }
57 outputProgress(state, pathStr, SkPath::kWinding_FillType);
58 testSimplify(path, false, out, state, pathStr);
59 state.testsRun++;
60 path.setFillType(SkPath::kEvenOdd_FillType);
61 outputProgress(state, pathStr, SkPath::kEvenOdd_FillType);
62 testSimplify(path, true, out, state, pathStr);
63 state.testsRun++;
64 }
65 }
66 }
67 } while (runNextTestSet(state));
68 return NULL;
69 }
70
71 static void TestSimplifyTrianglesThreaded(skiatest::Reporter* reporter) {
72 int testsRun = 0;
73 if (gShowTestProgress) SkDebugf("%s\n", __FUNCTION__);
74 #ifdef SK_DEBUG
75 gDebugMaxWindSum = 2;
76 gDebugMaxWindValue = 2;
77 #endif
78 const char testStr[] = "testTriangles";
79 initializeTests(reporter, testStr, sizeof(testStr));
80 for (int a = 0; a < 15; ++a) {
81 int ax = a & 0x03;
82 int ay = a >> 2;
83 for (int b = a + 1; b < 16; ++b) {
84 int bx = b & 0x03;
85 int by = b >> 2;
86 for (int c = a + 1; c < 16; ++c) {
87 if (b == c) {
88 continue;
89 }
90 int cx = c & 0x03;
91 int cy = c >> 2;
92 if ((bx - ax) * (cy - ay) == (by - ay) * (cx - ax)) {
93 continue;
94 }
95 testsRun += dispatchTest4(testSimplifyTrianglesMain, a, b, c, 0) ;
96 }
97 if (!gAllowExtendedTest) goto finish;
98 if (gShowTestProgress) SkDebugf(".");
99 }
100 if (gShowTestProgress) SkDebugf("\n%d", a);
101 }
102 finish:
103 testsRun += waitForCompletion();
104 if (gShowTestProgress) SkDebugf("%s tests=%d\n", __FUNCTION__, testsRun);
105 }
106
107 #include "TestClassDef.h"
108 DEFINE_TESTCLASS("SimplifyTrianglesThreaded", SimplifyTrianglesThreadedTestClass , \
109 TestSimplifyTrianglesThreaded)
OLDNEW
« no previous file with comments | « tests/PathOpsSimplifyTest.cpp ('k') | tests/PathOpsTestCommon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698