blob: 1b6e4e86b935ab4fa27db1a116d23e2df49c7f5d [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"
caryclark@google.com818b0cc2013-04-08 11:50:46 +00009
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)
15// cw or ccw (1 bit)
16
caryclark@google.com66089e42013-04-10 15:55:37 +000017static void testPathOpsRectsMain(PathOpsThreadState* data)
caryclark@google.com818b0cc2013-04-08 11:50:46 +000018{
19 SkASSERT(data);
caryclark@google.com66089e42013-04-10 15:55:37 +000020 PathOpsThreadState& state = *data;
caryclark@google.com818b0cc2013-04-08 11:50:46 +000021 char pathStr[1024]; // gdb: set print elements 400
caryclark@google.com8d0a5242013-07-16 16:11:16 +000022 bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter?
23 if (progress) {
24 sk_bzero(pathStr, sizeof(pathStr));
25 }
caryclark@google.com66089e42013-04-10 15:55:37 +000026 for (int a = 0 ; a < 6; ++a) {
27 for (int b = a + 1 ; b < 7; ++b) {
28 for (int c = 0 ; c < 6; ++c) {
29 for (int d = c + 1 ; d < 7; ++d) {
30 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) {
31 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) {
caryclark@google.com8d0a5242013-07-16 16:11:16 +000032 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::kEvenOdd_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::kEvenOdd_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 }
caryclark@google.com66089e42013-04-10 15:55:37 +000049 SkPath pathA, pathB;
caryclark@google.com66089e42013-04-10 15:55:37 +000050 pathA.setFillType((SkPath::FillType) e);
caryclark@google.com66089e42013-04-10 15:55:37 +000051 pathA.addRect(SkIntToScalar(state.fA), SkIntToScalar(state.fA), SkIntToScalar(state.fB),
52 SkIntToScalar(state.fB), SkPath::kCW_Direction);
caryclark@google.com66089e42013-04-10 15:55:37 +000053 pathA.addRect(SkIntToScalar(state.fC), SkIntToScalar(state.fC), SkIntToScalar(state.fD),
54 SkIntToScalar(state.fD), SkPath::kCW_Direction);
caryclark@google.com66089e42013-04-10 15:55:37 +000055 pathA.close();
56 pathB.setFillType((SkPath::FillType) f);
caryclark@google.com66089e42013-04-10 15:55:37 +000057 pathB.addRect(SkIntToScalar(a), SkIntToScalar(a), SkIntToScalar(b),
58 SkIntToScalar(b), SkPath::kCW_Direction);
caryclark@google.com66089e42013-04-10 15:55:37 +000059 pathB.addRect(SkIntToScalar(c), SkIntToScalar(c), SkIntToScalar(d),
60 SkIntToScalar(d), SkPath::kCW_Direction);
caryclark@google.com66089e42013-04-10 15:55:37 +000061 pathB.close();
62 for (int op = 0 ; op <= kXOR_PathOp; ++op) {
caryclark@google.com8d0a5242013-07-16 16:11:16 +000063 if (progress) {
64 outputProgress(state.fPathStr, pathStr, (SkPathOp) op);
65 }
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000066 testThreadedPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "rects");
caryclark@google.com66089e42013-04-10 15:55:37 +000067 }
68 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000069 }
70 }
71 }
caryclark@google.com66089e42013-04-10 15:55:37 +000072 }
73 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000074}
75
tfarina@chromium.org78e7b4e2014-01-02 21:45:03 +000076DEF_TEST(PathOpsRectsThreaded, reporter) {
mtklein406654b2014-09-03 15:34:37 -070077 initializeTests(reporter, "testOp");
78 PathOpsThreadedTestRunner testRunner(reporter);
caryclark@google.com818b0cc2013-04-08 11:50:46 +000079 for (int a = 0; a < 6; ++a) { // outermost
80 for (int b = a + 1; b < 7; ++b) {
81 for (int c = 0 ; c < 6; ++c) {
82 for (int d = c + 1; d < 7; ++d) {
caryclark@google.com66089e42013-04-10 15:55:37 +000083 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable,
84 (&testPathOpsRectsMain, a, b, c, d, &testRunner));
caryclark@google.com818b0cc2013-04-08 11:50:46 +000085 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000086 }
caryclark@google.com66089e42013-04-10 15:55:37 +000087 if (!reporter->allowExtendedTest()) goto finish;
caryclark@google.com818b0cc2013-04-08 11:50:46 +000088 }
caryclark@google.com818b0cc2013-04-08 11:50:46 +000089 }
90finish:
caryclark@google.com66089e42013-04-10 15:55:37 +000091 testRunner.render();
caryclark@google.com818b0cc2013-04-08 11:50:46 +000092}