diff options
author | caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-04-08 11:47:37 +0000 |
---|---|---|
committer | caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-04-08 11:47:37 +0000 |
commit | 07393cab57ce74a4aae89a31fae9aaa9780fc19d (patch) | |
tree | 2923009427914f3da107d4797e7e7fd2b9266f9a /include/pathops | |
parent | 390c6d7a9018e233a6519397ac6c739fb21a99ef (diff) |
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
Diffstat (limited to 'include/pathops')
-rw-r--r-- | include/pathops/SkPathOps.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/include/pathops/SkPathOps.h b/include/pathops/SkPathOps.h new file mode 100644 index 0000000000..0ad6ef2e1c --- /dev/null +++ b/include/pathops/SkPathOps.h @@ -0,0 +1,39 @@ +/* + * 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 SkPathOps_DEFINED +#define SkPathOps_DEFINED + +class SkPath; + +// FIXME: move this into SkPaths.h or just use the equivalent in SkRegion.h +enum SkPathOp { + kDifference_PathOp, //!< subtract the op path from the first path + kIntersect_PathOp, //!< intersect the two paths + kUnion_PathOp, //!< union (inclusive-or) the two paths + kXOR_PathOp, //!< exclusive-or the two paths + /** subtract the first path from the op path */ + kReverseDifference_PathOp, // FIXME: unsupported + kReplace_PathOp //!< replace the dst path with the op FIXME: unsupported: should it be? +}; + +// FIXME: these functions become members of SkPath +/** + * Set this path to the result of applying the Op to this path and the + * specified path: this = (this op operand). The resulting path will be constructed + * from non-overlapping contours. The curve order is reduced where possible so that cubics may + * be turned into quadratics, and quadratics maybe turned into lines. + */ +void Op(const SkPath& one, const SkPath& two, SkPathOp op, SkPath* result); + +/** + * Set this path to a set of non-overlapping contours that describe the same + * area as the original path. The curve order is reduced where possible so that cubics may + * be turned into quadratics, and quadratics maybe turned into lines. + */ +void Simplify(const SkPath& path, SkPath* result); + +#endif |