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 #include "SkString.h" 10 11 static int loopNo = 4; 12 13 static void testOpCirclesMain(PathOpsThreadState* data) { 14 SkASSERT(data); 15 PathOpsThreadState& state = *data; 16 SkString pathStr; 17 for (int a = 0 ; a < 6; ++a) { 18 for (int b = a + 1 ; b < 7; ++b) { 19 for (int c = 0 ; c < 6; ++c) { 20 for (int d = c + 1 ; d < 7; ++d) { 21 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) { 22 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) { 23 SkPath pathA, pathB; 24 pathA.setFillType((SkPath::FillType) e); 25 pathA.addCircle(SkIntToScalar(state.fA), SkIntToScalar(state.fB), SkIntToScalar(state.fC), 26 state.fD ? SkPath::kCW_Direction : SkPath::kCCW_Direction); 27 pathB.setFillType((SkPath::FillType) f); 28 pathB.addCircle(SkIntToScalar(a), SkIntToScalar(b), SkIntToScalar(c), 29 d ? SkPath::kCW_Direction : SkPath::kCCW_Direction); 30 for (int op = 0 ; op <= kXOR_SkPathOp; ++op) { 31 if (state.fReporter->verbose()) { 32 pathStr.printf("static void circlesOp%d(skiatest::Reporter* reporter," 33 " const char* filename) {\n", loopNo); 34 pathStr.appendf(" SkPath path, pathB;\n"); 35 pathStr.appendf(" path.setFillType(SkPath::k%s_FillType);\n", 36 e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType 37 ? "EvenOdd" : "?UNDEFINED"); 38 pathStr.appendf(" path.addCircle(%d, %d, %d, %s);\n", state.fA, state.fB, 39 state.fC, state.fD ? "SkPath::kCW_Direction" : "SkPath::kCCW_Direction"); 40 pathStr.appendf(" pathB.setFillType(SkPath::k%s_FillType);\n", 41 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType 42 ? "EvenOdd" : "?UNDEFINED"); 43 pathStr.appendf(" pathB.addCircle(%d, %d, %d, %s);\n", a, b, 44 c, d ? "SkPath::kCW_Direction" : "SkPath::kCCW_Direction"); 45 pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filename);\n", 46 SkPathOpsDebug::OpStr((SkPathOp) op)); 47 pathStr.appendf("}\n"); 48 state.outputProgress(pathStr.c_str(), (SkPathOp) op); 49 } 50 if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "circles")) { 51 if (state.fReporter->verbose()) { 52 ++loopNo; 53 goto skipToNext; 54 } 55 } 56 } 57 } 58 } 59 skipToNext: ; 60 } 61 } 62 } 63 } 64 } 65 66 DEF_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 } 80 finish: 81 testRunner.render(); 82 } 83