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

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

Issue 52653002: pathops work in progress (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: add raster vs gpu test Created 7 years, 1 month 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 | Annotate | Revision Log
« 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 A += C - 2 * B; // A = a - 2*b + c 134 A += C - 2 * B; // A = a - 2*b + c
135 B -= C; // B = -(b - c) 135 B -= C; // B = -(b - c)
136 return SkDQuad::RootsValidT(A, 2 * B, C, roots); 136 return SkDQuad::RootsValidT(A, 2 * B, C, roots);
137 } 137 }
138 138
139 int intersect() { 139 int intersect() {
140 addExactEndPoints(); 140 addExactEndPoints();
141 if (fAllowNear) { 141 if (fAllowNear) {
142 addNearEndPoints(); 142 addNearEndPoints();
143 } 143 }
144 double rootVals[2]; 144 if (fIntersections->used() == 2) {
145 int roots = intersectRay(rootVals); 145 // FIXME : need sharable code that turns spans into coincident if mi ddle point is on
146 for (int index = 0; index < roots; ++index) { 146 } else {
147 double quadT = rootVals[index]; 147 double rootVals[2];
148 double lineT = findLineT(quadT); 148 int roots = intersectRay(rootVals);
149 SkDPoint pt; 149 for (int index = 0; index < roots; ++index) {
150 if (pinTs(&quadT, &lineT, &pt, kPointUninitialized)) { 150 double quadT = rootVals[index];
151 fIntersections->insert(quadT, lineT, pt); 151 double lineT = findLineT(quadT);
152 SkDPoint pt;
153 if (pinTs(&quadT, &lineT, &pt, kPointUninitialized)) {
154 fIntersections->insert(quadT, lineT, pt);
155 }
152 } 156 }
153 } 157 }
154 return fIntersections->used(); 158 return fIntersections->used();
155 } 159 }
156 160
157 int horizontalIntersect(double axisIntercept, double roots[2]) { 161 int horizontalIntersect(double axisIntercept, double roots[2]) {
158 double D = fQuad[2].fY; // f 162 double D = fQuad[2].fY; // f
159 double E = fQuad[1].fY; // e 163 double E = fQuad[1].fY; // e
160 double F = fQuad[0].fY; // d 164 double F = fQuad[0].fY; // d
161 D += F - 2 * E; // D = d - 2*e + f 165 D += F - 2 * E; // D = d - 2*e + f
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 } 409 }
406 410
407 int SkIntersections::intersectRay(const SkDQuad& quad, const SkDLine& line) { 411 int SkIntersections::intersectRay(const SkDQuad& quad, const SkDLine& line) {
408 LineQuadraticIntersections q(quad, line, this); 412 LineQuadraticIntersections q(quad, line, this);
409 fUsed = q.intersectRay(fT[0]); 413 fUsed = q.intersectRay(fT[0]);
410 for (int index = 0; index < fUsed; ++index) { 414 for (int index = 0; index < fUsed; ++index) {
411 fPt[index] = quad.ptAtT(fT[0][index]); 415 fPt[index] = quad.ptAtT(fT[0][index]);
412 } 416 }
413 return fUsed; 417 return fUsed;
414 } 418 }
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