OLD | NEW |
---|---|
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 2667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2678 top_controls_manager_->PinchBegin(); | 2678 top_controls_manager_->PinchBegin(); |
2679 } | 2679 } |
2680 | 2680 |
2681 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, | 2681 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, |
2682 const gfx::Point& anchor) { | 2682 const gfx::Point& anchor) { |
2683 if (!InnerViewportScrollLayer()) | 2683 if (!InnerViewportScrollLayer()) |
2684 return; | 2684 return; |
2685 | 2685 |
2686 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); | 2686 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); |
2687 | 2687 |
2688 // For a moment the scroll offset ends up being outside of the max range. This | |
2689 // confuses the delegate so we switch it off till after we're done processing | |
2690 // the pinch update. | |
2691 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); | |
aelias_OOO_until_Jul13
2014/05/09 01:00:01
Is there any way to avoid this workaround by chang
mkosiba (inactive)
2014/05/09 17:05:33
AFAICT the problem is caused by 2 things:
a) the L
| |
2692 | |
2688 // Keep the center-of-pinch anchor specified by (x, y) in a stable | 2693 // Keep the center-of-pinch anchor specified by (x, y) in a stable |
2689 // position over the course of the magnify. | 2694 // position over the course of the magnify. |
2690 float page_scale_delta = active_tree_->page_scale_delta(); | 2695 float page_scale_delta = active_tree_->page_scale_delta(); |
2691 gfx::PointF previous_scale_anchor = | 2696 gfx::PointF previous_scale_anchor = |
2692 gfx::ScalePoint(anchor, 1.f / page_scale_delta); | 2697 gfx::ScalePoint(anchor, 1.f / page_scale_delta); |
2693 active_tree_->SetPageScaleDelta(page_scale_delta * magnify_delta); | 2698 active_tree_->SetPageScaleDelta(page_scale_delta * magnify_delta); |
2694 page_scale_delta = active_tree_->page_scale_delta(); | 2699 page_scale_delta = active_tree_->page_scale_delta(); |
2695 gfx::PointF new_scale_anchor = | 2700 gfx::PointF new_scale_anchor = |
2696 gfx::ScalePoint(anchor, 1.f / page_scale_delta); | 2701 gfx::ScalePoint(anchor, 1.f / page_scale_delta); |
2697 gfx::Vector2dF move = previous_scale_anchor - new_scale_anchor; | 2702 gfx::Vector2dF move = previous_scale_anchor - new_scale_anchor; |
(...skipping 13 matching lines...) Expand all Loading... | |
2711 // 3) pinching should not engage the top controls manager. | 2716 // 3) pinching should not engage the top controls manager. |
2712 gfx::Vector2dF unused = OuterViewportScrollLayer() | 2717 gfx::Vector2dF unused = OuterViewportScrollLayer() |
2713 ? OuterViewportScrollLayer()->ScrollBy(move) | 2718 ? OuterViewportScrollLayer()->ScrollBy(move) |
2714 : move; | 2719 : move; |
2715 | 2720 |
2716 if (!unused.IsZero()) { | 2721 if (!unused.IsZero()) { |
2717 InnerViewportScrollLayer()->ScrollBy(unused); | 2722 InnerViewportScrollLayer()->ScrollBy(unused); |
2718 InnerViewportScrollLayer()->ClampScrollToMaxScrollOffset(); | 2723 InnerViewportScrollLayer()->ClampScrollToMaxScrollOffset(); |
2719 } | 2724 } |
2720 | 2725 |
2726 active_tree_->SetRootLayerScrollOffsetDelegate( | |
2727 root_layer_scroll_offset_delegate_); | |
2728 | |
2721 client_->SetNeedsCommitOnImplThread(); | 2729 client_->SetNeedsCommitOnImplThread(); |
2722 SetNeedsRedraw(); | 2730 SetNeedsRedraw(); |
2723 client_->RenewTreePriority(); | 2731 client_->RenewTreePriority(); |
2724 } | 2732 } |
2725 | 2733 |
2726 void LayerTreeHostImpl::PinchGestureEnd() { | 2734 void LayerTreeHostImpl::PinchGestureEnd() { |
2727 pinch_gesture_active_ = false; | 2735 pinch_gesture_active_ = false; |
2728 if (pinch_gesture_end_should_clear_scrolling_layer_) { | 2736 if (pinch_gesture_end_should_clear_scrolling_layer_) { |
2729 pinch_gesture_end_should_clear_scrolling_layer_ = false; | 2737 pinch_gesture_end_should_clear_scrolling_layer_ = false; |
2730 ClearCurrentlyScrollingLayer(); | 2738 ClearCurrentlyScrollingLayer(); |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3151 swap_promise_monitor_.erase(monitor); | 3159 swap_promise_monitor_.erase(monitor); |
3152 } | 3160 } |
3153 | 3161 |
3154 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3162 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
3155 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3163 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3156 for (; it != swap_promise_monitor_.end(); it++) | 3164 for (; it != swap_promise_monitor_.end(); it++) |
3157 (*it)->OnSetNeedsRedrawOnImpl(); | 3165 (*it)->OnSetNeedsRedrawOnImpl(); |
3158 } | 3166 } |
3159 | 3167 |
3160 } // namespace cc | 3168 } // namespace cc |
OLD | NEW |