diff options
Diffstat (limited to 'experimental/Intersection/SimplifyRect4x4_Test.cpp')
-rw-r--r-- | experimental/Intersection/SimplifyRect4x4_Test.cpp | 119 |
1 files changed, 77 insertions, 42 deletions
diff --git a/experimental/Intersection/SimplifyRect4x4_Test.cpp b/experimental/Intersection/SimplifyRect4x4_Test.cpp index ef468068ae..0143e1a336 100644 --- a/experimental/Intersection/SimplifyRect4x4_Test.cpp +++ b/experimental/Intersection/SimplifyRect4x4_Test.cpp @@ -19,6 +19,15 @@ // same with x (3 bits, 5 values) // not included, square, tall, wide (2 bits) // cw or ccw (1 bit) +static const char marker[] = + "</div>\n" + "\n" + "<script type=\"text/javascript\">\n" + "\n" + "var testDivs = [\n"; +static const char testLineStr[] = " testLine"; +static const char filename[] = "../../experimental/Intersection/debugXX.txt"; +static int testNumber; static void* testSimplify4x4RectsMain(void* data) { @@ -27,13 +36,13 @@ static void* testSimplify4x4RectsMain(void* data) SkASSERT(data); State4& state = *(State4*) data; int aShape = state.a & 0x03; - int aCW = state.a >> 1; + int aCW = state.a >> 2; int bShape = state.b & 0x03; - int bCW = state.b >> 1; + int bCW = state.b >> 2; int cShape = state.c & 0x03; - int cCW = state.c >> 1; + int cCW = state.c >> 2; int dShape = state.d & 0x03; - int dCW = state.d >> 1; + int dCW = state.d >> 2; for (int aXAlign = 0 ; aXAlign < 5; ++aXAlign) { for (int aYAlign = 0 ; aYAlign < 5; ++aYAlign) { for (int bXAlign = 0 ; bXAlign < 5; ++bXAlign) { @@ -159,54 +168,43 @@ static void* testSimplify4x4RectsMain(void* data) dYAlign = 5; } path.close(); - SkDebugf("%s", pathStr); - if (!testSimplifyx(path, out, state.bitmap, state.canvas)) { - SkDebugf("*/\n{ %s %d, %d, %d, %d, %d, %d, %d, %d," - " %d, %d, %d, %d },\n/*\n", - __FUNCTION__, state.a, state.b, state.c, state.d, - aXAlign, aYAlign, bXAlign, bYAlign, - cXAlign, cYAlign, dXAlign, dYAlign); - SkFILEStream inFile("../../experimental/Intersection/op.htm"); - if (!inFile.isValid()) { - continue; - } - SkTDArray<char> inData; - inData.setCount(inFile.getLength()); - size_t inLen = inData.count(); - inFile.read(inData.begin(), inLen); - inFile.setPath(NULL); - SkFILEWStream outFile("../../experimental/Intersection/xop.htm"); + if (gRunTestsInOneThread) { + SkDebugf("%s\n", pathStr); + } else { + SkFILEWStream outFile(state.filename); if (!outFile.isValid()) { continue; } - const char marker[] = - "</div>\n" - "\n" - "<script type=\"text/javascript\">\n" - "\n" - "var testDivs = [\n"; - const char testLineStr[] = " testLine"; - char* insert = strstr(inData.begin(), marker); - if (!insert) { - continue; - } - size_t startLen = insert - inData.begin(); - insert += sizeof(marker); - const char* numLoc = insert + sizeof(testLineStr); - int testNumber = atoi(numLoc) + 1; - outFile.write(inData.begin(), startLen); outFile.writeText("<div id=\"testLine"); outFile.writeDecAsText(testNumber); outFile.writeText("\">\n"); outFile.writeText(pathStr); outFile.writeText("</div>\n\n"); + outFile.writeText(marker); outFile.writeText(testLineStr); outFile.writeDecAsText(testNumber); - outFile.writeText(",\n"); - outFile.write(insert, inLen - startLen - sizeof(marker)); + outFile.writeText(",\n\n\n"); + + outFile.writeText("static void testLine"); + outFile.writeDecAsText(testNumber); + outFile.writeText("() {\n SkPath path, simple;\n"); + outFile.writeText(pathStr); + outFile.writeText(" testSimplifyx(path);\n}\n"); + outFile.writeText("static void (*firstTest)() = testLine"); + outFile.writeDecAsText(testNumber); + outFile.writeText(";\n\n"); + + outFile.writeText("static struct {\n"); + outFile.writeText(" void (*fun)();\n"); + outFile.writeText(" const char* str;\n"); + outFile.writeText("} tests[] = {\n"); + outFile.writeText(" TEST(testLine"); + outFile.writeDecAsText(testNumber); + outFile.writeText("),\n"); outFile.flush(); - } + } + testSimplifyx(path, out, state.bitmap, state.canvas); } } } @@ -218,12 +216,41 @@ static void* testSimplify4x4RectsMain(void* data) return NULL; } -const int maxThreads = 1; // gRunTestsInOneThread ? 1 : 24; +const int maxThreads = gRunTestsInOneThread ? 1 : 8; void Simplify4x4RectsThreaded_Test() { +#ifdef SK_DEBUG + gDebugMaxWindSum = 3; + gDebugMaxWindValue = 3; +#endif + if (maxThreads > 1) { + SkFILEStream inFile("../../experimental/Intersection/op.htm"); + if (inFile.isValid()) { + SkTDArray<char> inData; + inData.setCount(inFile.getLength()); + size_t inLen = inData.count(); + inFile.read(inData.begin(), inLen); + inFile.setPath(NULL); + char* insert = strstr(inData.begin(), marker); + if (insert) { + insert += sizeof(marker) - 1; + const char* numLoc = insert + sizeof(testLineStr) - 1; + testNumber = atoi(numLoc) + 1; + } + } + } State4 threadState[maxThreads]; - int threadIndex = 0; + int threadIndex; + for (threadIndex = 0; threadIndex < maxThreads; ++threadIndex) { + State4* statePtr = &threadState[threadIndex]; + strcpy(statePtr->filename, filename); + SkASSERT(statePtr->filename[sizeof(filename) - 7] == 'X'); + SkASSERT(statePtr->filename[sizeof(filename) - 6] == 'X'); + statePtr->filename[sizeof(filename) - 7] = '0' + threadIndex / 10; + statePtr->filename[sizeof(filename) - 6] = '0' + threadIndex % 10; + } + threadIndex = 0; for (int a = 0; a < 8; ++a) { // outermost for (int b = a ; b < 8; ++b) { for (int c = b ; c < 8; ++c) { @@ -241,10 +268,18 @@ void Simplify4x4RectsThreaded_Test() } else { testSimplify4x4RectsMain(statePtr); } + if (maxThreads > 1) SkDebugf("."); } + if (maxThreads > 1) SkDebugf("%d", c); } + if (maxThreads > 1) SkDebugf("\n%d", b); } + if (maxThreads > 1) SkDebugf("\n\n%d", a); } waitForCompletion(threadState, threadIndex); +#ifdef SK_DEBUG + gDebugMaxWindSum = SK_MaxS32; + gDebugMaxWindValue = SK_MaxS32; +#endif } |