OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
4 * | 3 * |
5 * 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 |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 | |
10 #ifndef SkRect_DEFINED | 8 #ifndef SkRect_DEFINED |
11 #define SkRect_DEFINED | 9 #define SkRect_DEFINED |
12 | 10 |
13 #include "SkPoint.h" | 11 #include "SkPoint.h" |
14 #include "SkSize.h" | 12 #include "SkSize.h" |
15 | 13 |
16 /** \struct SkIRect | 14 /** \struct SkIRect |
17 | 15 |
18 SkIRect holds four 32 bit integer coordinates for a rectangle | 16 SkIRect holds four 32 bit integer coordinates for a rectangle |
19 */ | 17 */ |
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 this->round(&ir); | 833 this->round(&ir); |
836 return ir; | 834 return ir; |
837 } | 835 } |
838 | 836 |
839 /** | 837 /** |
840 * Swap top/bottom or left/right if there are flipped (i.e. if width() | 838 * Swap top/bottom or left/right if there are flipped (i.e. if width() |
841 * or height() would have returned a negative value.) This should be called | 839 * or height() would have returned a negative value.) This should be called |
842 * if the edges are computed separately, and may have crossed over each | 840 * if the edges are computed separately, and may have crossed over each |
843 * other. When this returns, left <= right && top <= bottom | 841 * other. When this returns, left <= right && top <= bottom |
844 */ | 842 */ |
845 void sort(); | 843 void sort() { |
| 844 SkScalar min = SkMinScalar(fLeft, fRight); |
| 845 SkScalar max = SkMaxScalar(fLeft, fRight); |
| 846 fLeft = min; |
| 847 fRight = max; |
| 848 |
| 849 min = SkMinScalar(fTop, fBottom); |
| 850 max = SkMaxScalar(fTop, fBottom); |
| 851 fTop = min; |
| 852 fBottom = max; |
| 853 } |
846 | 854 |
847 /** | 855 /** |
848 * cast-safe way to treat the rect as an array of (4) SkScalars. | 856 * cast-safe way to treat the rect as an array of (4) SkScalars. |
849 */ | 857 */ |
850 const SkScalar* asScalars() const { return &fLeft; } | 858 const SkScalar* asScalars() const { return &fLeft; } |
851 | 859 |
852 #ifdef SK_DEVELOPER | 860 #ifdef SK_DEVELOPER |
853 /** | 861 /** |
854 * Dumps the rect using SkDebugf. This is intended for Skia development debu
gging. Don't | 862 * Dumps the rect using SkDebugf. This is intended for Skia development debu
gging. Don't |
855 * rely on the existence of this function or the formatting of its output. | 863 * rely on the existence of this function or the formatting of its output. |
856 */ | 864 */ |
857 void dump() const { | 865 void dump() const { |
858 SkDebugf("{ l: %f, t: %f, r: %f, b: %f }", fLeft, fTop, fRight, fBottom)
; | 866 SkDebugf("{ l: %f, t: %f, r: %f, b: %f }", fLeft, fTop, fRight, fBottom)
; |
859 } | 867 } |
860 #endif | 868 #endif |
861 | 869 |
862 }; | 870 }; |
863 | 871 |
864 #endif | 872 #endif |
OLD | NEW |