2012-07-02 20:27:02 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
#include "EdgeWalker_Test.h"
|
|
|
|
#include "Intersection_Tests.h"
|
|
|
|
#include "ShapeOps.h"
|
|
|
|
|
|
|
|
// four rects, of four sizes
|
|
|
|
// for 3 smaller sizes, tall, wide
|
|
|
|
// top upper mid lower bottom aligned (3 bits, 5 values)
|
|
|
|
// same with x (3 bits, 5 values)
|
|
|
|
// not included, square, tall, wide (2 bits)
|
|
|
|
// cw or ccw (1 bit)
|
2012-08-07 21:25:27 +00:00
|
|
|
|
2012-07-02 20:27:02 +00:00
|
|
|
static void* testSimplify4x4RectsMain(void* data)
|
|
|
|
{
|
|
|
|
SkASSERT(data);
|
|
|
|
State4& state = *(State4*) data;
|
2012-08-07 21:25:27 +00:00
|
|
|
char pathStr[1024]; // gdb: set print elements 400
|
|
|
|
bzero(pathStr, sizeof(pathStr));
|
2012-08-09 18:17:47 +00:00
|
|
|
do {
|
|
|
|
int aShape = state.a & 0x03;
|
2012-11-29 14:31:50 +00:00
|
|
|
SkPath::Direction aCW = state.a >> 2 ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
|
2012-08-09 18:17:47 +00:00
|
|
|
int bShape = state.b & 0x03;
|
2012-11-29 14:31:50 +00:00
|
|
|
SkPath::Direction bCW = state.b >> 2 ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
|
2012-08-09 18:17:47 +00:00
|
|
|
int cShape = state.c & 0x03;
|
2012-11-29 14:31:50 +00:00
|
|
|
SkPath::Direction cCW = state.c >> 2 ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
|
2012-08-09 18:17:47 +00:00
|
|
|
int dShape = state.d & 0x03;
|
2012-11-29 14:31:50 +00:00
|
|
|
SkPath::Direction dCW = state.d >> 2 ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
|
2012-08-09 18:17:47 +00:00
|
|
|
for (int aXAlign = 0 ; aXAlign < 5; ++aXAlign) {
|
|
|
|
for (int aYAlign = 0 ; aYAlign < 5; ++aYAlign) {
|
|
|
|
for (int bXAlign = 0 ; bXAlign < 5; ++bXAlign) {
|
|
|
|
for (int bYAlign = 0 ; bYAlign < 5; ++bYAlign) {
|
|
|
|
for (int cXAlign = 0 ; cXAlign < 5; ++cXAlign) {
|
|
|
|
for (int cYAlign = 0 ; cYAlign < 5; ++cYAlign) {
|
|
|
|
for (int dXAlign = 0 ; dXAlign < 5; ++dXAlign) {
|
|
|
|
for (int dYAlign = 0 ; dYAlign < 5; ++dYAlign) {
|
|
|
|
SkPath path, out;
|
|
|
|
char* str = pathStr;
|
|
|
|
path.setFillType(SkPath::kWinding_FillType);
|
|
|
|
int l, t, r, b;
|
|
|
|
if (aShape) {
|
|
|
|
switch (aShape) {
|
|
|
|
case 1: // square
|
|
|
|
l = 0; r = 60;
|
|
|
|
t = 0; b = 60;
|
|
|
|
aXAlign = 5;
|
|
|
|
aYAlign = 5;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
l = aXAlign * 12;
|
2012-08-23 18:14:13 +00:00
|
|
|
r = l + 30;
|
2012-08-09 18:17:47 +00:00
|
|
|
t = 0; b = 60;
|
|
|
|
aYAlign = 5;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
l = 0; r = 60;
|
|
|
|
t = aYAlign * 12;
|
2012-08-23 18:14:13 +00:00
|
|
|
b = l + 30;
|
2012-08-09 18:17:47 +00:00
|
|
|
aXAlign = 5;
|
|
|
|
break;
|
|
|
|
}
|
2012-11-29 14:31:50 +00:00
|
|
|
path.addRect(l, t, r, b, aCW);
|
2012-08-09 18:17:47 +00:00
|
|
|
str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
|
2013-01-03 21:18:16 +00:00
|
|
|
" SkPath::kC%sW_Direction);\n", l, t, r, b, aCW ? "C" : "");
|
2012-08-09 18:17:47 +00:00
|
|
|
} else {
|
|
|
|
aXAlign = 5;
|
|
|
|
aYAlign = 5;
|
2012-07-02 20:27:02 +00:00
|
|
|
}
|
2012-08-09 18:17:47 +00:00
|
|
|
if (bShape) {
|
|
|
|
switch (bShape) {
|
|
|
|
case 1: // square
|
|
|
|
l = bXAlign * 10;
|
2012-08-23 18:14:13 +00:00
|
|
|
r = l + 20;
|
2012-08-09 18:17:47 +00:00
|
|
|
t = bYAlign * 10;
|
2012-08-23 18:14:13 +00:00
|
|
|
b = l + 20;
|
2012-08-09 18:17:47 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
l = bXAlign * 10;
|
2012-08-23 18:14:13 +00:00
|
|
|
r = l + 20;
|
2012-08-09 18:17:47 +00:00
|
|
|
t = 10; b = 40;
|
|
|
|
bYAlign = 5;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
l = 10; r = 40;
|
|
|
|
t = bYAlign * 10;
|
2012-08-23 18:14:13 +00:00
|
|
|
b = l + 20;
|
2012-08-09 18:17:47 +00:00
|
|
|
bXAlign = 5;
|
|
|
|
break;
|
|
|
|
}
|
2012-11-29 14:31:50 +00:00
|
|
|
path.addRect(l, t, r, b, bCW);
|
2012-08-09 18:17:47 +00:00
|
|
|
str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
|
2013-01-03 21:18:16 +00:00
|
|
|
" SkPath::kC%sW_Direction);\n", l, t, r, b, bCW ? "C" : "");
|
2012-08-09 18:17:47 +00:00
|
|
|
} else {
|
|
|
|
bXAlign = 5;
|
|
|
|
bYAlign = 5;
|
2012-07-02 20:27:02 +00:00
|
|
|
}
|
2012-08-09 18:17:47 +00:00
|
|
|
if (cShape) {
|
|
|
|
switch (cShape) {
|
|
|
|
case 1: // square
|
|
|
|
l = cXAlign * 6;
|
2012-08-23 18:14:13 +00:00
|
|
|
r = l + 12;
|
2012-08-09 18:17:47 +00:00
|
|
|
t = cYAlign * 6;
|
2012-08-23 18:14:13 +00:00
|
|
|
b = l + 12;
|
2012-08-09 18:17:47 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
l = cXAlign * 6;
|
2012-08-23 18:14:13 +00:00
|
|
|
r = l + 12;
|
2012-08-09 18:17:47 +00:00
|
|
|
t = 20; b = 30;
|
|
|
|
cYAlign = 5;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
l = 20; r = 30;
|
|
|
|
t = cYAlign * 6;
|
2012-08-23 18:14:13 +00:00
|
|
|
b = l + 20;
|
2012-08-09 18:17:47 +00:00
|
|
|
cXAlign = 5;
|
|
|
|
break;
|
|
|
|
}
|
2012-11-29 14:31:50 +00:00
|
|
|
path.addRect(l, t, r, b, cCW);
|
2012-08-09 18:17:47 +00:00
|
|
|
str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
|
2013-01-03 21:18:16 +00:00
|
|
|
" SkPath::kC%sW_Direction);\n", l, t, r, b, cCW ? "C" : "");
|
2012-08-09 18:17:47 +00:00
|
|
|
} else {
|
|
|
|
cXAlign = 5;
|
|
|
|
cYAlign = 5;
|
2012-07-02 20:27:02 +00:00
|
|
|
}
|
2012-08-09 18:17:47 +00:00
|
|
|
if (dShape) {
|
|
|
|
switch (dShape) {
|
|
|
|
case 1: // square
|
|
|
|
l = dXAlign * 4;
|
2012-08-23 18:14:13 +00:00
|
|
|
r = l + 9;
|
2012-08-09 18:17:47 +00:00
|
|
|
t = dYAlign * 4;
|
2012-08-23 18:14:13 +00:00
|
|
|
b = l + 9;
|
2012-08-09 18:17:47 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
l = dXAlign * 6;
|
2012-08-23 18:14:13 +00:00
|
|
|
r = l + 9;
|
2012-08-09 18:17:47 +00:00
|
|
|
t = 32; b = 36;
|
|
|
|
dYAlign = 5;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
l = 32; r = 36;
|
|
|
|
t = dYAlign * 6;
|
2012-08-23 18:14:13 +00:00
|
|
|
b = l + 9;
|
2012-08-09 18:17:47 +00:00
|
|
|
dXAlign = 5;
|
|
|
|
break;
|
|
|
|
}
|
2012-11-29 14:31:50 +00:00
|
|
|
path.addRect(l, t, r, b, dCW);
|
2012-08-09 18:17:47 +00:00
|
|
|
str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
|
2013-01-03 21:18:16 +00:00
|
|
|
" SkPath::kC%sW_Direction);\n", l, t, r, b, dCW ? "C" : "");
|
2012-08-09 18:17:47 +00:00
|
|
|
} else {
|
|
|
|
dXAlign = 5;
|
|
|
|
dYAlign = 5;
|
2012-07-11 17:52:32 +00:00
|
|
|
}
|
2012-08-09 18:17:47 +00:00
|
|
|
path.close();
|
2012-08-20 12:43:57 +00:00
|
|
|
outputProgress(state, pathStr, SkPath::kWinding_FillType);
|
|
|
|
testSimplifyx(path, false, out, state, pathStr);
|
|
|
|
state.testsRun++;
|
|
|
|
outputProgress(state, pathStr, SkPath::kEvenOdd_FillType);
|
|
|
|
testSimplifyx(path, true, out, state, pathStr);
|
2012-08-09 18:17:47 +00:00
|
|
|
state.testsRun++;
|
|
|
|
}
|
2012-07-02 20:27:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-08-09 18:17:47 +00:00
|
|
|
} while (runNextTestSet(state));
|
2012-07-02 20:27:02 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-08-20 12:43:57 +00:00
|
|
|
void Simplify4x4RectsThreaded_Test(int& testsRun)
|
2012-07-02 20:27:02 +00:00
|
|
|
{
|
2012-08-09 18:17:47 +00:00
|
|
|
SkDebugf("%s\n", __FUNCTION__);
|
2012-07-23 12:14:49 +00:00
|
|
|
#ifdef SK_DEBUG
|
2012-07-27 18:26:38 +00:00
|
|
|
gDebugMaxWindSum = 4;
|
|
|
|
gDebugMaxWindValue = 4;
|
2012-07-23 12:14:49 +00:00
|
|
|
#endif
|
2012-08-09 18:17:47 +00:00
|
|
|
const char testLineStr[] = "testLine";
|
|
|
|
initializeTests(testLineStr, sizeof(testLineStr));
|
2012-08-20 12:43:57 +00:00
|
|
|
int testsStart = testsRun;
|
2012-07-02 20:27:02 +00:00
|
|
|
for (int a = 0; a < 8; ++a) { // outermost
|
|
|
|
for (int b = a ; b < 8; ++b) {
|
|
|
|
for (int c = b ; c < 8; ++c) {
|
2012-08-23 18:14:13 +00:00
|
|
|
for (int d = c; d < 8; ++d) {
|
2012-08-09 18:17:47 +00:00
|
|
|
testsRun += dispatchTest4(testSimplify4x4RectsMain, a, b, c, d);
|
2012-07-02 20:27:02 +00:00
|
|
|
}
|
2012-08-09 18:17:47 +00:00
|
|
|
if (!gRunTestsInOneThread) SkDebugf(".");
|
2012-08-07 21:25:27 +00:00
|
|
|
}
|
2012-08-09 18:17:47 +00:00
|
|
|
if (!gRunTestsInOneThread) SkDebugf("%d", b);
|
2012-08-07 21:25:27 +00:00
|
|
|
}
|
2012-08-09 18:17:47 +00:00
|
|
|
if (!gRunTestsInOneThread) SkDebugf("\n%d", a);
|
2012-07-27 18:26:38 +00:00
|
|
|
}
|
2012-08-09 18:17:47 +00:00
|
|
|
testsRun += waitForCompletion();
|
2012-08-20 12:43:57 +00:00
|
|
|
SkDebugf("%s tests=%d total=%d\n", __FUNCTION__, testsRun - testsStart, testsRun);
|
2012-07-02 20:27:02 +00:00
|
|
|
}
|