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 2646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2657 top_controls_manager_->PinchBegin(); | 2657 top_controls_manager_->PinchBegin(); |
2658 } | 2658 } |
2659 | 2659 |
2660 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, | 2660 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, |
2661 const gfx::Point& anchor) { | 2661 const gfx::Point& anchor) { |
2662 if (!InnerViewportScrollLayer()) | 2662 if (!InnerViewportScrollLayer()) |
2663 return; | 2663 return; |
2664 | 2664 |
2665 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); | 2665 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); |
2666 | 2666 |
| 2667 // For a moment the scroll offset ends up being outside of the max range. This |
| 2668 // confuses the delegate so we switch it off till after we're done processing |
| 2669 // the pinch update. |
| 2670 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); |
| 2671 |
2667 // Keep the center-of-pinch anchor specified by (x, y) in a stable | 2672 // Keep the center-of-pinch anchor specified by (x, y) in a stable |
2668 // position over the course of the magnify. | 2673 // position over the course of the magnify. |
2669 float page_scale_delta = active_tree_->page_scale_delta(); | 2674 float page_scale_delta = active_tree_->page_scale_delta(); |
2670 gfx::PointF previous_scale_anchor = | 2675 gfx::PointF previous_scale_anchor = |
2671 gfx::ScalePoint(anchor, 1.f / page_scale_delta); | 2676 gfx::ScalePoint(anchor, 1.f / page_scale_delta); |
2672 active_tree_->SetPageScaleDelta(page_scale_delta * magnify_delta); | 2677 active_tree_->SetPageScaleDelta(page_scale_delta * magnify_delta); |
2673 page_scale_delta = active_tree_->page_scale_delta(); | 2678 page_scale_delta = active_tree_->page_scale_delta(); |
2674 gfx::PointF new_scale_anchor = | 2679 gfx::PointF new_scale_anchor = |
2675 gfx::ScalePoint(anchor, 1.f / page_scale_delta); | 2680 gfx::ScalePoint(anchor, 1.f / page_scale_delta); |
2676 gfx::Vector2dF move = previous_scale_anchor - new_scale_anchor; | 2681 gfx::Vector2dF move = previous_scale_anchor - new_scale_anchor; |
(...skipping 13 matching lines...) Expand all Loading... |
2690 // 3) pinching should not engage the top controls manager. | 2695 // 3) pinching should not engage the top controls manager. |
2691 gfx::Vector2dF unused = OuterViewportScrollLayer() | 2696 gfx::Vector2dF unused = OuterViewportScrollLayer() |
2692 ? OuterViewportScrollLayer()->ScrollBy(move) | 2697 ? OuterViewportScrollLayer()->ScrollBy(move) |
2693 : move; | 2698 : move; |
2694 | 2699 |
2695 if (!unused.IsZero()) { | 2700 if (!unused.IsZero()) { |
2696 InnerViewportScrollLayer()->ScrollBy(unused); | 2701 InnerViewportScrollLayer()->ScrollBy(unused); |
2697 InnerViewportScrollLayer()->ClampScrollToMaxScrollOffset(); | 2702 InnerViewportScrollLayer()->ClampScrollToMaxScrollOffset(); |
2698 } | 2703 } |
2699 | 2704 |
| 2705 active_tree_->SetRootLayerScrollOffsetDelegate( |
| 2706 root_layer_scroll_offset_delegate_); |
| 2707 |
2700 client_->SetNeedsCommitOnImplThread(); | 2708 client_->SetNeedsCommitOnImplThread(); |
2701 SetNeedsRedraw(); | 2709 SetNeedsRedraw(); |
2702 client_->RenewTreePriority(); | 2710 client_->RenewTreePriority(); |
2703 } | 2711 } |
2704 | 2712 |
2705 void LayerTreeHostImpl::PinchGestureEnd() { | 2713 void LayerTreeHostImpl::PinchGestureEnd() { |
2706 pinch_gesture_active_ = false; | 2714 pinch_gesture_active_ = false; |
2707 if (pinch_gesture_end_should_clear_scrolling_layer_) { | 2715 if (pinch_gesture_end_should_clear_scrolling_layer_) { |
2708 pinch_gesture_end_should_clear_scrolling_layer_ = false; | 2716 pinch_gesture_end_should_clear_scrolling_layer_ = false; |
2709 ClearCurrentlyScrollingLayer(); | 2717 ClearCurrentlyScrollingLayer(); |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3119 swap_promise_monitor_.erase(monitor); | 3127 swap_promise_monitor_.erase(monitor); |
3120 } | 3128 } |
3121 | 3129 |
3122 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3130 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
3123 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3131 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
3124 for (; it != swap_promise_monitor_.end(); it++) | 3132 for (; it != swap_promise_monitor_.end(); it++) |
3125 (*it)->OnSetNeedsRedrawOnImpl(); | 3133 (*it)->OnSetNeedsRedrawOnImpl(); |
3126 } | 3134 } |
3127 | 3135 |
3128 } // namespace cc | 3136 } // namespace cc |
OLD | NEW |