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

Side by Side Diff: tests/PathOpsOpLoopThreadedTest.cpp

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