Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 584503005: Make scroll offset type of float in cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update unittests Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 2528 matching lines...) Expand 10 before | Expand all | Expand 10 after
2539 layer_impl = layer_impl->parent()) { 2539 layer_impl = layer_impl->parent()) {
2540 if (!layer_impl->scrollable()) 2540 if (!layer_impl->scrollable())
2541 continue; 2541 continue;
2542 2542
2543 if (layer_impl == InnerViewportScrollLayer()) { 2543 if (layer_impl == InnerViewportScrollLayer()) {
2544 // Only allow bubble scrolling when the scroll is in the direction to make 2544 // Only allow bubble scrolling when the scroll is in the direction to make
2545 // the top controls visible. 2545 // the top controls visible.
2546 gfx::Vector2dF applied_delta; 2546 gfx::Vector2dF applied_delta;
2547 gfx::Vector2dF excess_delta; 2547 gfx::Vector2dF excess_delta;
2548 if (consume_by_top_controls) { 2548 if (consume_by_top_controls) {
2549 LOG(ERROR) << "consumed_by top_control";
danakj 2014/09/18 21:21:52 remove
Yufeng Shen (Slow to review) 2014/09/18 22:47:55 Done.
2549 excess_delta = top_controls_manager_->ScrollBy(pending_delta); 2550 excess_delta = top_controls_manager_->ScrollBy(pending_delta);
2550 applied_delta = pending_delta - excess_delta; 2551 applied_delta = pending_delta - excess_delta;
2551 pending_delta = excess_delta; 2552 pending_delta = excess_delta;
2552 // Force updating of vertical adjust values if needed. 2553 // Force updating of vertical adjust values if needed.
2553 if (applied_delta.y() != 0) { 2554 if (applied_delta.y() != 0) {
2554 did_scroll_top_controls = true; 2555 did_scroll_top_controls = true;
2555 layer_impl->ScrollbarParametersDidChange(); 2556 layer_impl->ScrollbarParametersDidChange();
2556 } 2557 }
2557 } 2558 }
2558 // Track root layer deltas for reporting overscroll. 2559 // Track root layer deltas for reporting overscroll.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2609 active_tree_->SetCurrentlyScrollingLayer(layer_impl); 2610 active_tree_->SetCurrentlyScrollingLayer(layer_impl);
2610 break; 2611 break;
2611 } 2612 }
2612 2613
2613 // If the applied delta is within 45 degrees of the input delta, bail out to 2614 // 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 2615 // make it easier to scroll just one layer in one direction without
2615 // affecting any of its parents. 2616 // affecting any of its parents.
2616 float angle_threshold = 45; 2617 float angle_threshold = 45;
2617 if (MathUtil::SmallestAngleBetweenVectors( 2618 if (MathUtil::SmallestAngleBetweenVectors(
2618 applied_delta, pending_delta) < angle_threshold) { 2619 applied_delta, pending_delta) < angle_threshold) {
2619 pending_delta = gfx::Vector2d(); 2620 pending_delta = gfx::Vector2dF();
2620 break; 2621 break;
2621 } 2622 }
2622 2623
2623 // Allow further movement only on an axis perpendicular to the direction in 2624 // Allow further movement only on an axis perpendicular to the direction in
2624 // which the layer moved. 2625 // which the layer moved.
2625 gfx::Vector2dF perpendicular_axis(-applied_delta.y(), applied_delta.x()); 2626 gfx::Vector2dF perpendicular_axis(-applied_delta.y(), applied_delta.x());
2626 pending_delta = MathUtil::ProjectVector(pending_delta, perpendicular_axis); 2627 pending_delta = MathUtil::ProjectVector(pending_delta, perpendicular_axis);
2627 2628
2628 if (gfx::ToRoundedVector2d(pending_delta).IsZero()) 2629 if (gfx::ToRoundedVector2d(pending_delta).IsZero())
2629 break; 2630 break;
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
2910 if (top_controls_manager_) 2911 if (top_controls_manager_)
2911 top_controls_manager_->PinchEnd(); 2912 top_controls_manager_->PinchEnd();
2912 client_->SetNeedsCommitOnImplThread(); 2913 client_->SetNeedsCommitOnImplThread();
2913 } 2914 }
2914 2915
2915 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, 2916 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info,
2916 LayerImpl* layer_impl) { 2917 LayerImpl* layer_impl) {
2917 if (!layer_impl) 2918 if (!layer_impl)
2918 return; 2919 return;
2919 2920
2920 gfx::Vector2d scroll_delta = 2921 gfx::Vector2dF scroll_delta = layer_impl->ScrollDelta();
2921 gfx::ToFlooredVector2d(layer_impl->ScrollDelta());
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698