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

Side by Side Diff: src/pathops/SkPathOpsCurve.cpp

Issue 2366893003: fix msan bug in pathops (Closed)
Patch Set: Created 4 years, 2 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/pathops/SkOpEdgeBuilder.cpp ('k') | tests/PathOpsOpTest.cpp » ('j') | 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 #include "SkPathOpsBounds.h" 7 #include "SkPathOpsBounds.h"
8 #include "SkPathOpsRect.h" 8 #include "SkPathOpsRect.h"
9 #include "SkPathOpsCurve.h" 9 #include "SkPathOpsCurve.h"
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 } 47 }
48 double largest = SkTMax(SkTMax(maxX, maxY), -SkTMin(minX, minY)); 48 double largest = SkTMax(SkTMax(maxX, maxY), -SkTMin(minX, minY));
49 if (!AlmostEqualUlps_Pin(largest, largest + minDist)) { // is distance withi n ULPS tolerance? 49 if (!AlmostEqualUlps_Pin(largest, largest + minDist)) { // is distance withi n ULPS tolerance?
50 return -1; 50 return -1;
51 } 51 }
52 return SkPinT(i[0][minIndex]); 52 return SkPinT(i[0][minIndex]);
53 } 53 }
54 54
55 void SkDCurve::offset(SkPath::Verb verb, const SkDVector& off) { 55 void SkDCurve::offset(SkPath::Verb verb, const SkDVector& off) {
56 int count = SkPathOpsVerbToPoints(verb); 56 int count = SkPathOpsVerbToPoints(verb);
57 for (int index = 0; index < count; ++index) { 57 for (int index = 0; index <= count; ++index) {
58 fCubic.fPts[index] += off; 58 fCubic.fPts[index] += off;
59 } 59 }
60 } 60 }
61 61
62 void SkDCurve::setConicBounds(const SkPoint curve[3], SkScalar curveWeight, 62 void SkDCurve::setConicBounds(const SkPoint curve[3], SkScalar curveWeight,
63 double tStart, double tEnd, SkPathOpsBounds* bounds) { 63 double tStart, double tEnd, SkPathOpsBounds* bounds) {
64 SkDConic dCurve; 64 SkDConic dCurve;
65 dCurve.set(curve, curveWeight); 65 dCurve.set(curve, curveWeight);
66 SkDRect dRect; 66 SkDRect dRect;
67 dRect.setBounds(dCurve, fConic, tStart, tEnd); 67 dRect.setBounds(dCurve, fConic, tStart, tEnd);
(...skipping 26 matching lines...) Expand all
94 fSweep[0] = fCurve[1] - fCurve[0]; 94 fSweep[0] = fCurve[1] - fCurve[0];
95 if (SkPath::kLine_Verb == verb) { 95 if (SkPath::kLine_Verb == verb) {
96 fSweep[1] = fSweep[0]; 96 fSweep[1] = fSweep[0];
97 fIsCurve = false; 97 fIsCurve = false;
98 return; 98 return;
99 } 99 }
100 fSweep[1] = fCurve[2] - fCurve[0]; 100 fSweep[1] = fCurve[2] - fCurve[0];
101 // OPTIMIZE: I do the following float check a lot -- probably need a 101 // OPTIMIZE: I do the following float check a lot -- probably need a
102 // central place for this val-is-small-compared-to-curve check 102 // central place for this val-is-small-compared-to-curve check
103 double maxVal = 0; 103 double maxVal = 0;
104 for (int index = 0; index < SkPathOpsVerbToPoints(verb); ++index) { 104 for (int index = 0; index <= SkPathOpsVerbToPoints(verb); ++index) {
105 maxVal = SkTMax(maxVal, SkTMax(SkTAbs(fCurve[index].fX), 105 maxVal = SkTMax(maxVal, SkTMax(SkTAbs(fCurve[index].fX),
106 SkTAbs(fCurve[index].fY))); 106 SkTAbs(fCurve[index].fY)));
107 } 107 }
108 { 108 {
109 if (SkPath::kCubic_Verb != verb) { 109 if (SkPath::kCubic_Verb != verb) {
110 if (roughly_zero_when_compared_to(fSweep[0].fX, maxVal) 110 if (roughly_zero_when_compared_to(fSweep[0].fX, maxVal)
111 && roughly_zero_when_compared_to(fSweep[0].fY, maxVal)) { 111 && roughly_zero_when_compared_to(fSweep[0].fY, maxVal)) {
112 fSweep[0] = fSweep[1]; 112 fSweep[0] = fSweep[1];
113 } 113 }
114 goto setIsCurve; 114 goto setIsCurve;
(...skipping 21 matching lines...) Expand all
136 if (s3x2 * s2x1 < 0) { 136 if (s3x2 * s2x1 < 0) {
137 SkASSERT(s2x1 * s1x3 > 0); 137 SkASSERT(s2x1 * s1x3 > 0);
138 fSweep[0] = fSweep[1]; 138 fSweep[0] = fSweep[1];
139 fOrdered = false; 139 fOrdered = false;
140 } 140 }
141 fSweep[1] = thirdSweep; 141 fSweep[1] = thirdSweep;
142 } 142 }
143 setIsCurve: 143 setIsCurve:
144 fIsCurve = fSweep[0].crossCheck(fSweep[1]) != 0; 144 fIsCurve = fSweep[0].crossCheck(fSweep[1]) != 0;
145 } 145 }
OLDNEW
« no previous file with comments | « src/pathops/SkOpEdgeBuilder.cpp ('k') | tests/PathOpsOpTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698