OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkStrokerPriv.h" | 8 #include "SkStrokerPriv.h" |
9 #include "SkGeometry.h" | 9 #include "SkGeometry.h" |
10 #include "SkPath.h" | 10 #include "SkPathPriv.h" |
11 | 11 |
12 enum { | 12 enum { |
13 kTangent_RecursiveLimit, | 13 kTangent_RecursiveLimit, |
14 kCubic_RecursiveLimit, | 14 kCubic_RecursiveLimit, |
15 kConic_RecursiveLimit, | 15 kConic_RecursiveLimit, |
16 kQuad_RecursiveLimit | 16 kQuad_RecursiveLimit |
17 }; | 17 }; |
18 | 18 |
19 // quads with extreme widths (e.g. (0,1) (1,6) (0,3) width=5e7) recurse to point
of failure | 19 // quads with extreme widths (e.g. (0,1) (1,6) (0,3) width=5e7) recurse to point
of failure |
20 // largest seen for normal cubics : 5, 26 | 20 // largest seen for normal cubics : 5, 26 |
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1337 stroker.close(lastSegment == SkPath::kLine_Verb); | 1337 stroker.close(lastSegment == SkPath::kLine_Verb); |
1338 break; | 1338 break; |
1339 case SkPath::kDone_Verb: | 1339 case SkPath::kDone_Verb: |
1340 goto DONE; | 1340 goto DONE; |
1341 } | 1341 } |
1342 } | 1342 } |
1343 DONE: | 1343 DONE: |
1344 stroker.done(dst, lastSegment == SkPath::kLine_Verb); | 1344 stroker.done(dst, lastSegment == SkPath::kLine_Verb); |
1345 | 1345 |
1346 if (fDoFill) { | 1346 if (fDoFill) { |
1347 if (src.cheapIsDirection(SkPath::kCCW_Direction)) { | 1347 if (SkPathPriv::CheapIsFirstDirection(src, SkPathPriv::kCCW_FirstDirecti
on)) { |
1348 dst->reverseAddPath(src); | 1348 dst->reverseAddPath(src); |
1349 } else { | 1349 } else { |
1350 dst->addPath(src); | 1350 dst->addPath(src); |
1351 } | 1351 } |
1352 } else { | 1352 } else { |
1353 // Seems like we can assume that a 2-point src would always result in | 1353 // Seems like we can assume that a 2-point src would always result in |
1354 // a convex stroke, but testing has proved otherwise. | 1354 // a convex stroke, but testing has proved otherwise. |
1355 // TODO: fix the stroker to make this assumption true (without making | 1355 // TODO: fix the stroker to make this assumption true (without making |
1356 // it slower that the work that will be done in computeConvexity()) | 1356 // it slower that the work that will be done in computeConvexity()) |
1357 #if 0 | 1357 #if 0 |
(...skipping 14 matching lines...) Expand all Loading... |
1372 } | 1372 } |
1373 | 1373 |
1374 // our answer should preserve the inverseness of the src | 1374 // our answer should preserve the inverseness of the src |
1375 if (src.isInverseFillType()) { | 1375 if (src.isInverseFillType()) { |
1376 SkASSERT(!dst->isInverseFillType()); | 1376 SkASSERT(!dst->isInverseFillType()); |
1377 dst->toggleInverseFillType(); | 1377 dst->toggleInverseFillType(); |
1378 } | 1378 } |
1379 } | 1379 } |
1380 | 1380 |
1381 static SkPath::Direction reverse_direction(SkPath::Direction dir) { | 1381 static SkPath::Direction reverse_direction(SkPath::Direction dir) { |
1382 SkASSERT(SkPath::kUnknown_Direction != dir); | 1382 static const SkPath::Direction gOpposite[] = { SkPath::kCCW_Direction, SkPat
h::kCW_Direction }; |
1383 return SkPath::kCW_Direction == dir ? SkPath::kCCW_Direction : SkPath::kCW_D
irection; | 1383 return gOpposite[dir]; |
1384 } | 1384 } |
1385 | 1385 |
1386 static void addBevel(SkPath* path, const SkRect& r, const SkRect& outer, SkPath:
:Direction dir) { | 1386 static void addBevel(SkPath* path, const SkRect& r, const SkRect& outer, SkPath:
:Direction dir) { |
1387 SkPoint pts[8]; | 1387 SkPoint pts[8]; |
1388 | 1388 |
1389 if (SkPath::kCW_Direction == dir) { | 1389 if (SkPath::kCW_Direction == dir) { |
1390 pts[0].set(r.fLeft, outer.fTop); | 1390 pts[0].set(r.fLeft, outer.fTop); |
1391 pts[1].set(r.fRight, outer.fTop); | 1391 pts[1].set(r.fRight, outer.fTop); |
1392 pts[2].set(outer.fRight, r.fTop); | 1392 pts[2].set(outer.fRight, r.fTop); |
1393 pts[3].set(outer.fRight, r.fBottom); | 1393 pts[3].set(outer.fRight, r.fBottom); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 default: | 1450 default: |
1451 break; | 1451 break; |
1452 } | 1452 } |
1453 | 1453 |
1454 if (fWidth < SkMinScalar(rw, rh) && !fDoFill) { | 1454 if (fWidth < SkMinScalar(rw, rh) && !fDoFill) { |
1455 r = rect; | 1455 r = rect; |
1456 r.inset(radius, radius); | 1456 r.inset(radius, radius); |
1457 dst->addRect(r, reverse_direction(dir)); | 1457 dst->addRect(r, reverse_direction(dir)); |
1458 } | 1458 } |
1459 } | 1459 } |
OLD | NEW |