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

Side by Side Diff: src/core/SkStroke.cpp

Issue 1484873003: add more conservative check for wayward divide (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: greater than compare removes need for finite check Created 5 years 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 | « gm/strokes.cpp ('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 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 "SkPathPriv.h" 10 #include "SkPathPriv.h"
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 // are small, a straight line is good enough 829 // are small, a straight line is good enough
830 SkScalar dist1 = pt_to_line(start, end, quadPts->fTangentEnd); 830 SkScalar dist1 = pt_to_line(start, end, quadPts->fTangentEnd);
831 SkScalar dist2 = pt_to_line(end, start, quadPts->fTangentStart); 831 SkScalar dist2 = pt_to_line(end, start, quadPts->fTangentStart);
832 if (SkTMax(dist1, dist2) <= fInvResScaleSquared) { 832 if (SkTMax(dist1, dist2) <= fInvResScaleSquared) {
833 return STROKER_RESULT(kDegenerate_ResultType, depth, quadPts, 833 return STROKER_RESULT(kDegenerate_ResultType, depth, quadPts,
834 "SkTMax(dist1=%g, dist2=%g) <= fInvResScaleSquared", dist1, dist2); 834 "SkTMax(dist1=%g, dist2=%g) <= fInvResScaleSquared", dist1, dist2);
835 } 835 }
836 return STROKER_RESULT(kSplit_ResultType, depth, quadPts, 836 return STROKER_RESULT(kSplit_ResultType, depth, quadPts,
837 "(numerA=%g >= 0) == (numerB=%g >= 0)", numerA, numerB); 837 "(numerA=%g >= 0) == (numerB=%g >= 0)", numerA, numerB);
838 } 838 }
839 // check to see if the denomerator is teeny relative to the numerator 839 // check to see if the denominator is teeny relative to the numerator
840 bool validDivide = SkScalarAbs(numerA) * SK_ScalarNearlyZero < SkScalarAbs(d enom); 840 // if the offset by one will be lost, the ratio is too large
841 // the divide check is the same as checking if the scaled denom is nearly zero 841 numerA /= denom;
842 // (commented out because on some platforms the two are not bit-identical) 842 bool validDivide = numerA > numerA - 1;
843 // SkASSERT(!SkScalarNearlyZero(denom / numerA) == validDivide);
844 if (validDivide) { 843 if (validDivide) {
845 if (kCtrlPt_RayType == intersectRayType) { 844 if (kCtrlPt_RayType == intersectRayType) {
846 numerA /= denom;
847 SkPoint* ctrlPt = &quadPts->fQuad[1]; 845 SkPoint* ctrlPt = &quadPts->fQuad[1];
848 // the intersection of the tangents need not be on the tangent segme nt 846 // the intersection of the tangents need not be on the tangent segme nt
849 // so 0 <= numerA <= 1 is not necessarily true 847 // so 0 <= numerA <= 1 is not necessarily true
850 ctrlPt->fX = start.fX * (1 - numerA) + quadPts->fTangentStart.fX * n umerA; 848 ctrlPt->fX = start.fX * (1 - numerA) + quadPts->fTangentStart.fX * n umerA;
851 ctrlPt->fY = start.fY * (1 - numerA) + quadPts->fTangentStart.fY * n umerA; 849 ctrlPt->fY = start.fY * (1 - numerA) + quadPts->fTangentStart.fY * n umerA;
852 } 850 }
853 return STROKER_RESULT(kQuad_ResultType, depth, quadPts, 851 return STROKER_RESULT(kQuad_ResultType, depth, quadPts,
854 "(numerA=%g >= 0) != (numerB=%g >= 0)", numerA, numerB); 852 "(numerA=%g >= 0) != (numerB=%g >= 0)", numerA, numerB);
855 } 853 }
856 // if the lines are parallel, straight line is good enough 854 // if the lines are parallel, straight line is good enough
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 default: 1480 default:
1483 break; 1481 break;
1484 } 1482 }
1485 1483
1486 if (fWidth < SkMinScalar(rw, rh) && !fDoFill) { 1484 if (fWidth < SkMinScalar(rw, rh) && !fDoFill) {
1487 r = rect; 1485 r = rect;
1488 r.inset(radius, radius); 1486 r.inset(radius, radius);
1489 dst->addRect(r, reverse_direction(dir)); 1487 dst->addRect(r, reverse_direction(dir));
1490 } 1488 }
1491 } 1489 }
OLDNEW
« no previous file with comments | « gm/strokes.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698