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.
|
|
|
|
*/
|
|
|
|
#ifndef SkPathOpsCurve_DEFINE
|
|
|
|
#define SkPathOpsCurve_DEFINE
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/pathops/SkIntersections.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
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
#ifndef SK_RELEASE
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkPath.h"
|
2015-04-20 15:31:59 +00:00
|
|
|
#endif
|
|
|
|
|
2015-04-29 15:28:30 +00:00
|
|
|
struct SkPathOpsBounds;
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
struct SkOpCurve {
|
|
|
|
SkPoint fPts[4];
|
|
|
|
SkScalar fWeight;
|
|
|
|
SkDEBUGCODE(SkPath::Verb fVerb);
|
|
|
|
|
|
|
|
const SkPoint& operator[](int n) const {
|
|
|
|
SkASSERT(n >= 0 && n <= SkPathOpsVerbToPoints(fVerb));
|
|
|
|
return fPts[n];
|
|
|
|
}
|
|
|
|
|
2015-04-23 16:13:37 +00:00
|
|
|
void dump() const;
|
|
|
|
|
|
|
|
void set(const SkDQuad& quad) {
|
|
|
|
for (int index = 0; index < SkDQuad::kPointCount; ++index) {
|
|
|
|
fPts[index] = quad[index].asSkPoint();
|
|
|
|
}
|
|
|
|
SkDEBUGCODE(fWeight = 1);
|
|
|
|
SkDEBUGCODE(fVerb = SkPath::kQuad_Verb);
|
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
void set(const SkDCubic& cubic) {
|
|
|
|
for (int index = 0; index < SkDCubic::kPointCount; ++index) {
|
|
|
|
fPts[index] = cubic[index].asSkPoint();
|
|
|
|
}
|
|
|
|
SkDEBUGCODE(fWeight = 1);
|
|
|
|
SkDEBUGCODE(fVerb = SkPath::kCubic_Verb);
|
|
|
|
}
|
2015-04-29 15:28:30 +00:00
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SkDCurve {
|
|
|
|
union {
|
|
|
|
SkDLine fLine;
|
|
|
|
SkDQuad fQuad;
|
|
|
|
SkDConic fConic;
|
|
|
|
SkDCubic fCubic;
|
|
|
|
};
|
|
|
|
SkDEBUGCODE(SkPath::Verb fVerb);
|
|
|
|
|
|
|
|
const SkDPoint& operator[](int n) const {
|
|
|
|
SkASSERT(n >= 0 && n <= SkPathOpsVerbToPoints(fVerb));
|
|
|
|
return fCubic[n];
|
|
|
|
}
|
|
|
|
|
|
|
|
SkDPoint& operator[](int n) {
|
|
|
|
SkASSERT(n >= 0 && n <= SkPathOpsVerbToPoints(fVerb));
|
|
|
|
return fCubic[n];
|
|
|
|
}
|
|
|
|
|
2016-07-18 17:01:36 +00:00
|
|
|
SkDPoint conicTop(const SkPoint curve[3], SkScalar curveWeight,
|
2015-04-29 15:28:30 +00:00
|
|
|
double s, double e, double* topT);
|
|
|
|
SkDPoint cubicTop(const SkPoint curve[4], SkScalar , double s, double e, double* topT);
|
2016-07-18 17:01:36 +00:00
|
|
|
void dump() const;
|
2015-04-20 15:31:59 +00:00
|
|
|
void dumpID(int ) const;
|
2015-04-29 15:28:30 +00:00
|
|
|
SkDPoint lineTop(const SkPoint[2], SkScalar , double , double , double* topT);
|
2016-07-18 17:01:36 +00:00
|
|
|
double nearPoint(SkPath::Verb verb, const SkDPoint& xy, const SkDPoint& opp) const;
|
|
|
|
void offset(SkPath::Verb verb, const SkDVector& );
|
2015-04-29 15:28:30 +00:00
|
|
|
SkDPoint quadTop(const SkPoint curve[3], SkScalar , double s, double e, double* topT);
|
|
|
|
|
2016-07-18 17:01:36 +00:00
|
|
|
void setConicBounds(const SkPoint curve[3], SkScalar curveWeight,
|
2015-04-29 15:28:30 +00:00
|
|
|
double s, double e, SkPathOpsBounds* );
|
|
|
|
void setCubicBounds(const SkPoint curve[4], SkScalar ,
|
|
|
|
double s, double e, SkPathOpsBounds* );
|
|
|
|
void setQuadBounds(const SkPoint curve[3], SkScalar ,
|
|
|
|
double s, double e, SkPathOpsBounds*);
|
2015-04-20 15:31:59 +00:00
|
|
|
};
|
|
|
|
|
2016-09-14 14:18:20 +00:00
|
|
|
class SkDCurveSweep {
|
|
|
|
public:
|
|
|
|
bool isCurve() const { return fIsCurve; }
|
|
|
|
bool isOrdered() const { return fOrdered; }
|
|
|
|
void setCurveHullSweep(SkPath::Verb verb);
|
|
|
|
|
|
|
|
SkDCurve fCurve;
|
|
|
|
SkDVector fSweep[2];
|
|
|
|
private:
|
|
|
|
bool fIsCurve;
|
|
|
|
bool fOrdered; // cleared when a cubic's control point isn't between the sweep vectors
|
|
|
|
|
|
|
|
};
|
2015-04-29 15:28:30 +00:00
|
|
|
|
|
|
|
extern SkDPoint (SkDCurve::* const Top[])(const SkPoint curve[], SkScalar cWeight,
|
|
|
|
double tStart, double tEnd, double* topT);
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
static SkDPoint dline_xy_at_t(const SkPoint a[2], SkScalar , double t) {
|
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
|
|
|
SkDLine line;
|
|
|
|
line.set(a);
|
2013-07-23 15:27:41 +00:00
|
|
|
return line.ptAtT(t);
|
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
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
static SkDPoint dquad_xy_at_t(const SkPoint a[3], SkScalar , double t) {
|
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
|
|
|
SkDQuad quad;
|
|
|
|
quad.set(a);
|
2013-07-23 15:27:41 +00:00
|
|
|
return quad.ptAtT(t);
|
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
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
static SkDPoint dconic_xy_at_t(const SkPoint a[3], SkScalar weight, double t) {
|
|
|
|
SkDConic conic;
|
|
|
|
conic.set(a, weight);
|
|
|
|
return conic.ptAtT(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
static SkDPoint dcubic_xy_at_t(const SkPoint a[4], SkScalar , double t) {
|
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
|
|
|
SkDCubic cubic;
|
|
|
|
cubic.set(a);
|
2013-07-23 15:27:41 +00:00
|
|
|
return cubic.ptAtT(t);
|
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
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
static SkDPoint (* const CurveDPointAtT[])(const SkPoint[], SkScalar , double ) = {
|
2015-08-27 14:41:13 +00:00
|
|
|
nullptr,
|
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
|
|
|
dline_xy_at_t,
|
|
|
|
dquad_xy_at_t,
|
2015-04-20 15:31:59 +00:00
|
|
|
dconic_xy_at_t,
|
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
|
|
|
dcubic_xy_at_t
|
|
|
|
};
|
|
|
|
|
2016-07-18 17:01:36 +00:00
|
|
|
static SkDPoint ddline_xy_at_t(const SkDCurve& c, double t) {
|
|
|
|
return c.fLine.ptAtT(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
static SkDPoint ddquad_xy_at_t(const SkDCurve& c, double t) {
|
|
|
|
return c.fQuad.ptAtT(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
static SkDPoint ddconic_xy_at_t(const SkDCurve& c, double t) {
|
|
|
|
return c.fConic.ptAtT(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
static SkDPoint ddcubic_xy_at_t(const SkDCurve& c, double t) {
|
|
|
|
return c.fCubic.ptAtT(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
static SkDPoint (* const CurveDDPointAtT[])(const SkDCurve& , double ) = {
|
|
|
|
nullptr,
|
|
|
|
ddline_xy_at_t,
|
|
|
|
ddquad_xy_at_t,
|
|
|
|
ddconic_xy_at_t,
|
|
|
|
ddcubic_xy_at_t
|
|
|
|
};
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
static SkPoint fline_xy_at_t(const SkPoint a[2], SkScalar weight, double t) {
|
|
|
|
return dline_xy_at_t(a, weight, t).asSkPoint();
|
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
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
static SkPoint fquad_xy_at_t(const SkPoint a[3], SkScalar weight, double t) {
|
|
|
|
return dquad_xy_at_t(a, weight, t).asSkPoint();
|
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
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
static SkPoint fconic_xy_at_t(const SkPoint a[3], SkScalar weight, double t) {
|
|
|
|
return dconic_xy_at_t(a, weight, t).asSkPoint();
|
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
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
static SkPoint fcubic_xy_at_t(const SkPoint a[4], SkScalar weight, double t) {
|
|
|
|
return dcubic_xy_at_t(a, weight, t).asSkPoint();
|
|
|
|
}
|
|
|
|
|
|
|
|
static SkPoint (* const CurvePointAtT[])(const SkPoint[], SkScalar , double ) = {
|
2015-08-27 14:41:13 +00:00
|
|
|
nullptr,
|
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
|
|
|
fline_xy_at_t,
|
|
|
|
fquad_xy_at_t,
|
2015-04-20 15:31:59 +00:00
|
|
|
fconic_xy_at_t,
|
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
|
|
|
fcubic_xy_at_t
|
|
|
|
};
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
static SkDVector dline_dxdy_at_t(const SkPoint a[2], SkScalar , double ) {
|
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
|
|
|
SkDLine line;
|
|
|
|
line.set(a);
|
|
|
|
return line[1] - line[0];
|
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
static SkDVector dquad_dxdy_at_t(const SkPoint a[3], SkScalar , double t) {
|
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
|
|
|
SkDQuad quad;
|
|
|
|
quad.set(a);
|
|
|
|
return quad.dxdyAtT(t);
|
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
static SkDVector dconic_dxdy_at_t(const SkPoint a[3], SkScalar weight, double t) {
|
|
|
|
SkDConic conic;
|
|
|
|
conic.set(a, weight);
|
|
|
|
return conic.dxdyAtT(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
static SkDVector dcubic_dxdy_at_t(const SkPoint a[4], SkScalar , double t) {
|
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
|
|
|
SkDCubic cubic;
|
|
|
|
cubic.set(a);
|
|
|
|
return cubic.dxdyAtT(t);
|
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
static SkDVector (* const CurveDSlopeAtT[])(const SkPoint[], SkScalar , double ) = {
|
2015-08-27 14:41:13 +00:00
|
|
|
nullptr,
|
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
|
|
|
dline_dxdy_at_t,
|
|
|
|
dquad_dxdy_at_t,
|
2015-04-20 15:31:59 +00:00
|
|
|
dconic_dxdy_at_t,
|
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
|
|
|
dcubic_dxdy_at_t
|
|
|
|
};
|
|
|
|
|
2016-07-18 17:01:36 +00:00
|
|
|
static SkDVector ddline_dxdy_at_t(const SkDCurve& c, double ) {
|
|
|
|
return c.fLine.fPts[1] - c.fLine.fPts[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
static SkDVector ddquad_dxdy_at_t(const SkDCurve& c, double t) {
|
|
|
|
return c.fQuad.dxdyAtT(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
static SkDVector ddconic_dxdy_at_t(const SkDCurve& c, double t) {
|
|
|
|
return c.fConic.dxdyAtT(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
static SkDVector ddcubic_dxdy_at_t(const SkDCurve& c, double t) {
|
|
|
|
return c.fCubic.dxdyAtT(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
static SkDVector (* const CurveDDSlopeAtT[])(const SkDCurve& , double ) = {
|
|
|
|
nullptr,
|
|
|
|
ddline_dxdy_at_t,
|
|
|
|
ddquad_dxdy_at_t,
|
|
|
|
ddconic_dxdy_at_t,
|
|
|
|
ddcubic_dxdy_at_t
|
|
|
|
};
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
static SkVector fline_dxdy_at_t(const SkPoint a[2], SkScalar , double ) {
|
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 a[1] - a[0];
|
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
static SkVector fquad_dxdy_at_t(const SkPoint a[3], SkScalar weight, double t) {
|
|
|
|
return dquad_dxdy_at_t(a, weight, t).asSkVector();
|
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
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
static SkVector fconic_dxdy_at_t(const SkPoint a[3], SkScalar weight, double t) {
|
|
|
|
return dconic_dxdy_at_t(a, weight, t).asSkVector();
|
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
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
static SkVector fcubic_dxdy_at_t(const SkPoint a[4], SkScalar weight, double t) {
|
|
|
|
return dcubic_dxdy_at_t(a, weight, t).asSkVector();
|
|
|
|
}
|
|
|
|
|
|
|
|
static SkVector (* const CurveSlopeAtT[])(const SkPoint[], SkScalar , double ) = {
|
2015-08-27 14:41:13 +00:00
|
|
|
nullptr,
|
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
|
|
|
fline_dxdy_at_t,
|
|
|
|
fquad_dxdy_at_t,
|
2015-04-20 15:31:59 +00:00
|
|
|
fconic_dxdy_at_t,
|
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
|
|
|
fcubic_dxdy_at_t
|
|
|
|
};
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
static bool line_is_vertical(const SkPoint a[2], SkScalar , double startT, double endT) {
|
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
|
|
|
SkDLine line;
|
|
|
|
line.set(a);
|
2013-07-23 15:27:41 +00:00
|
|
|
SkDPoint dst[2] = { line.ptAtT(startT), line.ptAtT(endT) };
|
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 AlmostEqualUlps(dst[0].fX, dst[1].fX);
|
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
static bool quad_is_vertical(const SkPoint a[3], SkScalar , double startT, double endT) {
|
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
|
|
|
SkDQuad quad;
|
|
|
|
quad.set(a);
|
|
|
|
SkDQuad dst = quad.subDivide(startT, endT);
|
|
|
|
return AlmostEqualUlps(dst[0].fX, dst[1].fX) && AlmostEqualUlps(dst[1].fX, dst[2].fX);
|
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
static bool conic_is_vertical(const SkPoint a[3], SkScalar weight, double startT, double endT) {
|
|
|
|
SkDConic conic;
|
|
|
|
conic.set(a, weight);
|
|
|
|
SkDConic dst = conic.subDivide(startT, endT);
|
|
|
|
return AlmostEqualUlps(dst[0].fX, dst[1].fX) && AlmostEqualUlps(dst[1].fX, dst[2].fX);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool cubic_is_vertical(const SkPoint a[4], SkScalar , double startT, double endT) {
|
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
|
|
|
SkDCubic cubic;
|
|
|
|
cubic.set(a);
|
|
|
|
SkDCubic dst = cubic.subDivide(startT, endT);
|
|
|
|
return AlmostEqualUlps(dst[0].fX, dst[1].fX) && AlmostEqualUlps(dst[1].fX, dst[2].fX)
|
|
|
|
&& AlmostEqualUlps(dst[2].fX, dst[3].fX);
|
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
static bool (* const CurveIsVertical[])(const SkPoint[], SkScalar , double , double) = {
|
2015-08-27 14:41:13 +00:00
|
|
|
nullptr,
|
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
|
|
|
line_is_vertical,
|
|
|
|
quad_is_vertical,
|
2015-04-20 15:31:59 +00:00
|
|
|
conic_is_vertical,
|
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
|
|
|
cubic_is_vertical
|
|
|
|
};
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
static void line_intersect_ray(const SkPoint a[2], SkScalar , const SkDLine& ray,
|
|
|
|
SkIntersections* i) {
|
2014-04-14 17:08:59 +00:00
|
|
|
SkDLine line;
|
|
|
|
line.set(a);
|
|
|
|
i->intersectRay(line, ray);
|
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
static void quad_intersect_ray(const SkPoint a[3], SkScalar , const SkDLine& ray,
|
|
|
|
SkIntersections* i) {
|
2014-04-14 17:08:59 +00:00
|
|
|
SkDQuad quad;
|
|
|
|
quad.set(a);
|
|
|
|
i->intersectRay(quad, ray);
|
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
static void conic_intersect_ray(const SkPoint a[3], SkScalar weight, const SkDLine& ray,
|
|
|
|
SkIntersections* i) {
|
|
|
|
SkDConic conic;
|
|
|
|
conic.set(a, weight);
|
|
|
|
i->intersectRay(conic, ray);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cubic_intersect_ray(const SkPoint a[4], SkScalar , const SkDLine& ray,
|
|
|
|
SkIntersections* i) {
|
2014-04-14 17:08:59 +00:00
|
|
|
SkDCubic cubic;
|
|
|
|
cubic.set(a);
|
|
|
|
i->intersectRay(cubic, ray);
|
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
static void (* const CurveIntersectRay[])(const SkPoint[] , SkScalar , const SkDLine& ,
|
|
|
|
SkIntersections* ) = {
|
2015-08-27 14:41:13 +00:00
|
|
|
nullptr,
|
2014-04-14 17:08:59 +00:00
|
|
|
line_intersect_ray,
|
|
|
|
quad_intersect_ray,
|
2015-04-20 15:31:59 +00:00
|
|
|
conic_intersect_ray,
|
2014-04-14 17:08:59 +00:00
|
|
|
cubic_intersect_ray
|
|
|
|
};
|
|
|
|
|
2016-07-18 17:01:36 +00:00
|
|
|
static void dline_intersect_ray(const SkDCurve& c, const SkDLine& ray, SkIntersections* i) {
|
|
|
|
i->intersectRay(c.fLine, ray);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dquad_intersect_ray(const SkDCurve& c, const SkDLine& ray, SkIntersections* i) {
|
|
|
|
i->intersectRay(c.fQuad, ray);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dconic_intersect_ray(const SkDCurve& c, const SkDLine& ray, SkIntersections* i) {
|
|
|
|
i->intersectRay(c.fConic, ray);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dcubic_intersect_ray(const SkDCurve& c, const SkDLine& ray, SkIntersections* i) {
|
|
|
|
i->intersectRay(c.fCubic, ray);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void (* const CurveDIntersectRay[])(const SkDCurve& , const SkDLine& , SkIntersections* ) = {
|
|
|
|
nullptr,
|
|
|
|
dline_intersect_ray,
|
|
|
|
dquad_intersect_ray,
|
|
|
|
dconic_intersect_ray,
|
|
|
|
dcubic_intersect_ray
|
|
|
|
};
|
|
|
|
|
2015-05-11 14:21:27 +00:00
|
|
|
static int line_intercept_h(const SkPoint a[2], SkScalar , SkScalar y, double* roots) {
|
2018-07-10 14:57:54 +00:00
|
|
|
if (a[0].fY == a[1].fY) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-05-11 14:21:27 +00:00
|
|
|
SkDLine line;
|
|
|
|
roots[0] = SkIntersections::HorizontalIntercept(line.set(a), y);
|
|
|
|
return between(0, roots[0], 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int line_intercept_v(const SkPoint a[2], SkScalar , SkScalar x, double* roots) {
|
2018-07-10 14:57:54 +00:00
|
|
|
if (a[0].fX == a[1].fX) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-05-11 14:21:27 +00:00
|
|
|
SkDLine line;
|
|
|
|
roots[0] = SkIntersections::VerticalIntercept(line.set(a), x);
|
|
|
|
return between(0, roots[0], 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int quad_intercept_h(const SkPoint a[2], SkScalar , SkScalar y, double* roots) {
|
|
|
|
SkDQuad quad;
|
|
|
|
return SkIntersections::HorizontalIntercept(quad.set(a), y, roots);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int quad_intercept_v(const SkPoint a[2], SkScalar , SkScalar x, double* roots) {
|
|
|
|
SkDQuad quad;
|
|
|
|
return SkIntersections::VerticalIntercept(quad.set(a), x, roots);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int conic_intercept_h(const SkPoint a[2], SkScalar w, SkScalar y, double* roots) {
|
|
|
|
SkDConic conic;
|
|
|
|
return SkIntersections::HorizontalIntercept(conic.set(a, w), y, roots);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int conic_intercept_v(const SkPoint a[2], SkScalar w, SkScalar x, double* roots) {
|
|
|
|
SkDConic conic;
|
|
|
|
return SkIntersections::VerticalIntercept(conic.set(a, w), x, roots);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cubic_intercept_h(const SkPoint a[3], SkScalar , SkScalar y, double* roots) {
|
|
|
|
SkDCubic cubic;
|
|
|
|
return cubic.set(a).horizontalIntersect(y, roots);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cubic_intercept_v(const SkPoint a[3], SkScalar , SkScalar x, double* roots) {
|
|
|
|
SkDCubic cubic;
|
|
|
|
return cubic.set(a).verticalIntersect(x, roots);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int (* const CurveIntercept[])(const SkPoint[] , SkScalar , SkScalar , double* ) = {
|
2015-08-27 14:41:13 +00:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2015-05-11 14:21:27 +00:00
|
|
|
line_intercept_h,
|
|
|
|
line_intercept_v,
|
|
|
|
quad_intercept_h,
|
|
|
|
quad_intercept_v,
|
|
|
|
conic_intercept_h,
|
|
|
|
conic_intercept_v,
|
|
|
|
cubic_intercept_h,
|
|
|
|
cubic_intercept_v,
|
|
|
|
};
|
|
|
|
|
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
|
|
|
#endif
|