skia2/tests/PathOpsOpTest.cpp
caryclark@google.com cffbcc3b96 path ops -- rewrite angle sort
This is a major change resulting from a minor
tweak. In the old code, the intersection point
of two curves was shared between them, but the
intersection points and end points of sorted edges was
computed directly from the intersection T value.

In this CL, both intersection points and sorted points
are the same, and intermediate control points are computed
to preserve their slope.

The sort itself has been completely rewritten to be more
robust and remove 'magic' checks, conditions that empirically
worked but couldn't be rationalized.

This CL was triggered by errors generated computing the clips
of SKP files. At this point, all 73M standard tests work and
at least the first troublesome SKPs work.

Review URL: https://codereview.chromium.org/15338003

git-svn-id: http://skia.googlecode.com/svn/trunk@9432 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-06-04 17:59:42 +00:00

1764 lines
54 KiB
C++

/*
* 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 cubicOp66u(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(2,6, 4,2, 5,3);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(2,4);
pathB.cubicTo(3,5, 1,0, 6,2);
pathB.close();
testPathOp(reporter, path, pathB, kUnion_PathOp);
}
static void cubicOp67u(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.moveTo(3,5);
path.cubicTo(1,6, 5,0, 3,1);
path.lineTo(3,5);
path.close();
pathB.moveTo(0,5);
pathB.cubicTo(1,3, 5,3, 6,1);
pathB.lineTo(0,5);
pathB.close();
testPathOp(reporter, path, pathB, kUnion_PathOp);
}
static void cubicOp68u(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.moveTo(0,5);
path.cubicTo(4,5, 4,1, 5,0);
path.close();
pathB.moveTo(1,4);
pathB.cubicTo(0,5, 5,0, 5,4);
pathB.close();
testPathOp(reporter, path, pathB, kUnion_PathOp);
}
static void cubicOp69d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.moveTo(1,3);
path.cubicTo(0,1, 3,1, 2,0);
path.close();
pathB.moveTo(1,3);
pathB.cubicTo(0,2, 3,1, 1,0);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
SkPathOp ops[] = {
kUnion_PathOp,
kXOR_PathOp,
kReverseDifference_PathOp,
kXOR_PathOp,
kReverseDifference_PathOp,
};
static void rRect1(skiatest::Reporter* reporter) {
SkScalar xA = SkFloatToScalar(0.65f);
SkScalar xB = SkFloatToScalar(10.65f);
SkScalar xC = SkFloatToScalar(20.65f);
SkScalar xD = SkFloatToScalar(30.65f);
SkScalar xE = SkFloatToScalar(40.65f);
SkScalar xF = SkFloatToScalar(50.65f);
SkScalar yA = SkFloatToScalar(0.65f);
SkScalar yB = SkFloatToScalar(10.65f);
SkScalar yC = SkFloatToScalar(20.65f);
SkScalar yD = SkFloatToScalar(30.65f);
SkScalar yE = SkFloatToScalar(40.65f);
SkScalar yF = SkFloatToScalar(50.65f);
SkPath paths[5];
SkRect rects[5];
rects[0].set(xB, yB, xE, yE);
paths[0].addRoundRect(rects[0], SkIntToScalar(5), SkIntToScalar(5)); // red
rects[1].set(xA, yA, xD, yD);
paths[1].addRoundRect(rects[1], SkIntToScalar(5), SkIntToScalar(5)); // green
rects[2].set(xC, yA, xF, yD);
paths[2].addRoundRect(rects[2], SkIntToScalar(5), SkIntToScalar(5)); // blue
rects[3].set(xA, yC, xD, yF);
paths[3].addRoundRect(rects[3], SkIntToScalar(5), SkIntToScalar(5)); // yellow
rects[4].set(xC, yC, xF, yF);
paths[4].addRoundRect(rects[4], SkIntToScalar(5), SkIntToScalar(5)); // cyan
SkPath path;
path.setFillType(SkPath::kInverseEvenOdd_FillType);
for (int index = 0; index < 5; ++index) {
testPathOp(reporter, path, paths[index], ops[index]);
Op(path, paths[index], ops[index], &path);
}
}
static void skp1(skiatest::Reporter* reporter) {
SkPath path;
path.setFillType(SkPath::kEvenOdd_FillType);
path.moveTo(189,7);
path.cubicTo(189,5.34314585f, 190.34314f,4, 192,4);
path.lineTo(243,4);
path.cubicTo(244.65686f,4, 246,5.34314585f, 246,7);
path.lineTo(246,21);
path.cubicTo(246,22.6568546f, 244.65686f,24, 243,24);
path.lineTo(192,24);
path.cubicTo(190.34314f,24, 189,22.6568546f, 189,21);
path.lineTo(189,7);
path.close();
path.moveTo(191,8);
path.cubicTo(191,6.89543009f, 191.895432f,6, 193,6);
path.lineTo(242,6);
path.cubicTo(243.104568f,6, 244,6.89543009f, 244,8);
path.lineTo(244,20);
path.cubicTo(244,21.1045704f, 243.104568f,22, 242,22);
path.lineTo(193,22);
path.cubicTo(191.895432f,22, 191,21.1045704f, 191,20);
path.lineTo(191,8);
path.close();
SkPath pathB;
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(189,4);
pathB.lineTo(199,14);
pathB.lineTo(236,14);
pathB.lineTo(246,4);
pathB.lineTo(189,4);
pathB.close();
testPathOp(reporter, path, pathB, kIntersect_PathOp);
}
static void skp2(skiatest::Reporter* reporter) {
SkPath path;
path.setFillType(SkPath::kEvenOdd_FillType);
path.moveTo(253.000000f, 11757.0000f);
path.lineTo(253.000000f, 222.000000f);
path.lineTo(823.000000f, 222.000000f);
path.lineTo(823.000000f, 11757.0000f);
path.lineTo(253.000000f, 11757.0000f);
path.close();
SkPath pathB;
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(258.000000f, 1028.00000f);
pathB.lineTo(258.000000f, 1027.00000f);
pathB.lineTo(823.000000f, 1027.00000f);
pathB.lineTo(823.000000f, 1028.00000f);
pathB.lineTo(258.000000f, 1028.00000f);
pathB.close();
testPathOp(reporter, path, pathB, kIntersect_PathOp);
}
static void skp3(skiatest::Reporter* reporter) {
SkPath path;
path.setFillType(SkPath::kEvenOdd_FillType);
path.moveTo(717.000000f, 507.000000f);
path.lineTo(717.000000f, 425.000000f);
path.lineTo(973.000000f, 425.000000f);
path.lineTo(973.000000f, 507.000000f);
path.quadTo(973.000000f, 508.242645f, 972.121582f, 509.121613f);
path.quadTo(971.242615f, 510.000000f, 970.000000f, 510.000000f);
path.lineTo(720.000000f, 510.000000f);
path.quadTo(718.757385f, 510.000000f, 717.878418f, 509.121613f);
path.quadTo(717.000000f, 508.242645f, 717.000000f, 507.000000f);
path.close();
path.moveTo(719.000000f, 426.000000f);
path.lineTo(971.000000f, 426.000000f);
path.lineTo(971.000000f, 506.000000f);
path.cubicTo(971.000000f, 507.104584f, 970.104553f, 508.000000f, 969.000000f, 508.000000f);
path.lineTo(721.000000f, 508.000000f);
path.cubicTo(719.895447f, 508.000000f, 719.000000f, 507.104584f, 719.000000f, 506.000000f);
path.lineTo(719.000000f, 426.000000f);
path.close();
SkPath pathB;
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(717.000000f, 510.000000f);
pathB.lineTo(760.000000f, 467.000000f);
pathB.lineTo(930.000000f, 467.000000f);
pathB.lineTo(973.000000f, 510.000000f);
pathB.lineTo(717.000000f, 510.000000f);
pathB.close();
testPathOp(reporter, path, pathB, kIntersect_PathOp);
}
static void skp4(skiatest::Reporter* reporter) {
SkPath path;
path.setFillType(SkPath::kEvenOdd_FillType);
path.moveTo(230.756805f, 591.756775f);
path.quadTo(232.514725f, 590.000000f, 235.000000f, 590.000000f);
path.lineTo(300.000000f, 590.000000f);
path.quadTo(302.485291f, 590.000000f, 304.243195f, 591.756775f);
path.quadTo(306.000000f, 593.514709f, 306.000000f, 596.000000f);
path.lineTo(306.000000f, 617.000000f);
path.lineTo(229.000000f, 617.000000f);
path.lineTo(229.000000f, 596.000000f);
path.quadTo(229.000000f, 593.514709f, 230.756805f, 591.756775f);
path.close();
path.moveTo(231.000000f, 597.000000f);
path.cubicTo(231.000000f, 594.238586f, 233.238571f, 592.000000f, 236.000000f, 592.000000f);
path.lineTo(299.000000f, 592.000000f);
path.cubicTo(301.761414f, 592.000000f, 304.000000f, 594.238586f, 304.000000f, 597.000000f);
path.lineTo(304.000000f, 616.000000f);
path.lineTo(231.000000f, 616.000000f);
path.lineTo(231.000000f, 597.000000f);
path.close();
SkPath pathB;
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(306.000000f, 590.000000f);
pathB.lineTo(292.000000f, 604.000000f);
pathB.lineTo(305.000000f, 617.000000f);
pathB.lineTo(306.000000f, 617.000000f);
pathB.lineTo(306.000000f, 590.000000f);
pathB.close();
testPathOp(reporter, path, pathB, kIntersect_PathOp);
}
static void skp5(skiatest::Reporter* reporter) {
SkPath path;
path.setFillType(SkPath::kEvenOdd_FillType);
path.moveTo(18.0000000f, 226.000000f);
path.quadTo(14.6862917f, 226.000000f, 12.3423996f, 228.342407f);
path.quadTo(10.0000000f, 230.686295f, 10.0000000f, 234.000000f);
path.lineTo(10.0000000f, 253.000000f);
path.lineTo(1247.00000f, 253.000000f);
path.lineTo(1247.00000f, 234.000000f);
path.quadTo(1247.00000f, 230.686295f, 1244.65759f, 228.342407f);
path.quadTo(1242.31372f, 226.000000f, 1239.00000f, 226.000000f);
path.lineTo(18.0000000f, 226.000000f);
path.close();
SkPath pathB;
pathB.setFillType(SkPath::kInverseWinding_FillType);
pathB.moveTo(18.0000000f, 226.000000f);
pathB.lineTo(1239.00000f, 226.000000f);
pathB.cubicTo(1243.41833f, 226.000000f, 1247.00000f, 229.581726f, 1247.00000f, 234.000000f);
pathB.lineTo(1247.00000f, 252.000000f);
pathB.lineTo(10.0000000f, 252.000000f);
pathB.lineTo(10.0000000f, 234.000000f);
pathB.cubicTo(10.0000000f, 229.581726f, 13.5817204f, 226.000000f, 18.0000000f, 226.000000f);
pathB.close();
testPathOp(reporter, path, pathB, kIntersect_PathOp);
}
static void cubicOp70d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(0,5, 4,0, 5,0);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,4);
pathB.cubicTo(0,5, 1,0, 5,0);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp71d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(0,5, 4,1, 6,4);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(1,4);
pathB.cubicTo(4,6, 1,0, 5,0);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp72i(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(0,5, 5,2, 5,4);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(2,5);
pathB.cubicTo(4,5, 1,0, 5,0);
pathB.close();
testPathOp(reporter, path, pathB, kIntersect_PathOp);
}
static void cubicOp73d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(3,4, 4,0, 6,4);
path.lineTo(0,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,4);
pathB.cubicTo(4,6, 1,0, 4,3);
pathB.lineTo(0,4);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp74d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(1,5, 5,1, 5,1);
path.lineTo(0,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(1,5);
pathB.cubicTo(1,5, 1,0, 5,1);
pathB.lineTo(1,5);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp75d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(0,4, 5,1, 6,4);
path.lineTo(0,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(1,5);
pathB.cubicTo(4,6, 1,0, 4,0);
pathB.lineTo(1,5);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp76u(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(0,2, 2,0, 5,3);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,2);
pathB.cubicTo(3,5, 1,0, 2,0);
pathB.close();
testPathOp(reporter, path, pathB, kUnion_PathOp);
}
static void cubicOp77i(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kEvenOdd_FillType);
path.moveTo(0,1);
path.cubicTo(1,3, 2,0, 3,2);
path.lineTo(0,1);
path.close();
pathB.setFillType(SkPath::kEvenOdd_FillType);
pathB.moveTo(0,2);
pathB.cubicTo(2,3, 1,0, 3,1);
pathB.lineTo(0,2);
pathB.close();
testPathOp(reporter, path, pathB, kIntersect_PathOp);
}
static void cubicOp78u(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kEvenOdd_FillType);
path.moveTo(1,6);
path.cubicTo(1,6, 5,0, 6,1);
path.lineTo(1,6);
path.close();
pathB.setFillType(SkPath::kEvenOdd_FillType);
pathB.moveTo(0,5);
pathB.cubicTo(1,6, 6,1, 6,1);
pathB.lineTo(0,5);
pathB.close();
testPathOp(reporter, path, pathB, kUnion_PathOp);
}
static void cubicOp79u(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(1,3, 1,0, 6,4);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(0,1);
pathB.cubicTo(4,6, 1,0, 3,1);
pathB.close();
testPathOp(reporter, path, pathB, kIntersect_PathOp);
}
static void cubicOp80i(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(2,3, 2,1, 4,3);
path.lineTo(0,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(1,2);
pathB.cubicTo(3,4, 1,0, 3,2);
pathB.lineTo(1,2);
pathB.close();
testPathOp(reporter, path, pathB, kIntersect_PathOp);
}
static void cubicOp81d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(4,6, 4,3, 5,4);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(3,4);
pathB.cubicTo(4,5, 1,0, 6,4);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void cubicOp82i(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kEvenOdd_FillType);
path.moveTo(0,1);
path.cubicTo(2,3, 5,2, 3,0);
path.lineTo(0,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(2,5);
pathB.cubicTo(0,3, 1,0, 3,2);
pathB.lineTo(2,5);
pathB.close();
testPathOp(reporter, path, pathB, kIntersect_PathOp);
}
static void cubicOp83i(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,1);
path.cubicTo(0,3, 2,1, 4,1);
path.lineTo(0,1);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(1,2);
pathB.cubicTo(1,4, 1,0, 3,0);
pathB.lineTo(1,2);
pathB.close();
testPathOp(reporter, path, pathB, kIntersect_PathOp);
}
static void cubicOp84d(skiatest::Reporter* reporter) {
SkPath path, pathB;
path.setFillType(SkPath::kWinding_FillType);
path.moveTo(0,4);
path.cubicTo(2,3, 6,3, 3,2);
path.close();
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(3,6);
pathB.cubicTo(2,3, 4,0, 3,2);
pathB.close();
testPathOp(reporter, path, pathB, kDifference_PathOp);
}
static void skpClip1(skiatest::Reporter* reporter) {
SkPath path;
path.setFillType(SkPath::kEvenOdd_FillType);
path.moveTo(1126.17114f, 877.171204f);
path.quadTo(1127.34314f, 876.000000f, 1129.00000f, 876.000000f);
path.lineTo(1243.00000f, 876.000000f);
path.quadTo(1244.65686f, 876.000000f, 1245.82886f, 877.171204f);
path.quadTo(1247.00000f, 878.343140f, 1247.00000f, 880.000000f);
path.lineTo(1247.00000f, 907.000000f);
path.lineTo(1246.00000f, 907.000000f);
path.lineTo(1246.00000f, 880.000000f);
path.cubicTo(1246.00000f, 878.343140f, 1244.65686f, 877.000000f, 1243.00000f, 877.000000f);
path.lineTo(1129.00000f, 877.000000f);
path.cubicTo(1127.34314f, 877.000000f, 1126.00000f, 878.343140f, 1126.00000f, 880.000000f);
path.lineTo(1126.00000f, 907.000000f);
path.lineTo(1125.00000f, 907.000000f);
path.lineTo(1125.00000f, 880.000000f);
path.quadTo(1125.00000f, 878.343140f, 1126.17114f, 877.171204f);
path.close();
SkPath pathB;
pathB.setFillType(SkPath::kWinding_FillType);
pathB.moveTo(1247.00000f, 876.000000f);
pathB.lineTo(1231.00000f, 892.000000f);
pathB.lineTo(1246.00000f, 907.000000f);
pathB.lineTo(1247.00000f, 907.000000f);
pathB.lineTo(1247.00000f, 876.000000f);
pathB.close();
testPathOp(reporter, path, pathB, kIntersect_PathOp);
}
#if 1 // FIXME: work in progress -- coincident cubic undetected
static void skpClip2(skiatest::Reporter* reporter) {
SkPath path;
path.setFillType(SkPath::kEvenOdd_FillType);
path.moveTo(134.000000f, 11414.0000f);
path.cubicTo(131.990234f, 11414.0000f, 130.326660f, 11415.4824f, 130.042755f, 11417.4131f);
path.cubicTo(130.233124f, 11418.3193f, 131.037079f, 11419.0000f, 132.000000f, 11419.0000f);
path.lineTo(806.000000f, 11419.0000f);
path.cubicTo(806.962891f, 11419.0000f, 807.766907f, 11418.3193f, 807.957275f, 11417.4131f);
path.cubicTo(807.673401f, 11415.4824f, 806.009766f, 11414.0000f, 804.000000f, 11414.0000f);
path.lineTo(134.000000f, 11414.0000f);
path.close();
SkPath pathB;
pathB.setFillType(SkPath::kInverseWinding_FillType);
pathB.moveTo(132.000000f, 11415.0000f);
pathB.lineTo(806.000000f, 11415.0000f);
pathB.cubicTo(807.104553f, 11415.0000f, 808.000000f, 11415.4473f, 808.000000f, 11416.0000f);
pathB.lineTo(808.000000f, 11417.0000f);
pathB.cubicTo(808.000000f, 11418.1045f, 807.104553f, 11419.0000f, 806.000000f, 11419.0000f);
pathB.lineTo(132.000000f, 11419.0000f);
pathB.cubicTo(130.895432f, 11419.0000f, 130.000000f, 11418.1045f, 130.000000f, 11417.0000f);
pathB.lineTo(130.000000f, 11416.0000f);
pathB.cubicTo(130.000000f, 11415.4473f, 130.895432f, 11415.0000f, 132.000000f, 11415.0000f);
pathB.close();
testPathOp(reporter, path, pathB, kIntersect_PathOp);
}
#endif
static void (*firstTest)(skiatest::Reporter* ) = 0;
static struct TestDesc tests[] = {
#if 1 // FIXME: work in progress -- coincident cubic undetected
TEST(skpClip2),
#endif
TEST(skpClip1),
TEST(cubicOp84d),
TEST(cubicOp83i),
TEST(cubicOp82i),
TEST(cubicOp81d),
TEST(cubicOp80i),
TEST(cubicOp79u),
TEST(cubicOp78u),
TEST(cubicOp77i),
TEST(cubicOp76u),
TEST(cubicOp75d),
TEST(cubicOp74d),
TEST(cubicOp73d),
TEST(cubicOp72i),
TEST(cubicOp71d),
TEST(skp5),
TEST(skp4),
TEST(skp3),
TEST(skp2),
TEST(skp1),
TEST(rRect1),
TEST(cubicOp70d),
TEST(cubicOp69d),
TEST(cubicOp68u),
TEST(cubicOp67u),
TEST(cubicOp66u),
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(cubicOp6d),
TEST(cubicOp8d),
TEST(cubicOp70d),
TEST(cubicOp16d),
TEST(skp5),
};
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)