blob: e33333a9e58da163faec81413b5bb74ae69711e1 [file] [log] [blame]
caryclark@google.com818b0cc2013-04-08 11:50:46 +00001/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7#include "PathOpsExtendedTest.h"
caryclark@google.com66089e42013-04-10 15:55:37 +00008#include "PathOpsThreadedCommon.h"
tfarina@chromium.org78e7b4e2014-01-02 21:45:03 +00009#include "TestClassDef.h"
caryclark@google.com818b0cc2013-04-08 11:50:46 +000010
caryclark@google.com66089e42013-04-10 15:55:37 +000011static void testSimplifyQuadsMain(PathOpsThreadState* data)
caryclark@google.com818b0cc2013-04-08 11:50:46 +000012{
13 SkASSERT(data);
caryclark@google.com66089e42013-04-10 15:55:37 +000014 PathOpsThreadState& state = *data;
caryclark@google.com818b0cc2013-04-08 11:50:46 +000015 char pathStr[1024];
caryclark@google.com8d0a5242013-07-16 16:11:16 +000016 bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter?
17 if (progress) {
18 sk_bzero(pathStr, sizeof(pathStr));
19 }
caryclark@google.com66089e42013-04-10 15:55:37 +000020 int ax = state.fA & 0x03;
21 int ay = state.fA >> 2;
22 int bx = state.fB & 0x03;
23 int by = state.fB >> 2;
24 int cx = state.fC & 0x03;
25 int cy = state.fC >> 2;
26 int dx = state.fD & 0x03;
27 int dy = state.fD >> 2;
28 for (int e = 0 ; e < 16; ++e) {
29 int ex = e & 0x03;
30 int ey = e >> 2;
31 for (int f = e ; f < 16; ++f) {
32 int fx = f & 0x03;
33 int fy = f >> 2;
34 for (int g = f ; g < 16; ++g) {
35 int gx = g & 0x03;
36 int gy = g >> 2;
37 for (int h = g ; h < 16; ++h) {
38 int hx = h & 0x03;
39 int hy = h >> 2;
40 SkPath path, out;
41 path.setFillType(SkPath::kWinding_FillType);
42 path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay));
43 path.quadTo(SkIntToScalar(bx), SkIntToScalar(by),
44 SkIntToScalar(cx), SkIntToScalar(cy));
45 path.lineTo(SkIntToScalar(dx), SkIntToScalar(dy));
46 path.close();
47 path.moveTo(SkIntToScalar(ex), SkIntToScalar(ey));
48 path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy));
49 path.quadTo(SkIntToScalar(gx), SkIntToScalar(gy),
50 SkIntToScalar(hx), SkIntToScalar(hy));
51 path.close();
caryclark@google.com8d0a5242013-07-16 16:11:16 +000052 if (progress) {
53 // gdb: set print elements 400
54 char* str = pathStr;
55 str += sprintf(str, " path.moveTo(%d, %d);\n", ax, ay);
56 str += sprintf(str, " path.quadTo(%d, %d, %d, %d);\n", bx, by, cx, cy);
57 str += sprintf(str, " path.lineTo(%d, %d);\n", dx, dy);
58 str += sprintf(str, " path.close();\n");
59 str += sprintf(str, " path.moveTo(%d, %d);\n", ex, ey);
60 str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy);
61 str += sprintf(str, " path.quadTo(%d, %d, %d, %d);\n", gx, gy, hx, hy);
62 str += sprintf(str, " path.close();\n");
63 outputProgress(state.fPathStr, pathStr, SkPath::kWinding_FillType);
64 }
caryclark@google.com66089e42013-04-10 15:55:37 +000065 testSimplify(path, false, out, state, pathStr);
66 path.setFillType(SkPath::kEvenOdd_FillType);
caryclark@google.com8d0a5242013-07-16 16:11:16 +000067 if (progress) {
68 outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_FillType);
69 }
caryclark@google.com66089e42013-04-10 15:55:37 +000070 testSimplify(path, true, out, state, pathStr);
caryclark@google.com818b0cc2013-04-08 11:50:46 +000071 }
72 }
73 }
caryclark@google.com66089e42013-04-10 15:55:37 +000074 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000075}
76
tfarina@chromium.org78e7b4e2014-01-02 21:45:03 +000077DEF_TEST(PathOpsSimplifyQuadsThreaded, reporter) {
caryclark@google.com16cfe402013-04-18 18:47:37 +000078 int threadCount = initializeTests(reporter, "testQuads");
caryclark@google.com66089e42013-04-10 15:55:37 +000079 PathOpsThreadedTestRunner testRunner(reporter, threadCount);
caryclark@google.com818b0cc2013-04-08 11:50:46 +000080 int a = 0;
81 for (; a < 16; ++a) {
82 for (int b = a ; b < 16; ++b) {
83 for (int c = b ; c < 16; ++c) {
84 for (int d = c; d < 16; ++d) {
caryclark@google.com66089e42013-04-10 15:55:37 +000085 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable,
86 (&testSimplifyQuadsMain, a, b, c, d, &testRunner));
caryclark@google.com818b0cc2013-04-08 11:50:46 +000087 }
caryclark@google.com66089e42013-04-10 15:55:37 +000088 if (!reporter->allowExtendedTest()) goto finish;
caryclark@google.com818b0cc2013-04-08 11:50:46 +000089 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000090 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000091 }
92finish:
caryclark@google.com66089e42013-04-10 15:55:37 +000093 testRunner.render();
caryclark@google.com818b0cc2013-04-08 11:50:46 +000094}