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 11:47:37 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
2013-07-08 17:17:02 +00:00
|
|
|
#include "SkGeometry.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 11:47:37 +00:00
|
|
|
#include "SkOpEdgeBuilder.h"
|
|
|
|
#include "SkReduceOrder.h"
|
|
|
|
|
|
|
|
void SkOpEdgeBuilder::init() {
|
|
|
|
fCurrentContour = NULL;
|
|
|
|
fOperand = false;
|
|
|
|
fXorMask[0] = fXorMask[1] = (fPath->getFillType() & 1) ? kEvenOdd_PathOpsMask
|
|
|
|
: kWinding_PathOpsMask;
|
2013-04-26 19:51:16 +00:00
|
|
|
fUnparseable = false;
|
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 11:47:37 +00:00
|
|
|
fSecondHalf = preFetch();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkOpEdgeBuilder::addOperand(const SkPath& path) {
|
|
|
|
SkASSERT(fPathVerbs.count() > 0 && fPathVerbs.end()[-1] == SkPath::kDone_Verb);
|
2013-06-17 14:10:36 +00:00
|
|
|
fPathVerbs.pop_back();
|
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 11:47:37 +00:00
|
|
|
fPath = &path;
|
|
|
|
fXorMask[1] = (fPath->getFillType() & 1) ? kEvenOdd_PathOpsMask
|
|
|
|
: kWinding_PathOpsMask;
|
|
|
|
preFetch();
|
|
|
|
}
|
|
|
|
|
2013-04-26 19:51:16 +00:00
|
|
|
bool SkOpEdgeBuilder::finish() {
|
|
|
|
if (fUnparseable || !walk()) {
|
|
|
|
return false;
|
|
|
|
}
|
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 11:47:37 +00:00
|
|
|
complete();
|
|
|
|
if (fCurrentContour && !fCurrentContour->segments().count()) {
|
|
|
|
fContours.pop_back();
|
|
|
|
}
|
2013-07-08 17:17:02 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkOpEdgeBuilder::closeContour(const SkPoint& curveEnd, const SkPoint& curveStart) {
|
2013-11-01 17:36:03 +00:00
|
|
|
if (!SkDPoint::ApproximatelyEqual(curveEnd, curveStart)) {
|
2013-07-08 17:17:02 +00:00
|
|
|
fPathVerbs.push_back(SkPath::kLine_Verb);
|
2013-07-09 07:00:56 +00:00
|
|
|
fPathPts.push_back_n(1, &curveStart);
|
2013-07-08 17:17:02 +00:00
|
|
|
} else {
|
2013-11-01 17:36:03 +00:00
|
|
|
fPathPts[fPathPts.count() - 1] = curveStart;
|
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 11:47:37 +00:00
|
|
|
}
|
2013-07-08 17:17:02 +00:00
|
|
|
fPathVerbs.push_back(SkPath::kClose_Verb);
|
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 11:47:37 +00:00
|
|
|
}
|
|
|
|
|
2014-09-18 17:32:57 +00:00
|
|
|
// very tiny points cause numerical instability : don't allow them
|
|
|
|
static void force_small_to_zero(SkPoint* pt) {
|
|
|
|
if (SkScalarAbs(pt->fX) < FLT_EPSILON_ORDERABLE_ERR) {
|
|
|
|
pt->fX = 0;
|
|
|
|
}
|
|
|
|
if (SkScalarAbs(pt->fY) < FLT_EPSILON_ORDERABLE_ERR) {
|
|
|
|
pt->fY = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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 11:47:37 +00:00
|
|
|
int SkOpEdgeBuilder::preFetch() {
|
2013-04-26 19:51:16 +00:00
|
|
|
if (!fPath->isFinite()) {
|
|
|
|
fUnparseable = true;
|
|
|
|
return 0;
|
|
|
|
}
|
2013-07-08 17:17:02 +00:00
|
|
|
SkAutoConicToQuads quadder;
|
|
|
|
const SkScalar quadderTol = SK_Scalar1 / 16;
|
2013-04-25 11:51:54 +00:00
|
|
|
SkPath::RawIter iter(*fPath);
|
2013-07-08 17:17:02 +00:00
|
|
|
SkPoint curveStart;
|
|
|
|
SkPoint curve[4];
|
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 11:47:37 +00:00
|
|
|
SkPoint pts[4];
|
|
|
|
SkPath::Verb verb;
|
2013-07-08 17:17:02 +00:00
|
|
|
bool lastCurve = false;
|
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 11:47:37 +00:00
|
|
|
do {
|
|
|
|
verb = iter.next(pts);
|
2013-07-08 17:17:02 +00:00
|
|
|
switch (verb) {
|
|
|
|
case SkPath::kMove_Verb:
|
|
|
|
if (!fAllowOpenContours && lastCurve) {
|
|
|
|
closeContour(curve[0], curveStart);
|
|
|
|
}
|
|
|
|
fPathVerbs.push_back(verb);
|
2014-09-18 17:32:57 +00:00
|
|
|
force_small_to_zero(&pts[0]);
|
2013-07-08 17:17:02 +00:00
|
|
|
fPathPts.push_back(pts[0]);
|
|
|
|
curveStart = curve[0] = pts[0];
|
|
|
|
lastCurve = false;
|
|
|
|
continue;
|
|
|
|
case SkPath::kLine_Verb:
|
2014-09-18 17:32:57 +00:00
|
|
|
force_small_to_zero(&pts[1]);
|
2013-11-01 17:36:03 +00:00
|
|
|
if (SkDPoint::ApproximatelyEqual(curve[0], pts[1])) {
|
|
|
|
uint8_t lastVerb = fPathVerbs.back();
|
|
|
|
if (lastVerb != SkPath::kLine_Verb && lastVerb != SkPath::kMove_Verb) {
|
2013-09-16 15:55:01 +00:00
|
|
|
fPathPts.back() = pts[1];
|
|
|
|
}
|
2013-07-08 17:17:02 +00:00
|
|
|
continue; // skip degenerate points
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SkPath::kQuad_Verb:
|
2014-09-18 17:32:57 +00:00
|
|
|
force_small_to_zero(&pts[1]);
|
|
|
|
force_small_to_zero(&pts[2]);
|
2013-07-08 17:17:02 +00:00
|
|
|
curve[1] = pts[1];
|
|
|
|
curve[2] = pts[2];
|
|
|
|
verb = SkReduceOrder::Quad(curve, pts);
|
|
|
|
if (verb == SkPath::kMove_Verb) {
|
|
|
|
continue; // skip degenerate points
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SkPath::kConic_Verb: {
|
|
|
|
const SkPoint* quadPts = quadder.computeQuads(pts, iter.conicWeight(),
|
|
|
|
quadderTol);
|
|
|
|
const int nQuads = quadder.countQuads();
|
|
|
|
for (int i = 0; i < nQuads; ++i) {
|
|
|
|
fPathVerbs.push_back(SkPath::kQuad_Verb);
|
|
|
|
}
|
2015-01-06 15:44:21 +00:00
|
|
|
fPathPts.push_back_n(nQuads * 2, &quadPts[1]);
|
|
|
|
curve[0] = pts[2];
|
2013-07-08 17:17:02 +00:00
|
|
|
lastCurve = true;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
case SkPath::kCubic_Verb:
|
2014-09-18 17:32:57 +00:00
|
|
|
force_small_to_zero(&pts[1]);
|
|
|
|
force_small_to_zero(&pts[2]);
|
|
|
|
force_small_to_zero(&pts[3]);
|
2013-07-08 17:17:02 +00:00
|
|
|
curve[1] = pts[1];
|
|
|
|
curve[2] = pts[2];
|
|
|
|
curve[3] = pts[3];
|
|
|
|
verb = SkReduceOrder::Cubic(curve, pts);
|
|
|
|
if (verb == SkPath::kMove_Verb) {
|
|
|
|
continue; // skip degenerate points
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SkPath::kClose_Verb:
|
|
|
|
closeContour(curve[0], curveStart);
|
|
|
|
lastCurve = false;
|
|
|
|
continue;
|
|
|
|
case SkPath::kDone_Verb:
|
|
|
|
continue;
|
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 11:47:37 +00:00
|
|
|
}
|
2013-07-08 17:17:02 +00:00
|
|
|
fPathVerbs.push_back(verb);
|
|
|
|
int ptCount = SkPathOpsVerbToPoints(verb);
|
|
|
|
fPathPts.push_back_n(ptCount, &pts[1]);
|
|
|
|
curve[0] = pts[ptCount];
|
|
|
|
lastCurve = true;
|
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 11:47:37 +00:00
|
|
|
} while (verb != SkPath::kDone_Verb);
|
2013-07-08 17:17:02 +00:00
|
|
|
if (!fAllowOpenContours && lastCurve) {
|
|
|
|
closeContour(curve[0], curveStart);
|
|
|
|
}
|
|
|
|
fPathVerbs.push_back(SkPath::kDone_Verb);
|
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 11:47:37 +00:00
|
|
|
return fPathVerbs.count() - 1;
|
|
|
|
}
|
|
|
|
|
2013-04-26 19:51:16 +00:00
|
|
|
bool SkOpEdgeBuilder::close() {
|
|
|
|
complete();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SkOpEdgeBuilder::walk() {
|
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 11:47:37 +00:00
|
|
|
uint8_t* verbPtr = fPathVerbs.begin();
|
|
|
|
uint8_t* endOfFirstHalf = &verbPtr[fSecondHalf];
|
2013-07-08 17:17:02 +00:00
|
|
|
const SkPoint* pointsPtr = fPathPts.begin() - 1;
|
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 11:47:37 +00:00
|
|
|
SkPath::Verb verb;
|
2013-04-25 11:51:54 +00:00
|
|
|
while ((verb = (SkPath::Verb) *verbPtr) != SkPath::kDone_Verb) {
|
|
|
|
if (verbPtr == endOfFirstHalf) {
|
|
|
|
fOperand = true;
|
|
|
|
}
|
|
|
|
verbPtr++;
|
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 11:47:37 +00:00
|
|
|
switch (verb) {
|
|
|
|
case SkPath::kMove_Verb:
|
2013-04-26 19:51:16 +00:00
|
|
|
if (fCurrentContour) {
|
|
|
|
if (fAllowOpenContours) {
|
|
|
|
complete();
|
|
|
|
} else if (!close()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
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 11:47:37 +00:00
|
|
|
if (!fCurrentContour) {
|
|
|
|
fCurrentContour = fContours.push_back_n(1);
|
|
|
|
fCurrentContour->setOperand(fOperand);
|
|
|
|
fCurrentContour->setXor(fXorMask[fOperand] == kEvenOdd_PathOpsMask);
|
|
|
|
}
|
2013-07-08 17:17:02 +00:00
|
|
|
pointsPtr += 1;
|
2013-04-25 11:51:54 +00:00
|
|
|
continue;
|
2013-07-08 17:17:02 +00:00
|
|
|
case SkPath::kLine_Verb:
|
|
|
|
fCurrentContour->addLine(pointsPtr);
|
|
|
|
break;
|
|
|
|
case SkPath::kQuad_Verb:
|
|
|
|
fCurrentContour->addQuad(pointsPtr);
|
|
|
|
break;
|
|
|
|
case SkPath::kCubic_Verb:
|
|
|
|
fCurrentContour->addCubic(pointsPtr);
|
|
|
|
break;
|
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 11:47:37 +00:00
|
|
|
case SkPath::kClose_Verb:
|
|
|
|
SkASSERT(fCurrentContour);
|
2013-04-26 19:51:16 +00:00
|
|
|
if (!close()) {
|
|
|
|
return false;
|
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 11:47:37 +00:00
|
|
|
}
|
2013-04-25 11:51:54 +00:00
|
|
|
continue;
|
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 11:47:37 +00:00
|
|
|
default:
|
|
|
|
SkDEBUGFAIL("bad verb");
|
2013-04-26 19:51:16 +00:00
|
|
|
return false;
|
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 11:47:37 +00:00
|
|
|
}
|
2013-05-31 15:17:50 +00:00
|
|
|
pointsPtr += SkPathOpsVerbToPoints(verb);
|
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 11:47:37 +00:00
|
|
|
SkASSERT(fCurrentContour);
|
|
|
|
}
|
2013-04-26 19:51:16 +00:00
|
|
|
if (fCurrentContour && !fAllowOpenContours && !close()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
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 11:47:37 +00:00
|
|
|
}
|