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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
351 tmp[3].fX = clip.fRight; | 351 tmp[3].fX = clip.fRight; |
352 clamp_le(tmp[2].fX, clip.fRight); | 352 clamp_le(tmp[2].fX, clip.fRight); |
353 | 353 |
354 this->appendCubic(tmp, reverse); | 354 this->appendCubic(tmp, reverse); |
355 this->appendVLine(clip.fRight, tmp[3].fY, tmp[6].fY, reverse); | 355 this->appendVLine(clip.fRight, tmp[3].fY, tmp[6].fY, reverse); |
356 } else { // wholly inside the clip | 356 } else { // wholly inside the clip |
357 this->appendCubic(pts, reverse); | 357 this->appendCubic(pts, reverse); |
358 } | 358 } |
359 } | 359 } |
360 | 360 |
361 static bool quick_reject_in_y(const SkPoint pts[4], const SkRect& clip) { | |
mtklein
2015/12/17 14:58:15
Just for fun, let's compare speed with
SkScalar
| |
362 Sk4s ys(pts[0].fY, pts[1].fY, pts[2].fY, pts[3].fY); | |
363 Sk4s t(clip.top()); | |
364 Sk4s b(clip.bottom()); | |
365 | |
366 return (ys < t).allTrue() || (ys > b).allTrue(); | |
367 } | |
368 | |
361 bool SkEdgeClipper::clipCubic(const SkPoint srcPts[4], const SkRect& clip) { | 369 bool SkEdgeClipper::clipCubic(const SkPoint srcPts[4], const SkRect& clip) { |
362 fCurrPoint = fPoints; | 370 fCurrPoint = fPoints; |
363 fCurrVerb = fVerbs; | 371 fCurrVerb = fVerbs; |
364 | 372 |
365 SkRect bounds; | 373 if (!quick_reject_in_y(srcPts, clip)) { |
366 bounds.set(srcPts, 4); | |
367 | |
368 if (!quick_reject(bounds, clip)) { | |
369 SkPoint monoY[10]; | 374 SkPoint monoY[10]; |
370 int countY = SkChopCubicAtYExtrema(srcPts, monoY); | 375 int countY = SkChopCubicAtYExtrema(srcPts, monoY); |
371 for (int y = 0; y <= countY; y++) { | 376 for (int y = 0; y <= countY; y++) { |
372 SkPoint monoX[10]; | 377 SkPoint monoX[10]; |
373 int countX = SkChopCubicAtXExtrema(&monoY[y * 3], monoX); | 378 int countX = SkChopCubicAtXExtrema(&monoY[y * 3], monoX); |
374 for (int x = 0; x <= countX; x++) { | 379 for (int x = 0; x <= countX; x++) { |
375 this->clipMonoCubic(&monoX[x * 3], clip); | 380 this->clipMonoCubic(&monoX[x * 3], clip); |
376 SkASSERT(fCurrVerb - fVerbs < kMaxVerbs); | 381 SkASSERT(fCurrVerb - fVerbs < kMaxVerbs); |
377 SkASSERT(fCurrPoint - fPoints <= kMaxPoints); | 382 SkASSERT(fCurrPoint - fPoints <= kMaxPoints); |
378 } | 383 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
478 assert_monotonic(&pts[0].fY, count); | 483 assert_monotonic(&pts[0].fY, count); |
479 } | 484 } |
480 } | 485 } |
481 | 486 |
482 void sk_assert_monotonic_x(const SkPoint pts[], int count) { | 487 void sk_assert_monotonic_x(const SkPoint pts[], int count) { |
483 if (count > 1) { | 488 if (count > 1) { |
484 assert_monotonic(&pts[0].fX, count); | 489 assert_monotonic(&pts[0].fX, count); |
485 } | 490 } |
486 } | 491 } |
487 #endif | 492 #endif |
OLD | NEW |