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

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

Issue 272153002: fix bugs found by computing flat clips in 800K skps (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix maybe-uninitialized error in unbuntu Created 6 years, 6 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/SkDQuadIntersection.cpp ('k') | src/pathops/SkIntersectionHelper.h » ('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 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 "SkIntersections.h" 7 #include "SkIntersections.h"
8 #include "SkPathOpsLine.h" 8 #include "SkPathOpsLine.h"
9 #include "SkPathOpsQuad.h" 9 #include "SkPathOpsQuad.h"
10 10
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 fIntersections->insert(quadT, lineT, fQuad[qIndex]); 231 fIntersections->insert(quadT, lineT, fQuad[qIndex]);
232 } 232 }
233 } 233 }
234 234
235 void addNearEndPoints() { 235 void addNearEndPoints() {
236 for (int qIndex = 0; qIndex < 3; qIndex += 2) { 236 for (int qIndex = 0; qIndex < 3; qIndex += 2) {
237 double quadT = (double) (qIndex >> 1); 237 double quadT = (double) (qIndex >> 1);
238 if (fIntersections->hasT(quadT)) { 238 if (fIntersections->hasT(quadT)) {
239 continue; 239 continue;
240 } 240 }
241 double lineT = fLine.nearPoint(fQuad[qIndex]); 241 double lineT = fLine.nearPoint(fQuad[qIndex], NULL);
242 if (lineT < 0) { 242 if (lineT < 0) {
243 continue; 243 continue;
244 } 244 }
245 fIntersections->insert(quadT, lineT, fQuad[qIndex]); 245 fIntersections->insert(quadT, lineT, fQuad[qIndex]);
246 } 246 }
247 // FIXME: see if line end is nearly on quad 247 // FIXME: see if line end is nearly on quad
248 } 248 }
249 249
250 void addExactHorizontalEndPoints(double left, double right, double y) { 250 void addExactHorizontalEndPoints(double left, double right, double y) {
251 for (int qIndex = 0; qIndex < 3; qIndex += 2) { 251 for (int qIndex = 0; qIndex < 3; qIndex += 2) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 return false; 317 return false;
318 } 318 }
319 double qT = *quadT = SkPinT(*quadT); 319 double qT = *quadT = SkPinT(*quadT);
320 double lT = *lineT = SkPinT(*lineT); 320 double lT = *lineT = SkPinT(*lineT);
321 if (lT == 0 || lT == 1 || (ptSet == kPointUninitialized && qT != 0 && qT != 1)) { 321 if (lT == 0 || lT == 1 || (ptSet == kPointUninitialized && qT != 0 && qT != 1)) {
322 *pt = fLine.ptAtT(lT); 322 *pt = fLine.ptAtT(lT);
323 } else if (ptSet == kPointUninitialized) { 323 } else if (ptSet == kPointUninitialized) {
324 *pt = fQuad.ptAtT(qT); 324 *pt = fQuad.ptAtT(qT);
325 } 325 }
326 SkPoint gridPt = pt->asSkPoint(); 326 SkPoint gridPt = pt->asSkPoint();
327 if (gridPt == fLine[0].asSkPoint()) { 327 if (SkDPoint::ApproximatelyEqual(gridPt, fLine[0].asSkPoint())) {
328 *pt = fLine[0]; 328 *pt = fLine[0];
329 *lineT = 0; 329 *lineT = 0;
330 } else if (gridPt == fLine[1].asSkPoint()) { 330 } else if (SkDPoint::ApproximatelyEqual(gridPt, fLine[1].asSkPoint())) {
331 *pt = fLine[1]; 331 *pt = fLine[1];
332 *lineT = 1; 332 *lineT = 1;
333 } 333 }
334 if (fIntersections->used() > 0 && approximately_equal((*fIntersections)[ 1][0], *lineT)) { 334 if (fIntersections->used() > 0 && approximately_equal((*fIntersections)[ 1][0], *lineT)) {
335 return false; 335 return false;
336 } 336 }
337 if (gridPt == fQuad[0].asSkPoint()) { 337 if (gridPt == fQuad[0].asSkPoint()) {
338 *pt = fQuad[0]; 338 *pt = fQuad[0];
339 *quadT = 0; 339 *quadT = 0;
340 } else if (gridPt == fQuad[2].asSkPoint()) { 340 } else if (gridPt == fQuad[2].asSkPoint()) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 } 372 }
373 373
374 int SkIntersections::intersectRay(const SkDQuad& quad, const SkDLine& line) { 374 int SkIntersections::intersectRay(const SkDQuad& quad, const SkDLine& line) {
375 LineQuadraticIntersections q(quad, line, this); 375 LineQuadraticIntersections q(quad, line, this);
376 fUsed = q.intersectRay(fT[0]); 376 fUsed = q.intersectRay(fT[0]);
377 for (int index = 0; index < fUsed; ++index) { 377 for (int index = 0; index < fUsed; ++index) {
378 fPt[index] = quad.ptAtT(fT[0][index]); 378 fPt[index] = quad.ptAtT(fT[0][index]);
379 } 379 }
380 return fUsed; 380 return fUsed;
381 } 381 }
OLDNEW
« no previous file with comments | « src/pathops/SkDQuadIntersection.cpp ('k') | src/pathops/SkIntersectionHelper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698