| 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 2625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2636 top_controls_manager_->PinchBegin(); | 2636 top_controls_manager_->PinchBegin(); |
| 2637 } | 2637 } |
| 2638 | 2638 |
| 2639 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, | 2639 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, |
| 2640 const gfx::Point& anchor) { | 2640 const gfx::Point& anchor) { |
| 2641 if (!InnerViewportScrollLayer()) | 2641 if (!InnerViewportScrollLayer()) |
| 2642 return; | 2642 return; |
| 2643 | 2643 |
| 2644 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); | 2644 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); |
| 2645 | 2645 |
| 2646 // For a moment the scroll offset ends up being outside of the max range. This |
| 2647 // confuses the delegate so we switch it off till after we're done processing |
| 2648 // the pinch update. |
| 2649 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); |
| 2650 |
| 2646 // Keep the center-of-pinch anchor specified by (x, y) in a stable | 2651 // Keep the center-of-pinch anchor specified by (x, y) in a stable |
| 2647 // position over the course of the magnify. | 2652 // position over the course of the magnify. |
| 2648 float page_scale_delta = active_tree_->page_scale_delta(); | 2653 float page_scale_delta = active_tree_->page_scale_delta(); |
| 2649 gfx::PointF previous_scale_anchor = | 2654 gfx::PointF previous_scale_anchor = |
| 2650 gfx::ScalePoint(anchor, 1.f / page_scale_delta); | 2655 gfx::ScalePoint(anchor, 1.f / page_scale_delta); |
| 2651 active_tree_->SetPageScaleDelta(page_scale_delta * magnify_delta); | 2656 active_tree_->SetPageScaleDelta(page_scale_delta * magnify_delta); |
| 2652 page_scale_delta = active_tree_->page_scale_delta(); | 2657 page_scale_delta = active_tree_->page_scale_delta(); |
| 2653 gfx::PointF new_scale_anchor = | 2658 gfx::PointF new_scale_anchor = |
| 2654 gfx::ScalePoint(anchor, 1.f / page_scale_delta); | 2659 gfx::ScalePoint(anchor, 1.f / page_scale_delta); |
| 2655 gfx::Vector2dF move = previous_scale_anchor - new_scale_anchor; | 2660 gfx::Vector2dF move = previous_scale_anchor - new_scale_anchor; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2669 // 3) pinching should not engage the top controls manager. | 2674 // 3) pinching should not engage the top controls manager. |
| 2670 gfx::Vector2dF unused = OuterViewportScrollLayer() | 2675 gfx::Vector2dF unused = OuterViewportScrollLayer() |
| 2671 ? OuterViewportScrollLayer()->ScrollBy(move) | 2676 ? OuterViewportScrollLayer()->ScrollBy(move) |
| 2672 : move; | 2677 : move; |
| 2673 | 2678 |
| 2674 if (!unused.IsZero()) { | 2679 if (!unused.IsZero()) { |
| 2675 InnerViewportScrollLayer()->ScrollBy(unused); | 2680 InnerViewportScrollLayer()->ScrollBy(unused); |
| 2676 InnerViewportScrollLayer()->ClampScrollToMaxScrollOffset(); | 2681 InnerViewportScrollLayer()->ClampScrollToMaxScrollOffset(); |
| 2677 } | 2682 } |
| 2678 | 2683 |
| 2684 active_tree_->SetRootLayerScrollOffsetDelegate( |
| 2685 root_layer_scroll_offset_delegate_); |
| 2686 |
| 2679 client_->SetNeedsCommitOnImplThread(); | 2687 client_->SetNeedsCommitOnImplThread(); |
| 2680 SetNeedsRedraw(); | 2688 SetNeedsRedraw(); |
| 2681 client_->RenewTreePriority(); | 2689 client_->RenewTreePriority(); |
| 2682 } | 2690 } |
| 2683 | 2691 |
| 2684 void LayerTreeHostImpl::PinchGestureEnd() { | 2692 void LayerTreeHostImpl::PinchGestureEnd() { |
| 2685 pinch_gesture_active_ = false; | 2693 pinch_gesture_active_ = false; |
| 2686 if (pinch_gesture_end_should_clear_scrolling_layer_) { | 2694 if (pinch_gesture_end_should_clear_scrolling_layer_) { |
| 2687 pinch_gesture_end_should_clear_scrolling_layer_ = false; | 2695 pinch_gesture_end_should_clear_scrolling_layer_ = false; |
| 2688 ClearCurrentlyScrollingLayer(); | 2696 ClearCurrentlyScrollingLayer(); |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3122 swap_promise_monitor_.erase(monitor); | 3130 swap_promise_monitor_.erase(monitor); |
| 3123 } | 3131 } |
| 3124 | 3132 |
| 3125 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 3133 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
| 3126 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 3134 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
| 3127 for (; it != swap_promise_monitor_.end(); it++) | 3135 for (; it != swap_promise_monitor_.end(); it++) |
| 3128 (*it)->OnSetNeedsRedrawOnImpl(); | 3136 (*it)->OnSetNeedsRedrawOnImpl(); |
| 3129 } | 3137 } |
| 3130 | 3138 |
| 3131 } // namespace cc | 3139 } // namespace cc |
| OLD | NEW |