OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "sk_tool_utils.h" | 8 #include "sk_tool_utils.h" |
9 #include "sk_tool_utils_flags.h" | 9 #include "sk_tool_utils_flags.h" |
10 | 10 |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 if (!radii.isZero()) { | 506 if (!radii.isZero()) { |
507 SkPoint p = intersection(radii.fX, radii.fY); | 507 SkPoint p = intersection(radii.fX, radii.fY); |
508 | 508 |
509 newL = SkTMax(newL, r.fLeft + radii.fX - p.fX); | 509 newL = SkTMax(newL, r.fLeft + radii.fX - p.fX); |
510 newB = SkTMin(newB, r.fBottom - radii.fY + p.fY); | 510 newB = SkTMin(newB, r.fBottom - radii.fY + p.fY); |
511 } | 511 } |
512 | 512 |
513 return SkRect::MakeLTRB(newL, newT, newR, newB); | 513 return SkRect::MakeLTRB(newL, newT, newR, newB); |
514 } | 514 } |
515 | 515 |
| 516 // The widest inset rect |
| 517 SkRect compute_widest_occluder(const SkRRect& rr) { |
| 518 const SkRect& r = rr.getBounds(); |
| 519 |
| 520 const SkVector& ul = rr.radii(SkRRect::kUpperLeft_Corner); |
| 521 const SkVector& ur = rr.radii(SkRRect::kUpperRight_Corner); |
| 522 const SkVector& lr = rr.radii(SkRRect::kLowerRight_Corner); |
| 523 const SkVector& ll = rr.radii(SkRRect::kLowerLeft_Corner); |
| 524 |
| 525 SkScalar maxT = SkTMax(ul.fY, ur.fY); |
| 526 SkScalar maxB = SkTMax(ll.fY, lr.fY); |
| 527 |
| 528 return SkRect::MakeLTRB(r.fLeft, r.fTop + maxT, r.fRight, r.fBottom - maxB); |
| 529 |
| 530 } |
| 531 |
| 532 // The tallest inset rect |
| 533 SkRect compute_tallest_occluder(const SkRRect& rr) { |
| 534 const SkRect& r = rr.getBounds(); |
| 535 |
| 536 const SkVector& ul = rr.radii(SkRRect::kUpperLeft_Corner); |
| 537 const SkVector& ur = rr.radii(SkRRect::kUpperRight_Corner); |
| 538 const SkVector& lr = rr.radii(SkRRect::kLowerRight_Corner); |
| 539 const SkVector& ll = rr.radii(SkRRect::kLowerLeft_Corner); |
| 540 |
| 541 SkScalar maxL = SkTMax(ul.fX, ll.fX); |
| 542 SkScalar maxR = SkTMax(ur.fX, lr.fX); |
| 543 |
| 544 return SkRect::MakeLTRB(r.fLeft + maxL, r.fTop, r.fRight - maxR, r.fBottom); |
| 545 } |
| 546 |
| 547 |
516 } // namespace sk_tool_utils | 548 } // namespace sk_tool_utils |
OLD | NEW |