diff options
author | ajay.berwal@samsung.com <ajay.berwal@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-23 10:39:12 +0000 |
---|---|---|
committer | ajay.berwal@samsung.com <ajay.berwal@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-23 10:39:12 +0000 |
commit | 3244c913f7fc31c43107ffd895c786f26b892c07 (patch) | |
tree | 15f33a1820994df0998f7be8b89740f82dbde1ed /cc/input | |
parent | 8aaf0f58eb8b532a4190a55c753f4796d7515933 (diff) | |
download | chromium_src-3244c913f7fc31c43107ffd895c786f26b892c07.zip chromium_src-3244c913f7fc31c43107ffd895c786f26b892c07.tar.gz chromium_src-3244c913f7fc31c43107ffd895c786f26b892c07.tar.bz2 |
Pass gfx structs by const ref (gfx::Vector2dF)
Avoid unneccessary copy of structures gfx::Vector2dF
by passing them by const ref rather than value.
Any struct of size > 4 bytes should be passed by const ref.
Passing by ref for these structs is faster than passing
by value, especially when invoking function has multiple parameters.
Pass gfx structs by const ref (gfx::Vector2dF)
BUG=159273
Review URL: https://codereview.chromium.org/130443005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@246563 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/input')
-rw-r--r-- | cc/input/input_handler.h | 4 | ||||
-rw-r--r-- | cc/input/layer_scroll_offset_delegate.h | 4 | ||||
-rw-r--r-- | cc/input/page_scale_animation.cc | 16 | ||||
-rw-r--r-- | cc/input/page_scale_animation.h | 8 | ||||
-rw-r--r-- | cc/input/top_controls_manager.cc | 2 | ||||
-rw-r--r-- | cc/input/top_controls_manager.h | 2 |
6 files changed, 18 insertions, 18 deletions
diff --git a/cc/input/input_handler.h b/cc/input/input_handler.h index fde89d2..987f7a6 100644 --- a/cc/input/input_handler.h +++ b/cc/input/input_handler.h @@ -85,7 +85,7 @@ class CC_EXPORT InputHandler { // to the client. // Should only be called if ScrollBegin() returned ScrollStarted. virtual bool ScrollBy(gfx::Point viewport_point, - gfx::Vector2dF scroll_delta) = 0; + const gfx::Vector2dF& scroll_delta) = 0; virtual bool ScrollVerticallyByPage( gfx::Point viewport_point, @@ -95,7 +95,7 @@ class CC_EXPORT InputHandler { // ScrollIgnored if not. virtual ScrollStatus FlingScrollBegin() = 0; - virtual void NotifyCurrentFlingVelocity(gfx::Vector2dF velocity) = 0; + virtual void NotifyCurrentFlingVelocity(const gfx::Vector2dF& velocity) = 0; virtual void MouseMoveAt(gfx::Point mouse_position) = 0; diff --git a/cc/input/layer_scroll_offset_delegate.h b/cc/input/layer_scroll_offset_delegate.h index 1ee9736..034daab 100644 --- a/cc/input/layer_scroll_offset_delegate.h +++ b/cc/input/layer_scroll_offset_delegate.h @@ -19,11 +19,11 @@ class LayerScrollOffsetDelegate { public: // This is called by the compositor to notify the delegate what is the upper // total scroll offset bound. - virtual void SetMaxScrollOffset(gfx::Vector2dF max_scroll_offset) = 0; + virtual void SetMaxScrollOffset(const gfx::Vector2dF& max_scroll_offset) = 0; // This is called by the compositor when the scroll offset of the layer would // have otherwise changed. - virtual void SetTotalScrollOffset(gfx::Vector2dF new_value) = 0; + virtual void SetTotalScrollOffset(const gfx::Vector2dF& new_value) = 0; // This is called by the compositor to query the current scroll offset of the // layer. diff --git a/cc/input/page_scale_animation.cc b/cc/input/page_scale_animation.cc index 88b64d59..7df0244 100644 --- a/cc/input/page_scale_animation.cc +++ b/cc/input/page_scale_animation.cc @@ -16,22 +16,22 @@ namespace { // This takes a viewport-relative vector and returns a vector whose values are // between 0 and 1, representing the percentage position within the viewport. -gfx::Vector2dF NormalizeFromViewport(gfx::Vector2dF denormalized, +gfx::Vector2dF NormalizeFromViewport(const gfx::Vector2dF& denormalized, const gfx::SizeF& viewport_size) { return gfx::ScaleVector2d(denormalized, 1.f / viewport_size.width(), 1.f / viewport_size.height()); } -gfx::Vector2dF DenormalizeToViewport(gfx::Vector2dF normalized, +gfx::Vector2dF DenormalizeToViewport(const gfx::Vector2dF& normalized, const gfx::SizeF& viewport_size) { return gfx::ScaleVector2d(normalized, viewport_size.width(), viewport_size.height()); } -gfx::Vector2dF InterpolateBetween(gfx::Vector2dF start, - gfx::Vector2dF end, +gfx::Vector2dF InterpolateBetween(const gfx::Vector2dF& start, + const gfx::Vector2dF& end, float interp) { return start + gfx::ScaleVector2d(end - start, interp); } @@ -41,7 +41,7 @@ gfx::Vector2dF InterpolateBetween(gfx::Vector2dF start, namespace cc { scoped_ptr<PageScaleAnimation> PageScaleAnimation::Create( - gfx::Vector2dF start_scroll_offset, + const gfx::Vector2dF& start_scroll_offset, float start_page_scale_factor, const gfx::SizeF& viewport_size, const gfx::SizeF& root_layer_size, @@ -54,7 +54,7 @@ scoped_ptr<PageScaleAnimation> PageScaleAnimation::Create( } PageScaleAnimation::PageScaleAnimation( - gfx::Vector2dF start_scroll_offset, + const gfx::Vector2dF& start_scroll_offset, float start_page_scale_factor, const gfx::SizeF& viewport_size, const gfx::SizeF& root_layer_size, @@ -72,7 +72,7 @@ PageScaleAnimation::PageScaleAnimation( PageScaleAnimation::~PageScaleAnimation() {} -void PageScaleAnimation::ZoomTo(gfx::Vector2dF target_scroll_offset, +void PageScaleAnimation::ZoomTo(const gfx::Vector2dF& target_scroll_offset, float target_page_scale_factor, double duration) { target_page_scale_factor_ = target_page_scale_factor; @@ -92,7 +92,7 @@ void PageScaleAnimation::ZoomTo(gfx::Vector2dF target_scroll_offset, start_anchor_ = target_anchor_; } -void PageScaleAnimation::ZoomWithAnchor(gfx::Vector2dF anchor, +void PageScaleAnimation::ZoomWithAnchor(const gfx::Vector2dF& anchor, float target_page_scale_factor, double duration) { start_anchor_ = anchor; diff --git a/cc/input/page_scale_animation.h b/cc/input/page_scale_animation.h index f2e315d..c7856e1 100644 --- a/cc/input/page_scale_animation.h +++ b/cc/input/page_scale_animation.h @@ -25,7 +25,7 @@ class PageScaleAnimation { public: // Construct with the state at the beginning of the animation. static scoped_ptr<PageScaleAnimation> Create( - gfx::Vector2dF start_scroll_offset, + const gfx::Vector2dF& start_scroll_offset, float start_page_scale_factor, const gfx::SizeF& viewport_size, const gfx::SizeF& root_layer_size, @@ -37,7 +37,7 @@ class PageScaleAnimation { // immediately after construction to set the final scroll and page scale. // Zoom while explicitly specifying the top-left scroll position. - void ZoomTo(gfx::Vector2dF target_scroll_offset, + void ZoomTo(const gfx::Vector2dF& target_scroll_offset, float target_page_scale_factor, double duration); @@ -45,7 +45,7 @@ class PageScaleAnimation { // at the same position on the physical display throughout the animation, // unless the edges of the root layer are hit. The anchor is specified // as an offset from the content layer. - void ZoomWithAnchor(gfx::Vector2dF anchor, + void ZoomWithAnchor(const gfx::Vector2dF& anchor, float target_page_scale_factor, double duration); @@ -69,7 +69,7 @@ class PageScaleAnimation { float target_page_scale_factor() const { return target_page_scale_factor_; } protected: - PageScaleAnimation(gfx::Vector2dF start_scroll_offset, + PageScaleAnimation(const gfx::Vector2dF& start_scroll_offset, float start_page_scale_factor, const gfx::SizeF& viewport_size, const gfx::SizeF& root_layer_size, diff --git a/cc/input/top_controls_manager.cc b/cc/input/top_controls_manager.cc index 871d9e6..07a9e19 100644 --- a/cc/input/top_controls_manager.cc +++ b/cc/input/top_controls_manager.cc @@ -98,7 +98,7 @@ void TopControlsManager::ScrollBegin() { } gfx::Vector2dF TopControlsManager::ScrollBy( - const gfx::Vector2dF pending_delta) { + const gfx::Vector2dF& pending_delta) { if (pinch_gesture_active_) return pending_delta; diff --git a/cc/input/top_controls_manager.h b/cc/input/top_controls_manager.h index 246efba..7d631d8 100644 --- a/cc/input/top_controls_manager.h +++ b/cc/input/top_controls_manager.h @@ -53,7 +53,7 @@ class CC_EXPORT TopControlsManager bool animate); void ScrollBegin(); - gfx::Vector2dF ScrollBy(const gfx::Vector2dF pending_delta); + gfx::Vector2dF ScrollBy(const gfx::Vector2dF& pending_delta); void ScrollEnd(); // The caller should ensure that |Pinch{Begin,End}| are called within |