EdgeWalkerQuadratic4x4_Test.cpp revision 8f9f468b0555e95b8fc3cf4e6ee1f1fbf5492a1b
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 "SkBitmap.h" 10#include "SkCanvas.h" 11#include <assert.h> 12 13 14static void* testSimplify4x4QuadraticsMain(void* data) 15{ 16 SkASSERT(data); 17 State4& state = *(State4*) data; 18 char pathStr[1024]; 19 bzero(pathStr, sizeof(pathStr)); 20 do { 21 int ax = state.a & 0x03; 22 int ay = state.a >> 2; 23 int bx = state.b & 0x03; 24 int by = state.b >> 2; 25 int cx = state.c & 0x03; 26 int cy = state.c >> 2; 27 int dx = state.d & 0x03; 28 int dy = state.d >> 2; 29 for (int e = 0 ; e < 16; ++e) { 30 int ex = e & 0x03; 31 int ey = e >> 2; 32 for (int f = e ; f < 16; ++f) { 33 int fx = f & 0x03; 34 int fy = f >> 2; 35 for (int g = f ; g < 16; ++g) { 36 int gx = g & 0x03; 37 int gy = g >> 2; 38 for (int h = g ; h < 16; ++h) { 39 int hx = h & 0x03; 40 int hy = h >> 2; 41 SkPath path, out; 42 path.setFillType(SkPath::kWinding_FillType); 43 path.moveTo(ax, ay); 44 path.quadTo(bx, by, cx, cy); 45 path.lineTo(dx, dy); 46 path.close(); 47 path.moveTo(ex, ey); 48 path.lineTo(fx, fy); 49 path.quadTo(gx, gy, hx, hy); 50 path.close(); 51 if (1) { // gdb: set print elements 400 52 char* str = pathStr; 53 str += sprintf(str, " path.moveTo(%d, %d);\n", ax, ay); 54 str += sprintf(str, " path.quadTo(%d, %d, %d, %d);\n", bx, by, cx, cy); 55 str += sprintf(str, " path.lineTo(%d, %d);\n", dx, dy); 56 str += sprintf(str, " path.close();\n"); 57 str += sprintf(str, " path.moveTo(%d, %d);\n", ex, ey); 58 str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy); 59 str += sprintf(str, " path.quadTo(%d, %d, %d, %d);\n", gx, gy, hx, hy); 60 str += sprintf(str, " path.close();\n"); 61 } 62 outputProgress(state, pathStr, SkPath::kWinding_FillType); 63 testSimplifyx(path, false, out, state, pathStr); 64 state.testsRun++; 65 path.setFillType(SkPath::kEvenOdd_FillType); 66 outputProgress(state, pathStr, SkPath::kEvenOdd_FillType); 67 testSimplifyx(path, true, out, state, pathStr); 68 state.testsRun++; 69 } 70 } 71 } 72 } 73 } while (runNextTestSet(state)); 74 return NULL; 75} 76 77void Simplify4x4QuadraticsThreaded_Test(int& testsRun) 78{ 79 SkDebugf("%s\n", __FUNCTION__); 80#ifdef SK_DEBUG 81 gDebugMaxWindSum = 4; // FIXME: 3? 82 gDebugMaxWindValue = 4; 83#endif 84 const char testStr[] = "testQuadratic"; 85 initializeTests(testStr, sizeof(testStr)); 86 int testsStart = testsRun; 87 int a = 0; 88#define SKIP_A 0 89#if SKIP_A 90 a = 2; 91#endif 92 for (; a < 16; ++a) { 93 for (int b = a ; b < 16; ++b) { 94 for (int c = b ; c < 16; ++c) { 95 for (int d = c; d < 16; ++d) { 96 testsRun += dispatchTest4(testSimplify4x4QuadraticsMain, 97 a, b, c, d); 98 } 99 if (!gRunTestsInOneThread) SkDebugf("."); 100 } 101 if (!gRunTestsInOneThread) SkDebugf("%d", b); 102 } 103 if (!gRunTestsInOneThread) SkDebugf("\n%d", a); 104 } 105 testsRun += waitForCompletion(); 106 SkDebugf("%s tests=%d total=%d\n", __FUNCTION__, testsRun - testsStart, testsRun); 107} 108