| 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 2598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2609 active_tree_->SetCurrentlyScrollingLayer(layer_impl); | 2609 active_tree_->SetCurrentlyScrollingLayer(layer_impl); |
| 2610 break; | 2610 break; |
| 2611 } | 2611 } |
| 2612 | 2612 |
| 2613 // If the applied delta is within 45 degrees of the input delta, bail out to | 2613 // If the applied delta is within 45 degrees of the input delta, bail out to |
| 2614 // make it easier to scroll just one layer in one direction without | 2614 // make it easier to scroll just one layer in one direction without |
| 2615 // affecting any of its parents. | 2615 // affecting any of its parents. |
| 2616 float angle_threshold = 45; | 2616 float angle_threshold = 45; |
| 2617 if (MathUtil::SmallestAngleBetweenVectors( | 2617 if (MathUtil::SmallestAngleBetweenVectors( |
| 2618 applied_delta, pending_delta) < angle_threshold) { | 2618 applied_delta, pending_delta) < angle_threshold) { |
| 2619 pending_delta = gfx::Vector2d(); | 2619 pending_delta = gfx::Vector2dF(); |
| 2620 break; | 2620 break; |
| 2621 } | 2621 } |
| 2622 | 2622 |
| 2623 // Allow further movement only on an axis perpendicular to the direction in | 2623 // Allow further movement only on an axis perpendicular to the direction in |
| 2624 // which the layer moved. | 2624 // which the layer moved. |
| 2625 gfx::Vector2dF perpendicular_axis(-applied_delta.y(), applied_delta.x()); | 2625 gfx::Vector2dF perpendicular_axis(-applied_delta.y(), applied_delta.x()); |
| 2626 pending_delta = MathUtil::ProjectVector(pending_delta, perpendicular_axis); | 2626 pending_delta = MathUtil::ProjectVector(pending_delta, perpendicular_axis); |
| 2627 | 2627 |
| 2628 if (gfx::ToRoundedVector2d(pending_delta).IsZero()) | 2628 if (gfx::ToRoundedVector2d(pending_delta).IsZero()) |
| 2629 break; | 2629 break; |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2910 if (top_controls_manager_) | 2910 if (top_controls_manager_) |
| 2911 top_controls_manager_->PinchEnd(); | 2911 top_controls_manager_->PinchEnd(); |
| 2912 client_->SetNeedsCommitOnImplThread(); | 2912 client_->SetNeedsCommitOnImplThread(); |
| 2913 } | 2913 } |
| 2914 | 2914 |
| 2915 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, | 2915 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, |
| 2916 LayerImpl* layer_impl) { | 2916 LayerImpl* layer_impl) { |
| 2917 if (!layer_impl) | 2917 if (!layer_impl) |
| 2918 return; | 2918 return; |
| 2919 | 2919 |
| 2920 gfx::Vector2d scroll_delta = | 2920 gfx::ScrollOffset scroll_delta(layer_impl->ScrollDelta().x(), |
| 2921 gfx::ToFlooredVector2d(layer_impl->ScrollDelta()); | 2921 layer_impl->ScrollDelta().y()); |
| 2922 if (!scroll_delta.IsZero()) { | 2922 if (!scroll_delta.IsZero()) { |
| 2923 LayerTreeHostCommon::ScrollUpdateInfo scroll; | 2923 LayerTreeHostCommon::ScrollUpdateInfo scroll; |
| 2924 scroll.layer_id = layer_impl->id(); | 2924 scroll.layer_id = layer_impl->id(); |
| 2925 scroll.scroll_delta = scroll_delta; | 2925 scroll.scroll_delta = scroll_delta; |
| 2926 scroll_info->scrolls.push_back(scroll); | 2926 scroll_info->scrolls.push_back(scroll); |
| 2927 layer_impl->SetSentScrollDelta(scroll_delta); | 2927 layer_impl->SetSentScrollDelta(scroll_delta); |
| 2928 } | 2928 } |
| 2929 | 2929 |
| 2930 for (size_t i = 0; i < layer_impl->children().size(); ++i) | 2930 for (size_t i = 0; i < layer_impl->children().size(); ++i) |
| 2931 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); | 2931 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3378 } | 3378 } |
| 3379 | 3379 |
| 3380 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3380 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
| 3381 std::vector<PictureLayerImpl*>::iterator it = | 3381 std::vector<PictureLayerImpl*>::iterator it = |
| 3382 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3382 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
| 3383 DCHECK(it != picture_layers_.end()); | 3383 DCHECK(it != picture_layers_.end()); |
| 3384 picture_layers_.erase(it); | 3384 picture_layers_.erase(it); |
| 3385 } | 3385 } |
| 3386 | 3386 |
| 3387 } // namespace cc | 3387 } // namespace cc |
| OLD | NEW |