OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2009 The Android Open Source Project | 3 * Copyright 2009 The Android Open Source Project |
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 | 8 |
9 | 9 |
10 #include "SkEdgeClipper.h" | 10 #include "SkEdgeClipper.h" |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 } | 260 } |
261 if (delta < TOLERANCE) { | 261 if (delta < TOLERANCE) { |
262 break; | 262 break; |
263 } | 263 } |
264 } | 264 } |
265 *t = mid; | 265 *t = mid; |
266 // SkDebugf("-- evalCubicAt %d delta %g\n", i, eval_cubic_coeff(A, B, C, D, *
t)); | 266 // SkDebugf("-- evalCubicAt %d delta %g\n", i, eval_cubic_coeff(A, B, C, D, *
t)); |
267 return true; | 267 return true; |
268 } | 268 } |
269 | 269 |
| 270 #if 0 |
270 static bool chopMonoCubicAtY(SkPoint pts[4], SkScalar y, SkScalar* t) { | 271 static bool chopMonoCubicAtY(SkPoint pts[4], SkScalar y, SkScalar* t) { |
271 return chopMonoCubicAt(pts[0].fY, pts[1].fY, pts[2].fY, pts[3].fY, y, t); | 272 return chopMonoCubicAt(pts[0].fY, pts[1].fY, pts[2].fY, pts[3].fY, y, t); |
272 } | 273 } |
| 274 #endif |
273 | 275 |
274 static bool chopMonoCubicAtX(SkPoint pts[4], SkScalar x, SkScalar* t) { | 276 static bool chopMonoCubicAtX(SkPoint pts[4], SkScalar x, SkScalar* t) { |
275 return chopMonoCubicAt(pts[0].fX, pts[1].fX, pts[2].fX, pts[3].fX, x, t); | 277 return chopMonoCubicAt(pts[0].fX, pts[1].fX, pts[2].fX, pts[3].fX, x, t); |
276 } | 278 } |
277 | 279 |
278 // Modify pts[] in place so that it is clipped in Y to the clip rect | 280 // Modify pts[] in place so that it is clipped in Y to the clip rect |
279 static void chop_cubic_in_Y(SkPoint pts[4], const SkRect& clip) { | 281 static void chop_cubic_in_Y(SkPoint pts[4], const SkRect& clip) { |
280 | 282 |
281 // are we partially above | 283 // are we partially above |
282 if (pts[0].fY < clip.fTop) { | 284 if (pts[0].fY < clip.fTop) { |
| 285 SkPoint tmp[7]; |
| 286 #if 0 |
283 SkScalar t; | 287 SkScalar t; |
284 if (chopMonoCubicAtY(pts, clip.fTop, &t)) { | 288 if (chopMonoCubicAtY(pts, clip.fTop, &t)) { |
285 SkPoint tmp[7]; | |
286 SkChopCubicAt(pts, tmp, t); | 289 SkChopCubicAt(pts, tmp, t); |
287 | 290 #else |
| 291 if (SkChopMonoCubicAtY(pts, clip.fTop, tmp)) { |
| 292 #endif |
288 // tmp[3, 4, 5].fY should all be to the below clip.fTop. | 293 // tmp[3, 4, 5].fY should all be to the below clip.fTop. |
289 // Since we can't trust the numerics of | 294 // Since we can't trust the numerics of |
290 // the chopper, we force those conditions now | 295 // the chopper, we force those conditions now |
291 tmp[3].fY = clip.fTop; | 296 tmp[3].fY = clip.fTop; |
292 clamp_ge(tmp[4].fY, clip.fTop); | 297 clamp_ge(tmp[4].fY, clip.fTop); |
293 clamp_ge(tmp[5].fY, clip.fTop); | 298 // clamp_ge(tmp[5].fY, clip.fTop); |
294 | 299 |
295 pts[0] = tmp[3]; | 300 pts[0] = tmp[3]; |
296 pts[1] = tmp[4]; | 301 pts[1] = tmp[4]; |
297 pts[2] = tmp[5]; | 302 pts[2] = tmp[5]; |
298 } else { | 303 } else { |
299 // if chopMonoCubicAtY failed, then we may have hit inexact numerics | 304 // if chopMonoCubicAtY failed, then we may have hit inexact numerics |
300 // so we just clamp against the top | 305 // so we just clamp against the top |
301 for (int i = 0; i < 4; i++) { | 306 for (int i = 0; i < 4; i++) { |
302 clamp_ge(pts[i].fY, clip.fTop); | 307 clamp_ge(pts[i].fY, clip.fTop); |
303 } | 308 } |
304 } | 309 } |
305 } | 310 } |
306 | 311 |
307 // are we partially below | 312 // are we partially below |
308 if (pts[3].fY > clip.fBottom) { | 313 if (pts[3].fY > clip.fBottom) { |
| 314 SkPoint tmp[7]; |
| 315 #if 0 |
309 SkScalar t; | 316 SkScalar t; |
310 if (chopMonoCubicAtY(pts, clip.fBottom, &t)) { | 317 if (chopMonoCubicAtY(pts, clip.fBottom, &t)) { |
311 SkPoint tmp[7]; | |
312 SkChopCubicAt(pts, tmp, t); | 318 SkChopCubicAt(pts, tmp, t); |
| 319 #else |
| 320 if (SkChopMonoCubicAtY(pts, clip.fBottom, tmp)) { |
| 321 #endif |
313 tmp[3].fY = clip.fBottom; | 322 tmp[3].fY = clip.fBottom; |
314 clamp_le(tmp[2].fY, clip.fBottom); | 323 clamp_le(tmp[2].fY, clip.fBottom); |
315 | 324 |
316 pts[1] = tmp[1]; | 325 pts[1] = tmp[1]; |
317 pts[2] = tmp[2]; | 326 pts[2] = tmp[2]; |
318 pts[3] = tmp[3]; | 327 pts[3] = tmp[3]; |
319 } else { | 328 } else { |
320 // if chopMonoCubicAtY failed, then we may have hit inexact numerics | 329 // if chopMonoCubicAtY failed, then we may have hit inexact numerics |
321 // so we just clamp against the bottom | 330 // so we just clamp against the bottom |
322 for (int i = 0; i < 4; i++) { | 331 for (int i = 0; i < 4; i++) { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 assert_monotonic(&pts[0].fY, count); | 535 assert_monotonic(&pts[0].fY, count); |
527 } | 536 } |
528 } | 537 } |
529 | 538 |
530 void sk_assert_monotonic_x(const SkPoint pts[], int count) { | 539 void sk_assert_monotonic_x(const SkPoint pts[], int count) { |
531 if (count > 1) { | 540 if (count > 1) { |
532 assert_monotonic(&pts[0].fX, count); | 541 assert_monotonic(&pts[0].fX, count); |
533 } | 542 } |
534 } | 543 } |
535 #endif | 544 #endif |
OLD | NEW |