caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 1 | /* |
| 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.org | 13b3aa1 | 2013-07-09 19:43:35 +0000 | [diff] [blame] | 10 | #include "SkPreConfig.h" |
| 11 | |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 12 | class SkPath; |
caryclark | a8d2ffb | 2014-06-24 07:55:11 -0700 | [diff] [blame^] | 13 | struct SkRect; |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 14 | |
caryclark@google.com | 7dfbb07 | 2013-04-22 14:37:05 +0000 | [diff] [blame] | 15 | // FIXME: move everything below into the SkPath class |
| 16 | /** |
| 17 | * The logical operations that can be performed when combining two paths. |
| 18 | */ |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 19 | enum SkPathOp { |
caryclark@google.com | 7dfbb07 | 2013-04-22 14:37:05 +0000 | [diff] [blame] | 20 | kDifference_PathOp, //!< subtract the op path from the first path |
| 21 | kIntersect_PathOp, //!< intersect the two paths |
| 22 | kUnion_PathOp, //!< union (inclusive-or) the two paths |
| 23 | kXOR_PathOp, //!< exclusive-or the two paths |
| 24 | kReverseDifference_PathOp, //!< subtract the first path from the op path |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 25 | }; |
| 26 | |
caryclark@google.com | 66560ca | 2013-04-26 19:51:16 +0000 | [diff] [blame] | 27 | /** Set this path to the result of applying the Op to this path and the |
| 28 | specified path: this = (this op operand). |
| 29 | The resulting path will be constructed from non-overlapping contours. |
skia.committer@gmail.com | 214c870 | 2013-04-27 07:02:53 +0000 | [diff] [blame] | 30 | The curve order is reduced where possible so that cubics may be turned |
caryclark@google.com | 66560ca | 2013-04-26 19:51:16 +0000 | [diff] [blame] | 31 | into quadratics, and quadratics maybe turned into lines. |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 32 | |
skia.committer@gmail.com | 214c870 | 2013-04-27 07:02:53 +0000 | [diff] [blame] | 33 | Returns true if operation was able to produce a result; |
caryclark@google.com | 66560ca | 2013-04-26 19:51:16 +0000 | [diff] [blame] | 34 | otherwise, result is unmodified. |
| 35 | |
| 36 | @param one The first operand (for difference, the minuend) |
| 37 | @param two The second operand (for difference, the subtrahend) |
| 38 | @param result The product of the operands. The result may be one of the |
| 39 | inputs. |
| 40 | @return True if operation succeeded. |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 41 | */ |
commit-bot@chromium.org | 13b3aa1 | 2013-07-09 19:43:35 +0000 | [diff] [blame] | 42 | bool SK_API Op(const SkPath& one, const SkPath& two, SkPathOp op, SkPath* result); |
caryclark@google.com | 66560ca | 2013-04-26 19:51:16 +0000 | [diff] [blame] | 43 | |
| 44 | /** Set this path to a set of non-overlapping contours that describe the |
skia.committer@gmail.com | 214c870 | 2013-04-27 07:02:53 +0000 | [diff] [blame] | 45 | same area as the original path. |
caryclark@google.com | 66560ca | 2013-04-26 19:51:16 +0000 | [diff] [blame] | 46 | The curve order is reduced where possible so that cubics may |
| 47 | be turned into quadratics, and quadratics maybe turned into lines. |
| 48 | |
skia.committer@gmail.com | 214c870 | 2013-04-27 07:02:53 +0000 | [diff] [blame] | 49 | Returns true if operation was able to produce a result; |
caryclark@google.com | 66560ca | 2013-04-26 19:51:16 +0000 | [diff] [blame] | 50 | otherwise, result is unmodified. |
| 51 | |
| 52 | @param path The path to simplify. |
| 53 | @param result The simplified path. The result may be the input. |
| 54 | @return True if simplification succeeded. |
| 55 | */ |
commit-bot@chromium.org | 13b3aa1 | 2013-07-09 19:43:35 +0000 | [diff] [blame] | 56 | bool SK_API Simplify(const SkPath& path, SkPath* result); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 57 | |
caryclark | a8d2ffb | 2014-06-24 07:55:11 -0700 | [diff] [blame^] | 58 | /** Set the resulting rectangle to the tight bounds of the path. |
| 59 | |
| 60 | @param path The path measured. |
| 61 | @param result The tight bounds of the path. |
| 62 | @return True if the bounds could be computed. |
| 63 | */ |
| 64 | bool SK_API TightBounds(const SkPath& path, SkRect* result); |
| 65 | |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 66 | #endif |