OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "SkLineClipper.h" | 8 #include "SkLineClipper.h" |
9 | 9 |
10 template <typename T> T pin_unsorted(T value, T limit0, T limit1) { | 10 template <typename T> T pin_unsorted(T value, T limit0, T limit1) { |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 const SkPoint pts[] = { | 166 const SkPoint pts[] = { |
167 { -540000, -720000 }, | 167 { -540000, -720000 }, |
168 { -9.10000017e-05f, 9.99999996e-13f } | 168 { -9.10000017e-05f, 9.99999996e-13f } |
169 }; | 169 }; |
170 float x = sect_with_horizontal(pts, 0); | 170 float x = sect_with_horizontal(pts, 0); |
171 SkASSERT(is_between_unsorted(x, pts[0].fX, pts[1].fX)); | 171 SkASSERT(is_between_unsorted(x, pts[0].fX, pts[1].fX)); |
172 } | 172 } |
173 #endif | 173 #endif |
174 | 174 |
175 int SkLineClipper::ClipLine(const SkPoint pts[], const SkRect& clip, | 175 int SkLineClipper::ClipLine(const SkPoint pts[], const SkRect& clip, |
176 SkPoint lines[]) { | 176 SkPoint lines[], bool canClipToTheRight) { |
| 177 #if 1 |
| 178 // Disable this while we investigate layouttest failures |
| 179 canClipToTheRight = false; |
| 180 #endif |
| 181 |
177 #ifdef SK_DEBUG | 182 #ifdef SK_DEBUG |
178 { | 183 { |
179 static bool gOnce; | 184 static bool gOnce; |
180 if (!gOnce) { | 185 if (!gOnce) { |
181 sect_with_horizontal_test_for_pin_results(); | 186 sect_with_horizontal_test_for_pin_results(); |
182 gOnce = true; | 187 gOnce = true; |
183 } | 188 } |
184 } | 189 } |
185 #endif | 190 #endif |
186 | 191 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 index0 = 1; | 239 index0 = 1; |
235 index1 = 0; | 240 index1 = 0; |
236 reverse = true; | 241 reverse = true; |
237 } | 242 } |
238 | 243 |
239 if (tmp[index1].fX <= clip.fLeft) { // wholly to the left | 244 if (tmp[index1].fX <= clip.fLeft) { // wholly to the left |
240 tmp[0].fX = tmp[1].fX = clip.fLeft; | 245 tmp[0].fX = tmp[1].fX = clip.fLeft; |
241 result = tmp; | 246 result = tmp; |
242 reverse = false; | 247 reverse = false; |
243 } else if (tmp[index0].fX >= clip.fRight) { // wholly to the right | 248 } else if (tmp[index0].fX >= clip.fRight) { // wholly to the right |
| 249 if (canClipToTheRight) { |
| 250 return 0; |
| 251 } |
244 tmp[0].fX = tmp[1].fX = clip.fRight; | 252 tmp[0].fX = tmp[1].fX = clip.fRight; |
245 result = tmp; | 253 result = tmp; |
246 reverse = false; | 254 reverse = false; |
247 } else { | 255 } else { |
248 result = resultStorage; | 256 result = resultStorage; |
249 SkPoint* r = result; | 257 SkPoint* r = result; |
250 | 258 |
251 if (tmp[index0].fX < clip.fLeft) { | 259 if (tmp[index0].fX < clip.fLeft) { |
252 r->set(clip.fLeft, tmp[index0].fY); | 260 r->set(clip.fLeft, tmp[index0].fY); |
253 r += 1; | 261 r += 1; |
(...skipping 20 matching lines...) Expand all Loading... |
274 if (reverse) { | 282 if (reverse) { |
275 // copy the pts in reverse order to maintain winding order | 283 // copy the pts in reverse order to maintain winding order |
276 for (int i = 0; i <= lineCount; i++) { | 284 for (int i = 0; i <= lineCount; i++) { |
277 lines[lineCount - i] = result[i]; | 285 lines[lineCount - i] = result[i]; |
278 } | 286 } |
279 } else { | 287 } else { |
280 memcpy(lines, result, (lineCount + 1) * sizeof(SkPoint)); | 288 memcpy(lines, result, (lineCount + 1) * sizeof(SkPoint)); |
281 } | 289 } |
282 return lineCount; | 290 return lineCount; |
283 } | 291 } |
OLD | NEW |