OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrAAConvexPathRenderer.h" | 9 #include "GrAAConvexPathRenderer.h" |
10 | 10 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 // draw nothing. | 236 // draw nothing. |
237 DegenerateTestData degenerateData; | 237 DegenerateTestData degenerateData; |
238 SkPath::Direction dir; | 238 SkPath::Direction dir; |
239 // get_direction can fail for some degenerate paths. | 239 // get_direction can fail for some degenerate paths. |
240 if (!get_direction(path, m, &dir)) { | 240 if (!get_direction(path, m, &dir)) { |
241 return false; | 241 return false; |
242 } | 242 } |
243 | 243 |
244 for (;;) { | 244 for (;;) { |
245 GrPoint pts[4]; | 245 GrPoint pts[4]; |
246 GrPathCmd cmd = (GrPathCmd)iter.next(pts); | 246 SkPath::Verb verb = iter.next(pts); |
247 switch (cmd) { | 247 switch (verb) { |
248 case kMove_PathCmd: | 248 case SkPath::kMove_Verb: |
249 m.mapPoints(pts, 1); | 249 m.mapPoints(pts, 1); |
250 update_degenerate_test(°enerateData, pts[0]); | 250 update_degenerate_test(°enerateData, pts[0]); |
251 break; | 251 break; |
252 case kLine_PathCmd: { | 252 case SkPath::kLine_Verb: { |
253 m.mapPoints(pts + 1, 1); | 253 m.mapPoints(pts + 1, 1); |
254 update_degenerate_test(°enerateData, pts[1]); | 254 update_degenerate_test(°enerateData, pts[1]); |
255 segments->push_back(); | 255 segments->push_back(); |
256 segments->back().fType = Segment::kLine; | 256 segments->back().fType = Segment::kLine; |
257 segments->back().fPts[0] = pts[1]; | 257 segments->back().fPts[0] = pts[1]; |
258 break; | 258 break; |
259 } | 259 } |
260 case kQuadratic_PathCmd: | 260 case SkPath::kQuad_Verb: |
261 m.mapPoints(pts + 1, 2); | 261 m.mapPoints(pts + 1, 2); |
262 update_degenerate_test(°enerateData, pts[1]); | 262 update_degenerate_test(°enerateData, pts[1]); |
263 update_degenerate_test(°enerateData, pts[2]); | 263 update_degenerate_test(°enerateData, pts[2]); |
264 segments->push_back(); | 264 segments->push_back(); |
265 segments->back().fType = Segment::kQuad; | 265 segments->back().fType = Segment::kQuad; |
266 segments->back().fPts[0] = pts[1]; | 266 segments->back().fPts[0] = pts[1]; |
267 segments->back().fPts[1] = pts[2]; | 267 segments->back().fPts[1] = pts[2]; |
268 break; | 268 break; |
269 case kCubic_PathCmd: { | 269 case SkPath::kCubic_Verb: { |
270 m.mapPoints(pts, 4); | 270 m.mapPoints(pts, 4); |
271 update_degenerate_test(°enerateData, pts[1]); | 271 update_degenerate_test(°enerateData, pts[1]); |
272 update_degenerate_test(°enerateData, pts[2]); | 272 update_degenerate_test(°enerateData, pts[2]); |
273 update_degenerate_test(°enerateData, pts[3]); | 273 update_degenerate_test(°enerateData, pts[3]); |
274 // unlike quads and lines, the pts[0] will also be read (in | 274 // unlike quads and lines, the pts[0] will also be read (in |
275 // convertCubicToQuads). | 275 // convertCubicToQuads). |
276 SkSTArray<15, SkPoint, true> quads; | 276 SkSTArray<15, SkPoint, true> quads; |
277 GrPathUtils::convertCubicToQuads(pts, SK_Scalar1, true, dir, &qu
ads); | 277 GrPathUtils::convertCubicToQuads(pts, SK_Scalar1, true, dir, &qu
ads); |
278 int count = quads.count(); | 278 int count = quads.count(); |
279 for (int q = 0; q < count; q += 3) { | 279 for (int q = 0; q < count; q += 3) { |
280 segments->push_back(); | 280 segments->push_back(); |
281 segments->back().fType = Segment::kQuad; | 281 segments->back().fType = Segment::kQuad; |
282 segments->back().fPts[0] = quads[q + 1]; | 282 segments->back().fPts[0] = quads[q + 1]; |
283 segments->back().fPts[1] = quads[q + 2]; | 283 segments->back().fPts[1] = quads[q + 2]; |
284 } | 284 } |
285 break; | 285 break; |
286 }; | 286 }; |
287 case kEnd_PathCmd: | 287 case SkPath::kDone_Verb: |
288 if (degenerateData.isDegenerate()) { | 288 if (degenerateData.isDegenerate()) { |
289 return false; | 289 return false; |
290 } else { | 290 } else { |
291 compute_vectors(segments, fanPt, dir, vCount, iCount); | 291 compute_vectors(segments, fanPt, dir, vCount, iCount); |
292 return true; | 292 return true; |
293 } | 293 } |
294 default: | 294 default: |
295 break; | 295 break; |
296 } | 296 } |
297 } | 297 } |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 create_vertices(segments, fanPt, verts, idxs); | 632 create_vertices(segments, fanPt, verts, idxs); |
633 | 633 |
634 target->drawIndexed(kTriangles_GrPrimitiveType, | 634 target->drawIndexed(kTriangles_GrPrimitiveType, |
635 0, // start vertex | 635 0, // start vertex |
636 0, // start index | 636 0, // start index |
637 vCount, | 637 vCount, |
638 iCount); | 638 iCount); |
639 | 639 |
640 return true; | 640 return true; |
641 } | 641 } |
OLD | NEW |