blob: a98f4ea4d6d55f5d3b891c426d165bf8a79c6f05 [file] [log] [blame]
caryclark@google.com07393ca2013-04-08 11:47:37 +00001/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7#ifndef SkPathOps_DEFINED
8#define SkPathOps_DEFINED
9
commit-bot@chromium.org13b3aa12013-07-09 19:43:35 +000010#include "SkPreConfig.h"
11
caryclark@google.com07393ca2013-04-08 11:47:37 +000012class SkPath;
13
caryclark@google.com7dfbb072013-04-22 14:37:05 +000014// FIXME: move everything below into the SkPath class
15/**
16 * The logical operations that can be performed when combining two paths.
17 */
caryclark@google.com07393ca2013-04-08 11:47:37 +000018enum SkPathOp {
caryclark@google.com7dfbb072013-04-22 14:37:05 +000019 kDifference_PathOp, //!< subtract the op path from the first path
20 kIntersect_PathOp, //!< intersect the two paths
21 kUnion_PathOp, //!< union (inclusive-or) the two paths
22 kXOR_PathOp, //!< exclusive-or the two paths
23 kReverseDifference_PathOp, //!< subtract the first path from the op path
caryclark@google.com07393ca2013-04-08 11:47:37 +000024};
25
caryclark@google.com66560ca2013-04-26 19:51:16 +000026/** Set this path to the result of applying the Op to this path and the
27 specified path: this = (this op operand).
28 The resulting path will be constructed from non-overlapping contours.
skia.committer@gmail.com214c8702013-04-27 07:02:53 +000029 The curve order is reduced where possible so that cubics may be turned
caryclark@google.com66560ca2013-04-26 19:51:16 +000030 into quadratics, and quadratics maybe turned into lines.
caryclark@google.com07393ca2013-04-08 11:47:37 +000031
skia.committer@gmail.com214c8702013-04-27 07:02:53 +000032 Returns true if operation was able to produce a result;
caryclark@google.com66560ca2013-04-26 19:51:16 +000033 otherwise, result is unmodified.
34
35 @param one The first operand (for difference, the minuend)
36 @param two The second operand (for difference, the subtrahend)
37 @param result The product of the operands. The result may be one of the
38 inputs.
39 @return True if operation succeeded.
caryclark@google.com07393ca2013-04-08 11:47:37 +000040 */
commit-bot@chromium.org13b3aa12013-07-09 19:43:35 +000041bool SK_API Op(const SkPath& one, const SkPath& two, SkPathOp op, SkPath* result);
caryclark@google.com66560ca2013-04-26 19:51:16 +000042
43/** Set this path to a set of non-overlapping contours that describe the
skia.committer@gmail.com214c8702013-04-27 07:02:53 +000044 same area as the original path.
caryclark@google.com66560ca2013-04-26 19:51:16 +000045 The curve order is reduced where possible so that cubics may
46 be turned into quadratics, and quadratics maybe turned into lines.
47
skia.committer@gmail.com214c8702013-04-27 07:02:53 +000048 Returns true if operation was able to produce a result;
caryclark@google.com66560ca2013-04-26 19:51:16 +000049 otherwise, result is unmodified.
50
51 @param path The path to simplify.
52 @param result The simplified path. The result may be the input.
53 @return True if simplification succeeded.
54 */
commit-bot@chromium.org13b3aa12013-07-09 19:43:35 +000055bool SK_API Simplify(const SkPath& path, SkPath* result);
caryclark@google.com07393ca2013-04-08 11:47:37 +000056
57#endif