diff options
author | Chris Craik <ccraik@google.com> | 2015-06-30 17:56:13 -0700 |
---|---|---|
committer | Chris Craik <ccraik@google.com> | 2015-06-30 17:58:21 -0700 |
commit | df72b63928cc1492b72ba9a4e99d5e714f93ccc6 (patch) | |
tree | 38b94479dabc9aea2dfcde3a64348c51bc39cecf /libs/hwui/Rect.h | |
parent | 82b3f67711246ad5beaf7702ce16e9d433406d1e (diff) |
Switch from fminf/fmaxf to std::min/max
bug:22208220
Shows considerable improvement in performance, especially in tight
loops.
Change-Id: I4bcf6584a3c145bfc55e73c9c73dcf6199290b3c
Diffstat (limited to 'libs/hwui/Rect.h')
-rw-r--r-- | libs/hwui/Rect.h | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/libs/hwui/Rect.h b/libs/hwui/Rect.h index c82082fe9727..4c4cd3da3be4 100644 --- a/libs/hwui/Rect.h +++ b/libs/hwui/Rect.h @@ -18,6 +18,7 @@ #define ANDROID_HWUI_RECT_H #include <cmath> +#include <algorithm> #include <SkRect.h> #include <utils/Log.h> @@ -246,17 +247,17 @@ public: } void expandToCoverVertex(float x, float y) { - left = fminf(left, x); - top = fminf(top, y); - right = fmaxf(right, x); - bottom = fmaxf(bottom, y); + left = std::min(left, x); + top = std::min(top, y); + right = std::max(right, x); + bottom = std::max(bottom, y); } void expandToCoverRect(float otherLeft, float otherTop, float otherRight, float otherBottom) { - left = fminf(left, otherLeft); - top = fminf(top, otherTop); - right = fmaxf(right, otherRight); - bottom = fmaxf(bottom, otherBottom); + left = std::min(left, otherLeft); + top = std::min(top, otherTop); + right = std::max(right, otherRight); + bottom = std::max(bottom, otherBottom); } SkRect toSkRect() const { @@ -273,18 +274,18 @@ public: private: void intersectWith(Rect& tmp) const { - tmp.left = fmaxf(left, tmp.left); - tmp.top = fmaxf(top, tmp.top); - tmp.right = fminf(right, tmp.right); - tmp.bottom = fminf(bottom, tmp.bottom); + tmp.left = std::max(left, tmp.left); + tmp.top = std::max(top, tmp.top); + tmp.right = std::min(right, tmp.right); + tmp.bottom = std::min(bottom, tmp.bottom); } Rect intersectWith(float l, float t, float r, float b) const { Rect tmp; - tmp.left = fmaxf(left, l); - tmp.top = fmaxf(top, t); - tmp.right = fminf(right, r); - tmp.bottom = fminf(bottom, b); + tmp.left = std::max(left, l); + tmp.top = std::max(top, t); + tmp.right = std::min(right, r); + tmp.bottom = std::min(bottom, b); return tmp; } |