Add base types for path ops
Paths contain lines, quads, and cubics, which are
collectively curves.
To work with path intersections, intermediary curves
are constructed. For now, those intermediates use
doubles to guarantee sufficient precision.
The DVector, DPoint, DLine, DQuad, and DCubic
structs encapsulate these intermediate curves.
The DRect and DTriangle structs are created to
describe intersectable areas of interest.
The Bounds struct inherits from SkRect to create
a SkScalar-based rectangle that intersects shared
edges.
This also includes common math equalities and
debugging that the remainder of path ops builds on,
as well as a temporary top-level interface in
include/pathops/SkPathOps.h.
Review URL: https://codereview.chromium.org/12827020
git-svn-id: http://skia.googlecode.com/svn/trunk@8551 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-04-08 15:47:37 +04: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.
|
|
|
|
*/
|
2013-07-16 20:11:16 +04:00
|
|
|
#include "PathOpsTestCommon.h"
|
2013-11-01 21:36:03 +04:00
|
|
|
#include "SkPath.h"
|
Add base types for path ops
Paths contain lines, quads, and cubics, which are
collectively curves.
To work with path intersections, intermediary curves
are constructed. For now, those intermediates use
doubles to guarantee sufficient precision.
The DVector, DPoint, DLine, DQuad, and DCubic
structs encapsulate these intermediate curves.
The DRect and DTriangle structs are created to
describe intersectable areas of interest.
The Bounds struct inherits from SkRect to create
a SkScalar-based rectangle that intersects shared
edges.
This also includes common math equalities and
debugging that the remainder of path ops builds on,
as well as a temporary top-level interface in
include/pathops/SkPathOps.h.
Review URL: https://codereview.chromium.org/12827020
git-svn-id: http://skia.googlecode.com/svn/trunk@8551 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-04-08 15:47:37 +04:00
|
|
|
#include "SkPathOpsQuad.h"
|
2013-11-01 21:36:03 +04:00
|
|
|
#include "SkRRect.h"
|
Add base types for path ops
Paths contain lines, quads, and cubics, which are
collectively curves.
To work with path intersections, intermediary curves
are constructed. For now, those intermediates use
doubles to guarantee sufficient precision.
The DVector, DPoint, DLine, DQuad, and DCubic
structs encapsulate these intermediate curves.
The DRect and DTriangle structs are created to
describe intersectable areas of interest.
The Bounds struct inherits from SkRect to create
a SkScalar-based rectangle that intersects shared
edges.
This also includes common math equalities and
debugging that the remainder of path ops builds on,
as well as a temporary top-level interface in
include/pathops/SkPathOps.h.
Review URL: https://codereview.chromium.org/12827020
git-svn-id: http://skia.googlecode.com/svn/trunk@8551 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-04-08 15:47:37 +04:00
|
|
|
#include "Test.h"
|
|
|
|
|
|
|
|
static const SkDQuad tests[] = {
|
|
|
|
{{{1, 1}, {2, 1}, {0, 2}}},
|
|
|
|
{{{0, 0}, {1, 1}, {3, 1}}},
|
|
|
|
{{{2, 0}, {1, 1}, {2, 2}}},
|
|
|
|
{{{4, 0}, {0, 1}, {4, 2}}},
|
|
|
|
{{{0, 0}, {0, 1}, {1, 1}}},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const SkDPoint inPoint[]= {
|
|
|
|
{1, 1.2},
|
|
|
|
{1, 0.8},
|
|
|
|
{1.8, 1},
|
|
|
|
{1.5, 1},
|
2013-11-01 21:36:03 +04:00
|
|
|
{0.4999, 0.5}, // was 0.5, 0.5; points on the hull are considered outside
|
Add base types for path ops
Paths contain lines, quads, and cubics, which are
collectively curves.
To work with path intersections, intermediary curves
are constructed. For now, those intermediates use
doubles to guarantee sufficient precision.
The DVector, DPoint, DLine, DQuad, and DCubic
structs encapsulate these intermediate curves.
The DRect and DTriangle structs are created to
describe intersectable areas of interest.
The Bounds struct inherits from SkRect to create
a SkScalar-based rectangle that intersects shared
edges.
This also includes common math equalities and
debugging that the remainder of path ops builds on,
as well as a temporary top-level interface in
include/pathops/SkPathOps.h.
Review URL: https://codereview.chromium.org/12827020
git-svn-id: http://skia.googlecode.com/svn/trunk@8551 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-04-08 15:47:37 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static const SkDPoint outPoint[]= {
|
|
|
|
{1, 1.6},
|
|
|
|
{1, 1.5},
|
|
|
|
{2.2, 1},
|
|
|
|
{1.5, 1.5},
|
|
|
|
{1.1, 0.5},
|
|
|
|
};
|
|
|
|
|
2013-04-15 23:13:59 +04:00
|
|
|
static const size_t tests_count = SK_ARRAY_COUNT(tests);
|
Add base types for path ops
Paths contain lines, quads, and cubics, which are
collectively curves.
To work with path intersections, intermediary curves
are constructed. For now, those intermediates use
doubles to guarantee sufficient precision.
The DVector, DPoint, DLine, DQuad, and DCubic
structs encapsulate these intermediate curves.
The DRect and DTriangle structs are created to
describe intersectable areas of interest.
The Bounds struct inherits from SkRect to create
a SkScalar-based rectangle that intersects shared
edges.
This also includes common math equalities and
debugging that the remainder of path ops builds on,
as well as a temporary top-level interface in
include/pathops/SkPathOps.h.
Review URL: https://codereview.chromium.org/12827020
git-svn-id: http://skia.googlecode.com/svn/trunk@8551 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-04-08 15:47:37 +04:00
|
|
|
|
2014-01-03 01:45:03 +04:00
|
|
|
DEF_TEST(PathOpsDQuad, reporter) {
|
Add base types for path ops
Paths contain lines, quads, and cubics, which are
collectively curves.
To work with path intersections, intermediary curves
are constructed. For now, those intermediates use
doubles to guarantee sufficient precision.
The DVector, DPoint, DLine, DQuad, and DCubic
structs encapsulate these intermediate curves.
The DRect and DTriangle structs are created to
describe intersectable areas of interest.
The Bounds struct inherits from SkRect to create
a SkScalar-based rectangle that intersects shared
edges.
This also includes common math equalities and
debugging that the remainder of path ops builds on,
as well as a temporary top-level interface in
include/pathops/SkPathOps.h.
Review URL: https://codereview.chromium.org/12827020
git-svn-id: http://skia.googlecode.com/svn/trunk@8551 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-04-08 15:47:37 +04:00
|
|
|
for (size_t index = 0; index < tests_count; ++index) {
|
|
|
|
const SkDQuad& quad = tests[index];
|
2013-07-16 20:11:16 +04:00
|
|
|
SkASSERT(ValidQuad(quad));
|
Add base types for path ops
Paths contain lines, quads, and cubics, which are
collectively curves.
To work with path intersections, intermediary curves
are constructed. For now, those intermediates use
doubles to guarantee sufficient precision.
The DVector, DPoint, DLine, DQuad, and DCubic
structs encapsulate these intermediate curves.
The DRect and DTriangle structs are created to
describe intersectable areas of interest.
The Bounds struct inherits from SkRect to create
a SkScalar-based rectangle that intersects shared
edges.
This also includes common math equalities and
debugging that the remainder of path ops builds on,
as well as a temporary top-level interface in
include/pathops/SkPathOps.h.
Review URL: https://codereview.chromium.org/12827020
git-svn-id: http://skia.googlecode.com/svn/trunk@8551 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-04-08 15:47:37 +04:00
|
|
|
bool result = quad.pointInHull(inPoint[index]);
|
|
|
|
if (!result) {
|
|
|
|
SkDebugf("%s [%d] expected in hull\n", __FUNCTION__, index);
|
|
|
|
REPORTER_ASSERT(reporter, 0);
|
|
|
|
}
|
|
|
|
result = quad.pointInHull(outPoint[index]);
|
|
|
|
if (result) {
|
|
|
|
SkDebugf("%s [%d] expected outside hull\n", __FUNCTION__, index);
|
|
|
|
REPORTER_ASSERT(reporter, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-03 01:45:03 +04:00
|
|
|
DEF_TEST(PathOpsRRect, reporter) {
|
2013-11-01 21:36:03 +04:00
|
|
|
SkPath path;
|
|
|
|
SkRRect rRect;
|
|
|
|
SkRect rect = {135, 143, 250, 177};
|
|
|
|
SkVector radii[4] = {{8, 8}, {8, 8}, {0, 0}, {0, 0}};
|
|
|
|
rRect.setRectRadii(rect, radii);
|
|
|
|
path.addRRect(rRect);
|
|
|
|
}
|