2012-03-28 16:20:21 +00:00
|
|
|
#include "EdgeWalker_Test.h"
|
|
|
|
#include "Intersection_Tests.h"
|
2012-03-30 18:47:02 +00:00
|
|
|
#include "SkBitmap.h"
|
|
|
|
|
|
|
|
static SkBitmap bitmap;
|
2012-03-28 16:20:21 +00:00
|
|
|
|
|
|
|
static void testSimplifyQuadratic1() {
|
|
|
|
SkPath path, out;
|
|
|
|
path.moveTo(0, 0);
|
|
|
|
path.quadTo(1, 0, 1, 1);
|
|
|
|
path.close();
|
|
|
|
path.moveTo(1, 0);
|
|
|
|
path.quadTo(0, 0, 0, 1);
|
|
|
|
path.close();
|
2012-03-30 18:47:02 +00:00
|
|
|
testSimplify(path, true, out, bitmap);
|
2012-03-28 16:20:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void testSimplifyQuadratic2() {
|
|
|
|
SkPath path, out;
|
|
|
|
path.moveTo(0, 0);
|
|
|
|
path.quadTo(20, 0, 20, 20);
|
|
|
|
path.close();
|
|
|
|
path.moveTo(20, 0);
|
|
|
|
path.quadTo(0, 0, 0, 20);
|
|
|
|
path.close();
|
2012-03-30 18:47:02 +00:00
|
|
|
testSimplify(path, true, out, bitmap);
|
2012-03-28 16:20:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void testSimplifyQuadratic3() {
|
|
|
|
SkPath path, out;
|
|
|
|
path.moveTo(0, 0);
|
|
|
|
path.quadTo(20, 0, 20, 20);
|
|
|
|
path.close();
|
|
|
|
path.moveTo(0, 20);
|
|
|
|
path.quadTo(0, 0, 20, 0);
|
|
|
|
path.close();
|
2012-03-30 18:47:02 +00:00
|
|
|
testSimplify(path, true, out, bitmap);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void testSimplifyQuadratic4() {
|
|
|
|
SkPath path, out;
|
|
|
|
path.moveTo(0, 20);
|
|
|
|
path.quadTo(20, 0, 40, 20);
|
|
|
|
path.close();
|
|
|
|
path.moveTo(40, 10);
|
|
|
|
path.quadTo(20, 30, 0, 10);
|
|
|
|
path.close();
|
|
|
|
testSimplify(path, true, out, bitmap);
|
2012-03-28 16:20:21 +00:00
|
|
|
drawAsciiPaths(path, out, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void (*simplifyTests[])() = {
|
2012-03-30 18:47:02 +00:00
|
|
|
testSimplifyQuadratic4,
|
2012-03-28 16:20:21 +00:00
|
|
|
testSimplifyQuadratic3,
|
|
|
|
testSimplifyQuadratic2,
|
|
|
|
testSimplifyQuadratic1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static size_t simplifyTestsCount = sizeof(simplifyTests) / sizeof(simplifyTests[0]);
|
|
|
|
|
|
|
|
static void (*firstTest)() = 0;
|
|
|
|
|
|
|
|
void SimplifyQuadraticPaths_Test() {
|
|
|
|
size_t index = 0;
|
|
|
|
if (firstTest) {
|
|
|
|
while (index < simplifyTestsCount && simplifyTests[index] != firstTest) {
|
|
|
|
++index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool firstTestComplete = false;
|
|
|
|
for ( ; index < simplifyTestsCount; ++index) {
|
|
|
|
(*simplifyTests[index])();
|
|
|
|
if (simplifyTests[index] == testSimplifyQuadratic1) {
|
|
|
|
SkDebugf("%s last fast quad test\n", __FUNCTION__);
|
|
|
|
}
|
|
|
|
firstTestComplete = true;
|
|
|
|
}
|
|
|
|
}
|