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

Side by Side Diff: src/pathops/SkIntersections.h

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 #ifndef SkIntersections_DEFINE 7 #ifndef SkIntersections_DEFINE
8 #define SkIntersections_DEFINE 8 #define SkIntersections_DEFINE
9 9
10 #include "SkPathOpsConic.h" 10 #include "SkPathOpsConic.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 #ifdef SK_DEBUG 106 #ifdef SK_DEBUG
107 SkOpGlobalState* debugGlobalState() { return fDebugGlobalState; } 107 SkOpGlobalState* debugGlobalState() { return fDebugGlobalState; }
108 #endif 108 #endif
109 109
110 bool hasT(double t) const { 110 bool hasT(double t) const {
111 SkASSERT(t == 0 || t == 1); 111 SkASSERT(t == 0 || t == 1);
112 return fUsed > 0 && (t == 0 ? fT[0][0] == 0 : fT[0][fUsed - 1] == 1); 112 return fUsed > 0 && (t == 0 ? fT[0][0] == 0 : fT[0][fUsed - 1] == 1);
113 } 113 }
114 114
115 bool hasOppT(double t) const {
116 SkASSERT(t == 0 || t == 1);
117 return fUsed > 0 && (fT[1][0] == t || fT[1][fUsed - 1] == t);
118 }
119
115 int insertSwap(double one, double two, const SkDPoint& pt) { 120 int insertSwap(double one, double two, const SkDPoint& pt) {
116 if (fSwap) { 121 if (fSwap) {
117 return insert(two, one, pt); 122 return insert(two, one, pt);
118 } else { 123 } else {
119 return insert(one, two, pt); 124 return insert(one, two, pt);
120 } 125 }
121 } 126 }
122 127
123 bool isCoincident(int index) { 128 bool isCoincident(int index) {
124 return (fIsCoincident[0] & 1 << index) != 0; 129 return (fIsCoincident[0] & 1 << index) != 0;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 quad.set(a); 178 quad.set(a);
174 fMax = 2; 179 fMax = 2;
175 return vertical(quad, top, bottom, x, flipped); 180 return vertical(quad, top, bottom, x, flipped);
176 } 181 }
177 182
178 int quadLine(const SkPoint a[3], const SkPoint b[2]) { 183 int quadLine(const SkPoint a[3], const SkPoint b[2]) {
179 SkDQuad quad; 184 SkDQuad quad;
180 quad.set(a); 185 quad.set(a);
181 SkDLine line; 186 SkDLine line;
182 line.set(b); 187 line.set(b);
183 fMax = 3; // 2; permit small coincident segment + non-coincident inters ection
184 return intersect(quad, line); 188 return intersect(quad, line);
185 } 189 }
186 190
187 // leaves swap, max alone 191 // leaves swap, max alone
188 void reset() { 192 void reset() {
189 fAllowNear = true; 193 fAllowNear = true;
190 fUsed = 0; 194 fUsed = 0;
191 sk_bzero(fIsCoincident, sizeof(fIsCoincident)); 195 sk_bzero(fIsCoincident, sizeof(fIsCoincident));
192 } 196 }
193 197
194 void set(bool swap, int tIndex, double t) { 198 void set(bool swap, int tIndex, double t) {
195 fT[(int) swap][tIndex] = t; 199 fT[(int) swap][tIndex] = t;
196 } 200 }
197 201
198 void setMax(int max) { 202 void setMax(int max) {
199 SkASSERT(max <= (int) SK_ARRAY_COUNT(fPt)); 203 SkASSERT(max <= (int) SK_ARRAY_COUNT(fPt));
200 fMax = max; 204 fMax = max;
201 } 205 }
202 206
203 void swap() { 207 void swap() {
204 fSwap ^= true; 208 fSwap ^= true;
205 } 209 }
206 210
207 bool swapped() const { 211 bool swapped() const {
208 return fSwap; 212 return fSwap;
209 } 213 }
210 214
211 int used() const { 215 int used() const {
212 return fUsed; 216 return fUsed;
213 } 217 }
214 218
215 void downDepth() { 219 void downDepth() {
216 SkASSERT(--fDepth >= 0); 220 SkASSERT(--fDepth >= 0);
217 } 221 }
218 222
219 bool unBumpT(int index) { 223 bool unBumpT(int index) {
220 SkASSERT(fUsed == 1); 224 SkASSERT(fUsed == 1);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 #ifdef SK_DEBUG 320 #ifdef SK_DEBUG
317 SkOpGlobalState* fDebugGlobalState; 321 SkOpGlobalState* fDebugGlobalState;
318 int fDepth; 322 int fDepth;
319 #endif 323 #endif
320 #if DEBUG_T_SECT_LOOP_COUNT 324 #if DEBUG_T_SECT_LOOP_COUNT
321 int fDebugLoopCount[3]; 325 int fDebugLoopCount[3];
322 #endif 326 #endif
323 }; 327 };
324 328
325 #endif 329 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698