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 "EdgeWalker_Test.h" 8 #include "Intersection_Tests.h" 9 #include "ShapeOps.h" 10 11 // four rects, of four sizes 12 // for 3 smaller sizes, tall, wide 13 // top upper mid lower bottom aligned (3 bits, 5 values) 14 // same with x (3 bits, 5 values) 15 // not included, square, tall, wide (2 bits) 16 // cw or ccw (1 bit) 17 18 static void* testShapeOps4x4RectsMain(void* data) 19 { 20 SkASSERT(data); 21 State4& state = *(State4*) data; 22 char pathStr[1024]; // gdb: set print elements 400 23 bzero(pathStr, sizeof(pathStr)); 24 do { 25 for (int a = 0 ; a < 6; ++a) { 26 for (int b = a + 1 ; b < 7; ++b) { 27 for (int c = 0 ; c < 6; ++c) { 28 for (int d = c + 1 ; d < 7; ++d) { 29 for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) { 30 for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) { 31 SkPath pathA, pathB; 32 char* str = pathStr; 33 pathA.setFillType((SkPath::FillType) e); 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 pathA.addRect(state.a, state.a, state.b, state.b, SkPath::kCW_Direction); 38 str += sprintf(str, " path.addRect(%d, %d, %d, %d," 39 " SkPath::kCW_Direction);\n", state.a, state.a, state.b, state.b); 40 pathA.addRect(state.c, state.c, state.d, 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(a, a, b, b, SkPath::kCW_Direction); 49 str += sprintf(str, " pathB.addRect(%d, %d, %d, %d," 50 " SkPath::kCW_Direction);\n", a, a, b, b); 51 pathB.addRect(c, c, d, d, SkPath::kCW_Direction); 52 str += sprintf(str, " pathB.addRect(%d, %d, %d, %d," 53 " SkPath::kCW_Direction);\n", c, c, d, d); 54 pathB.close(); 55 for (int op = 0 ; op < kShapeOp_Count; ++op) { 56 outputProgress(state, pathStr, (ShapeOp) op); 57 testShapeOp(pathA, pathB, (ShapeOp) op); 58 state.testsRun++; 59 } 60 } 61 } 62 } 63 } 64 } 65 } 66 } while (runNextTestSet(state)); 67 return NULL; 68 } 69 70 void ShapeOps4x4RectsThreaded_Test(int& testsRun) 71 { 72 SkDebugf("%s\n", __FUNCTION__); 73 #ifdef SK_DEBUG 74 gDebugMaxWindSum = 4; 75 gDebugMaxWindValue = 4; 76 #endif 77 const char testLineStr[] = "testOp"; 78 initializeTests(testLineStr, sizeof(testLineStr)); 79 int testsStart = testsRun; 80 for (int a = 0; a < 6; ++a) { // outermost 81 for (int b = a + 1; b < 7; ++b) { 82 for (int c = 0 ; c < 6; ++c) { 83 for (int d = c + 1; d < 7; ++d) { 84 testsRun += dispatchTest4(testShapeOps4x4RectsMain, a, b, c, d); 85 } 86 if (!gRunTestsInOneThread) SkDebugf("."); 87 } 88 if (!gRunTestsInOneThread) SkDebugf("%d", b); 89 } 90 if (!gRunTestsInOneThread) SkDebugf("\n%d", a); 91 } 92 testsRun += waitForCompletion(); 93 SkDebugf("%s tests=%d total=%d\n", __FUNCTION__, testsRun - testsStart, testsRun); 94 } 95