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

Side by Side Diff: tests/PathOpsOpCubicThreadedTest.cpp

Issue 19374003: harden and speed up path op unit tests (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rename threaded to single Created 7 years, 5 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/PathOpsLineParametetersTest.cpp ('k') | tests/PathOpsOpRectThreadedTest.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 2012 Google Inc. 2 * Copyright 2012 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 void testOpCubicsMain(PathOpsThreadState* data) 10 static void testOpCubicsMain(PathOpsThreadState* data)
11 { 11 {
12 #if DEBUG_SHOW_TEST_NAME 12 #if DEBUG_SHOW_TEST_NAME
13 strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH); 13 strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH);
14 #endif 14 #endif
15 SkASSERT(data); 15 SkASSERT(data);
16 PathOpsThreadState& state = *data; 16 PathOpsThreadState& state = *data;
17 char pathStr[1024]; // gdb: set print elements 400 17 char pathStr[1024]; // gdb: set print elements 400
18 sk_bzero(pathStr, sizeof(pathStr)); 18 bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter?
19 if (progress) {
20 sk_bzero(pathStr, sizeof(pathStr));
21 }
19 for (int a = 0 ; a < 6; ++a) { 22 for (int a = 0 ; a < 6; ++a) {
20 for (int b = a + 1 ; b < 7; ++b) { 23 for (int b = a + 1 ; b < 7; ++b) {
21 for (int c = 0 ; c < 6; ++c) { 24 for (int c = 0 ; c < 6; ++c) {
22 for (int d = c + 1 ; d < 7; ++d) { 25 for (int d = c + 1 ; d < 7; ++d) {
23 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenO dd_FillType; ++e) { 26 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenO dd_FillType; ++e) {
24 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f ) { 27 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f ) {
25 SkPath pathA, pathB; 28 SkPath pathA, pathB;
26 char* str = pathStr; 29 if (progress) {
30 char* str = pathStr;
31 str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n",
32 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kE venOdd_FillType
33 ? "EvenOdd" : "?UNDEFINED");
34 str += sprintf(str, " path.moveTo(%d,%d);\n", state.fA, state.fB) ;
35 str += sprintf(str, " path.cubicTo(%d,%d, %d,%d, %d,%d);\n", stat e.fC, state.fD,
36 b, a, d, c);
37 str += sprintf(str, " path.close();\n");
38 str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n" ,
39 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kE venOdd_FillType
40 ? "EvenOdd" : "?UNDEFINED");
41 str += sprintf(str, " pathB.moveTo(%d,%d);\n", a, b);
42 str += sprintf(str, " pathB.cubicTo(%d,%d, %d,%d, %d,%d);\n", c, d,
43 state.fB, state.fA, state.fD, state.fC);
44 str += sprintf(str, " pathB.close();\n");
45 }
27 pathA.setFillType((SkPath::FillType) e); 46 pathA.setFillType((SkPath::FillType) e);
28 str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n",
29 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenO dd_FillType
30 ? "EvenOdd" : "?UNDEFINED");
31 pathA.moveTo(SkIntToScalar(state.fA), SkIntToScalar(state.fB)); 47 pathA.moveTo(SkIntToScalar(state.fA), SkIntToScalar(state.fB));
32 str += sprintf(str, " path.moveTo(%d,%d);\n", state.fA, state.fB);
33 pathA.cubicTo(SkIntToScalar(state.fC), SkIntToScalar(state.fD), SkIntToS calar(b), 48 pathA.cubicTo(SkIntToScalar(state.fC), SkIntToScalar(state.fD), SkIntToS calar(b),
34 SkIntToScalar(a), SkIntToScalar(d), SkIntToScalar(c)); 49 SkIntToScalar(a), SkIntToScalar(d), SkIntToScalar(c));
35 str += sprintf(str, " path.cubicTo(%d,%d, %d,%d, %d,%d);\n", state.fC , state.fD,
36 b, a, d, c);
37 pathA.close(); 50 pathA.close();
38 str += sprintf(str, " path.close();\n");
39 pathB.setFillType((SkPath::FillType) f); 51 pathB.setFillType((SkPath::FillType) f);
40 str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n",
41 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenO dd_FillType
42 ? "EvenOdd" : "?UNDEFINED");
43 pathB.moveTo(SkIntToScalar(a), SkIntToScalar(b)); 52 pathB.moveTo(SkIntToScalar(a), SkIntToScalar(b));
44 str += sprintf(str, " pathB.moveTo(%d,%d);\n", a, b);
45 pathB.cubicTo(SkIntToScalar(c), SkIntToScalar(d), SkIntToScalar(state.fB ), 53 pathB.cubicTo(SkIntToScalar(c), SkIntToScalar(d), SkIntToScalar(state.fB ),
46 SkIntToScalar(state.fA), SkIntToScalar(state.fD), SkIntToScalar( state.fC)); 54 SkIntToScalar(state.fA), SkIntToScalar(state.fD), SkIntToScalar( state.fC));
47 str += sprintf(str, " pathB.cubicTo(%d,%d, %d,%d, %d,%d);\n", c, d,
48 state.fB, state.fA, state.fD, state.fC);
49 pathB.close(); 55 pathB.close();
50 str += sprintf(str, " pathB.close();\n");
51 for (int op = 0 ; op <= kXOR_PathOp; ++op) { 56 for (int op = 0 ; op <= kXOR_PathOp; ++op) {
52 outputProgress(state.fPathStr, pathStr, (SkPathOp) op); 57 if (progress) {
53 testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op); 58 outputProgress(state.fPathStr, pathStr, (SkPathOp) op);
59 }
60 testThreadedPathOp(state.fReporter, pathA, pathB, (SkPathOp) op);
54 } 61 }
55 } 62 }
56 } 63 }
57 } 64 }
58 } 65 }
59 } 66 }
60 } 67 }
61 } 68 }
62 69
63 static void PathOpsOpCubicsThreadedTest(skiatest::Reporter* reporter) 70 static void PathOpsOpCubicsThreadedTest(skiatest::Reporter* reporter)
(...skipping 10 matching lines...) Expand all
74 } 81 }
75 if (!reporter->allowExtendedTest()) goto finish; 82 if (!reporter->allowExtendedTest()) goto finish;
76 } 83 }
77 } 84 }
78 finish: 85 finish:
79 testRunner.render(); 86 testRunner.render();
80 } 87 }
81 88
82 #include "TestClassDef.h" 89 #include "TestClassDef.h"
83 DEFINE_TESTCLASS_SHORT(PathOpsOpCubicsThreadedTest) 90 DEFINE_TESTCLASS_SHORT(PathOpsOpCubicsThreadedTest)
OLDNEW
« no previous file with comments | « tests/PathOpsLineParametetersTest.cpp ('k') | tests/PathOpsOpRectThreadedTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698