Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: include/core/SkPath.h

Issue 2012233002: Make SkPath::isOval() and SkPath::isRRect return the orientation and starting index. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: record mod'ed start indices Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkMatrix.h ('k') | include/core/SkPathRef.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkPath.h
diff --git a/include/core/SkPath.h b/include/core/SkPath.h
index 8df7633d425f063a415884271685e0a1913feb59..4d99fdd0ebbc804f6314da829dfa23923e0765d0 100644
--- a/include/core/SkPath.h
+++ b/include/core/SkPath.h
@@ -26,6 +26,13 @@ class SkWStream;
*/
class SK_API SkPath {
public:
+ enum Direction {
+ /** clockwise direction for adding closed contours */
+ kCW_Direction,
+ /** counter-clockwise direction for adding closed contours */
+ kCCW_Direction,
+ };
+
SkPath();
SkPath(const SkPath&);
~SkPath();
@@ -166,24 +173,45 @@ public:
*
* @param rect returns the bounding rect of this oval. It's a circle
* if the height and width are the same.
- *
+ * @param dir is the oval CCW (or CW if false).
+ * @param start indicates where the contour starts on the oval (see
+ * SkPath::addOval for intepretation of the index).
* @return true if this path is an oval.
* Tracking whether a path is an oval is considered an
* optimization for performance and so some paths that are in
* fact ovals can report false.
*/
- bool isOval(SkRect* rect) const { return fPathRef->isOval(rect); }
+ bool isOval(SkRect* rect, Direction* dir = nullptr,
+ unsigned* start = nullptr) const {
+ bool isCCW;
+ bool result = fPathRef->isOval(rect, &isCCW, start);
+ if (dir && result) {
+ *dir = isCCW ? kCCW_Direction : kCW_Direction;
+ }
+ return result;
+ }
/** Returns true if the path is a round rect.
*
* @param rrect Returns the bounding rect and radii of this round rect.
+ * @param dir is the rrect CCW (or CW if false).
+ * @param start indicates where the contour starts on the rrect (see
+ * SkPath::addRRect for intepretation of the index).
*
* @return true if this path is a round rect.
* Tracking whether a path is a round rect is considered an
* optimization for performance and so some paths that are in
* fact round rects can report false.
*/
- bool isRRect(SkRRect* rrect) const { return fPathRef->isRRect(rrect); }
+ bool isRRect(SkRRect* rrect, Direction* dir = nullptr,
+ unsigned* start = nullptr) const {
+ bool isCCW;
+ bool result = fPathRef->isRRect(rrect, &isCCW, start);
+ if (dir && result) {
+ *dir = isCCW ? kCCW_Direction : kCW_Direction;
+ }
+ return result;
+ }
/** Clear any lines and curves from the path, making it empty. This frees up
internal storage associated with those segments.
@@ -526,13 +554,6 @@ public:
kLarge_ArcSize,
};
- enum Direction {
- /** clockwise direction for adding closed contours */
- kCW_Direction,
- /** counter-clockwise direction for adding closed contours */
- kCCW_Direction,
- };
-
/**
* Append an elliptical arc from the current point in the format used by SVG.
* The center of the ellipse is computed to satisfy the constraints below.
@@ -717,7 +738,8 @@ public:
void addOval(const SkRect& oval, Direction dir, unsigned start);
/**
- * Add a closed circle contour to the path
+ * Add a closed circle contour to the path. The circle contour begins at
+ * the right-most point (as though 1 were passed to addOval's 'start' param).
*
* @param x The x-coordinate of the center of a circle to add as a
* closed contour to the path
« no previous file with comments | « include/core/SkMatrix.h ('k') | include/core/SkPathRef.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698