summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsataya.m@samsung.com <sataya.m@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-26 22:44:34 +0000
committersataya.m@samsung.com <sataya.m@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-26 22:44:34 +0000
commit485a42dc330297c829dd08da2798e5df35e88aa9 (patch)
tree91e592104e4f058d6e2f3eefd9298bfd77c68a56
parentff5d96c501ce41f1314f83adf1fdc600d36561dd (diff)
downloadchromium_src-485a42dc330297c829dd08da2798e5df35e88aa9.zip
chromium_src-485a42dc330297c829dd08da2798e5df35e88aa9.tar.gz
chromium_src-485a42dc330297c829dd08da2798e5df35e88aa9.tar.bz2
Avoid unnecessary gloweffect calls
When there's some overscroll in the x axis (getting us past the rounding check) and an epsilon of overscroll in the y axis due to numerical error, this later convinces OverscrollGlow to trigger the fling glow in that direction. The Rounded check only protected us against epsilons in *both* directions. Replace this with removing the epsilon explicitly in unused_scroll_delta. BUG=354325 Review URL: https://codereview.chromium.org/206153002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259729 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--AUTHORS1
-rw-r--r--cc/trees/layer_tree_host_impl.cc10
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc36
3 files changed, 45 insertions, 2 deletions
diff --git a/AUTHORS b/AUTHORS
index f1e25bf..a1e27b3 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -315,6 +315,7 @@ Song YeWen <ffmpeg@gmail.com>
Soren Dreijer <dreijerbit@gmail.com>
Stephen Searles <stephen.searles@gmail.com>
Steven Pennington <spenn@engr.uvic.ca>
+Subrahmanya Praveen Munukutla <sataya.m@samsung.com>
Suchit Agrawal <a.suchit@samsung.com>
Sudarsana Babu Nagineni <sudarsana.nagineni@intel.com>
Sudarshan Parthasarathy <sudarshan.p@samsung.com>
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 7422dc9..f4054fd1 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -2268,8 +2268,14 @@ bool LayerTreeHostImpl::ScrollBy(const gfx::Point& viewport_point,
break;
}
- if (layer_impl == InnerViewportScrollLayer())
+ if (layer_impl == InnerViewportScrollLayer()) {
unused_root_delta.Subtract(applied_delta);
+ const float kOverscrollEpsilon = 0.01f;
+ if (std::abs(unused_root_delta.x()) < kOverscrollEpsilon)
+ unused_root_delta.set_x(0.0f);
+ if (std::abs(unused_root_delta.y()) < kOverscrollEpsilon)
+ unused_root_delta.set_y(0.0f);
+ }
did_lock_scrolling_layer_ = true;
if (!should_bubble_scrolls_) {
@@ -2310,7 +2316,7 @@ bool LayerTreeHostImpl::ScrollBy(const gfx::Point& viewport_point,
accumulated_root_overscroll_.set_y(0);
accumulated_root_overscroll_ += unused_root_delta;
- bool did_overscroll = !gfx::ToRoundedVector2d(unused_root_delta).IsZero();
+ bool did_overscroll = !unused_root_delta.IsZero();
if (did_overscroll && input_handler_client_) {
DidOverscrollParams params;
params.accumulated_overscroll = accumulated_root_overscroll_;
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 37f2cd5..59d819b 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -3162,6 +3162,42 @@ TEST_F(LayerTreeHostImplTest, OverscrollAlways) {
EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity());
}
+TEST_F(LayerTreeHostImplTest, UnnecessaryGlowEffectCallsWhileScrollingUp) {
+ // Edge glow effect should be applicable only upon reaching Edges
+ // of the content. unnecessary glow effect calls shouldn't be
+ // called while scrolling up without reaching the edge of the content.
+ gfx::Size surface_size(100, 100);
+ gfx::Size content_size(200, 200);
+ scoped_ptr<LayerImpl> root_clip =
+ LayerImpl::Create(host_impl_->active_tree(), 3);
+ scoped_ptr<LayerImpl> root =
+ CreateScrollableLayer(1, content_size, root_clip.get());
+ root->SetIsContainerForFixedPositionLayers(true);
+ scoped_ptr<LayerImpl> child =
+ CreateScrollableLayer(2, content_size, root_clip.get());
+
+ child->SetScrollClipLayer(Layer::INVALID_ID);
+ root->AddChild(child.Pass());
+ root_clip->AddChild(root.Pass());
+
+ host_impl_->SetViewportSize(surface_size);
+ host_impl_->active_tree()->SetRootLayer(root_clip.Pass());
+ host_impl_->active_tree()->SetViewportLayersFromIds(3, 1, Layer::INVALID_ID);
+ host_impl_->active_tree()->DidBecomeActive();
+ DrawFrame();
+ {
+ EXPECT_EQ(InputHandler::ScrollStarted,
+ host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Wheel));
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 100));
+ EXPECT_EQ(gfx::Vector2dF().ToString(),
+ host_impl_->accumulated_root_overscroll().ToString());
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, -2.30f));
+ EXPECT_EQ(gfx::Vector2dF().ToString(),
+ host_impl_->accumulated_root_overscroll().ToString());
+ host_impl_->ScrollEnd();
+ }
+}
+
class BlendStateCheckLayer : public LayerImpl {
public:
static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl,