diff options
author | whunt@chromium.org <whunt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-31 02:09:35 +0000 |
---|---|---|
committer | whunt@chromium.org <whunt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-31 02:09:35 +0000 |
commit | 854bfc1371e7eb0eb1a3d686504a27e7d0a8e557 (patch) | |
tree | 67058acb87ab400c1871473ac37f44daefaf3338 /ui/gfx/rect_f.h | |
parent | cae769ccb848f62ed3d6d1ac1499038f55d7cce9 (diff) | |
download | chromium_src-854bfc1371e7eb0eb1a3d686504a27e7d0a8e557.zip chromium_src-854bfc1371e7eb0eb1a3d686504a27e7d0a8e557.tar.gz chromium_src-854bfc1371e7eb0eb1a3d686504a27e7d0a8e557.tar.bz2 |
A host of micro-optimizations and a refactor of TimeForBoundsToIntersect
I used perf to profile the compositor thread and addressed performance problems
with the top fuctions. The result is about a 2.5x performance boost.
(~1.3ms -> ~.5ms) on List of Pokemon for UpdateTilePriorities.
Most of the optimizations are inlining small functions. The refactor of
TimeForBoundsToIntersect also eliminates many unnecessary float-double
conversions.
BUG=172406
Review URL: https://chromiumcodereview.appspot.com/12084031
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179770 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/rect_f.h')
-rw-r--r-- | ui/gfx/rect_f.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/ui/gfx/rect_f.h b/ui/gfx/rect_f.h index 78524a0..62bedf2 100644 --- a/ui/gfx/rect_f.h +++ b/ui/gfx/rect_f.h @@ -69,8 +69,15 @@ inline bool operator!=(const RectF& lhs, const RectF& rhs) { return !(lhs == rhs); } -UI_EXPORT RectF operator+(const RectF& lhs, const Vector2dF& rhs); -UI_EXPORT RectF operator-(const RectF& lhs, const Vector2dF& rhs); +inline RectF operator+(const RectF& lhs, const Vector2dF& rhs) { + return RectF(lhs.x() + rhs.x(), lhs.y() + rhs.y(), + lhs.width(), lhs.height()); +} + +inline RectF operator-(const RectF& lhs, const Vector2dF& rhs) { + return RectF(lhs.x() - rhs.x(), lhs.y() - rhs.y(), + lhs.width(), lhs.height()); +} inline RectF operator+(const Vector2dF& lhs, const RectF& rhs) { return rhs + lhs; @@ -79,7 +86,11 @@ inline RectF operator+(const Vector2dF& lhs, const RectF& rhs) { UI_EXPORT RectF IntersectRects(const RectF& a, const RectF& b); UI_EXPORT RectF UnionRects(const RectF& a, const RectF& b); UI_EXPORT RectF SubtractRects(const RectF& a, const RectF& b); -UI_EXPORT RectF ScaleRect(const RectF& r, float x_scale, float y_scale); + +inline RectF ScaleRect(const RectF& r, float x_scale, float y_scale) { + return RectF(r.x() * x_scale, r.y() * y_scale, + r.width() * x_scale, r.height() * y_scale); +} inline RectF ScaleRect(const RectF& r, float scale) { return ScaleRect(r, scale, scale); |