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

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

Issue 2133413002: try to speed-up maprect + round2i + contains (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add dox 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
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"
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
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 /**
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
873 /** 895 /**
874 * Swap top/bottom or left/right if there are flipped (i.e. if width() 896 * 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 897 * 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 898 * if the edges are computed separately, and may have crossed over each
877 * other. When this returns, left <= right && top <= bottom 899 * other. When this returns, left <= right && top <= bottom
878 */ 900 */
879 void sort() { 901 void sort() {
880 if (fLeft > fRight) { 902 if (fLeft > fRight) {
881 SkTSwap<SkScalar>(fLeft, fRight); 903 SkTSwap<SkScalar>(fLeft, fRight);
882 } 904 }
(...skipping 13 matching lines...) Expand all
896 void dumpHex() const { this->dump(true); } 918 void dumpHex() const { this->dump(true); }
897 }; 919 };
898 920
899 inline bool SkIRect::contains(const SkRect& r) const { 921 inline bool SkIRect::contains(const SkRect& r) const {
900 return !r.isEmpty() && !this->isEmpty() && // check for empties 922 return !r.isEmpty() && !this->isEmpty() && // check for empties
901 (SkScalar)fLeft <= r.fLeft && (SkScalar)fTop <= r.fTop && 923 (SkScalar)fLeft <= r.fLeft && (SkScalar)fTop <= r.fTop &&
902 (SkScalar)fRight >= r.fRight && (SkScalar)fBottom >= r.fBottom; 924 (SkScalar)fRight >= r.fRight && (SkScalar)fBottom >= r.fBottom;
903 } 925 }
904 926
905 #endif 927 #endif
OLDNEW
« no previous file with comments | « gyp/tools.gyp ('k') | include/private/SkNx.h » ('j') | include/private/SkNx_sse.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698