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 SkPathOpBounds_DEFINED
|
|
|
|
#define SkPathOpBounds_DEFINED
|
|
|
|
|
|
|
|
#include "SkPathOpsRect.h"
|
|
|
|
#include "SkRect.h"
|
|
|
|
|
|
|
|
// SkPathOpsBounds, unlike SkRect, does not consider a line to be empty.
|
|
|
|
struct SkPathOpsBounds : public SkRect {
|
|
|
|
static bool Intersects(const SkPathOpsBounds& a, const SkPathOpsBounds& b) {
|
2013-09-16 15:55:01 +00:00
|
|
|
return AlmostLessOrEqualUlps(a.fLeft, b.fRight)
|
|
|
|
&& AlmostLessOrEqualUlps(b.fLeft, a.fRight)
|
|
|
|
&& AlmostLessOrEqualUlps(a.fTop, b.fBottom)
|
|
|
|
&& AlmostLessOrEqualUlps(b.fTop, a.fBottom);
|
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-23 11:56:44 +00:00
|
|
|
// Note that add(), unlike SkRect::join() or SkRect::growToInclude()
|
|
|
|
// does not treat the bounds of horizontal and vertical lines as
|
|
|
|
// empty rectangles.
|
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
|
|
|
void add(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) {
|
|
|
|
if (left < fLeft) fLeft = left;
|
|
|
|
if (top < fTop) fTop = top;
|
|
|
|
if (right > fRight) fRight = right;
|
|
|
|
if (bottom > fBottom) fBottom = bottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
void add(const SkPathOpsBounds& toAdd) {
|
|
|
|
add(toAdd.fLeft, toAdd.fTop, toAdd.fRight, toAdd.fBottom);
|
|
|
|
}
|
|
|
|
|
2016-07-18 17:01:36 +00:00
|
|
|
void add(const SkPoint& pt) {
|
|
|
|
if (pt.fX < fLeft) fLeft = pt.fX;
|
|
|
|
if (pt.fY < fTop) fTop = pt.fY;
|
|
|
|
if (pt.fX > fRight) fRight = pt.fX;
|
|
|
|
if (pt.fY > fBottom) fBottom = pt.fY;
|
|
|
|
}
|
|
|
|
|
2015-04-29 15:28:30 +00:00
|
|
|
void add(const SkDPoint& pt) {
|
|
|
|
if (pt.fX < fLeft) fLeft = SkDoubleToScalar(pt.fX);
|
|
|
|
if (pt.fY < fTop) fTop = SkDoubleToScalar(pt.fY);
|
|
|
|
if (pt.fX > fRight) fRight = SkDoubleToScalar(pt.fX);
|
|
|
|
if (pt.fY > fBottom) fBottom = SkDoubleToScalar(pt.fY);
|
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
|
|
|
}
|
|
|
|
|
2016-07-18 17:01:36 +00:00
|
|
|
bool almostContains(const SkPoint& pt) const {
|
2013-09-16 15:55:01 +00:00
|
|
|
return AlmostLessOrEqualUlps(fLeft, pt.fX)
|
|
|
|
&& AlmostLessOrEqualUlps(pt.fX, fRight)
|
|
|
|
&& AlmostLessOrEqualUlps(fTop, pt.fY)
|
|
|
|
&& AlmostLessOrEqualUlps(pt.fY, fBottom);
|
|
|
|
}
|
|
|
|
|
2016-07-18 17:01:36 +00:00
|
|
|
bool contains(const SkPoint& pt) const {
|
|
|
|
return fLeft <= pt.fX && fTop <= pt.fY &&
|
|
|
|
fRight >= pt.fX && fBottom >= pt.fY;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
typedef SkRect INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|