blob: 4d7c621c3e3683ba6713b22327eff0ff58fdbd9f [file] [log] [blame]
/*
* 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 "PathOpsExtendedTest.h"
#define TEST(name) { name, #name }
static void cubicOp1d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(0,2, 1,0, 1,0);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,1);
pathB.cubicTo(0,1, 1,0, 2,0);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp2d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,2);
path.cubicTo(0,1, 1,0, 1,0);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,1);
pathB.cubicTo(0,1, 2,0, 1,0);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp3d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(2,3, 1,0, 1,0);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,1);
pathB.cubicTo(0,1, 1,0, 3,2);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp5d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(0,2, 1,0, 2,0);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,1);
pathB.cubicTo(0,2, 1,0, 2,0);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp6d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(0,6, 1,0, 3,0);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,1);
pathB.cubicTo(0,3, 1,0, 6,0);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp7d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(3,4, 1,0, 3,0);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,1);
pathB.cubicTo(0,3, 1,0, 4,3);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp8d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(0,5, 1,0, 4,0);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,1);
pathB.cubicTo(0,4, 1,0, 5,0);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp9d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(1,6, 1,0, 2,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,1);
pathB.cubicTo(1,2, 1,0, 6,1);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void quadOp9d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.quadTo(1,6, 1.5f,1);
path.quadTo(1.5f,0.5f, 2,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,1);
pathB.quadTo(1,2, 1.4f,1);
pathB.quadTo(3,0.4f, 6,1);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void lineOp9d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.lineTo(1,6);
path.lineTo(1.5f,1);
path.lineTo(1.8f,0.8f);
path.lineTo(2,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,1);
pathB.lineTo(1,2);
pathB.lineTo(1.4f,1);
pathB.lineTo(3,0.4f);
pathB.lineTo(6,1);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp1i(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(1,2, 1,0, 2,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,1);
pathB.cubicTo(1,2, 1,0, 2,1);
pathB.close();
testPathOp(reporter, path, pathB, kIntersect_PathOp);
}
static void cubicOp10d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(1,3, 1,0, 4,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,1);
pathB.cubicTo(1,4, 1,0, 3,1);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp11d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(3,4, 1,0, 5,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,1);
pathB.cubicTo(1,5, 1,0, 4,3);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp12d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(1,6, 1,0, 1,0);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,1);
pathB.cubicTo(0,1, 1,0, 6,1);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp13d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(4,5, 1,0, 5,3);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,1);
pathB.cubicTo(3,5, 1,0, 5,4);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp14d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(0,2, 2,0, 2,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,2);
pathB.cubicTo(1,2, 1,0, 2,0);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp15d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(3,6, 2,0, 2,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,2);
pathB.cubicTo(1,2, 1,0, 6,3);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp16d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,2);
path.cubicTo(0,1, 3,0, 1,0);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,3);
pathB.cubicTo(0,1, 2,0, 1,0);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp17d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,2);
path.cubicTo(0,2, 4,0, 2,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,4);
pathB.cubicTo(1,2, 2,0, 2,0);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp18d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(3,5, 2,0, 2,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,2);
pathB.cubicTo(1,2, 1,0, 5,3);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp19i(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,2);
path.cubicTo(0,1, 2,1, 6,2);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(1,2);
pathB.cubicTo(2,6, 2,0, 1,0);
pathB.close();
testPathOp(reporter, path, pathB, kIntersect_PathOp);
}
static void cubicOp20d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(0,1, 6,0, 2,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,6);
pathB.cubicTo(1,2, 1,0, 1,0);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp21d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(0,1, 2,1, 6,5);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(1,2);
pathB.cubicTo(5,6, 1,0, 1,0);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp22d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(2,3, 3,0, 2,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,3);
pathB.cubicTo(1,2, 1,0, 3,2);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp23d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(1,2, 4,0, 2,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,4);
pathB.cubicTo(1,2, 1,0, 2,1);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp24d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(1,2, 2,0, 3,2);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,2);
pathB.cubicTo(2,3, 1,0, 2,1);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void testIntersect1(skiatest::Reporter* reporter) {
SkPath one, two;
one.addRect(0, 0, 6, 6, SkPath::kCW_Direction);
two.addRect(3, 3, 9, 9, SkPath::kCW_Direction);
testPathOp(reporter, one, two, kIntersect_PathOp);
}
static void testUnion1(skiatest::Reporter* reporter) {
SkPath one, two;
one.addRect(0, 0, 6, 6, SkPath::kCW_Direction);
two.addRect(3, 3, 9, 9, SkPath::kCW_Direction);
testPathOp(reporter, one, two, kUnion_PathOp);
}
static void testDiff1(skiatest::Reporter* reporter) {
SkPath one, two;
one.addRect(0, 0, 6, 6, SkPath::kCW_Direction);
two.addRect(3, 3, 9, 9, SkPath::kCW_Direction);
testPathOp(reporter, one, two, kDifference_PathOp);
}
static void testXor1(skiatest::Reporter* reporter) {
SkPath one, two;
one.addRect(0, 0, 6, 6, SkPath::kCW_Direction);
two.addRect(3, 3, 9, 9, SkPath::kCW_Direction);
testPathOp(reporter, one, two, kXOR_PathOp);
}
static void testIntersect2(skiatest::Reporter* reporter) {
SkPath one, two;
one.addRect(0, 0, 6, 6, SkPath::kCW_Direction);
two.addRect(0, 3, 9, 9, SkPath::kCW_Direction);
testPathOp(reporter, one, two, kIntersect_PathOp);
}
static void testUnion2(skiatest::Reporter* reporter) {
SkPath one, two;
one.addRect(0, 0, 6, 6, SkPath::kCW_Direction);
two.addRect(0, 3, 9, 9, SkPath::kCW_Direction);
testPathOp(reporter, one, two, kUnion_PathOp);
}
static void testDiff2(skiatest::Reporter* reporter) {
SkPath one, two;
one.addRect(0, 0, 6, 6, SkPath::kCW_Direction);
two.addRect(0, 3, 9, 9, SkPath::kCW_Direction);
testPathOp(reporter, one, two, kDifference_PathOp);
}
static void testXor2(skiatest::Reporter* reporter) {
SkPath one, two;
one.addRect(0, 0, 6, 6, SkPath::kCW_Direction);
two.addRect(0, 3, 9, 9, SkPath::kCW_Direction);
testPathOp(reporter, one, two, kXOR_PathOp);
}
static void testOp1d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
path.addRect(0, 0, 2, 2, SkPath::kCW_Direction);
pathB.setFillType(SkPath::kWinding_FillType);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void testOp2d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
path.addRect(0, 0, 2, 2, SkPath::kCW_Direction);
pathB.setFillType(SkPath::kEvenOdd_FillType);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void testOp3d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
path.addRect(1, 1, 2, 2, SkPath::kCW_Direction);
pathB.setFillType(SkPath::kWinding_FillType);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void testOp1u(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
path.addRect(0, 0, 3, 3, SkPath::kCW_Direction);
pathB.setFillType(SkPath::kWinding_FillType);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
testPathOp(reporter, path, pathB, kUnion_PathOp);
}
static void testOp4d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
path.addRect(2, 2, 4, 4, SkPath::kCW_Direction);
pathB.setFillType(SkPath::kWinding_FillType);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void testOp5d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kEvenOdd_FillType);
path.addRect(0, 0, 2, 2, SkPath::kCW_Direction);
path.addRect(0, 0, 3, 3, SkPath::kCW_Direction);
pathB.setFillType(SkPath::kEvenOdd_FillType);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void testOp6d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kEvenOdd_FillType);
path.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
path.addRect(0, 0, 3, 3, SkPath::kCW_Direction);
pathB.setFillType(SkPath::kWinding_FillType);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void testOp7d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kEvenOdd_FillType);
path.addRect(0, 0, 2, 2, SkPath::kCW_Direction);
path.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.setFillType(SkPath::kEvenOdd_FillType);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
pathB.addRect(0, 0, 1, 1, SkPath::kCW_Direction);
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void testOp2u(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kEvenOdd_FillType);
path.addRect(0, 0, 2, 2, SkPath::kCW_Direction);
path.addRect(0, 0, 2, 2, SkPath::kCW_Direction);
pathB.setFillType(SkPath::kWinding_FillType);
pathB.addRect(0, 0, 3, 3, SkPath::kCW_Direction);
pathB.addRect(1, 1, 2, 2, SkPath::kCW_Direction);
testPathOp(reporter, path, pathB, kUnion_PathOp);
}
static void testOp8d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.addRect(0, 0, 640, 480);
pathB.moveTo(577330, 1971.72f);
pathB.cubicTo(10.7082f, -116.596f, 262.057f, 45.6468f, 294.694f, 1.96237f);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp25i(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(2,4, 5,0, 3,2);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,5);
pathB.cubicTo(2,3, 1,0, 4,2);
pathB.close();
testPathOp(reporter, path, pathB, kIntersect_PathOp);
}
static void cubicOp26d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(3,4, 4,0, 3,2);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,4);
pathB.cubicTo(2,3, 1,0, 4,3);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp27d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(3,6, 1,0, 5,2);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,1);
pathB.cubicTo(2,5, 1,0, 6,3);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp28u(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(1,4, 6,0, 3,2);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,6);
pathB.cubicTo(2,3, 1,0, 4,1);
pathB.close();
testPathOp(reporter, path, pathB, kUnion_PathOp);
}
static void cubicOp29d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(2,5, 6,0, 4,2);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,6);
pathB.cubicTo(2,4, 1,0, 5,2);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp30d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(2,5, 6,0, 5,3);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,6);
pathB.cubicTo(3,5, 1,0, 5,2);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp31d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,2);
path.cubicTo(0,3, 2,1, 4,0);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(1,2);
pathB.cubicTo(0,4, 2,0, 3,0);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp31u(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,2);
path.cubicTo(0,3, 2,1, 4,0);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(1,2);
pathB.cubicTo(0,4, 2,0, 3,0);
pathB.close();
testPathOp(reporter, path, pathB, kUnion_PathOp);
}
static void cubicOp31x(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,2);
path.cubicTo(0,3, 2,1, 4,0);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(1,2);
pathB.cubicTo(0,4, 2,0, 3,0);
pathB.close();
testPathOp(reporter, path, pathB, kXOR_PathOp);
}
static void cubicOp32d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(1,2, 6,0, 3,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,6);
pathB.cubicTo(1,3, 1,0, 2,1);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp33i(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(1,2, 6,0, 3,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,6);
pathB.cubicTo(1,3, 1,0, 2,1);
pathB.close();
testPathOp(reporter, path, pathB, kIntersect_PathOp);
}
static void cubicOp34d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(3,5, 2,1, 3,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(1,2);
pathB.cubicTo(1,3, 1,0, 5,3);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp35d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(1,5, 2,1, 4,0);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(1,2);
pathB.cubicTo(0,4, 1,0, 5,1);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp36u(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(1,6, 2,0, 5,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,2);
pathB.cubicTo(1,5, 1,0, 6,1);
pathB.close();
testPathOp(reporter, path, pathB, kUnion_PathOp);
}
static void cubicOp37d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(2,6, 6,1, 4,3);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(1,6);
pathB.cubicTo(3,4, 1,0, 6,2);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
#if 1
// this fails to detect a cubic/cubic intersection
// the slight overlap is missed when the cubics are approximated by quadratics
// and the subsequent line/cubic intersection also (correctly) misses the intersection
// if the line/cubic was a matching line/approx.quadratic then the missing intersection
// could have been detected
static void cubicOp38d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(0,6, 3,2, 4,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(2,3);
pathB.cubicTo(1,4, 1,0, 6,0);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
#endif
static void cubicOp39d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(2,3, 5,1, 4,3);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(1,5);
pathB.cubicTo(3,4, 1,0, 3,2);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp40d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(1,5, 3,2, 4,2);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(2,3);
pathB.cubicTo(2,4, 1,0, 5,1);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp41i(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(2,6, 4,3, 6,4);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(3,4);
pathB.cubicTo(4,6, 1,0, 6,2);
pathB.close();
testPathOp(reporter, path, pathB, kIntersect_PathOp);
}
static void cubicOp42d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(1,2, 6,5, 5,4);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(5,6);
pathB.cubicTo(4,5, 1,0, 2,1);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp43d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,2);
path.cubicTo(1,2, 4,0, 3,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,4);
pathB.cubicTo(1,3, 2,0, 2,1);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp44d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,2);
path.cubicTo(3,6, 4,0, 3,2);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,4);
pathB.cubicTo(2,3, 2,0, 6,3);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp45d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,2);
path.cubicTo(2,4, 4,0, 3,2);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,4);
pathB.cubicTo(2,3, 2,0, 4,2);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp46d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,2);
path.cubicTo(3,5, 5,0, 4,2);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,5);
pathB.cubicTo(2,4, 2,0, 5,3);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp47d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(1,6, 6,2, 5,4);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(2,6);
pathB.cubicTo(4,5, 1,0, 6,1);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp48d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,2);
path.cubicTo(2,3, 5,1, 3,2);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(1,5);
pathB.cubicTo(2,3, 2,0, 3,2);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp49d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,2);
path.cubicTo(1,5, 3,2, 4,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(2,3);
pathB.cubicTo(1,4, 2,0, 5,1);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp50d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,3);
path.cubicTo(1,6, 5,0, 5,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,5);
pathB.cubicTo(1,5, 3,0, 6,1);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp51d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,3);
path.cubicTo(1,2, 4,1, 6,0);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(1,4);
pathB.cubicTo(0,6, 3,0, 2,1);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp52d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,2);
path.cubicTo(1,2, 5,4, 4,3);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(4,5);
pathB.cubicTo(3,4, 2,0, 2,1);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp53d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,3);
path.cubicTo(1,2, 5,3, 2,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(3,5);
pathB.cubicTo(1,2, 3,0, 2,1);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp54d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,4);
path.cubicTo(1,3, 5,4, 4,2);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(4,5);
pathB.cubicTo(2,4, 4,0, 3,1);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp55d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,5);
path.cubicTo(1,3, 3,2, 5,0);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(2,3);
pathB.cubicTo(0,5, 5,0, 3,1);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp56d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(2,6, 5,0, 2,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,5);
pathB.cubicTo(1,2, 1,0, 6,2);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp57d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,5);
path.cubicTo(0,5, 5,4, 6,4);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(4,5);
pathB.cubicTo(4,6, 5,0, 5,0);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp58d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,5);
path.cubicTo(3,4, 6,5, 5,3);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(5,6);
pathB.cubicTo(3,5, 5,0, 4,3);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp59d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(5,6, 4,0, 4,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,4);
pathB.cubicTo(1,4, 1,0, 6,5);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp60d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,2);
path.cubicTo(4,6, 6,0, 5,2);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,6);
pathB.cubicTo(2,5, 2,0, 6,4);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp61d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(1,2);
path.cubicTo(0,5, 3,2, 6,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(2,3);
pathB.cubicTo(1,6, 2,1, 5,0);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp62d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(1,3);
path.cubicTo(5,6, 5,3, 5,4);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(3,5);
pathB.cubicTo(4,5, 3,1, 6,5);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp63d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(2,3);
path.cubicTo(0,4, 3,2, 5,3);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(2,3);
pathB.cubicTo(3,5, 3,2, 4,0);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp64d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.moveTo(0,1);
path.cubicTo(0,1, 1,0, 3,0);
path.lineTo(0,1);
path.close();
pathB.moveTo(0,1);
pathB.cubicTo(0,3, 1,0, 1,0);
pathB.lineTo(0,1);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp65d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.moveTo(0,1);
path.cubicTo(1,5, 1,0, 1,0);
path.lineTo(0,1);
path.close();
pathB.moveTo(0,1);
pathB.cubicTo(0,1, 1,0, 5,1);
pathB.lineTo(0,1);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void rectOp1d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.moveTo(0,1);
path.cubicTo(0,1, 1,0, 3,0);
path.lineTo(0,1);
path.close();
pathB.moveTo(0,1);
pathB.cubicTo(0,3, 1,0, 1,0);
pathB.lineTo(0,1);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void (*firstTest)(skiatest::Reporter* ) = rectOp1d;
static struct TestDesc tests[] = {
TEST(rectOp1d),
TEST(cubicOp65d),
TEST(cubicOp64d),
TEST(cubicOp63d),
TEST(cubicOp62d),
TEST(cubicOp61d),
TEST(cubicOp60d),
TEST(cubicOp59d),
TEST(cubicOp58d),
TEST(cubicOp57d),
TEST(cubicOp56d),
TEST(cubicOp55d),
TEST(cubicOp54d),
TEST(cubicOp53d),
TEST(cubicOp52d),
TEST(cubicOp51d),
TEST(cubicOp50d),
TEST(cubicOp49d),
TEST(cubicOp48d),
TEST(cubicOp47d),
TEST(cubicOp46d),
TEST(cubicOp45d),
TEST(cubicOp44d),
TEST(cubicOp43d),
TEST(cubicOp42d),
TEST(cubicOp41i),
TEST(cubicOp40d),
TEST(cubicOp39d),
TEST(cubicOp38d),
TEST(cubicOp37d),
TEST(cubicOp36u),
TEST(cubicOp35d),
TEST(cubicOp34d),
TEST(cubicOp33i),
TEST(cubicOp32d),
TEST(cubicOp31d),
TEST(cubicOp31x),
TEST(cubicOp31u),
TEST(cubicOp30d),
TEST(cubicOp29d),
TEST(cubicOp28u),
TEST(cubicOp27d),
TEST(cubicOp26d),
TEST(cubicOp25i),
TEST(testOp8d),
TEST(testDiff1),
TEST(testIntersect1),
TEST(testUnion1),
TEST(testXor1),
TEST(testDiff2),
TEST(testIntersect2),
TEST(testUnion2),
TEST(testXor2),
TEST(testOp1d),
TEST(testOp2d),
TEST(testOp3d),
TEST(testOp1u),
TEST(testOp4d),
TEST(testOp5d),
TEST(testOp6d),
TEST(testOp7d),
TEST(testOp2u),
TEST(cubicOp24d),
TEST(cubicOp23d),
TEST(cubicOp22d),
TEST(cubicOp21d),
TEST(cubicOp20d),
TEST(cubicOp19i),
TEST(cubicOp18d),
TEST(cubicOp17d),
TEST(cubicOp16d),
TEST(cubicOp15d),
TEST(cubicOp14d),
TEST(cubicOp13d),
TEST(cubicOp12d),
TEST(cubicOp11d),
TEST(cubicOp10d),
TEST(cubicOp1i),
TEST(cubicOp9d),
TEST(quadOp9d),
TEST(lineOp9d),
TEST(cubicOp8d),
TEST(cubicOp7d),
TEST(cubicOp6d),
TEST(cubicOp5d),
TEST(cubicOp3d),
TEST(cubicOp2d),
TEST(cubicOp1d),
};
static const size_t testCount = SK_ARRAY_COUNT(tests);
static struct TestDesc subTests[] = {
TEST(cubicOp43d),
TEST(quadOp9d),
TEST(cubicOp9d),
TEST(cubicOp1i),
TEST(cubicOp10d),
TEST(cubicOp11d),
TEST(cubicOp15d),
TEST(cubicOp18d),
TEST(cubicOp22d),
TEST(cubicOp23d),
TEST(cubicOp24d),
TEST(cubicOp28u),
TEST(cubicOp33i),
TEST(cubicOp36u),
TEST(cubicOp40d),
};
static const size_t subTestCount = SK_ARRAY_COUNT(subTests);
static void (*firstSubTest)(skiatest::Reporter* ) = 0;
static bool runSubTestsFirst = false;
static bool runReverse = false;
static void (*stopTest)(skiatest::Reporter* ) = 0;
static void PathOpsOpTest(skiatest::Reporter* reporter) {
#ifdef SK_DEBUG
gDebugMaxWindSum = 4;
gDebugMaxWindValue = 4;
#endif
if (runSubTestsFirst) {
RunTestSet(reporter, subTests, subTestCount, firstSubTest, stopTest, runReverse);
}
RunTestSet(reporter, tests, testCount, firstTest, stopTest, runReverse);
if (!runSubTestsFirst) {
RunTestSet(reporter, subTests, subTestCount, firstSubTest, stopTest, runReverse);
}
#ifdef SK_DEBUG
gDebugMaxWindSum = SK_MaxS32;
gDebugMaxWindValue = SK_MaxS32;
#endif
}
#include "TestClassDef.h"
DEFINE_TESTCLASS_SHORT(PathOpsOpTest)