| 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 2654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2665 top_controls_manager_->PinchBegin(); | 2665 top_controls_manager_->PinchBegin(); |
| 2666 } | 2666 } |
| 2667 | 2667 |
| 2668 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, | 2668 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, |
| 2669 const gfx::Point& anchor) { | 2669 const gfx::Point& anchor) { |
| 2670 if (!InnerViewportScrollLayer()) | 2670 if (!InnerViewportScrollLayer()) |
| 2671 return; | 2671 return; |
| 2672 | 2672 |
| 2673 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); | 2673 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); |
| 2674 | 2674 |
| 2675 // For a moment the scroll offset ends up being outside of the max range. This |
| 2676 // confuses the delegate so we switch it off till after we're done processing |
| 2677 // the pinch update. |
| 2678 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); |
| 2679 |
| 2675 // Keep the center-of-pinch anchor specified by (x, y) in a stable | 2680 // Keep the center-of-pinch anchor specified by (x, y) in a stable |
| 2676 // position over the course of the magnify. | 2681 // position over the course of the magnify. |
| 2677 float page_scale_delta = active_tree_->page_scale_delta(); | 2682 float page_scale_delta = active_tree_->page_scale_delta(); |
| 2678 gfx::PointF previous_scale_anchor = | 2683 gfx::PointF previous_scale_anchor = |
| 2679 gfx::ScalePoint(anchor, 1.f / page_scale_delta); | 2684 gfx::ScalePoint(anchor, 1.f / page_scale_delta); |
| 2680 active_tree_->SetPageScaleDelta(page_scale_delta * magnify_delta); | 2685 active_tree_->SetPageScaleDelta(page_scale_delta * magnify_delta); |
| 2681 page_scale_delta = active_tree_->page_scale_delta(); | 2686 page_scale_delta = active_tree_->page_scale_delta(); |
| 2682 gfx::PointF new_scale_anchor = | 2687 gfx::PointF new_scale_anchor = |
| 2683 gfx::ScalePoint(anchor, 1.f / page_scale_delta); | 2688 gfx::ScalePoint(anchor, 1.f / page_scale_delta); |
| 2684 gfx::Vector2dF move = previous_scale_anchor - new_scale_anchor; | 2689 gfx::Vector2dF move = previous_scale_anchor - new_scale_anchor; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2698 // 3) pinching should not engage the top controls manager. | 2703 // 3) pinching should not engage the top controls manager. |
| 2699 gfx::Vector2dF unused = OuterViewportScrollLayer() | 2704 gfx::Vector2dF unused = OuterViewportScrollLayer() |
| 2700 ? OuterViewportScrollLayer()->ScrollBy(move) | 2705 ? OuterViewportScrollLayer()->ScrollBy(move) |
| 2701 : move; | 2706 : move; |
| 2702 | 2707 |
| 2703 if (!unused.IsZero()) { | 2708 if (!unused.IsZero()) { |
| 2704 InnerViewportScrollLayer()->ScrollBy(unused); | 2709 InnerViewportScrollLayer()->ScrollBy(unused); |
| 2705 InnerViewportScrollLayer()->ClampScrollToMaxScrollOffset(); | 2710 InnerViewportScrollLayer()->ClampScrollToMaxScrollOffset(); |
| 2706 } | 2711 } |
| 2707 | 2712 |
| 2713 active_tree_->SetRootLayerScrollOffsetDelegate( |
| 2714 root_layer_scroll_offset_delegate_); |
| 2715 |
| 2708 client_->SetNeedsCommitOnImplThread(); | 2716 client_->SetNeedsCommitOnImplThread(); |
| 2709 SetNeedsRedraw(); | 2717 SetNeedsRedraw(); |
| 2710 client_->RenewTreePriority(); | 2718 client_->RenewTreePriority(); |
| 2711 } | 2719 } |
| 2712 | 2720 |
| 2713 void LayerTreeHostImpl::PinchGestureEnd() { | 2721 void LayerTreeHostImpl::PinchGestureEnd() { |
| 2714 pinch_gesture_active_ = false; | 2722 pinch_gesture_active_ = false; |
| 2715 if (pinch_gesture_end_should_clear_scrolling_layer_) { | 2723 if (pinch_gesture_end_should_clear_scrolling_layer_) { |
| 2716 pinch_gesture_end_should_clear_scrolling_layer_ = false; | 2724 pinch_gesture_end_should_clear_scrolling_layer_ = false; |
| 2717 ClearCurrentlyScrollingLayer(); | 2725 ClearCurrentlyScrollingLayer(); |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3154 swap_promise_monitor_.erase(monitor); | 3162 swap_promise_monitor_.erase(monitor); |
| 3155 } | 3163 } |
| 3156 | 3164 |
| 3157 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3165 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
| 3158 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3166 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
| 3159 for (; it != swap_promise_monitor_.end(); it++) | 3167 for (; it != swap_promise_monitor_.end(); it++) |
| 3160 (*it)->OnSetNeedsRedrawOnImpl(); | 3168 (*it)->OnSetNeedsRedrawOnImpl(); |
| 3161 } | 3169 } |
| 3162 | 3170 |
| 3163 } // namespace cc | 3171 } // namespace cc |
| OLD | NEW |