2 * Copyright 2012 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
7 #include "PathOpsExtendedTest.h"
8 #include "PathOpsThreadedCommon.h"
10 // four rects, of four sizes
11 // for 3 smaller sizes, tall, wide
12 // top upper mid lower bottom aligned (3 bits, 5 values)
13 // same with x (3 bits, 5 values)
14 // not included, square, tall, wide (2 bits)
17 static void testSimplify4x4RectsMain(PathOpsThreadState* data)
20 PathOpsThreadState& state = *data;
21 char pathStr[1024]; // gdb: set print elements 400
22 bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter?
24 sk_bzero(pathStr, sizeof(pathStr));
26 int aShape = state.fA & 0x03;
27 SkPath::Direction aCW = state.fA >> 2 ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
28 int bShape = state.fB & 0x03;
29 SkPath::Direction bCW = state.fB >> 2 ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
30 int cShape = state.fC & 0x03;
31 SkPath::Direction cCW = state.fC >> 2 ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
32 int dShape = state.fD & 0x03;
33 SkPath::Direction dCW = state.fD >> 2 ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
34 for (int aXAlign = 0; aXAlign < 5; ++aXAlign) {
35 for (int aYAlign = 0; aYAlign < 5; ++aYAlign) {
36 for (int bXAlign = 0; bXAlign < 5; ++bXAlign) {
37 for (int bYAlign = 0; bYAlign < 5; ++bYAlign) {
38 for (int cXAlign = 0; cXAlign < 5; ++cXAlign) {
39 for (int cYAlign = 0; cYAlign < 5; ++cYAlign) {
40 for (int dXAlign = 0; dXAlign < 5; ++dXAlign) {
41 for (int dYAlign = 0; dYAlign < 5; ++dYAlign) {
44 path.setFillType(SkPath::kWinding_FillType);
67 path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), SkIntToScalar(b),
70 str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
71 " SkPath::kC%sW_Direction);\n", l, t, r, b, aCW ? "C" : "");
98 path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), SkIntToScalar(b),
101 str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
102 " SkPath::kC%sW_Direction);\n", l, t, r, b, bCW ? "C" : "");
129 path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), SkIntToScalar(b),
132 str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
133 " SkPath::kC%sW_Direction);\n", l, t, r, b, cCW ? "C" : "");
160 path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), SkIntToScalar(b),
163 str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
164 " SkPath::kC%sW_Direction);\n", l, t, r, b, dCW ? "C" : "");
172 outputProgress(state.fPathStr, pathStr, SkPath::kWinding_FillType);
174 testSimplify(path, false, out, state, pathStr);
176 outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_FillType);
178 testSimplify(path, true, out, state, pathStr);
189 DEF_TEST(PathOpsSimplifyRectsThreaded, reporter) {
190 initializeTests(reporter, "testLine");
191 PathOpsThreadedTestRunner testRunner(reporter);
192 for (int a = 0; a < 8; ++a) { // outermost
193 for (int b = a ; b < 8; ++b) {
194 for (int c = b ; c < 8; ++c) {
195 for (int d = c; d < 8; ++d) {
196 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable,
197 (&testSimplify4x4RectsMain, a, b, c, d, &testRunner));
199 if (!reporter->allowExtendedTest()) goto finish;