| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 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 #ifndef SkRect_DEFINED | 8 #ifndef SkRect_DEFINED |
| 9 #define SkRect_DEFINED | 9 #define SkRect_DEFINED |
| 10 | 10 |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 * Set the dst rectangle by rounding "out" this rectangle, choosing the | 796 * Set the dst rectangle by rounding "out" this rectangle, choosing the |
| 797 * SkScalarFloor of top and left, and the SkScalarCeil of right and bottom. | 797 * SkScalarFloor of top and left, and the SkScalarCeil of right and bottom. |
| 798 */ | 798 */ |
| 799 void roundOut(SkIRect* dst) const { | 799 void roundOut(SkIRect* dst) const { |
| 800 SkASSERT(dst); | 800 SkASSERT(dst); |
| 801 dst->set(SkScalarFloorToInt(fLeft), SkScalarFloorToInt(fTop), | 801 dst->set(SkScalarFloorToInt(fLeft), SkScalarFloorToInt(fTop), |
| 802 SkScalarCeilToInt(fRight), SkScalarCeilToInt(fBottom)); | 802 SkScalarCeilToInt(fRight), SkScalarCeilToInt(fBottom)); |
| 803 } | 803 } |
| 804 | 804 |
| 805 /** | 805 /** |
| 806 * Expand this rectangle by rounding its coordinates "out", choosing the | 806 * Set the dst rectangle by rounding "out" this rectangle, choosing the |
| 807 * floor of top and left, and the ceil of right and bottom. If this rect | 807 * SkScalarFloorToScalar of top and left, and the SkScalarCeilToScalar of r
ight and bottom. |
| 808 * is already on integer coordinates, then it will be unchanged. | |
| 809 * | 808 * |
| 810 * It is safe for this == dst | 809 * It is safe for this == dst |
| 811 */ | 810 */ |
| 812 void roundOut(SkRect* dst) const { | 811 void roundOut(SkRect* dst) const { |
| 813 dst->set(SkScalarFloorToScalar(fLeft), | 812 dst->set(SkScalarFloorToScalar(fLeft), |
| 814 SkScalarFloorToScalar(fTop), | 813 SkScalarFloorToScalar(fTop), |
| 815 SkScalarCeilToScalar(fRight), | 814 SkScalarCeilToScalar(fRight), |
| 816 SkScalarCeilToScalar(fBottom)); | 815 SkScalarCeilToScalar(fBottom)); |
| 817 } | 816 } |
| 818 | 817 |
| 819 /** | 818 /** |
| 820 * Set the dst rectangle by rounding "in" this rectangle, choosing the | 819 * Set the dst rectangle by rounding "in" this rectangle, choosing the |
| 821 * ceil of top and left, and the floor of right and bottom. This does *not* | 820 * ceil of top and left, and the floor of right and bottom. This does *not* |
| 822 * call sort(), so it is possible that the resulting rect is inverted... | 821 * call sort(), so it is possible that the resulting rect is inverted... |
| 823 * e.g. left >= right or top >= bottom. Call isEmpty() to detect that. | 822 * e.g. left >= right or top >= bottom. Call isEmpty() to detect that. |
| 824 */ | 823 */ |
| 825 void roundIn(SkIRect* dst) const { | 824 void roundIn(SkIRect* dst) const { |
| 826 SkASSERT(dst); | 825 SkASSERT(dst); |
| 827 dst->set(SkScalarCeilToInt(fLeft), SkScalarCeilToInt(fTop), | 826 dst->set(SkScalarCeilToInt(fLeft), SkScalarCeilToInt(fTop), |
| 828 SkScalarFloorToInt(fRight), SkScalarFloorToInt(fBottom)); | 827 SkScalarFloorToInt(fRight), SkScalarFloorToInt(fBottom)); |
| 829 } | 828 } |
| 830 | 829 |
| 831 /** | 830 //! Returns the result of calling round(&dst) |
| 832 * Return a new SkIRect which is contains the rounded coordinates of this | |
| 833 * rect using SkScalarRoundToInt. | |
| 834 */ | |
| 835 SkIRect round() const { | 831 SkIRect round() const { |
| 836 SkIRect ir; | 832 SkIRect ir; |
| 837 this->round(&ir); | 833 this->round(&ir); |
| 838 return ir; | 834 return ir; |
| 839 } | 835 } |
| 840 | 836 |
| 837 //! Returns the result of calling roundOut(&dst) |
| 838 SkIRect roundOut() const { |
| 839 SkIRect ir; |
| 840 this->roundOut(&ir); |
| 841 return ir; |
| 842 } |
| 843 |
| 841 /** | 844 /** |
| 842 * Swap top/bottom or left/right if there are flipped (i.e. if width() | 845 * Swap top/bottom or left/right if there are flipped (i.e. if width() |
| 843 * or height() would have returned a negative value.) This should be called | 846 * or height() would have returned a negative value.) This should be called |
| 844 * if the edges are computed separately, and may have crossed over each | 847 * if the edges are computed separately, and may have crossed over each |
| 845 * other. When this returns, left <= right && top <= bottom | 848 * other. When this returns, left <= right && top <= bottom |
| 846 */ | 849 */ |
| 847 void sort() { | 850 void sort() { |
| 848 if (fLeft > fRight) { | 851 if (fLeft > fRight) { |
| 849 SkTSwap<SkScalar>(fLeft, fRight); | 852 SkTSwap<SkScalar>(fLeft, fRight); |
| 850 } | 853 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 865 * rely on the existence of this function or the formatting of its output. | 868 * rely on the existence of this function or the formatting of its output. |
| 866 */ | 869 */ |
| 867 void dump() const { | 870 void dump() const { |
| 868 SkDebugf("{ l: %f, t: %f, r: %f, b: %f }", fLeft, fTop, fRight, fBottom)
; | 871 SkDebugf("{ l: %f, t: %f, r: %f, b: %f }", fLeft, fTop, fRight, fBottom)
; |
| 869 } | 872 } |
| 870 #endif | 873 #endif |
| 871 | 874 |
| 872 }; | 875 }; |
| 873 | 876 |
| 874 #endif | 877 #endif |
| OLD | NEW |