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

Side by Side Diff: tests/PathOpsOpLoopThreadedTest.cpp

Issue 1002693002: pathops version two (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix arm 64 inspired coincident handling Created 5 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
« no previous file with comments | « tests/PathOpsOpCubicThreadedTest.cpp ('k') | tests/PathOpsOpTest.cpp » ('j') | 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 #include "PathOpsExtendedTest.h" 7 #include "PathOpsExtendedTest.h"
8 #include "PathOpsThreadedCommon.h" 8 #include "PathOpsThreadedCommon.h"
9 9
10 static int add_point(char* str, SkScalar x, SkScalar y) {
11 int result;
12 int asInt = SkScalarRoundToInt(x);
13 if (SkIntToScalar(asInt) == x) {
14 result = sprintf(str, "%d", asInt);
15 } else {
16 result = sprintf(str, "%1.9gf", x);
17 }
18 result += sprintf(str + result, ",");
19 asInt = SkScalarRoundToInt(y);
20 if (SkIntToScalar(asInt) == y) {
21 result += sprintf(str + result, "%d", asInt);
22 } else {
23 result += sprintf(str + result, "%1.9gf", y);
24 }
25 return result;
26 }
27
10 static void testOpLoopsMain(PathOpsThreadState* data) { 28 static void testOpLoopsMain(PathOpsThreadState* data) {
11 #if DEBUG_SHOW_TEST_NAME 29 #if DEBUG_SHOW_TEST_NAME
12 strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH); 30 strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH);
13 #endif 31 #endif
14 SkASSERT(data); 32 SkASSERT(data);
15 PathOpsThreadState& state = *data; 33 PathOpsThreadState& state = *data;
16 char pathStr[1024]; // gdb: set print elements 400 34 char pathStr[1024]; // gdb: set print elements 400
17 bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter? 35 bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter?
18 if (progress) { 36 if (progress) {
19 sk_bzero(pathStr, sizeof(pathStr)); 37 sk_bzero(pathStr, sizeof(pathStr));
20 } 38 }
21 for (int a = 0 ; a < 6; ++a) { 39 for (int a = 0 ; a < 6; ++a) {
22 for (int b = a + 1 ; b < 7; ++b) { 40 for (int b = a + 1 ; b < 7; ++b) {
23 for (int c = 0 ; c < 6; ++c) { 41 for (int c = 0 ; c < 6; ++c) {
24 for (int d = c + 1 ; d < 7; ++d) { 42 for (int d = c + 1 ; d < 7; ++d) {
25 // define 4 points that form two lines that often cross; one line is (a, b) (c, d) 43 // define 4 points that form two lines that often cross; one line is (a, b) (c, d)
26 SkVector v = {SkIntToScalar(a - c), SkIntToScalar(b - d)}; 44 SkVector v = {SkIntToScalar(a - c), SkIntToScalar(b - d)};
27 SkPoint midA = { SkIntToScalar(a * state.fA + c * (6 - state.fA)) / 6, 45 SkPoint midA = { SkIntToScalar(a * state.fA + c * (6 - state.fA)) / 6,
28 SkIntToScalar(b * state.fA + d * (6 - state.fA)) / 6 }; 46 SkIntToScalar(b * state.fA + d * (6 - state.fA)) / 6 };
29 SkPoint midB = { SkIntToScalar(a * state.fB + c * (6 - state.fB)) / 6, 47 SkPoint midB = { SkIntToScalar(a * state.fB + c * (6 - state.fB)) / 6,
30 SkIntToScalar(b * state.fB + d * (6 - state.fB)) / 6 }; 48 SkIntToScalar(b * state.fB + d * (6 - state.fB)) / 6 };
31 SkPoint endC = { midA.fX + v.fY * state.fC / 3, 49 SkPoint endC = { midA.fX + v.fY * state.fC / 3,
32 midA.fY + v.fX * state.fC / 3 }; 50 midA.fY + v.fX * state.fC / 3 };
33 SkPoint endD = { midB.fX - v.fY * state.fD / 3, 51 SkPoint endD = { midB.fX - v.fY * state.fD / 3,
34 midB.fY + v.fX * state.fD / 3 }; 52 midB.fY + v.fX * state.fD / 3 };
35 SkPath pathA, pathB; 53 SkPath pathA, pathB;
36 if (progress) { 54 if (progress) {
37 char* str = pathStr; 55 char* str = pathStr;
56 const int loopNo = 7;
57 str += sprintf(str, "static void loop%d(skiatest::Reporter* reporter ,"
58 " const char* filename) {\n", loopNo);
59 str += sprintf(str, " SkPath path, pathB;\n");
38 str += sprintf(str, " path.moveTo(%d,%d);\n", a, b); 60 str += sprintf(str, " path.moveTo(%d,%d);\n", a, b);
39 str += sprintf(str, " path.cubicTo(%d,%d, %1.9gf,%1.9gf, %1.9gf,% 1.9gf);\n", 61 str += sprintf(str, " path.cubicTo(%d,%d, ", c, d);
40 c, d, endC.fX, endC.fY, endD.fX, endD.fY); 62 str += add_point(str, endC.fX, endC.fY);
63 str += sprintf(str, ", ");
64 str += add_point(str, endD.fX, endD.fY);
65 str += sprintf(str, ");\n");
41 str += sprintf(str, " path.close();\n"); 66 str += sprintf(str, " path.close();\n");
42 str += sprintf(str, " pathB.moveTo(%d,%d);\n", c, d); 67 str += sprintf(str, " pathB.moveTo(%d,%d);\n", c, d);
43 str += sprintf(str, " pathB.cubicTo(%1.9gf,%1.9gf, %1.9gf,%1.9gf, %d,%d);\n", 68 str += sprintf(str, " pathB.cubicTo(");
44 endC.fX, endC.fY, endD.fX, endD.fY, a, b); 69 str += add_point(str, endC.fX, endC.fY);
70 str += sprintf(str, ", ");
71 str += add_point(str, endD.fX, endD.fY);
72 str += sprintf(str, ", %d,%d);\n", a, b);
45 str += sprintf(str, " pathB.close();\n"); 73 str += sprintf(str, " pathB.close();\n");
74 str += sprintf(str, " testPathOp(reporter, path, pathB, kIntersec t_PathOp,"
75 " filename);\n");
76 str += sprintf(str, "}\n");
46 } 77 }
47 pathA.moveTo(SkIntToScalar(a), SkIntToScalar(b)); 78 pathA.moveTo(SkIntToScalar(a), SkIntToScalar(b));
48 pathA.cubicTo(SkIntToScalar(c), SkIntToScalar(d), endC.fX, endC.fY, endD .fX, endD.fY); 79 pathA.cubicTo(SkIntToScalar(c), SkIntToScalar(d), endC.fX, endC.fY, endD .fX, endD.fY);
49 pathA.close(); 80 pathA.close();
50 pathB.moveTo(SkIntToScalar(c), SkIntToScalar(d)); 81 pathB.moveTo(SkIntToScalar(c), SkIntToScalar(d));
51 pathB.cubicTo(endC.fX, endC.fY, endD.fX, endD.fY, SkIntToScalar(a), SkIn tToScalar(b)); 82 pathB.cubicTo(endC.fX, endC.fY, endD.fX, endD.fY, SkIntToScalar(a), SkIn tToScalar(b));
52 pathB.close(); 83 pathB.close();
53 // SkDebugf("%s\n", pathStr); 84 // SkDebugf("%s\n", pathStr);
54 if (progress) { 85 if (progress) {
55 outputProgress(state.fPathStr, pathStr, kIntersect_PathOp); 86 outputProgress(state.fPathStr, pathStr, kIntersect_PathOp);
56 } 87 }
57 testThreadedPathOp(state.fReporter, pathA, pathB, kIntersect_PathOp, "lo ops"); 88 testThreadedPathOp(state.fReporter, pathA, pathB, kIntersect_PathOp, "lo ops");
58 } 89 }
59 } 90 }
60 } 91 }
61 } 92 }
62 } 93 }
63 94
64 DEF_TEST(PathOpsOpLoopsThreaded, reporter) { 95 DEF_TEST(PathOpsOpLoopsThreaded, reporter) {
65 if (!FLAGS_runFail) {
66 return;
67 }
68 initializeTests(reporter, "cubicOp"); 96 initializeTests(reporter, "cubicOp");
69 PathOpsThreadedTestRunner testRunner(reporter); 97 PathOpsThreadedTestRunner testRunner(reporter);
70 for (int a = 0; a < 6; ++a) { // outermost 98 for (int a = 0; a < 6; ++a) { // outermost
71 for (int b = a + 1; b < 7; ++b) { 99 for (int b = a + 1; b < 7; ++b) {
72 for (int c = 0 ; c < 6; ++c) { 100 for (int c = 0 ; c < 6; ++c) {
73 for (int d = c + 1; d < 7; ++d) { 101 for (int d = c + 1; d < 7; ++d) {
74 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreaded Runnable, 102 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreaded Runnable,
75 (&testOpLoopsMain, a, b, c, d, &testRunner)); 103 (&testOpLoopsMain, a, b, c, d, &testRunner));
76 } 104 }
77 } 105 }
78 if (!reporter->allowExtendedTest()) goto finish; 106 if (!reporter->allowExtendedTest()) goto finish;
79 } 107 }
80 } 108 }
81 finish: 109 finish:
82 testRunner.render(); 110 testRunner.render();
83 ShowTestArray(); 111 ShowTestArray();
84 } 112 }
85 113
86 DEF_TEST(PathOpsOpLoops, reporter) { 114 DEF_TEST(PathOpsOpLoops, reporter) {
87 if (!FLAGS_runFail) {
88 return;
89 }
90 initializeTests(reporter, "cubicOp"); 115 initializeTests(reporter, "cubicOp");
91 PathOpsThreadState state; 116 PathOpsThreadState state;
92 state.fReporter = reporter; 117 state.fReporter = reporter;
93 SkBitmap bitmap; 118 SkBitmap bitmap;
94 state.fBitmap = &bitmap; 119 state.fBitmap = &bitmap;
95 char pathStr[PATH_STR_SIZE]; 120 char pathStr[PATH_STR_SIZE];
96 state.fPathStr = pathStr; 121 state.fPathStr = pathStr;
97 for (state.fA = 0; state.fA < 6; ++state.fA) { // outermost 122 for (state.fA = 0; state.fA < 6; ++state.fA) { // outermost
98 for (state.fB = state.fA + 1; state.fB < 7; ++state.fB) { 123 for (state.fB = state.fA + 1; state.fB < 7; ++state.fB) {
99 for (state.fC = 0 ; state.fC < 6; ++state.fC) { 124 for (state.fC = 0 ; state.fC < 6; ++state.fC) {
100 for (state.fD = state.fC + 1; state.fD < 7; ++state.fD) { 125 for (state.fD = state.fC + 1; state.fD < 7; ++state.fD) {
101 testOpLoopsMain(&state); 126 testOpLoopsMain(&state);
102 } 127 }
103 } 128 }
104 if (!reporter->allowExtendedTest()) goto finish; 129 if (!reporter->allowExtendedTest()) goto finish;
105 } 130 }
106 } 131 }
107 finish: 132 finish:
108 ShowTestArray(); 133 ShowTestArray();
109 } 134 }
OLDNEW
« no previous file with comments | « tests/PathOpsOpCubicThreadedTest.cpp ('k') | tests/PathOpsOpTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698