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/SkReduceOrder.cpp

Issue 2128633003: pathops coincidence and security rewrite (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: require resulting t to be between 0 and 1 Created 4 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 "SkReduceOrder.h" 7 #include "SkReduceOrder.h"
8 8
9 int SkReduceOrder::reduce(const SkDLine& line) { 9 int SkReduceOrder::reduce(const SkDLine& line) {
10 fLine[0] = line[0]; 10 fLine[0] = line[0];
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 } 72 }
73 for (index = 0; index < 3; ++index) { 73 for (index = 0; index < 3; ++index) {
74 if (AlmostEqualUlps(quad[index].fX, quad[minX].fX)) { 74 if (AlmostEqualUlps(quad[index].fX, quad[minX].fX)) {
75 minXSet |= 1 << index; 75 minXSet |= 1 << index;
76 } 76 }
77 if (AlmostEqualUlps(quad[index].fY, quad[minY].fY)) { 77 if (AlmostEqualUlps(quad[index].fY, quad[minY].fY)) {
78 minYSet |= 1 << index; 78 minYSet |= 1 << index;
79 } 79 }
80 } 80 }
81 if ((minXSet & 0x05) == 0x5 && (minYSet & 0x05) == 0x5) { // test for degene rate
82 // this quad starts and ends at the same place, so never contributes
83 // to the fill
84 return coincident_line(quad, fQuad);
85 }
81 if (minXSet == 0x7) { // test for vertical line 86 if (minXSet == 0x7) { // test for vertical line
82 if (minYSet == 0x7) { // return 1 if all three are coincident
83 return coincident_line(quad, fQuad);
84 }
85 return vertical_line(quad, fQuad); 87 return vertical_line(quad, fQuad);
86 } 88 }
87 if (minYSet == 0x7) { // test for horizontal line 89 if (minYSet == 0x7) { // test for horizontal line
88 return horizontal_line(quad, fQuad); 90 return horizontal_line(quad, fQuad);
89 } 91 }
90 int result = check_linear(quad, minX, maxX, minY, maxY, fQuad); 92 int result = check_linear(quad, minX, maxX, minY, maxY, fQuad);
91 if (result) { 93 if (result) {
92 return result; 94 return result;
93 } 95 }
94 fQuad = quad; 96 fQuad = quad;
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 cubic.set(a); 273 cubic.set(a);
272 SkReduceOrder reducer; 274 SkReduceOrder reducer;
273 int order = reducer.reduce(cubic, kAllow_Quadratics); 275 int order = reducer.reduce(cubic, kAllow_Quadratics);
274 if (order == 2 || order == 3) { // cubic became line or quad 276 if (order == 2 || order == 3) { // cubic became line or quad
275 for (int index = 0; index < order; ++index) { 277 for (int index = 0; index < order; ++index) {
276 *reducePts++ = reducer.fQuad[index].asSkPoint(); 278 *reducePts++ = reducer.fQuad[index].asSkPoint();
277 } 279 }
278 } 280 }
279 return SkPathOpsPointsToVerb(order - 1); 281 return SkPathOpsPointsToVerb(order - 1);
280 } 282 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698