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 |
11 #include "SkPoint.h" | 11 #include "SkPoint.h" |
12 #include "SkSize.h" | 12 #include "SkSize.h" |
13 #include "../private/SkNx.h" | |
13 | 14 |
14 struct SkRect; | 15 struct SkRect; |
15 | 16 |
16 /** \struct SkIRect | 17 /** \struct SkIRect |
17 | 18 |
18 SkIRect holds four 32 bit integer coordinates for a rectangle | 19 SkIRect holds four 32 bit integer coordinates for a rectangle |
19 */ | 20 */ |
20 struct SK_API SkIRect { | 21 struct SK_API SkIRect { |
21 int32_t fLeft, fTop, fRight, fBottom; | 22 int32_t fLeft, fTop, fRight, fBottom; |
22 | 23 |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
862 this->round(&ir); | 863 this->round(&ir); |
863 return ir; | 864 return ir; |
864 } | 865 } |
865 | 866 |
866 //! Returns the result of calling roundOut(&dst) | 867 //! Returns the result of calling roundOut(&dst) |
867 SkIRect roundOut() const { | 868 SkIRect roundOut() const { |
868 SkIRect ir; | 869 SkIRect ir; |
869 this->roundOut(&ir); | 870 this->roundOut(&ir); |
870 return ir; | 871 return ir; |
871 } | 872 } |
872 | 873 |
874 SkIRect round2i() const { | |
msarett
2016/07/11 12:50:06
On Intel this disassembles to roundps and cvtt?
T
| |
875 SkIRect dst; | |
876 Sk4s rd = (Sk4s::Load(&fLeft) + Sk4s(0.5)).floor(); | |
msarett
2016/07/11 12:50:06
Why call floor when the cast will floor anyway?
mtklein
2016/07/11 13:39:13
We've got to make sure we're careful to distinguis
| |
877 SkNx_cast<int32_t>(rd).store(&dst.fLeft); | |
878 return dst; | |
879 } | |
880 | |
881 SkRect round2s() const { | |
882 SkRect dst; | |
883 (Sk4s::Load(&fLeft) + Sk4s(0.5)).floor().store(&dst.fLeft); | |
884 return dst; | |
885 } | |
886 | |
873 /** | 887 /** |
874 * Swap top/bottom or left/right if there are flipped (i.e. if width() | 888 * Swap top/bottom or left/right if there are flipped (i.e. if width() |
875 * or height() would have returned a negative value.) This should be called | 889 * or height() would have returned a negative value.) This should be called |
876 * if the edges are computed separately, and may have crossed over each | 890 * if the edges are computed separately, and may have crossed over each |
877 * other. When this returns, left <= right && top <= bottom | 891 * other. When this returns, left <= right && top <= bottom |
878 */ | 892 */ |
879 void sort() { | 893 void sort() { |
880 if (fLeft > fRight) { | 894 if (fLeft > fRight) { |
881 SkTSwap<SkScalar>(fLeft, fRight); | 895 SkTSwap<SkScalar>(fLeft, fRight); |
882 } | 896 } |
(...skipping 13 matching lines...) Expand all Loading... | |
896 void dumpHex() const { this->dump(true); } | 910 void dumpHex() const { this->dump(true); } |
897 }; | 911 }; |
898 | 912 |
899 inline bool SkIRect::contains(const SkRect& r) const { | 913 inline bool SkIRect::contains(const SkRect& r) const { |
900 return !r.isEmpty() && !this->isEmpty() && // check for empties | 914 return !r.isEmpty() && !this->isEmpty() && // check for empties |
901 (SkScalar)fLeft <= r.fLeft && (SkScalar)fTop <= r.fTop && | 915 (SkScalar)fLeft <= r.fLeft && (SkScalar)fTop <= r.fTop && |
902 (SkScalar)fRight >= r.fRight && (SkScalar)fBottom >= r.fBottom; | 916 (SkScalar)fRight >= r.fRight && (SkScalar)fBottom >= r.fBottom; |
903 } | 917 } |
904 | 918 |
905 #endif | 919 #endif |
OLD | NEW |