diff options
Diffstat (limited to 'cc')
-rw-r--r-- | cc/input/input_handler.h | 6 | ||||
-rw-r--r-- | cc/input/layer_scroll_offset_delegate.h | 5 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 74 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.h | 8 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl_unittest.cc | 15 |
5 files changed, 47 insertions, 61 deletions
diff --git a/cc/input/input_handler.h b/cc/input/input_handler.h index 4852bdc..67a2c57 100644 --- a/cc/input/input_handler.h +++ b/cc/input/input_handler.h @@ -143,9 +143,13 @@ class CC_EXPORT InputHandler { // Request another callback to InputHandlerClient::Animate(). virtual void SetNeedsAnimateInput() = 0; + // If there is a scroll active, this reports whether the scroll is on the + // root layer, or on some other sublayer. + virtual bool IsCurrentlyScrollingRoot() const = 0; + // Whether the layer under |viewport_point| is the currently scrolling layer. virtual bool IsCurrentlyScrollingLayerAt(const gfx::Point& viewport_point, - ScrollInputType type) = 0; + ScrollInputType type) const = 0; virtual bool HaveWheelEventHandlersAt(const gfx::Point& viewport_point) = 0; diff --git a/cc/input/layer_scroll_offset_delegate.h b/cc/input/layer_scroll_offset_delegate.h index a0c0e0d..afd6e4b 100644 --- a/cc/input/layer_scroll_offset_delegate.h +++ b/cc/input/layer_scroll_offset_delegate.h @@ -44,11 +44,6 @@ class LayerScrollOffsetDelegate { float min_page_scale_factor, float max_page_scale_factor) = 0; - // This is called by the compositor when a fling hitting the root layer - // requires a scheduled animation update. - typedef base::Callback<void(base::TimeTicks)> AnimationCallback; - virtual void SetNeedsAnimate(const AnimationCallback& animation) = 0; - protected: LayerScrollOffsetDelegate() {} virtual ~LayerScrollOffsetDelegate() {} diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 9770aac..b15226a 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -405,16 +405,23 @@ bool LayerTreeHostImpl::CanDraw() const { } void LayerTreeHostImpl::Animate() { + DCHECK(proxy_->IsImplThread()); base::TimeTicks monotonic_time = CurrentBeginFrameArgs().frame_time; // mithro(TODO): Enable these checks. // DCHECK(!current_begin_frame_tracker_.HasFinished()); // DCHECK(monotonic_time == current_begin_frame_tracker_.Current().frame_time) // << "Called animate with unknown frame time!?"; - if (!root_layer_scroll_offset_delegate_ || - (CurrentlyScrollingLayer() != InnerViewportScrollLayer() && - CurrentlyScrollingLayer() != OuterViewportScrollLayer())) - AnimateInput(monotonic_time); + + if (input_handler_client_) { + // This animates fling scrolls. But on Android WebView root flings are + // controlled by the application, so the compositor does not animate them. + bool ignore_fling = + settings_.ignore_root_layer_flings && IsCurrentlyScrollingRoot(); + if (!ignore_fling) + input_handler_client_->Animate(monotonic_time); + } + AnimatePageScale(monotonic_time); AnimateLayers(monotonic_time); AnimateScrollbars(monotonic_time); @@ -474,25 +481,24 @@ void LayerTreeHostImpl::StartPageScaleAnimation( } void LayerTreeHostImpl::SetNeedsAnimateInput() { - if (root_layer_scroll_offset_delegate_ && - (CurrentlyScrollingLayer() == InnerViewportScrollLayer() || - CurrentlyScrollingLayer() == OuterViewportScrollLayer())) { - if (root_layer_animation_callback_.is_null()) { - root_layer_animation_callback_ = - base::Bind(&LayerTreeHostImpl::AnimateInput, AsWeakPtr()); - } - root_layer_scroll_offset_delegate_->SetNeedsAnimate( - root_layer_animation_callback_); - return; - } - + DCHECK_IMPLIES(IsCurrentlyScrollingRoot(), + !settings_.ignore_root_layer_flings); SetNeedsAnimate(); } +bool LayerTreeHostImpl::IsCurrentlyScrollingRoot() const { + LayerImpl* scrolling_layer = CurrentlyScrollingLayer(); + if (!scrolling_layer) + return false; + return scrolling_layer == InnerViewportScrollLayer() || + scrolling_layer == OuterViewportScrollLayer(); +} + bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt( const gfx::Point& viewport_point, - InputHandler::ScrollInputType type) { - if (!CurrentlyScrollingLayer()) + InputHandler::ScrollInputType type) const { + LayerImpl* scrolling_layer_impl = CurrentlyScrollingLayer(); + if (!scrolling_layer_impl) return false; gfx::PointF device_viewport_point = @@ -502,20 +508,20 @@ bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt( active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); bool scroll_on_main_thread = false; - LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint( + LayerImpl* test_layer_impl = FindScrollLayerForDeviceViewportPoint( device_viewport_point, type, layer_impl, &scroll_on_main_thread, NULL); - if (!scrolling_layer_impl) + if (!test_layer_impl) return false; - if (CurrentlyScrollingLayer() == scrolling_layer_impl) + if (scrolling_layer_impl == test_layer_impl) return true; // For active scrolling state treat the inner/outer viewports interchangeably. - if ((CurrentlyScrollingLayer() == InnerViewportScrollLayer() && - scrolling_layer_impl == OuterViewportScrollLayer()) || - (CurrentlyScrollingLayer() == OuterViewportScrollLayer() && - scrolling_layer_impl == InnerViewportScrollLayer())) { + if ((scrolling_layer_impl == InnerViewportScrollLayer() && + test_layer_impl == OuterViewportScrollLayer()) || + (scrolling_layer_impl == OuterViewportScrollLayer() && + test_layer_impl == InnerViewportScrollLayer())) { return true; } @@ -1824,12 +1830,11 @@ LayerImpl* LayerTreeHostImpl::CurrentlyScrollingLayer() const { bool LayerTreeHostImpl::IsActivelyScrolling() const { if (!CurrentlyScrollingLayer()) return false; - if (root_layer_scroll_offset_delegate_ && - (CurrentlyScrollingLayer() == InnerViewportScrollLayer() || - CurrentlyScrollingLayer() == OuterViewportScrollLayer())) { - // ScrollDelegate cannot determine current scroll, so assume no. + // On Android WebView root flings are controlled by the application, + // so the compositor does not animate them and can't tell if they + // are actually animating. So assume there are none. + if (settings_.ignore_root_layer_flings && IsCurrentlyScrollingRoot()) return false; - } return did_lock_scrolling_layer_; } @@ -2773,8 +2778,9 @@ void LayerTreeHostImpl::OnRootLayerDelegatedScrollOffsetChanged() { DCHECK(root_layer_scroll_offset_delegate_); active_tree_->DistributeRootScrollOffset(); client_->SetNeedsCommitOnImplThread(); - SetNeedsRedraw(); active_tree_->set_needs_update_draw_properties(); + // No need to SetNeedsRedraw, this is for WebView and every frame has redraw + // requested by the WebView embedder already. } void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() { @@ -2998,12 +3004,6 @@ void LayerTreeHostImpl::ScrollViewportBy(gfx::Vector2dF scroll_delta) { InnerViewportScrollLayer()->ScrollBy(unused_delta); } -void LayerTreeHostImpl::AnimateInput(base::TimeTicks monotonic_time) { - DCHECK(proxy_->IsImplThread()); - if (input_handler_client_) - input_handler_client_->Animate(monotonic_time); -} - void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { if (!page_scale_animation_) return; diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index e66a1ff..424cc53 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -189,8 +189,10 @@ class CC_EXPORT LayerTreeHostImpl float page_scale, base::TimeDelta duration); void SetNeedsAnimateInput() override; - bool IsCurrentlyScrollingLayerAt(const gfx::Point& viewport_point, - InputHandler::ScrollInputType type) override; + bool IsCurrentlyScrollingRoot() const override; + bool IsCurrentlyScrollingLayerAt( + const gfx::Point& viewport_point, + InputHandler::ScrollInputType type) const override; bool HaveWheelEventHandlersAt(const gfx::Point& viewport_point) override; bool DoTouchEventsBlockScrollAt(const gfx::Point& viewport_port) override; scoped_ptr<SwapPromiseMonitor> CreateLatencyInfoSwapPromiseMonitor( @@ -642,7 +644,6 @@ class CC_EXPORT LayerTreeHostImpl LayerImpl* scrolling_layer_impl, InputHandler::ScrollInputType type); - void AnimateInput(base::TimeTicks monotonic_time); void AnimatePageScale(base::TimeTicks monotonic_time); void AnimateScrollbars(base::TimeTicks monotonic_time); void AnimateTopControls(base::TimeTicks monotonic_time); @@ -742,7 +743,6 @@ class CC_EXPORT LayerTreeHostImpl // The optional delegate for the root layer scroll offset. LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate_; - LayerScrollOffsetDelegate::AnimationCallback root_layer_animation_callback_; const LayerTreeSettings settings_; LayerTreeDebugState debug_state_; diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index 74d0a9c..a28b646 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -4499,8 +4499,7 @@ class TestScrollOffsetDelegate : public LayerScrollOffsetDelegate { TestScrollOffsetDelegate() : page_scale_factor_(0.f), min_page_scale_factor_(-1.f), - max_page_scale_factor_(-1.f), - needs_animate_(false) {} + max_page_scale_factor_(-1.f) {} ~TestScrollOffsetDelegate() override {} @@ -4508,10 +4507,6 @@ class TestScrollOffsetDelegate : public LayerScrollOffsetDelegate { return getter_return_value_; } - void SetNeedsAnimate(const AnimationCallback&) override { - needs_animate_ = true; - } - void UpdateRootLayerState(const gfx::ScrollOffset& total_scroll_offset, const gfx::ScrollOffset& max_scroll_offset, const gfx::SizeF& scrollable_size, @@ -4530,12 +4525,6 @@ class TestScrollOffsetDelegate : public LayerScrollOffsetDelegate { set_getter_return_value(last_set_scroll_offset_); } - bool GetAndResetNeedsAnimate() { - bool needs_animate = needs_animate_; - needs_animate_ = false; - return needs_animate; - } - gfx::ScrollOffset last_set_scroll_offset() { return last_set_scroll_offset_; } @@ -4572,10 +4561,8 @@ class TestScrollOffsetDelegate : public LayerScrollOffsetDelegate { float page_scale_factor_; float min_page_scale_factor_; float max_page_scale_factor_; - bool needs_animate_; }; -// TODO(jdduke): Test root fling animation. TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) { TestScrollOffsetDelegate scroll_delegate; host_impl_->SetViewportSize(gfx::Size(10, 20)); |