OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 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 #ifndef SkRect_DEFINED | 10 #ifndef SkRect_DEFINED |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 */ | 695 */ |
696 void join(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom); | 696 void join(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom); |
697 | 697 |
698 /** Update this rectangle to enclose itself and the specified rectangle. | 698 /** Update this rectangle to enclose itself and the specified rectangle. |
699 If this rectangle is empty, just set it to the specified rectangle. If t
he specified | 699 If this rectangle is empty, just set it to the specified rectangle. If t
he specified |
700 rectangle is empty, do nothing. | 700 rectangle is empty, do nothing. |
701 */ | 701 */ |
702 void join(const SkRect& r) { | 702 void join(const SkRect& r) { |
703 this->join(r.fLeft, r.fTop, r.fRight, r.fBottom); | 703 this->join(r.fLeft, r.fTop, r.fRight, r.fBottom); |
704 } | 704 } |
705 // alias for join() | 705 |
706 void growToInclude(const SkRect& r) { this->join(r); } | 706 void joinNonEmptyArg(const SkRect& r) { |
| 707 SkASSERT(!r.isEmpty()); |
| 708 // if we are empty, just assign |
| 709 if (fLeft >= fRight || fTop >= fBottom) { |
| 710 *this = r; |
| 711 } else { |
| 712 fLeft = SkMinScalar(fLeft, r.left()); |
| 713 fTop = SkMinScalar(fTop, r.top()); |
| 714 fRight = SkMaxScalar(fRight, r.right()); |
| 715 fBottom = SkMaxScalar(fBottom, r.bottom()); |
| 716 } |
| 717 } |
707 | 718 |
708 /** | 719 /** |
709 * Grow the rect to include the specified (x,y). After this call, the | 720 * Grow the rect to include the specified (x,y). After this call, the |
710 * following will be true: fLeft <= x <= fRight && fTop <= y <= fBottom. | 721 * following will be true: fLeft <= x <= fRight && fTop <= y <= fBottom. |
711 * | 722 * |
712 * This is close, but not quite the same contract as contains(), since | 723 * This is close, but not quite the same contract as contains(), since |
713 * contains() treats the left and top different from the right and bottom. | 724 * contains() treats the left and top different from the right and bottom. |
714 * contains(x,y) -> fLeft <= x < fRight && fTop <= y < fBottom. Also note | 725 * contains(x,y) -> fLeft <= x < fRight && fTop <= y < fBottom. Also note |
715 * that contains(x,y) always returns false if the rect is empty. | 726 * that contains(x,y) always returns false if the rect is empty. |
716 */ | 727 */ |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 * rely on the existence of this function or the formatting of its output. | 849 * rely on the existence of this function or the formatting of its output. |
839 */ | 850 */ |
840 void dump() const { | 851 void dump() const { |
841 SkDebugf("{ l: %f, t: %f, r: %f, b: %f }", fLeft, fTop, fRight, fBottom)
; | 852 SkDebugf("{ l: %f, t: %f, r: %f, b: %f }", fLeft, fTop, fRight, fBottom)
; |
842 } | 853 } |
843 #endif | 854 #endif |
844 | 855 |
845 }; | 856 }; |
846 | 857 |
847 #endif | 858 #endif |
OLD | NEW |