1/* 2 * Copyright 2015 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" 8#include "PathOpsThreadedCommon.h" 9 10static void testOpCirclesMain(PathOpsThreadState* data) { 11 SkASSERT(data); 12 PathOpsThreadState& state = *data; 13 char pathStr[1024]; 14 bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter? 15 if (progress) { 16 sk_bzero(pathStr, sizeof(pathStr)); 17 } 18 19 for (int a = 0 ; a < 6; ++a) { 20 for (int b = a + 1 ; b < 7; ++b) { 21 for (int c = 0 ; c < 6; ++c) { 22 for (int d = c + 1 ; d < 7; ++d) { 23 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) { 24 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) { 25 SkPath pathA, pathB; 26 if (progress) { 27 char* str = pathStr; 28 const int loopNo = 4; 29 str += sprintf(str, "static void circlesOp%d(skiatest::Reporter* reporter," 30 " const char* filename) {\n", loopNo); 31 str += sprintf(str, " SkPath path, pathB;\n"); 32 str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n", 33 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType 34 ? "EvenOdd" : "?UNDEFINED"); 35 str += sprintf(str, " path.addCircle(%d, %d, %d, %s);\n", state.fA, state.fB, 36 state.fC, state.fD ? "SkPath::kCW_Direction" : "SkPath::kCCW_Direction"); 37 str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n", 38 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType 39 ? "EvenOdd" : "?UNDEFINED"); 40 str += sprintf(str, " pathB.addCircle(%d, %d, %d, %s);\n", a, b, 41 c, d ? "SkPath::kCW_Direction" : "SkPath::kCCW_Direction"); 42 str += sprintf(str, " testPathOp(reporter, path, pathB, kDifference_SkPathOp," 43 " filename);\n"); 44 str += sprintf(str, "}\n"); 45 } 46 pathA.setFillType((SkPath::FillType) e); 47 pathA.addCircle(SkIntToScalar(state.fA), SkIntToScalar(state.fB), SkIntToScalar(state.fC), 48 state.fD ? SkPath::kCW_Direction : SkPath::kCCW_Direction); 49 pathB.setFillType((SkPath::FillType) f); 50 pathB.addCircle(SkIntToScalar(a), SkIntToScalar(b), SkIntToScalar(c), 51 d ? SkPath::kCW_Direction : SkPath::kCCW_Direction); 52 for (int op = 0 ; op <= kXOR_SkPathOp; ++op) { 53 if (progress) { 54 outputProgress(state.fPathStr, pathStr, (SkPathOp) op); 55 } 56 testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "circles"); 57 } 58 } 59 } 60 } 61 } 62 } 63 } 64} 65 66DEF_TEST(PathOpsOpCircleThreaded, reporter) { 67 initializeTests(reporter, "circleOp"); 68 PathOpsThreadedTestRunner testRunner(reporter); 69 for (int a = 0; a < 6; ++a) { // outermost 70 for (int b = a + 1; b < 7; ++b) { 71 for (int c = 0 ; c < 6; ++c) { 72 for (int d = 0; d < 2; ++d) { 73 *testRunner.fRunnables.append() = new PathOpsThreadedRunnable( 74 &testOpCirclesMain, a, b, c, d, &testRunner); 75 } 76 } 77 if (!reporter->allowExtendedTest()) goto finish; 78 } 79 } 80finish: 81 testRunner.render(); 82 ShowTestArray("circleOp"); 83} 84