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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « include/core/SkPath.h ('k') | include/core/SkPathIter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 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
8 #ifndef SkROPath_DEFINED
9 #define SkROPath_DEFINED
10
11 #include "SkMatrix.h"
12 #include "SkTDArray.h"
13 #include "SkRefCnt.h"
14
15 #if 0
16 class SkReader32;
17 class SkWriter32;
18 class SkString;
19 class SkRRect;
20 class SkWStream;
21
22 enum SkPathFillType {
23 /** Specifies that "inside" is computed by a non-zero sum of signed edge cro ssings */
24 kWinding_SkPathFillType,
25 /** Specifies that "inside" is computed by an odd number of edge crossings * /
26 kEvenOdd_SkPathFillType,
27 /** Same as Winding, but draws outside of the path, rather than inside */
28 kInverseWinding_SkPathFillType,
29 /** Same as EvenOdd, but draws outside of the path, rather than inside */
30 kInverseEvenOdd_SkPathFillType
31 };
32
33 static inline bool SkPathFillTypeIsInverse(SkPathFillType ft) {
34 return SkToBool(ft & 2);
35 }
36
37 enum SkPathConvexityType {
38 kUnknown_SkPathConvexityType,
39 kConvex_SkPathConvexityType,
40 kConcave_SkPathConvexityType
41 };
42
43 enum SkPathDirection {
44 /** Direction either has not been or could not be computed */
45 kUnknown_SkPathDirection,
46 /** clockwise direction for adding closed contours */
47 kCW_SkPathDirection,
48 /** counter-clockwise direction for adding closed contours */
49 kCCW_SkPathDirection,
50 };
51
52 enum SkPathSegmentMask {
53 kLine_SkPathSegmentMask = 1 << 0,
54 kQuad_SkPathSegmentMask = 1 << 1,
55 kConic_SkPathSegmentMask = 1 << 2,
56 kCubic_SkPathSegmentMask = 1 << 3,
57 };
58
59 enum SkPathVerb {
60 kMove_SkPathVerb, //!< iter.next returns 1 point
61 kLine_SkPathVerb, //!< iter.next returns 2 points
62 kQuad_SkPathVerb, //!< iter.next returns 3 points
63 kConic_SkPathVerb, //!< iter.next returns 3 points + iter.conicWeight()
64 kCubic_SkPathVerb, //!< iter.next returns 4 points
65 kClose_SkPathVerb, //!< iter.next returns 1 point (contour's moveTo pt)
66 kDone_SkPathVerb, //!< iter.next returns 0 points
67 };
68
69 class SkPathBuilder {
70 public:
71 SkROPath* finish();
72
73 void incReserve(int extraPtCount);
74
75 void moveTo(SkPoint pt);
76 void lineTo(SkPoint pt);
77 void quadTo(SkPoint pt1, SkPoint pt2);
78 void conicTo(SkPoint pt1, SkPoint pt2, SkScalar w);
79 void cubicTo(SkPoint pt1, SkPoint pt2, SkPoint pt3);
80 void close();
81
82 void moveTo(SkScalar x, SkScalar y) { this->moveTo(SkPoint::Make(x, y)); }
83 void lineTo(SkScalar x, SkScalar y) { this->lineTo(SkPoint::Make(x, y)); }
84 void quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2) {
85 this->quadTo(SkPoint::Make(x1, y1), SkPoint::Make(x2, y2));
86 }
87 void quadTo(const SkPoint pts[2]) { this->quadTo(pts[0], pts[1]); }
88 void conicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w) {
89 this->conicTo(SkPoint::Make(x1, y1), SkPoint::Make(x2, y2), w);
90 }
91 void conicTo(const SkPoint pts[2], SkScalar w) {
92 this->conicTo(pts[0], pts[1], w);
93 }
94 void cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3 , SkScalar y3) {
95 this->cubicTo(SkPoint::Make(x1, y1), SkPoint::Make(x2, y2), SkPoint::Mak e(x3, y3));
96 }
97 void cubicTo(const SkPoint pts[3]) {
98 this->cubicTo(pts[0], pts[1], pts[2]);
99 }
100
101 void addRect(const SkRect&, SkPathDirection dir = kCW_PathDirection);
102 void addOval(const SkRect&, SkPathDirection dir = kCW_PathDirection);
103 void addRRect(const SkRRect&, SkPathDirection dir = kCW_PathDirection);
104
105 private:
106 SkTDArray<SkPoint> fPts;
107 SkTDArray<char> fVerbs;
108 SkROPath* fCachedPath;
109 };
110
111 #endif
112 #endif
OLDNEW
« 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