1
2 /*
3 * Copyright 2006 The Android Open Source Project
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9
10 #include "SkPathParts.h"
11 #include "SkAnimateMaker.h"
12 #include "SkDrawMatrix.h"
13 #include "SkDrawRectangle.h"
14 #include "SkDrawPath.h"
15
SkPathPart()16 SkPathPart::SkPathPart() : fPath(NULL) {
17 }
18
dirty()19 void SkPathPart::dirty() {
20 fPath->dirty();
21 }
22
getParent() const23 SkDisplayable* SkPathPart::getParent() const {
24 return fPath;
25 }
26
setParent(SkDisplayable * parent)27 bool SkPathPart::setParent(SkDisplayable* parent) {
28 SkASSERT(parent != NULL);
29 if (parent->isPath() == false)
30 return true;
31 fPath = (SkDrawPath*) parent;
32 return false;
33 }
34
35 // MoveTo
36 #if SK_USE_CONDENSED_INFO == 0
37
38 const SkMemberInfo SkMoveTo::fInfo[] = {
39 SK_MEMBER(x, Float),
40 SK_MEMBER(y, Float)
41 };
42
43 #endif
44
45 DEFINE_GET_MEMBER(SkMoveTo);
46
SkMoveTo()47 SkMoveTo::SkMoveTo() : x(0), y(0) {
48 }
49
add()50 bool SkMoveTo::add() {
51 fPath->fPath.moveTo(x, y);
52 return false;
53 }
54
55
56 // RMoveTo
57 #if SK_USE_CONDENSED_INFO == 0
58
59 const SkMemberInfo SkRMoveTo::fInfo[] = {
60 SK_MEMBER_INHERITED
61 };
62
63 #endif
64
65 DEFINE_GET_MEMBER(SkRMoveTo);
66
add()67 bool SkRMoveTo::add() {
68 fPath->fPath.rMoveTo(x, y);
69 return false;
70 }
71
72
73 // LineTo
74 #if SK_USE_CONDENSED_INFO == 0
75
76 const SkMemberInfo SkLineTo::fInfo[] = {
77 SK_MEMBER(x, Float),
78 SK_MEMBER(y, Float)
79 };
80
81 #endif
82
83 DEFINE_GET_MEMBER(SkLineTo);
84
SkLineTo()85 SkLineTo::SkLineTo() : x(0), y(0) {
86 }
87
add()88 bool SkLineTo::add() {
89 fPath->fPath.lineTo(x, y);
90 return false;
91 }
92
93
94 // RLineTo
95 #if SK_USE_CONDENSED_INFO == 0
96
97 const SkMemberInfo SkRLineTo::fInfo[] = {
98 SK_MEMBER_INHERITED
99 };
100
101 #endif
102
103 DEFINE_GET_MEMBER(SkRLineTo);
104
add()105 bool SkRLineTo::add() {
106 fPath->fPath.rLineTo(x, y);
107 return false;
108 }
109
110
111 // QuadTo
112 #if SK_USE_CONDENSED_INFO == 0
113
114 const SkMemberInfo SkQuadTo::fInfo[] = {
115 SK_MEMBER(x1, Float),
116 SK_MEMBER(x2, Float),
117 SK_MEMBER(y1, Float),
118 SK_MEMBER(y2, Float)
119 };
120
121 #endif
122
123 DEFINE_GET_MEMBER(SkQuadTo);
124
SkQuadTo()125 SkQuadTo::SkQuadTo() : x1(0), y1(0), x2(0), y2(0) {
126 }
127
add()128 bool SkQuadTo::add() {
129 fPath->fPath.quadTo(x1, y1, x2, y2);
130 return false;
131 }
132
133
134 // RQuadTo
135 #if SK_USE_CONDENSED_INFO == 0
136
137 const SkMemberInfo SkRQuadTo::fInfo[] = {
138 SK_MEMBER_INHERITED
139 };
140
141 #endif
142
143 DEFINE_GET_MEMBER(SkRQuadTo);
144
add()145 bool SkRQuadTo::add() {
146 fPath->fPath.rQuadTo(x1, y1, x2, y2);
147 return false;
148 }
149
150
151 // CubicTo
152 #if SK_USE_CONDENSED_INFO == 0
153
154 const SkMemberInfo SkCubicTo::fInfo[] = {
155 SK_MEMBER(x1, Float),
156 SK_MEMBER(x2, Float),
157 SK_MEMBER(x3, Float),
158 SK_MEMBER(y1, Float),
159 SK_MEMBER(y2, Float),
160 SK_MEMBER(y3, Float)
161 };
162
163 #endif
164
165 DEFINE_GET_MEMBER(SkCubicTo);
166
SkCubicTo()167 SkCubicTo::SkCubicTo() : x1(0), y1(0), x2(0), y2(0), x3(0), y3(0) {
168 }
169
add()170 bool SkCubicTo::add() {
171 fPath->fPath.cubicTo(x1, y1, x2, y2, x3, y3);
172 return false;
173 }
174
175
176 // RCubicTo
177 #if SK_USE_CONDENSED_INFO == 0
178
179 const SkMemberInfo SkRCubicTo::fInfo[] = {
180 SK_MEMBER_INHERITED
181 };
182
183 #endif
184
185 DEFINE_GET_MEMBER(SkRCubicTo);
186
add()187 bool SkRCubicTo::add() {
188 fPath->fPath.rCubicTo(x1, y1, x2, y2, x3, y3);
189 return false;
190 }
191
192
193 // SkClose
add()194 bool SkClose::add() {
195 fPath->fPath.close();
196 return false;
197 }
198
199
200 // SkAddGeom
201 #if SK_USE_CONDENSED_INFO == 0
202
203 const SkMemberInfo SkAddGeom::fInfo[] = {
204 SK_MEMBER(direction, PathDirection)
205 };
206
207 #endif
208
209 DEFINE_GET_MEMBER(SkAddGeom);
210
SkAddGeom()211 SkAddGeom::SkAddGeom() : direction(SkPath::kCCW_Direction) {
212 }
213
214 #if SK_USE_CONDENSED_INFO == 0
215
216 const SkMemberInfo SkAddRect::fInfo[] = {
217 SK_MEMBER_INHERITED,
218 SK_MEMBER_ALIAS(bottom, fRect.fBottom, Float),
219 SK_MEMBER_ALIAS(left, fRect.fLeft, Float),
220 SK_MEMBER_ALIAS(right, fRect.fRight, Float),
221 SK_MEMBER_ALIAS(top, fRect.fTop, Float)
222 };
223
224 #endif
225
226 DEFINE_GET_MEMBER(SkAddRect);
227
SkAddRect()228 SkAddRect::SkAddRect() {
229 fRect.setEmpty();
230 }
231
add()232 bool SkAddRect::add() {
233 fPath->fPath.addRect(fRect, (SkPath::Direction) direction);
234 return false;
235 }
236
237
238 #if SK_USE_CONDENSED_INFO == 0
239
240 const SkMemberInfo SkAddOval::fInfo[] = {
241 SK_MEMBER_INHERITED
242 };
243
244 #endif
245
246 DEFINE_GET_MEMBER(SkAddOval);
247
add()248 bool SkAddOval::add() {
249 fPath->fPath.addOval(fRect, (SkPath::Direction) direction);
250 return false;
251 }
252
253
254 #if SK_USE_CONDENSED_INFO == 0
255
256 const SkMemberInfo SkAddCircle::fInfo[] = {
257 SK_MEMBER_INHERITED,
258 SK_MEMBER(radius, Float),
259 SK_MEMBER(x, Float),
260 SK_MEMBER(y, Float)
261 };
262
263 #endif
264
265 DEFINE_GET_MEMBER(SkAddCircle);
266
SkAddCircle()267 SkAddCircle::SkAddCircle() : radius(0), x(0), y(0) {
268 }
269
add()270 bool SkAddCircle::add() {
271 fPath->fPath.addCircle(x, y, radius, (SkPath::Direction) direction);
272 return false;
273 }
274
275
276 #if SK_USE_CONDENSED_INFO == 0
277
278 const SkMemberInfo SkAddRoundRect::fInfo[] = {
279 SK_MEMBER_INHERITED,
280 SK_MEMBER(rx, Float),
281 SK_MEMBER(ry, Float)
282 };
283
284 #endif
285
286 DEFINE_GET_MEMBER(SkAddRoundRect);
287
SkAddRoundRect()288 SkAddRoundRect::SkAddRoundRect() : rx(0), ry(0) {
289 }
290
add()291 bool SkAddRoundRect::add() {
292 fPath->fPath.addRoundRect(fRect, rx, ry, (SkPath::Direction) direction);
293 return false;
294 }
295
296
297 #if SK_USE_CONDENSED_INFO == 0
298
299 const SkMemberInfo SkAddPath::fInfo[] = {
300 SK_MEMBER(matrix, Matrix),
301 SK_MEMBER(path, Path)
302 };
303
304 #endif
305
306 DEFINE_GET_MEMBER(SkAddPath);
307
SkAddPath()308 SkAddPath::SkAddPath() : matrix(NULL), path(NULL) {
309 }
310
add()311 bool SkAddPath::add() {
312 SkASSERT (path != NULL);
313 if (matrix)
314 fPath->fPath.addPath(path->fPath, matrix->getMatrix());
315 else
316 fPath->fPath.addPath(path->fPath);
317 return false;
318 }
319
320
321