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

Side by Side Diff: src/pathops/SkIntersections.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/SkIntersections.h ('k') | src/pathops/SkOpAngle.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 7
8 #include "SkIntersections.h" 8 #include "SkIntersections.h"
9 9
10 void SkIntersections::append(const SkIntersections& i) { 10 void SkIntersections::append(const SkIntersections& i) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 } 96 }
97 if (fUsed >= fMax) { 97 if (fUsed >= fMax) {
98 SkASSERT(0); // FIXME : this error, if it is to be handled at runtime i n release, must 98 SkASSERT(0); // FIXME : this error, if it is to be handled at runtime i n release, must
99 // be propagated all the way back down to the caller, and return failure. 99 // be propagated all the way back down to the caller, and return failure.
100 fUsed = 0; 100 fUsed = 0;
101 return 0; 101 return 0;
102 } 102 }
103 int remaining = fUsed - index; 103 int remaining = fUsed - index;
104 if (remaining > 0) { 104 if (remaining > 0) {
105 memmove(&fPt[index + 1], &fPt[index], sizeof(fPt[0]) * remaining); 105 memmove(&fPt[index + 1], &fPt[index], sizeof(fPt[0]) * remaining);
106 memmove(&fPt2[index + 1], &fPt2[index], sizeof(fPt2[0]) * remaining);
106 memmove(&fT[0][index + 1], &fT[0][index], sizeof(fT[0][0]) * remaining); 107 memmove(&fT[0][index + 1], &fT[0][index], sizeof(fT[0][0]) * remaining);
107 memmove(&fT[1][index + 1], &fT[1][index], sizeof(fT[1][0]) * remaining); 108 memmove(&fT[1][index + 1], &fT[1][index], sizeof(fT[1][0]) * remaining);
108 int clearMask = ~((1 << index) - 1); 109 int clearMask = ~((1 << index) - 1);
109 fIsCoincident[0] += fIsCoincident[0] & clearMask; 110 fIsCoincident[0] += fIsCoincident[0] & clearMask;
110 fIsCoincident[1] += fIsCoincident[1] & clearMask; 111 fIsCoincident[1] += fIsCoincident[1] & clearMask;
111 } 112 }
112 fPt[index] = pt; 113 fPt[index] = pt;
113 fT[0][index] = one; 114 fT[0][index] = one;
114 fT[1][index] = two; 115 fT[1][index] = two;
115 ++fUsed; 116 ++fUsed;
116 return index; 117 return index;
117 } 118 }
118 119
120 void SkIntersections::insertNear(double one, double two, const SkDPoint& pt1, co nst SkDPoint& pt2) {
121 SkASSERT(one == 0 || one == 1);
122 SkASSERT(two == 0 || two == 1);
123 SkASSERT(pt1 != pt2);
124 SkASSERT(fNearlySame[(int) one]);
125 (void) insert(one, two, pt1);
126 fPt2[one ? fUsed - 1 : 0] = pt2;
127 }
128
119 void SkIntersections::insertCoincident(double one, double two, const SkDPoint& p t) { 129 void SkIntersections::insertCoincident(double one, double two, const SkDPoint& p t) {
120 int index = insertSwap(one, two, pt); 130 int index = insertSwap(one, two, pt);
121 int bit = 1 << index; 131 int bit = 1 << index;
122 fIsCoincident[0] |= bit; 132 fIsCoincident[0] |= bit;
123 fIsCoincident[1] |= bit; 133 fIsCoincident[1] |= bit;
124 } 134 }
125 135
126 int SkIntersections::lineRay(const SkPoint pts[2], const SkDLine& line) { 136 int SkIntersections::lineRay(const SkPoint pts[2], const SkDLine& line) {
127 SkDLine l; 137 SkDLine l;
128 l.set(pts); 138 l.set(pts);
(...skipping 22 matching lines...) Expand all
151 fT[0][index] = fT[0][replace]; 161 fT[0][index] = fT[0][replace];
152 } 162 }
153 } 163 }
154 164
155 void SkIntersections::removeOne(int index) { 165 void SkIntersections::removeOne(int index) {
156 int remaining = --fUsed - index; 166 int remaining = --fUsed - index;
157 if (remaining <= 0) { 167 if (remaining <= 0) {
158 return; 168 return;
159 } 169 }
160 memmove(&fPt[index], &fPt[index + 1], sizeof(fPt[0]) * remaining); 170 memmove(&fPt[index], &fPt[index + 1], sizeof(fPt[0]) * remaining);
171 memmove(&fPt2[index], &fPt2[index + 1], sizeof(fPt2[0]) * remaining);
161 memmove(&fT[0][index], &fT[0][index + 1], sizeof(fT[0][0]) * remaining); 172 memmove(&fT[0][index], &fT[0][index + 1], sizeof(fT[0][0]) * remaining);
162 memmove(&fT[1][index], &fT[1][index + 1], sizeof(fT[1][0]) * remaining); 173 memmove(&fT[1][index], &fT[1][index + 1], sizeof(fT[1][0]) * remaining);
163 SkASSERT(fIsCoincident[0] == 0); 174 SkASSERT(fIsCoincident[0] == 0);
164 int coBit = fIsCoincident[0] & (1 << index); 175 int coBit = fIsCoincident[0] & (1 << index);
165 fIsCoincident[0] -= ((fIsCoincident[0] >> 1) & ~((1 << index) - 1)) + coBit; 176 fIsCoincident[0] -= ((fIsCoincident[0] >> 1) & ~((1 << index) - 1)) + coBit;
166 SkASSERT(!(coBit ^ (fIsCoincident[1] & (1 << index)))); 177 SkASSERT(!(coBit ^ (fIsCoincident[1] & (1 << index))));
167 fIsCoincident[1] -= ((fIsCoincident[1] >> 1) & ~((1 << index) - 1)) + coBit; 178 fIsCoincident[1] -= ((fIsCoincident[1] >> 1) & ~((1 << index) - 1)) + coBit;
168 } 179 }
169 180
170 void SkIntersections::swapPts() { 181 void SkIntersections::swapPts() {
(...skipping 16 matching lines...) Expand all
187 quad.set(a); 198 quad.set(a);
188 return vertical(quad, top, bottom, x, flipped); 199 return vertical(quad, top, bottom, x, flipped);
189 } 200 }
190 201
191 int SkIntersections::verticalCubic(const SkPoint a[4], SkScalar top, SkScalar bo ttom, 202 int SkIntersections::verticalCubic(const SkPoint a[4], SkScalar top, SkScalar bo ttom,
192 SkScalar x, bool flipped) { 203 SkScalar x, bool flipped) {
193 SkDCubic cubic; 204 SkDCubic cubic;
194 cubic.set(a); 205 cubic.set(a);
195 return vertical(cubic, top, bottom, x, flipped); 206 return vertical(cubic, top, bottom, x, flipped);
196 } 207 }
OLDNEW
« no previous file with comments | « src/pathops/SkIntersections.h ('k') | src/pathops/SkOpAngle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698