Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Side by Side Diff: include/core/SkRect.h

Issue 2136343002: Revert of try to speed-up maprect + round2i + contains (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gyp/tools.gyp ('k') | include/private/SkNx.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
14 13
15 struct SkRect; 14 struct SkRect;
16 15
17 /** \struct SkIRect 16 /** \struct SkIRect
18 17
19 SkIRect holds four 32 bit integer coordinates for a rectangle 18 SkIRect holds four 32 bit integer coordinates for a rectangle
20 */ 19 */
21 struct SK_API SkIRect { 20 struct SK_API SkIRect {
22 int32_t fLeft, fTop, fRight, fBottom; 21 int32_t fLeft, fTop, fRight, fBottom;
23 22
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 this->round(&ir); 862 this->round(&ir);
864 return ir; 863 return ir;
865 } 864 }
866 865
867 //! Returns the result of calling roundOut(&dst) 866 //! Returns the result of calling roundOut(&dst)
868 SkIRect roundOut() const { 867 SkIRect roundOut() const {
869 SkIRect ir; 868 SkIRect ir;
870 this->roundOut(&ir); 869 this->roundOut(&ir);
871 return ir; 870 return ir;
872 } 871 }
873 872
874 /**
875 * Round the rect's values and return the result as a new SkIRect.
876 * This follows the same semantics as SkScalarRoundToInt().
877 */
878 SkIRect round2i() const {
879 SkIRect dst;
880 Sk4s rd = (Sk4s::Load(&fLeft) + Sk4s(0.5)).floor();
881 SkNx_cast<int32_t>(rd).store(&dst.fLeft);
882 return dst;
883 }
884
885 /**
886 * Round the rect's values and return the result as a new SkRect.
887 * This follows the same semantics as SkScalarRoundToScalar().
888 */
889 SkRect round2s() const {
890 SkRect dst;
891 (Sk4s::Load(&fLeft) + Sk4s(0.5)).floor().store(&dst.fLeft);
892 return dst;
893 }
894
895 /** 873 /**
896 * Swap top/bottom or left/right if there are flipped (i.e. if width() 874 * Swap top/bottom or left/right if there are flipped (i.e. if width()
897 * or height() would have returned a negative value.) This should be called 875 * or height() would have returned a negative value.) This should be called
898 * if the edges are computed separately, and may have crossed over each 876 * if the edges are computed separately, and may have crossed over each
899 * other. When this returns, left <= right && top <= bottom 877 * other. When this returns, left <= right && top <= bottom
900 */ 878 */
901 void sort() { 879 void sort() {
902 if (fLeft > fRight) { 880 if (fLeft > fRight) {
903 SkTSwap<SkScalar>(fLeft, fRight); 881 SkTSwap<SkScalar>(fLeft, fRight);
904 } 882 }
(...skipping 13 matching lines...) Expand all
918 void dumpHex() const { this->dump(true); } 896 void dumpHex() const { this->dump(true); }
919 }; 897 };
920 898
921 inline bool SkIRect::contains(const SkRect& r) const { 899 inline bool SkIRect::contains(const SkRect& r) const {
922 return !r.isEmpty() && !this->isEmpty() && // check for empties 900 return !r.isEmpty() && !this->isEmpty() && // check for empties
923 (SkScalar)fLeft <= r.fLeft && (SkScalar)fTop <= r.fTop && 901 (SkScalar)fLeft <= r.fLeft && (SkScalar)fTop <= r.fTop &&
924 (SkScalar)fRight >= r.fRight && (SkScalar)fBottom >= r.fBottom; 902 (SkScalar)fRight >= r.fRight && (SkScalar)fBottom >= r.fBottom;
925 } 903 }
926 904
927 #endif 905 #endif
OLDNEW
« no previous file with comments | « gyp/tools.gyp ('k') | include/private/SkNx.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698