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

Side by Side Diff: tests/PathOpsOpRectThreadedTest.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/PathOpsOpCubicThreadedTest.cpp ('k') | tests/PathOpsQuadIntersectionTest.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 // four rects, of four sizes 10 // four rects, of four sizes
11 // for 3 smaller sizes, tall, wide 11 // for 3 smaller sizes, tall, wide
12 // top upper mid lower bottom aligned (3 bits, 5 values) 12 // top upper mid lower bottom aligned (3 bits, 5 values)
13 // same with x (3 bits, 5 values) 13 // same with x (3 bits, 5 values)
14 // not included, square, tall, wide (2 bits) 14 // not included, square, tall, wide (2 bits)
15 // cw or ccw (1 bit) 15 // cw or ccw (1 bit)
16 16
17 static void testPathOpsRectsMain(PathOpsThreadState* data) 17 static void testPathOpsRectsMain(PathOpsThreadState* data)
18 { 18 {
19 SkASSERT(data); 19 SkASSERT(data);
20 PathOpsThreadState& state = *data; 20 PathOpsThreadState& state = *data;
21 char pathStr[1024]; // gdb: set print elements 400 21 char pathStr[1024]; // gdb: set print elements 400
22 sk_bzero(pathStr, sizeof(pathStr)); 22 bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter?
23 if (progress) {
24 sk_bzero(pathStr, sizeof(pathStr));
25 }
23 for (int a = 0 ; a < 6; ++a) { 26 for (int a = 0 ; a < 6; ++a) {
24 for (int b = a + 1 ; b < 7; ++b) { 27 for (int b = a + 1 ; b < 7; ++b) {
25 for (int c = 0 ; c < 6; ++c) { 28 for (int c = 0 ; c < 6; ++c) {
26 for (int d = c + 1 ; d < 7; ++d) { 29 for (int d = c + 1 ; d < 7; ++d) {
27 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenO dd_FillType; ++e) { 30 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenO dd_FillType; ++e) {
28 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f ) { 31 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f ) {
32 if (progress) {
33 char* str = pathStr;
34 str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n",
35 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kE venOdd_FillType
36 ? "EvenOdd" : "?UNDEFINED");
37 str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
38 " SkPath::kCW_Direction);\n", state.fA, state.fA, state.fB, state.fB);
39 str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
40 " SkPath::kCW_Direction);\n", state.fC, state.fC, state.fD, state.fD);
41 str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n" ,
42 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kE venOdd_FillType
43 ? "EvenOdd" : "?UNDEFINED");
44 str += sprintf(str, " pathB.addRect(%d, %d, %d, %d,"
45 " SkPath::kCW_Direction);\n", a, a, b, b);
46 str += sprintf(str, " pathB.addRect(%d, %d, %d, %d,"
47 " SkPath::kCW_Direction);\n", c, c, d, d);
48 }
29 SkPath pathA, pathB; 49 SkPath pathA, pathB;
30 char* str = pathStr;
31 pathA.setFillType((SkPath::FillType) e); 50 pathA.setFillType((SkPath::FillType) e);
32 str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n",
33 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenO dd_FillType
34 ? "EvenOdd" : "?UNDEFINED");
35 pathA.addRect(SkIntToScalar(state.fA), SkIntToScalar(state.fA), SkIntToS calar(state.fB), 51 pathA.addRect(SkIntToScalar(state.fA), SkIntToScalar(state.fA), SkIntToS calar(state.fB),
36 SkIntToScalar(state.fB), SkPath::kCW_Direction); 52 SkIntToScalar(state.fB), SkPath::kCW_Direction);
37 str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
38 " SkPath::kCW_Direction);\n", state.fA, state.fA, state.fB, stat e.fB);
39 pathA.addRect(SkIntToScalar(state.fC), SkIntToScalar(state.fC), SkIntToS calar(state.fD), 53 pathA.addRect(SkIntToScalar(state.fC), SkIntToScalar(state.fC), SkIntToS calar(state.fD),
40 SkIntToScalar(state.fD), SkPath::kCW_Direction); 54 SkIntToScalar(state.fD), SkPath::kCW_Direction);
41 str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
42 " SkPath::kCW_Direction);\n", state.fC, state.fC, state.fD, stat e.fD);
43 pathA.close(); 55 pathA.close();
44 pathB.setFillType((SkPath::FillType) f); 56 pathB.setFillType((SkPath::FillType) f);
45 str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n",
46 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenO dd_FillType
47 ? "EvenOdd" : "?UNDEFINED");
48 pathB.addRect(SkIntToScalar(a), SkIntToScalar(a), SkIntToScalar(b), 57 pathB.addRect(SkIntToScalar(a), SkIntToScalar(a), SkIntToScalar(b),
49 SkIntToScalar(b), SkPath::kCW_Direction); 58 SkIntToScalar(b), SkPath::kCW_Direction);
50 str += sprintf(str, " pathB.addRect(%d, %d, %d, %d,"
51 " SkPath::kCW_Direction);\n", a, a, b, b);
52 pathB.addRect(SkIntToScalar(c), SkIntToScalar(c), SkIntToScalar(d), 59 pathB.addRect(SkIntToScalar(c), SkIntToScalar(c), SkIntToScalar(d),
53 SkIntToScalar(d), SkPath::kCW_Direction); 60 SkIntToScalar(d), SkPath::kCW_Direction);
54 str += sprintf(str, " pathB.addRect(%d, %d, %d, %d,"
55 " SkPath::kCW_Direction);\n", c, c, d, d);
56 pathB.close(); 61 pathB.close();
57 for (int op = 0 ; op <= kXOR_PathOp; ++op) { 62 for (int op = 0 ; op <= kXOR_PathOp; ++op) {
58 outputProgress(state.fPathStr, pathStr, (SkPathOp) op); 63 if (progress) {
59 testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op); 64 outputProgress(state.fPathStr, pathStr, (SkPathOp) op);
65 }
66 testThreadedPathOp(state.fReporter, pathA, pathB, (SkPathOp) op);
60 } 67 }
61 } 68 }
62 } 69 }
63 } 70 }
64 } 71 }
65 } 72 }
66 } 73 }
67 } 74 }
68 75
69 static void PathOpsRectsThreadedTest(skiatest::Reporter* reporter) { 76 static void PathOpsRectsThreadedTest(skiatest::Reporter* reporter) {
70 int threadCount = initializeTests(reporter, "testOp"); 77 int threadCount = initializeTests(reporter, "testOp");
71 PathOpsThreadedTestRunner testRunner(reporter, threadCount); 78 PathOpsThreadedTestRunner testRunner(reporter, threadCount);
72 for (int a = 0; a < 6; ++a) { // outermost 79 for (int a = 0; a < 6; ++a) { // outermost
73 for (int b = a + 1; b < 7; ++b) { 80 for (int b = a + 1; b < 7; ++b) {
74 for (int c = 0 ; c < 6; ++c) { 81 for (int c = 0 ; c < 6; ++c) {
75 for (int d = c + 1; d < 7; ++d) { 82 for (int d = c + 1; d < 7; ++d) {
76 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreaded Runnable, 83 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreaded Runnable,
77 (&testPathOpsRectsMain, a, b, c, d, &testRunner)); 84 (&testPathOpsRectsMain, a, b, c, d, &testRunner));
78 } 85 }
79 } 86 }
80 if (!reporter->allowExtendedTest()) goto finish; 87 if (!reporter->allowExtendedTest()) goto finish;
81 } 88 }
82 } 89 }
83 finish: 90 finish:
84 testRunner.render(); 91 testRunner.render();
85 } 92 }
86 93
87 #include "TestClassDef.h" 94 #include "TestClassDef.h"
88 DEFINE_TESTCLASS_SHORT(PathOpsRectsThreadedTest) 95 DEFINE_TESTCLASS_SHORT(PathOpsRectsThreadedTest)
OLDNEW
« no previous file with comments | « tests/PathOpsOpCubicThreadedTest.cpp ('k') | tests/PathOpsQuadIntersectionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698