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

Side by Side Diff: src/gpu/batches/GrAAConvexTessellator.cpp

Issue 2280943003: fixed 'corners' of paths in GrAAConvexTessellator (Closed)
Patch Set: oops Created 4 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 | « src/gpu/batches/GrAAConvexTessellator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
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 "GrAAConvexTessellator.h" 8 #include "GrAAConvexTessellator.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkPath.h" 10 #include "SkPath.h"
(...skipping 11 matching lines...) Expand all
22 static const SkScalar kCloseSqd = SkScalarMul(kClose, kClose); 22 static const SkScalar kCloseSqd = SkScalarMul(kClose, kClose);
23 23
24 // tesselation tolerance values, in device space pixels 24 // tesselation tolerance values, in device space pixels
25 static const SkScalar kQuadTolerance = 0.2f; 25 static const SkScalar kQuadTolerance = 0.2f;
26 static const SkScalar kCubicTolerance = 0.2f; 26 static const SkScalar kCubicTolerance = 0.2f;
27 static const SkScalar kConicTolerance = 0.5f; 27 static const SkScalar kConicTolerance = 0.5f;
28 28
29 // dot product below which we use a round cap between curve segments 29 // dot product below which we use a round cap between curve segments
30 static const SkScalar kRoundCapThreshold = 0.8f; 30 static const SkScalar kRoundCapThreshold = 0.8f;
31 31
32 // dot product above which we consider two adjacent curves to be part of the "sa me" curve
33 static const SkScalar kCurveConnectionThreshold = 0.95f;
34
32 static SkScalar intersect(const SkPoint& p0, const SkPoint& n0, 35 static SkScalar intersect(const SkPoint& p0, const SkPoint& n0,
33 const SkPoint& p1, const SkPoint& n1) { 36 const SkPoint& p1, const SkPoint& n1) {
34 const SkPoint v = p1 - p0; 37 const SkPoint v = p1 - p0;
35 SkScalar perpDot = n0.fX * n1.fY - n0.fY * n1.fX; 38 SkScalar perpDot = n0.fX * n1.fY - n0.fY * n1.fX;
36 return (v.fX * n1.fY - v.fY * n1.fX) / perpDot; 39 return (v.fX * n1.fY - v.fY * n1.fX) / perpDot;
37 } 40 }
38 41
39 // This is a special case version of intersect where we have the vector 42 // This is a special case version of intersect where we have the vector
40 // perpendicular to the second line rather than the vector parallel to it. 43 // perpendicular to the second line rather than the vector parallel to it.
41 static SkScalar perp_intersect(const SkPoint& p0, const SkPoint& n0, 44 static SkScalar perp_intersect(const SkPoint& p0, const SkPoint& n0,
(...skipping 11 matching lines...) Expand all
53 static SkScalar abs_dist_from_line(const SkPoint& p0, const SkVector& v, const S kPoint& test) { 56 static SkScalar abs_dist_from_line(const SkPoint& p0, const SkVector& v, const S kPoint& test) {
54 SkPoint testV = test - p0; 57 SkPoint testV = test - p0;
55 SkScalar dist = testV.fX * v.fY - testV.fY * v.fX; 58 SkScalar dist = testV.fX * v.fY - testV.fY * v.fX;
56 return SkScalarAbs(dist); 59 return SkScalarAbs(dist);
57 } 60 }
58 61
59 int GrAAConvexTessellator::addPt(const SkPoint& pt, 62 int GrAAConvexTessellator::addPt(const SkPoint& pt,
60 SkScalar depth, 63 SkScalar depth,
61 SkScalar coverage, 64 SkScalar coverage,
62 bool movable, 65 bool movable,
63 bool isCurve) { 66 CurveState curve) {
64 this->validate(); 67 this->validate();
65 68
66 int index = fPts.count(); 69 int index = fPts.count();
67 *fPts.push() = pt; 70 *fPts.push() = pt;
68 *fCoverages.push() = coverage; 71 *fCoverages.push() = coverage;
69 *fMovable.push() = movable; 72 *fMovable.push() = movable;
70 *fIsCurve.push() = isCurve; 73 *fCurveState.push() = curve;
71 74
72 this->validate(); 75 this->validate();
73 return index; 76 return index;
74 } 77 }
75 78
76 void GrAAConvexTessellator::popLastPt() { 79 void GrAAConvexTessellator::popLastPt() {
77 this->validate(); 80 this->validate();
78 81
79 fPts.pop(); 82 fPts.pop();
80 fCoverages.pop(); 83 fCoverages.pop();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 if (!fBisectors[cur].normalize()) { 142 if (!fBisectors[cur].normalize()) {
140 SkASSERT(SkPoint::kLeft_Side == fSide || SkPoint::kRight_Side == fSi de); 143 SkASSERT(SkPoint::kLeft_Side == fSide || SkPoint::kRight_Side == fSi de);
141 fBisectors[cur].setOrthog(fNorms[cur], (SkPoint::Side)-fSide); 144 fBisectors[cur].setOrthog(fNorms[cur], (SkPoint::Side)-fSide);
142 SkVector other; 145 SkVector other;
143 other.setOrthog(fNorms[prev], fSide); 146 other.setOrthog(fNorms[prev], fSide);
144 fBisectors[cur] += other; 147 fBisectors[cur] += other;
145 SkAssertResult(fBisectors[cur].normalize()); 148 SkAssertResult(fBisectors[cur].normalize());
146 } else { 149 } else {
147 fBisectors[cur].negate(); // make the bisector face in 150 fBisectors[cur].negate(); // make the bisector face in
148 } 151 }
152 if (fCurveState[prev] == kIndeterminate_CurveState) {
153 if (fCurveState[cur] == kSharp_CurveState) {
154 fCurveState[prev] = kSharp_CurveState;
155 } else {
156 if (SkScalarAbs(fNorms[cur].dot(fNorms[prev])) > kCurveConnectio nThreshold) {
157 fCurveState[prev] = kCurve_CurveState;
158 fCurveState[cur] = kCurve_CurveState;
159 } else {
160 fCurveState[prev] = kSharp_CurveState;
161 fCurveState[cur] = kSharp_CurveState;
162 }
163 }
164 }
149 165
150 SkASSERT(SkScalarNearlyEqual(1.0f, fBisectors[cur].length())); 166 SkASSERT(SkScalarNearlyEqual(1.0f, fBisectors[cur].length()));
151 } 167 }
152 } 168 }
153 169
154 // Create as many rings as we need to (up to a predefined limit) to reach the sp ecified target 170 // Create as many rings as we need to (up to a predefined limit) to reach the sp ecified target
155 // depth. If we are in fill mode, the final ring will automatically be fanned. 171 // depth. If we are in fill mode, the final ring will automatically be fanned.
156 bool GrAAConvexTessellator::createInsetRings(Ring& previousRing, SkScalar initia lDepth, 172 bool GrAAConvexTessellator::createInsetRings(Ring& previousRing, SkScalar initia lDepth,
157 SkScalar initialCoverage, SkScalar targetDepth, 173 SkScalar initialCoverage, SkScalar targetDepth,
158 SkScalar targetCoverage, Ring** fin alRing) { 174 SkScalar targetCoverage, Ring** fin alRing) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 313
298 // TODO: is there a faster way to extract the points from the path? Perhaps 314 // TODO: is there a faster way to extract the points from the path? Perhaps
299 // get all the points via a new entry point, transform them all in bulk 315 // get all the points via a new entry point, transform them all in bulk
300 // and then walk them to find duplicates? 316 // and then walk them to find duplicates?
301 SkPath::Iter iter(path, true); 317 SkPath::Iter iter(path, true);
302 SkPoint pts[4]; 318 SkPoint pts[4];
303 SkPath::Verb verb; 319 SkPath::Verb verb;
304 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { 320 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
305 switch (verb) { 321 switch (verb) {
306 case SkPath::kLine_Verb: 322 case SkPath::kLine_Verb:
307 this->lineTo(m, pts[1], false); 323 this->lineTo(m, pts[1], kSharp_CurveState);
308 break; 324 break;
309 case SkPath::kQuad_Verb: 325 case SkPath::kQuad_Verb:
310 this->quadTo(m, pts); 326 this->quadTo(m, pts);
311 break; 327 break;
312 case SkPath::kCubic_Verb: 328 case SkPath::kCubic_Verb:
313 this->cubicTo(m, pts); 329 this->cubicTo(m, pts);
314 break; 330 break;
315 case SkPath::kConic_Verb: 331 case SkPath::kConic_Verb:
316 this->conicTo(m, pts, iter.conicWeight()); 332 this->conicTo(m, pts, iter.conicWeight());
317 break; 333 break;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 SkPoint perp1 = normal1; 470 SkPoint perp1 = normal1;
455 perp1.scale(outset); 471 perp1.scale(outset);
456 perp1 += this->point(originalIdx); 472 perp1 += this->point(originalIdx);
457 473
458 // The perpendicular point for the next edge. 474 // The perpendicular point for the next edge.
459 SkPoint normal2 = previousRing.norm(cur); 475 SkPoint normal2 = previousRing.norm(cur);
460 SkPoint perp2 = normal2; 476 SkPoint perp2 = normal2;
461 perp2.scale(outset); 477 perp2.scale(outset);
462 perp2 += fPts[originalIdx]; 478 perp2 += fPts[originalIdx];
463 479
464 bool isCurve = fIsCurve[originalIdx]; 480 CurveState curve = fCurveState[originalIdx];
465 481
466 // We know it isn't a duplicate of the prior point (since it and this 482 // We know it isn't a duplicate of the prior point (since it and this
467 // one are just perpendicular offsets from the non-merged polygon points ) 483 // one are just perpendicular offsets from the non-merged polygon points )
468 int perp1Idx = this->addPt(perp1, -outset, coverage, false, isCurve); 484 int perp1Idx = this->addPt(perp1, -outset, coverage, false, curve);
469 nextRing->addIdx(perp1Idx, originalIdx); 485 nextRing->addIdx(perp1Idx, originalIdx);
470 486
471 int perp2Idx; 487 int perp2Idx;
472 // For very shallow angles all the corner points could fuse. 488 // For very shallow angles all the corner points could fuse.
473 if (duplicate_pt(perp2, this->point(perp1Idx))) { 489 if (duplicate_pt(perp2, this->point(perp1Idx))) {
474 perp2Idx = perp1Idx; 490 perp2Idx = perp1Idx;
475 } else { 491 } else {
476 perp2Idx = this->addPt(perp2, -outset, coverage, false, isCurve); 492 perp2Idx = this->addPt(perp2, -outset, coverage, false, curve);
477 } 493 }
478 494
479 if (perp2Idx != perp1Idx) { 495 if (perp2Idx != perp1Idx) {
480 if (isCurve) { 496 if (curve == kCurve_CurveState) {
481 // bevel or round depending upon curvature 497 // bevel or round depending upon curvature
482 SkScalar dotProd = normal1.dot(normal2); 498 SkScalar dotProd = normal1.dot(normal2);
483 if (dotProd < kRoundCapThreshold) { 499 if (dotProd < kRoundCapThreshold) {
484 // Currently we "round" by creating a single extra point, wh ich produces 500 // Currently we "round" by creating a single extra point, wh ich produces
485 // good results for common cases. For thick strokes with hig h curvature, we will 501 // good results for common cases. For thick strokes with hig h curvature, we will
486 // need to add more points; for the time being we simply fal l back to software 502 // need to add more points; for the time being we simply fal l back to software
487 // rendering for thick strokes. 503 // rendering for thick strokes.
488 SkPoint miter = previousRing.bisector(cur); 504 SkPoint miter = previousRing.bisector(cur);
489 miter.setLength(-outset); 505 miter.setLength(-outset);
490 miter += fPts[originalIdx]; 506 miter += fPts[originalIdx];
491 507
492 // For very shallow angles all the corner points could fuse 508 // For very shallow angles all the corner points could fuse
493 if (!duplicate_pt(miter, this->point(perp1Idx))) { 509 if (!duplicate_pt(miter, this->point(perp1Idx))) {
494 int miterIdx; 510 int miterIdx;
495 miterIdx = this->addPt(miter, -outset, coverage, false, false); 511 miterIdx = this->addPt(miter, -outset, coverage, false, kSharp_CurveState);
496 nextRing->addIdx(miterIdx, originalIdx); 512 nextRing->addIdx(miterIdx, originalIdx);
497 // The two triangles for the corner 513 // The two triangles for the corner
498 this->addTri(originalIdx, perp1Idx, miterIdx); 514 this->addTri(originalIdx, perp1Idx, miterIdx);
499 this->addTri(originalIdx, miterIdx, perp2Idx); 515 this->addTri(originalIdx, miterIdx, perp2Idx);
500 } 516 }
501 } else { 517 } else {
502 this->addTri(originalIdx, perp1Idx, perp2Idx); 518 this->addTri(originalIdx, perp1Idx, perp2Idx);
503 } 519 }
504 } else { 520 } else {
505 switch (fJoin) { 521 switch (fJoin) {
506 case SkPaint::Join::kMiter_Join: { 522 case SkPaint::Join::kMiter_Join: {
507 // The bisector outset point 523 // The bisector outset point
508 SkPoint miter = previousRing.bisector(cur); 524 SkPoint miter = previousRing.bisector(cur);
509 SkScalar dotProd = normal1.dot(normal2); 525 SkScalar dotProd = normal1.dot(normal2);
510 SkScalar sinHalfAngleSq = SkScalarHalf(SK_Scalar1 + dotP rod); 526 SkScalar sinHalfAngleSq = SkScalarHalf(SK_Scalar1 + dotP rod);
511 SkScalar lengthSq = outsetSq / sinHalfAngleSq; 527 SkScalar lengthSq = outsetSq / sinHalfAngleSq;
512 if (lengthSq > miterLimitSq) { 528 if (lengthSq > miterLimitSq) {
513 // just bevel it 529 // just bevel it
514 this->addTri(originalIdx, perp1Idx, perp2Idx); 530 this->addTri(originalIdx, perp1Idx, perp2Idx);
515 break; 531 break;
516 } 532 }
517 miter.setLength(-SkScalarSqrt(lengthSq)); 533 miter.setLength(-SkScalarSqrt(lengthSq));
518 miter += fPts[originalIdx]; 534 miter += fPts[originalIdx];
519 535
520 // For very shallow angles all the corner points could f use 536 // For very shallow angles all the corner points could f use
521 if (!duplicate_pt(miter, this->point(perp1Idx))) { 537 if (!duplicate_pt(miter, this->point(perp1Idx))) {
522 int miterIdx; 538 int miterIdx;
523 miterIdx = this->addPt(miter, -outset, coverage, fal se, false); 539 miterIdx = this->addPt(miter, -outset, coverage, fal se,
540 kSharp_CurveState);
524 nextRing->addIdx(miterIdx, originalIdx); 541 nextRing->addIdx(miterIdx, originalIdx);
525 // The two triangles for the corner 542 // The two triangles for the corner
526 this->addTri(originalIdx, perp1Idx, miterIdx); 543 this->addTri(originalIdx, perp1Idx, miterIdx);
527 this->addTri(originalIdx, miterIdx, perp2Idx); 544 this->addTri(originalIdx, miterIdx, perp2Idx);
528 } 545 }
529 break; 546 break;
530 } 547 }
531 case SkPaint::Join::kBevel_Join: 548 case SkPaint::Join::kBevel_Join:
532 this->addTri(originalIdx, perp1Idx, perp2Idx); 549 this->addTri(originalIdx, perp1Idx, perp2Idx);
533 break; 550 break;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 714
698 // Fold the new ring's points into the global pool 715 // Fold the new ring's points into the global pool
699 for (int i = 0; i < fCandidateVerts.numPts(); ++i) { 716 for (int i = 0; i < fCandidateVerts.numPts(); ++i) {
700 int newIdx; 717 int newIdx;
701 if (fCandidateVerts.needsToBeNew(i) || forceNew) { 718 if (fCandidateVerts.needsToBeNew(i) || forceNew) {
702 // if the originating index is still valid then this point wasn't 719 // if the originating index is still valid then this point wasn't
703 // fused (and is thus movable) 720 // fused (and is thus movable)
704 SkScalar coverage = compute_coverage(depth, initialDepth, initialCov erage, 721 SkScalar coverage = compute_coverage(depth, initialDepth, initialCov erage,
705 targetDepth, targetCoverage); 722 targetDepth, targetCoverage);
706 newIdx = this->addPt(fCandidateVerts.point(i), depth, coverage, 723 newIdx = this->addPt(fCandidateVerts.point(i), depth, coverage,
707 fCandidateVerts.originatingIdx(i) != -1, false) ; 724 fCandidateVerts.originatingIdx(i) != -1, kSharp _CurveState);
708 } else { 725 } else {
709 SkASSERT(fCandidateVerts.originatingIdx(i) != -1); 726 SkASSERT(fCandidateVerts.originatingIdx(i) != -1);
710 this->updatePt(fCandidateVerts.originatingIdx(i), fCandidateVerts.po int(i), depth, 727 this->updatePt(fCandidateVerts.originatingIdx(i), fCandidateVerts.po int(i), depth,
711 targetCoverage); 728 targetCoverage);
712 newIdx = fCandidateVerts.originatingIdx(i); 729 newIdx = fCandidateVerts.originatingIdx(i);
713 } 730 }
714 731
715 nextRing->addIdx(newIdx, fCandidateVerts.origEdge(i)); 732 nextRing->addIdx(newIdx, fCandidateVerts.origEdge(i));
716 } 733 }
717 734
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 maxDot = 0; 833 maxDot = 0;
817 } 834 }
818 if (SkScalarNearlyEqual(minDot, 0.0f, 0.005f)) { 835 if (SkScalarNearlyEqual(minDot, 0.0f, 0.005f)) {
819 minDot = 0; 836 minDot = 0;
820 } 837 }
821 return (maxDot >= 0.0f) == (minDot >= 0.0f); 838 return (maxDot >= 0.0f) == (minDot >= 0.0f);
822 } 839 }
823 840
824 #endif 841 #endif
825 842
826 void GrAAConvexTessellator::lineTo(SkPoint p, bool isCurve) { 843 void GrAAConvexTessellator::lineTo(SkPoint p, CurveState curve) {
827 if (this->numPts() > 0 && duplicate_pt(p, this->lastPoint())) { 844 if (this->numPts() > 0 && duplicate_pt(p, this->lastPoint())) {
828 return; 845 return;
829 } 846 }
830 847
831 SkASSERT(fPts.count() <= 1 || fPts.count() == fNorms.count()+1); 848 SkASSERT(fPts.count() <= 1 || fPts.count() == fNorms.count()+1);
832 if (this->numPts() >= 2 && 849 if (this->numPts() >= 2 &&
833 abs_dist_from_line(fPts.top(), fNorms.top(), p) < kClose) { 850 abs_dist_from_line(fPts.top(), fNorms.top(), p) < kClose) {
834 // The old last point is on the line from the second to last to the new point 851 // The old last point is on the line from the second to last to the new point
835 this->popLastPt(); 852 this->popLastPt();
836 fNorms.pop(); 853 fNorms.pop();
837 fIsCurve.pop(); 854 fCurveState.pop();
838 // double-check that the new last point is not a duplicate of the new po int. In an ideal 855 // double-check that the new last point is not a duplicate of the new po int. In an ideal
839 // world this wouldn't be necessary (since it's only possible for non-co nvex paths), but 856 // world this wouldn't be necessary (since it's only possible for non-co nvex paths), but
840 // floating point precision issues mean it can actually happen on paths that were determined 857 // floating point precision issues mean it can actually happen on paths that were determined
841 // to be convex. 858 // to be convex.
842 if (duplicate_pt(p, this->lastPoint())) { 859 if (duplicate_pt(p, this->lastPoint())) {
843 return; 860 return;
844 } 861 }
845 } 862 }
846 SkScalar initialRingCoverage = fStrokeWidth < 0.0f ? 0.5f : 1.0f; 863 SkScalar initialRingCoverage = fStrokeWidth < 0.0f ? 0.5f : 1.0f;
847 this->addPt(p, 0.0f, initialRingCoverage, false, isCurve); 864 this->addPt(p, 0.0f, initialRingCoverage, false, curve);
848 if (this->numPts() > 1) { 865 if (this->numPts() > 1) {
849 *fNorms.push() = fPts.top() - fPts[fPts.count()-2]; 866 *fNorms.push() = fPts.top() - fPts[fPts.count()-2];
850 SkDEBUGCODE(SkScalar len =) SkPoint::Normalize(&fNorms.top()); 867 SkDEBUGCODE(SkScalar len =) SkPoint::Normalize(&fNorms.top());
851 SkASSERT(len > 0.0f); 868 SkASSERT(len > 0.0f);
852 SkASSERT(SkScalarNearlyEqual(1.0f, fNorms.top().length())); 869 SkASSERT(SkScalarNearlyEqual(1.0f, fNorms.top().length()));
853 } 870 }
854 } 871 }
855 872
856 void GrAAConvexTessellator::lineTo(const SkMatrix& m, SkPoint p, bool isCurve) { 873 void GrAAConvexTessellator::lineTo(const SkMatrix& m, SkPoint p, CurveState curv e) {
857 m.mapPoints(&p, 1); 874 m.mapPoints(&p, 1);
858 this->lineTo(p, isCurve); 875 this->lineTo(p, curve);
859 } 876 }
860 877
861 void GrAAConvexTessellator::quadTo(SkPoint pts[3]) { 878 void GrAAConvexTessellator::quadTo(SkPoint pts[3]) {
862 int maxCount = GrPathUtils::quadraticPointCount(pts, kQuadTolerance); 879 int maxCount = GrPathUtils::quadraticPointCount(pts, kQuadTolerance);
863 fPointBuffer.setReserve(maxCount); 880 fPointBuffer.setReserve(maxCount);
864 SkPoint* target = fPointBuffer.begin(); 881 SkPoint* target = fPointBuffer.begin();
865 int count = GrPathUtils::generateQuadraticPoints(pts[0], pts[1], pts[2], 882 int count = GrPathUtils::generateQuadraticPoints(pts[0], pts[1], pts[2],
866 kQuadTolerance, &target, maxCount); 883 kQuadTolerance, &target, maxCount);
867 fPointBuffer.setCount(count); 884 fPointBuffer.setCount(count);
868 for (int i = 0; i < count; i++) { 885 for (int i = 0; i < count - 1; i++) {
869 lineTo(fPointBuffer[i], true); 886 lineTo(fPointBuffer[i], kCurve_CurveState);
870 } 887 }
888 lineTo(fPointBuffer[count - 1], kIndeterminate_CurveState);
871 } 889 }
872 890
873 void GrAAConvexTessellator::quadTo(const SkMatrix& m, SkPoint pts[3]) { 891 void GrAAConvexTessellator::quadTo(const SkMatrix& m, SkPoint pts[3]) {
874 SkPoint transformed[3]; 892 SkPoint transformed[3];
875 transformed[0] = pts[0]; 893 transformed[0] = pts[0];
876 transformed[1] = pts[1]; 894 transformed[1] = pts[1];
877 transformed[2] = pts[2]; 895 transformed[2] = pts[2];
878 m.mapPoints(transformed, 3); 896 m.mapPoints(transformed, 3);
879 quadTo(transformed); 897 quadTo(transformed);
880 } 898 }
881 899
882 void GrAAConvexTessellator::cubicTo(const SkMatrix& m, SkPoint pts[4]) { 900 void GrAAConvexTessellator::cubicTo(const SkMatrix& m, SkPoint pts[4]) {
883 m.mapPoints(pts, 4); 901 m.mapPoints(pts, 4);
884 int maxCount = GrPathUtils::cubicPointCount(pts, kCubicTolerance); 902 int maxCount = GrPathUtils::cubicPointCount(pts, kCubicTolerance);
885 fPointBuffer.setReserve(maxCount); 903 fPointBuffer.setReserve(maxCount);
886 SkPoint* target = fPointBuffer.begin(); 904 SkPoint* target = fPointBuffer.begin();
887 int count = GrPathUtils::generateCubicPoints(pts[0], pts[1], pts[2], pts[3], 905 int count = GrPathUtils::generateCubicPoints(pts[0], pts[1], pts[2], pts[3],
888 kCubicTolerance, &target, maxCount); 906 kCubicTolerance, &target, maxCount);
889 fPointBuffer.setCount(count); 907 fPointBuffer.setCount(count);
890 for (int i = 0; i < count; i++) { 908 for (int i = 0; i < count - 1; i++) {
891 lineTo(fPointBuffer[i], true); 909 lineTo(fPointBuffer[i], kCurve_CurveState);
892 } 910 }
911 lineTo(fPointBuffer[count - 1], kIndeterminate_CurveState);
893 } 912 }
894 913
895 // include down here to avoid compilation errors caused by "-" overload in SkGeo metry.h 914 // include down here to avoid compilation errors caused by "-" overload in SkGeo metry.h
896 #include "SkGeometry.h" 915 #include "SkGeometry.h"
897 916
898 void GrAAConvexTessellator::conicTo(const SkMatrix& m, SkPoint pts[3], SkScalar w) { 917 void GrAAConvexTessellator::conicTo(const SkMatrix& m, SkPoint pts[3], SkScalar w) {
899 m.mapPoints(pts, 3); 918 m.mapPoints(pts, 3);
900 SkAutoConicToQuads quadder; 919 SkAutoConicToQuads quadder;
901 const SkPoint* quads = quadder.computeQuads(pts, w, kConicTolerance); 920 const SkPoint* quads = quadder.computeQuads(pts, w, kConicTolerance);
902 SkPoint lastPoint = *(quads++); 921 SkPoint lastPoint = *(quads++);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 1043
1025 SkString num; 1044 SkString num;
1026 num.printf("%d", i); 1045 num.printf("%d", i);
1027 canvas->drawText(num.c_str(), num.size(), 1046 canvas->drawText(num.c_str(), num.size(),
1028 this->point(i).fX, this->point(i).fY+(kPointRadius/2.0f ), 1047 this->point(i).fX, this->point(i).fY+(kPointRadius/2.0f ),
1029 paint); 1048 paint);
1030 } 1049 }
1031 } 1050 }
1032 1051
1033 #endif 1052 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAAConvexTessellator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698