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

Unified Diff: include/core/SkPathBuilder.h

Issue 1126993003: experimental path-builder Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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/SkPath.h ('k') | include/core/SkPathIter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkPathBuilder.h
diff --git a/include/core/SkPathBuilder.h b/include/core/SkPathBuilder.h
new file mode 100644
index 0000000000000000000000000000000000000000..a8cce3f63067407ae048d542f4143cc4487d068e
--- /dev/null
+++ b/include/core/SkPathBuilder.h
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkROPath_DEFINED
+#define SkROPath_DEFINED
+
+#include "SkMatrix.h"
+#include "SkTDArray.h"
+#include "SkRefCnt.h"
+
+#if 0
+class SkReader32;
+class SkWriter32;
+class SkString;
+class SkRRect;
+class SkWStream;
+
+enum SkPathFillType {
+ /** Specifies that "inside" is computed by a non-zero sum of signed edge crossings */
+ kWinding_SkPathFillType,
+ /** Specifies that "inside" is computed by an odd number of edge crossings */
+ kEvenOdd_SkPathFillType,
+ /** Same as Winding, but draws outside of the path, rather than inside */
+ kInverseWinding_SkPathFillType,
+ /** Same as EvenOdd, but draws outside of the path, rather than inside */
+ kInverseEvenOdd_SkPathFillType
+};
+
+static inline bool SkPathFillTypeIsInverse(SkPathFillType ft) {
+ return SkToBool(ft & 2);
+}
+
+enum SkPathConvexityType {
+ kUnknown_SkPathConvexityType,
+ kConvex_SkPathConvexityType,
+ kConcave_SkPathConvexityType
+};
+
+enum SkPathDirection {
+ /** Direction either has not been or could not be computed */
+ kUnknown_SkPathDirection,
+ /** clockwise direction for adding closed contours */
+ kCW_SkPathDirection,
+ /** counter-clockwise direction for adding closed contours */
+ kCCW_SkPathDirection,
+};
+
+enum SkPathSegmentMask {
+ kLine_SkPathSegmentMask = 1 << 0,
+ kQuad_SkPathSegmentMask = 1 << 1,
+ kConic_SkPathSegmentMask = 1 << 2,
+ kCubic_SkPathSegmentMask = 1 << 3,
+};
+
+enum SkPathVerb {
+ kMove_SkPathVerb, //!< iter.next returns 1 point
+ kLine_SkPathVerb, //!< iter.next returns 2 points
+ kQuad_SkPathVerb, //!< iter.next returns 3 points
+ kConic_SkPathVerb, //!< iter.next returns 3 points + iter.conicWeight()
+ kCubic_SkPathVerb, //!< iter.next returns 4 points
+ kClose_SkPathVerb, //!< iter.next returns 1 point (contour's moveTo pt)
+ kDone_SkPathVerb, //!< iter.next returns 0 points
+};
+
+class SkPathBuilder {
+public:
+ SkROPath* finish();
+
+ void incReserve(int extraPtCount);
+
+ void moveTo(SkPoint pt);
+ void lineTo(SkPoint pt);
+ void quadTo(SkPoint pt1, SkPoint pt2);
+ void conicTo(SkPoint pt1, SkPoint pt2, SkScalar w);
+ void cubicTo(SkPoint pt1, SkPoint pt2, SkPoint pt3);
+ void close();
+
+ void moveTo(SkScalar x, SkScalar y) { this->moveTo(SkPoint::Make(x, y)); }
+ void lineTo(SkScalar x, SkScalar y) { this->lineTo(SkPoint::Make(x, y)); }
+ void quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2) {
+ this->quadTo(SkPoint::Make(x1, y1), SkPoint::Make(x2, y2));
+ }
+ void quadTo(const SkPoint pts[2]) { this->quadTo(pts[0], pts[1]); }
+ void conicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w) {
+ this->conicTo(SkPoint::Make(x1, y1), SkPoint::Make(x2, y2), w);
+ }
+ void conicTo(const SkPoint pts[2], SkScalar w) {
+ this->conicTo(pts[0], pts[1], w);
+ }
+ void cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3) {
+ this->cubicTo(SkPoint::Make(x1, y1), SkPoint::Make(x2, y2), SkPoint::Make(x3, y3));
+ }
+ void cubicTo(const SkPoint pts[3]) {
+ this->cubicTo(pts[0], pts[1], pts[2]);
+ }
+
+ void addRect(const SkRect&, SkPathDirection dir = kCW_PathDirection);
+ void addOval(const SkRect&, SkPathDirection dir = kCW_PathDirection);
+ void addRRect(const SkRRect&, SkPathDirection dir = kCW_PathDirection);
+
+private:
+ SkTDArray<SkPoint> fPts;
+ SkTDArray<char> fVerbs;
+ SkROPath* fCachedPath;
+};
+
+#endif
+#endif
« no previous file with comments | « include/core/SkPath.h ('k') | include/core/SkPathIter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698