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

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

Issue 164753003: Potential fix for array bounds warning. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 10 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 | « no previous file | 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 http://stackoverflow.com/questions/2009160/how-do-i-convert-the-2-control-points -of-a-cubic-curve-to-the-single-control-poi 2 http://stackoverflow.com/questions/2009160/how-do-i-convert-the-2-control-points -of-a-cubic-curve-to-the-single-control-poi
3 */ 3 */
4 4
5 /* 5 /*
6 Let's call the control points of the cubic Q0..Q3 and the control points of the quadratic P0..P2. 6 Let's call the control points of the cubic Q0..Q3 and the control points of the quadratic P0..P2.
7 Then for degree elevation, the equations are: 7 Then for degree elevation, the equations are:
8 8
9 Q0 = P0 9 Q0 = P0
10 Q1 = 1/3 P0 + 2/3 P1 10 Q1 = 1/3 P0 + 2/3 P1
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 inflections += findMaxCurvature(&inflectT[inflections]); 129 inflections += findMaxCurvature(&inflectT[inflections]);
130 SkASSERT(inflections <= 5); 130 SkASSERT(inflections <= 5);
131 } 131 }
132 SkTQSort<double>(inflectT, &inflectT[inflections - 1]); 132 SkTQSort<double>(inflectT, &inflectT[inflections - 1]);
133 // OPTIMIZATION: is this filtering common enough that it needs to be pulled out into its 133 // OPTIMIZATION: is this filtering common enough that it needs to be pulled out into its
134 // own subroutine? 134 // own subroutine?
135 while (inflections && approximately_less_than_zero(inflectT[0])) { 135 while (inflections && approximately_less_than_zero(inflectT[0])) {
136 memmove(inflectT, &inflectT[1], sizeof(inflectT[0]) * --inflections); 136 memmove(inflectT, &inflectT[1], sizeof(inflectT[0]) * --inflections);
137 } 137 }
138 int start = 0; 138 int start = 0;
139 do { 139 int next = 1;
140 int next = start + 1; 140 while (next < inflections) {
141 if (next >= inflections) {
142 break;
143 }
144 if (!approximately_equal(inflectT[start], inflectT[next])) { 141 if (!approximately_equal(inflectT[start], inflectT[next])) {
145 ++start; 142 ++start;
143 ++next;
146 continue; 144 continue;
147 } 145 }
148 memmove(&inflectT[start], &inflectT[next], sizeof(inflectT[0]) * (--infl ections - start)); 146 memmove(&inflectT[start], &inflectT[next], sizeof(inflectT[0]) * (--infl ections - start));
149 } while (true); 147 }
148
150 while (inflections && approximately_greater_than_one(inflectT[inflections - 1])) { 149 while (inflections && approximately_greater_than_one(inflectT[inflections - 1])) {
151 --inflections; 150 --inflections;
152 } 151 }
153 SkDCubicPair pair; 152 SkDCubicPair pair;
154 if (inflections == 1) { 153 if (inflections == 1) {
155 pair = chopAt(inflectT[0]); 154 pair = chopAt(inflectT[0]);
156 int orderP1 = reducer.reduce(pair.first(), SkReduceOrder::kNo_Quadratics ); 155 int orderP1 = reducer.reduce(pair.first(), SkReduceOrder::kNo_Quadratics );
157 if (orderP1 < 2) { 156 if (orderP1 < 2) {
158 --inflections; 157 --inflections;
159 } else { 158 } else {
(...skipping 19 matching lines...) Expand all
179 for (int idx = 0; idx < last; ++idx) { 178 for (int idx = 0; idx < last; ++idx) {
180 part = subDivide(inflectT[idx], inflectT[idx + 1]); 179 part = subDivide(inflectT[idx], inflectT[idx + 1]);
181 addTs(part, precision, inflectT[idx], inflectT[idx + 1], ts); 180 addTs(part, precision, inflectT[idx], inflectT[idx + 1], ts);
182 } 181 }
183 part = subDivide(inflectT[last], 1); 182 part = subDivide(inflectT[last], 1);
184 addTs(part, precision, inflectT[last], 1, ts); 183 addTs(part, precision, inflectT[last], 1, ts);
185 return; 184 return;
186 } 185 }
187 addTs(*this, precision, 0, 1, ts); 186 addTs(*this, precision, 0, 1, ts);
188 } 187 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698