summaryrefslogtreecommitdiffstats
path: root/ui/gfx
diff options
context:
space:
mode:
authorwhunt@chromium.org <whunt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-02 01:51:58 +0000
committerwhunt@chromium.org <whunt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-02 01:51:58 +0000
commita3bca5f30e0148527b5a2268fb2b4457e3c3d88a (patch)
tree38f0ae322deb235be1a24ed0a4e9b9334e04cefa /ui/gfx
parentdc6c55257f665c63e3fd10fa3610bd097ec1e880 (diff)
downloadchromium_src-a3bca5f30e0148527b5a2268fb2b4457e3c3d88a.zip
chromium_src-a3bca5f30e0148527b5a2268fb2b4457e3c3d88a.tar.gz
chromium_src-a3bca5f30e0148527b5a2268fb2b4457e3c3d88a.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 NOTRY=true Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=179770 Review URL: https://chromiumcodereview.appspot.com/12084031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180229 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx')
-rw-r--r--ui/gfx/rect_f.cc18
-rw-r--r--ui/gfx/rect_f.h17
2 files changed, 14 insertions, 21 deletions
diff --git a/ui/gfx/rect_f.cc b/ui/gfx/rect_f.cc
index d7b1089..0f055e1 100644
--- a/ui/gfx/rect_f.cc
+++ b/ui/gfx/rect_f.cc
@@ -31,18 +31,6 @@ std::string RectF::ToString() const {
size().ToString().c_str());
}
-RectF operator+(const RectF& lhs, const Vector2dF& rhs) {
- RectF result(lhs);
- result += rhs;
- return result;
-}
-
-RectF operator-(const RectF& lhs, const Vector2dF& rhs) {
- RectF result(lhs);
- result -= rhs;
- return result;
-}
-
RectF IntersectRects(const RectF& a, const RectF& b) {
RectF result = a;
result.Intersect(b);
@@ -61,12 +49,6 @@ RectF SubtractRects(const RectF& a, const RectF& b) {
return result;
}
-RectF ScaleRect(const RectF& r, float x_scale, float y_scale) {
- RectF result = r;
- result.Scale(x_scale, y_scale);
- return result;
-}
-
RectF BoundingRect(const PointF& p1, const PointF& p2) {
float rx = std::min(p1.x(), p2.x());
float ry = std::min(p1.y(), p2.y());
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);