PathOpsOpRectThreadedTest.cpp revision 818b0cc1b8b0c4acc565e8e2cb8b0b61aa5a300e
1/* 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" 8 9// four rects, of four sizes 10// for 3 smaller sizes, tall, wide 11 // top upper mid lower bottom aligned (3 bits, 5 values) 12 // same with x (3 bits, 5 values) 13// not included, square, tall, wide (2 bits) 14// cw or ccw (1 bit) 15 16static THREAD_TYPE testPathOpsRectsMain(void* data) 17{ 18 SkASSERT(data); 19 State4& state = *(State4*) data; 20 char pathStr[1024]; // gdb: set print elements 400 21 sk_bzero(pathStr, sizeof(pathStr)); 22 do { 23 for (int a = 0 ; a < 6; ++a) { 24 for (int b = a + 1 ; b < 7; ++b) { 25 for (int c = 0 ; c < 6; ++c) { 26 for (int d = c + 1 ; d < 7; ++d) { 27 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) { 28 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) { 29 SkPath pathA, pathB; 30 char* str = pathStr; 31 pathA.setFillType((SkPath::FillType) e); 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 pathA.addRect(SkIntToScalar(state.a), SkIntToScalar(state.a), SkIntToScalar(state.b), 36 SkIntToScalar(state.b), SkPath::kCW_Direction); 37 str += sprintf(str, " path.addRect(%d, %d, %d, %d," 38 " SkPath::kCW_Direction);\n", state.a, state.a, state.b, state.b); 39 pathA.addRect(SkIntToScalar(state.c), SkIntToScalar(state.c), SkIntToScalar(state.d), 40 SkIntToScalar(state.d), SkPath::kCW_Direction); 41 str += sprintf(str, " path.addRect(%d, %d, %d, %d," 42 " SkPath::kCW_Direction);\n", state.c, state.c, state.d, state.d); 43 pathA.close(); 44 pathB.setFillType((SkPath::FillType) f); 45 str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n", 46 f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType 47 ? "EvenOdd" : "?UNDEFINED"); 48 pathB.addRect(SkIntToScalar(a), SkIntToScalar(a), SkIntToScalar(b), 49 SkIntToScalar(b), SkPath::kCW_Direction); 50 str += sprintf(str, " pathB.addRect(%d, %d, %d, %d," 51 " SkPath::kCW_Direction);\n", a, a, b, b); 52 pathB.addRect(SkIntToScalar(c), SkIntToScalar(c), SkIntToScalar(d), 53 SkIntToScalar(d), SkPath::kCW_Direction); 54 str += sprintf(str, " pathB.addRect(%d, %d, %d, %d," 55 " SkPath::kCW_Direction);\n", c, c, d, d); 56 pathB.close(); 57 for (int op = 0 ; op <= kXOR_PathOp; ++op) { 58 outputProgress(state, pathStr, (SkPathOp) op); 59 testPathOp(state.reporter, pathA, pathB, (SkPathOp) op); 60 state.testsRun++; 61 } 62 } 63 } 64 } 65 } 66 } 67 } 68 } while (runNextTestSet(state)); 69 THREAD_RETURN 70} 71 72static void TestPathOpsRectsThreaded(skiatest::Reporter* reporter) { 73 int testsRun = 0; 74 if (gShowTestProgress) SkDebugf("%s\n", __FUNCTION__); 75#ifdef SK_DEBUG 76 gDebugMaxWindSum = 4; 77 gDebugMaxWindValue = 4; 78#endif 79 const char testLineStr[] = "testOp"; 80 initializeTests(reporter, testLineStr, sizeof(testLineStr)); 81 for (int a = 0; a < 6; ++a) { // outermost 82 for (int b = a + 1; b < 7; ++b) { 83 for (int c = 0 ; c < 6; ++c) { 84 for (int d = c + 1; d < 7; ++d) { 85 testsRun += dispatchTest4(testPathOpsRectsMain, a, b, c, d); 86 } 87 if (gShowTestProgress) SkDebugf("."); 88 } 89 if (!gAllowExtendedTest) goto finish; 90 if (gShowTestProgress) SkDebugf("%d", b); 91 } 92 if (gShowTestProgress) SkDebugf("\n%d", a); 93 } 94finish: 95 testsRun += waitForCompletion(); 96 if (gShowTestProgress) SkDebugf("%s tests=%d total=%d\n", __FUNCTION__, testsRun); 97} 98 99#include "TestClassDef.h" 100DEFINE_TESTCLASS("PathOpsRectsThreaded", OpRectsThreadedTestClass, \ 101 TestPathOpsRectsThreaded) 102 103