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

Side by Side Diff: src/pathops/SkIntersections.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/SkIntersections.h ('k') | src/pathops/SkOpAngle.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 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 7
8 #include "SkIntersections.h" 8 #include "SkIntersections.h"
9 9
10 void SkIntersections::append(const SkIntersections& i) {
11 for (int index = 0; index < i.fUsed; ++index) {
12 insert(i[0][index], i[1][index], i.pt(index));
13 }
14 }
15
10 int (SkIntersections::*CurveVertical[])(const SkPoint[], SkScalar, SkScalar, SkS calar, bool) = { 16 int (SkIntersections::*CurveVertical[])(const SkPoint[], SkScalar, SkScalar, SkS calar, bool) = {
11 NULL, 17 NULL,
12 &SkIntersections::verticalLine, 18 &SkIntersections::verticalLine,
13 &SkIntersections::verticalQuad, 19 &SkIntersections::verticalQuad,
14 &SkIntersections::verticalCubic 20 &SkIntersections::verticalCubic
15 }; 21 };
16 22
17 int (SkIntersections::*CurveRay[])(const SkPoint[], const SkDLine&) = { 23 int (SkIntersections::*CurveRay[])(const SkPoint[], const SkDLine&) = {
18 NULL, 24 NULL,
19 NULL, 25 &SkIntersections::lineRay,
20 &SkIntersections::quadRay, 26 &SkIntersections::quadRay,
21 &SkIntersections::cubicRay 27 &SkIntersections::cubicRay
22 }; 28 };
23 29
24 int SkIntersections::coincidentUsed() const { 30 int SkIntersections::coincidentUsed() const {
25 if (!fIsCoincident[0]) { 31 if (!fIsCoincident[0]) {
26 SkASSERT(!fIsCoincident[1]); 32 SkASSERT(!fIsCoincident[1]);
27 return 0; 33 return 0;
28 } 34 }
29 int count = 0; 35 int count = 0;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 fIsNear |= 1 << index; 125 fIsNear |= 1 << index;
120 } 126 }
121 127
122 void SkIntersections::insertCoincident(double one, double two, const SkDPoint& p t) { 128 void SkIntersections::insertCoincident(double one, double two, const SkDPoint& p t) {
123 int index = insertSwap(one, two, pt); 129 int index = insertSwap(one, two, pt);
124 int bit = 1 << index; 130 int bit = 1 << index;
125 fIsCoincident[0] |= bit; 131 fIsCoincident[0] |= bit;
126 fIsCoincident[1] |= bit; 132 fIsCoincident[1] |= bit;
127 } 133 }
128 134
135 int SkIntersections::lineRay(const SkPoint pts[2], const SkDLine& line) {
136 SkDLine l;
137 l.set(pts);
138 fMax = 2;
139 return intersectRay(l, line);
140 }
141
129 void SkIntersections::offset(int base, double start, double end) { 142 void SkIntersections::offset(int base, double start, double end) {
130 for (int index = base; index < fUsed; ++index) { 143 for (int index = base; index < fUsed; ++index) {
131 double val = fT[fSwap][index]; 144 double val = fT[fSwap][index];
132 val *= end - start; 145 val *= end - start;
133 val += start; 146 val += start;
134 fT[fSwap][index] = val; 147 fT[fSwap][index] = val;
135 } 148 }
136 } 149 }
137 150
138 int SkIntersections::quadRay(const SkPoint pts[3], const SkDLine& line) { 151 int SkIntersections::quadRay(const SkPoint pts[3], const SkDLine& line) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 quad.set(a); 211 quad.set(a);
199 return vertical(quad, top, bottom, x, flipped); 212 return vertical(quad, top, bottom, x, flipped);
200 } 213 }
201 214
202 int SkIntersections::verticalCubic(const SkPoint a[4], SkScalar top, SkScalar bo ttom, 215 int SkIntersections::verticalCubic(const SkPoint a[4], SkScalar top, SkScalar bo ttom,
203 SkScalar x, bool flipped) { 216 SkScalar x, bool flipped) {
204 SkDCubic cubic; 217 SkDCubic cubic;
205 cubic.set(a); 218 cubic.set(a);
206 return vertical(cubic, top, bottom, x, flipped); 219 return vertical(cubic, top, bottom, x, flipped);
207 } 220 }
OLDNEW
« no previous file with comments | « src/pathops/SkIntersections.h ('k') | src/pathops/SkOpAngle.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698