OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009 The Android Open Source Project | 2 * Copyright 2009 The Android Open Source Project |
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 | 8 |
9 #include "SkEdgeClipper.h" | 9 #include "SkEdgeClipper.h" |
10 #include "SkGeometry.h" | 10 #include "SkGeometry.h" |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 SkChopCubicAt(src, dst, mono_cubic_closestT(&src->fY, y)); | 256 SkChopCubicAt(src, dst, mono_cubic_closestT(&src->fY, y)); |
257 } | 257 } |
258 | 258 |
259 // Modify pts[] in place so that it is clipped in Y to the clip rect | 259 // Modify pts[] in place so that it is clipped in Y to the clip rect |
260 static void chop_cubic_in_Y(SkPoint pts[4], const SkRect& clip) { | 260 static void chop_cubic_in_Y(SkPoint pts[4], const SkRect& clip) { |
261 | 261 |
262 // are we partially above | 262 // are we partially above |
263 if (pts[0].fY < clip.fTop) { | 263 if (pts[0].fY < clip.fTop) { |
264 SkPoint tmp[7]; | 264 SkPoint tmp[7]; |
265 chop_mono_cubic_at_y(pts, clip.fTop, tmp); | 265 chop_mono_cubic_at_y(pts, clip.fTop, tmp); |
| 266 |
| 267 /* |
| 268 * For a large range in the points, we can do a poor job of chopping, s
uch that the t |
| 269 * we computed resulted in the lower cubic still being partly above the
clip. |
| 270 * |
| 271 * If just the first or first 2 Y values are above the fTop, we can jus
t smash them |
| 272 * down. If the first 3 Ys are above fTop, we can't smash all 3, as tha
t can really |
| 273 * distort the cubic. In this case, we take the first output (tmp[3..6]
and treat it as |
| 274 * a guess, and re-chop against fTop. Then we fall through to checking
if we need to |
| 275 * smash the first 1 or 2 Y values. |
| 276 */ |
| 277 if (tmp[3].fY < clip.fTop && tmp[4].fY < clip.fTop && tmp[5].fY < clip.f
Top) { |
| 278 SkPoint tmp2[4]; |
| 279 memcpy(tmp2, &tmp[3].fX, 4 * sizeof(SkPoint)); |
| 280 chop_mono_cubic_at_y(tmp2, clip.fTop, tmp); |
| 281 } |
| 282 |
266 // tmp[3, 4].fY should all be to the below clip.fTop. | 283 // tmp[3, 4].fY should all be to the below clip.fTop. |
267 // Since we can't trust the numerics of | 284 // Since we can't trust the numerics of the chopper, we force those cond
itions now |
268 // the chopper, we force those conditions now | |
269 tmp[3].fY = clip.fTop; | 285 tmp[3].fY = clip.fTop; |
270 clamp_ge(tmp[4].fY, clip.fTop); | 286 clamp_ge(tmp[4].fY, clip.fTop); |
271 | 287 |
272 pts[0] = tmp[3]; | 288 pts[0] = tmp[3]; |
273 pts[1] = tmp[4]; | 289 pts[1] = tmp[4]; |
274 pts[2] = tmp[5]; | 290 pts[2] = tmp[5]; |
275 } | 291 } |
276 | 292 |
277 // are we partially below | 293 // are we partially below |
278 if (pts[3].fY > clip.fBottom) { | 294 if (pts[3].fY > clip.fBottom) { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 assert_monotonic(&pts[0].fY, count); | 498 assert_monotonic(&pts[0].fY, count); |
483 } | 499 } |
484 } | 500 } |
485 | 501 |
486 void sk_assert_monotonic_x(const SkPoint pts[], int count) { | 502 void sk_assert_monotonic_x(const SkPoint pts[], int count) { |
487 if (count > 1) { | 503 if (count > 1) { |
488 assert_monotonic(&pts[0].fX, count); | 504 assert_monotonic(&pts[0].fX, count); |
489 } | 505 } |
490 } | 506 } |
491 #endif | 507 #endif |
OLD | NEW |