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

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

Issue 961023002: (Reland) Always create top controls manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed calculate_top_controls_position flag from Android flags Created 5 years, 9 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 SetDebugState(settings.initial_debug_state); 234 SetDebugState(settings.initial_debug_state);
235 235
236 // LTHI always has an active tree. 236 // LTHI always has an active tree.
237 active_tree_ = 237 active_tree_ =
238 LayerTreeImpl::create(this, new SyncedProperty<ScaleGroup>(), 238 LayerTreeImpl::create(this, new SyncedProperty<ScaleGroup>(),
239 new SyncedTopControls, new SyncedElasticOverscroll); 239 new SyncedTopControls, new SyncedElasticOverscroll);
240 240
241 TRACE_EVENT_OBJECT_CREATED_WITH_ID( 241 TRACE_EVENT_OBJECT_CREATED_WITH_ID(
242 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); 242 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_);
243 243
244 if (settings.calculate_top_controls_position) { 244 top_controls_manager_ =
245 top_controls_manager_ = 245 TopControlsManager::Create(this,
246 TopControlsManager::Create(this, 246 settings.top_controls_show_threshold,
247 settings.top_controls_show_threshold, 247 settings.top_controls_hide_threshold);
248 settings.top_controls_hide_threshold);
249 }
250 } 248 }
251 249
252 LayerTreeHostImpl::~LayerTreeHostImpl() { 250 LayerTreeHostImpl::~LayerTreeHostImpl() {
253 DCHECK(proxy_->IsImplThread()); 251 DCHECK(proxy_->IsImplThread());
254 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); 252 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()");
255 TRACE_EVENT_OBJECT_DELETED_WITH_ID( 253 TRACE_EVENT_OBJECT_DELETED_WITH_ID(
256 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); 254 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_);
257 255
258 if (input_handler_client_) { 256 if (input_handler_client_) {
259 input_handler_client_->WillShutdown(); 257 input_handler_client_->WillShutdown();
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 907
910 // Should only have one render pass in resourceless software mode. 908 // Should only have one render pass in resourceless software mode.
911 DCHECK(draw_mode != DRAW_MODE_RESOURCELESS_SOFTWARE || 909 DCHECK(draw_mode != DRAW_MODE_RESOURCELESS_SOFTWARE ||
912 frame->render_passes.size() == 1u) 910 frame->render_passes.size() == 1u)
913 << frame->render_passes.size(); 911 << frame->render_passes.size();
914 912
915 return draw_result; 913 return draw_result;
916 } 914 }
917 915
918 void LayerTreeHostImpl::MainThreadHasStoppedFlinging() { 916 void LayerTreeHostImpl::MainThreadHasStoppedFlinging() {
919 if (top_controls_manager_) 917 top_controls_manager_->MainThreadHasStoppedFlinging();
920 top_controls_manager_->MainThreadHasStoppedFlinging();
921 if (input_handler_client_) 918 if (input_handler_client_)
922 input_handler_client_->MainThreadHasStoppedFlinging(); 919 input_handler_client_->MainThreadHasStoppedFlinging();
923 } 920 }
924 921
925 void LayerTreeHostImpl::DidAnimateScrollOffset() { 922 void LayerTreeHostImpl::DidAnimateScrollOffset() {
926 client_->SetNeedsCommitOnImplThread(); 923 client_->SetNeedsCommitOnImplThread();
927 client_->RenewTreePriority(); 924 client_->RenewTreePriority();
928 } 925 }
929 926
930 void LayerTreeHostImpl::SetViewportDamage(const gfx::Rect& damage_rect) { 927 void LayerTreeHostImpl::SetViewportDamage(const gfx::Rect& damage_rect) {
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 } 1413 }
1417 1414
1418 CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() const { 1415 CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() const {
1419 CompositorFrameMetadata metadata; 1416 CompositorFrameMetadata metadata;
1420 metadata.device_scale_factor = device_scale_factor_; 1417 metadata.device_scale_factor = device_scale_factor_;
1421 metadata.page_scale_factor = active_tree_->current_page_scale_factor(); 1418 metadata.page_scale_factor = active_tree_->current_page_scale_factor();
1422 metadata.scrollable_viewport_size = active_tree_->ScrollableViewportSize(); 1419 metadata.scrollable_viewport_size = active_tree_->ScrollableViewportSize();
1423 metadata.root_layer_size = active_tree_->ScrollableSize(); 1420 metadata.root_layer_size = active_tree_->ScrollableSize();
1424 metadata.min_page_scale_factor = active_tree_->min_page_scale_factor(); 1421 metadata.min_page_scale_factor = active_tree_->min_page_scale_factor();
1425 metadata.max_page_scale_factor = active_tree_->max_page_scale_factor(); 1422 metadata.max_page_scale_factor = active_tree_->max_page_scale_factor();
1426 if (top_controls_manager_) { 1423 metadata.location_bar_offset =
1427 metadata.location_bar_offset = 1424 gfx::Vector2dF(0.f, top_controls_manager_->ControlsTopOffset());
1428 gfx::Vector2dF(0.f, top_controls_manager_->ControlsTopOffset()); 1425 metadata.location_bar_content_translation =
1429 metadata.location_bar_content_translation = 1426 gfx::Vector2dF(0.f, top_controls_manager_->ContentTopOffset());
1430 gfx::Vector2dF(0.f, top_controls_manager_->ContentTopOffset());
1431 }
1432 1427
1433 active_tree_->GetViewportSelection(&metadata.selection_start, 1428 active_tree_->GetViewportSelection(&metadata.selection_start,
1434 &metadata.selection_end); 1429 &metadata.selection_end);
1435 1430
1436 LayerImpl* root_layer_for_overflow = OuterViewportScrollLayer() 1431 LayerImpl* root_layer_for_overflow = OuterViewportScrollLayer()
1437 ? OuterViewportScrollLayer() 1432 ? OuterViewportScrollLayer()
1438 : InnerViewportScrollLayer(); 1433 : InnerViewportScrollLayer();
1439 if (root_layer_for_overflow) { 1434 if (root_layer_for_overflow) {
1440 metadata.root_overflow_x_hidden = 1435 metadata.root_overflow_x_hidden =
1441 !root_layer_for_overflow->user_scrollable_horizontal(); 1436 !root_layer_for_overflow->user_scrollable_horizontal();
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 // to complete its work so that we can draw new tiles within the impl frame 1646 // to complete its work so that we can draw new tiles within the impl frame
1652 // we are beginning now. 1647 // we are beginning now.
1653 SetNeedsRedraw(); 1648 SetNeedsRedraw();
1654 } 1649 }
1655 } 1650 }
1656 1651
1657 void LayerTreeHostImpl::UpdateViewportContainerSizes() { 1652 void LayerTreeHostImpl::UpdateViewportContainerSizes() {
1658 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); 1653 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer();
1659 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); 1654 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer();
1660 1655
1661 if (!inner_container || !top_controls_manager_) 1656 if (!inner_container)
1662 return; 1657 return;
1663 1658
1664 ViewportAnchor anchor(InnerViewportScrollLayer(), 1659 ViewportAnchor anchor(InnerViewportScrollLayer(),
1665 OuterViewportScrollLayer()); 1660 OuterViewportScrollLayer());
1666 1661
1667 // Adjust the inner viewport by shrinking/expanding the container to account 1662 // Adjust the inner viewport by shrinking/expanding the container to account
1668 // for the change in top controls height since the last Resize from Blink. 1663 // for the change in top controls height since the last Resize from Blink.
1669 float top_controls_layout_height = 1664 float top_controls_layout_height =
1670 active_tree_->top_controls_shrink_blink_size() 1665 active_tree_->top_controls_shrink_blink_size()
1671 ? active_tree_->top_controls_height() 1666 ? active_tree_->top_controls_height()
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
2349 return ancestor == scroll_ancestor; 2344 return ancestor == scroll_ancestor;
2350 } 2345 }
2351 return false; 2346 return false;
2352 } 2347 }
2353 2348
2354 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( 2349 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin(
2355 const gfx::Point& viewport_point, 2350 const gfx::Point& viewport_point,
2356 InputHandler::ScrollInputType type) { 2351 InputHandler::ScrollInputType type) {
2357 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin"); 2352 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin");
2358 2353
2359 if (top_controls_manager_) 2354 top_controls_manager_->ScrollBegin();
2360 top_controls_manager_->ScrollBegin();
2361 2355
2362 DCHECK(!CurrentlyScrollingLayer()); 2356 DCHECK(!CurrentlyScrollingLayer());
2363 ClearCurrentlyScrollingLayer(); 2357 ClearCurrentlyScrollingLayer();
2364 2358
2365 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, 2359 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point,
2366 device_scale_factor_); 2360 device_scale_factor_);
2367 LayerImpl* layer_impl = 2361 LayerImpl* layer_impl =
2368 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); 2362 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point);
2369 2363
2370 if (layer_impl) { 2364 if (layer_impl) {
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
2561 layer_impl->ScrollBy(delta); 2555 layer_impl->ScrollBy(delta);
2562 gfx::ScrollOffset scrolled = 2556 gfx::ScrollOffset scrolled =
2563 layer_impl->CurrentScrollOffset() - previous_offset; 2557 layer_impl->CurrentScrollOffset() - previous_offset;
2564 return gfx::Vector2dF(scrolled.x(), scrolled.y()); 2558 return gfx::Vector2dF(scrolled.x(), scrolled.y());
2565 } 2559 }
2566 2560
2567 bool LayerTreeHostImpl::ShouldTopControlsConsumeScroll( 2561 bool LayerTreeHostImpl::ShouldTopControlsConsumeScroll(
2568 const gfx::Vector2dF& scroll_delta) const { 2562 const gfx::Vector2dF& scroll_delta) const {
2569 DCHECK(CurrentlyScrollingLayer()); 2563 DCHECK(CurrentlyScrollingLayer());
2570 2564
2571 if (!top_controls_manager_)
2572 return false;
2573
2574 // Always consume if it's in the direction to show the top controls. 2565 // Always consume if it's in the direction to show the top controls.
2575 if (scroll_delta.y() < 0) 2566 if (scroll_delta.y() < 0)
2576 return true; 2567 return true;
2577 2568
2578 if (active_tree()->TotalScrollOffset().y() < 2569 if (active_tree()->TotalScrollOffset().y() <
2579 active_tree()->TotalMaxScrollOffset().y()) 2570 active_tree()->TotalMaxScrollOffset().y())
2580 return true; 2571 return true;
2581 2572
2582 return false; 2573 return false;
2583 } 2574 }
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
2804 } 2795 }
2805 2796
2806 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() { 2797 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() {
2807 active_tree_->ClearCurrentlyScrollingLayer(); 2798 active_tree_->ClearCurrentlyScrollingLayer();
2808 did_lock_scrolling_layer_ = false; 2799 did_lock_scrolling_layer_ = false;
2809 scroll_affects_scroll_handler_ = false; 2800 scroll_affects_scroll_handler_ = false;
2810 accumulated_root_overscroll_ = gfx::Vector2dF(); 2801 accumulated_root_overscroll_ = gfx::Vector2dF();
2811 } 2802 }
2812 2803
2813 void LayerTreeHostImpl::ScrollEnd() { 2804 void LayerTreeHostImpl::ScrollEnd() {
2814 if (top_controls_manager_) 2805 top_controls_manager_->ScrollEnd();
2815 top_controls_manager_->ScrollEnd();
2816 ClearCurrentlyScrollingLayer(); 2806 ClearCurrentlyScrollingLayer();
2817 } 2807 }
2818 2808
2819 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { 2809 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() {
2820 if (!active_tree_->CurrentlyScrollingLayer()) 2810 if (!active_tree_->CurrentlyScrollingLayer())
2821 return SCROLL_IGNORED; 2811 return SCROLL_IGNORED;
2822 2812
2823 if (settings_.ignore_root_layer_flings && 2813 if (settings_.ignore_root_layer_flings &&
2824 (active_tree_->CurrentlyScrollingLayer() == InnerViewportScrollLayer() || 2814 (active_tree_->CurrentlyScrollingLayer() == InnerViewportScrollLayer() ||
2825 active_tree_->CurrentlyScrollingLayer() == OuterViewportScrollLayer())) { 2815 active_tree_->CurrentlyScrollingLayer() == OuterViewportScrollLayer())) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
2926 previous_pinch_anchor_ = gfx::Point(); 2916 previous_pinch_anchor_ = gfx::Point();
2927 client_->RenewTreePriority(); 2917 client_->RenewTreePriority();
2928 pinch_gesture_end_should_clear_scrolling_layer_ = !CurrentlyScrollingLayer(); 2918 pinch_gesture_end_should_clear_scrolling_layer_ = !CurrentlyScrollingLayer();
2929 if (active_tree_->OuterViewportScrollLayer()) { 2919 if (active_tree_->OuterViewportScrollLayer()) {
2930 active_tree_->SetCurrentlyScrollingLayer( 2920 active_tree_->SetCurrentlyScrollingLayer(
2931 active_tree_->OuterViewportScrollLayer()); 2921 active_tree_->OuterViewportScrollLayer());
2932 } else { 2922 } else {
2933 active_tree_->SetCurrentlyScrollingLayer( 2923 active_tree_->SetCurrentlyScrollingLayer(
2934 active_tree_->InnerViewportScrollLayer()); 2924 active_tree_->InnerViewportScrollLayer());
2935 } 2925 }
2936 if (top_controls_manager_) 2926 top_controls_manager_->PinchBegin();
2937 top_controls_manager_->PinchBegin();
2938 } 2927 }
2939 2928
2940 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, 2929 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta,
2941 const gfx::Point& anchor) { 2930 const gfx::Point& anchor) {
2942 if (!InnerViewportScrollLayer()) 2931 if (!InnerViewportScrollLayer())
2943 return; 2932 return;
2944 2933
2945 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); 2934 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate");
2946 2935
2947 // For a moment the scroll offset ends up being outside of the max range. This 2936 // For a moment the scroll offset ends up being outside of the max range. This
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2986 SetNeedsRedraw(); 2975 SetNeedsRedraw();
2987 client_->RenewTreePriority(); 2976 client_->RenewTreePriority();
2988 } 2977 }
2989 2978
2990 void LayerTreeHostImpl::PinchGestureEnd() { 2979 void LayerTreeHostImpl::PinchGestureEnd() {
2991 pinch_gesture_active_ = false; 2980 pinch_gesture_active_ = false;
2992 if (pinch_gesture_end_should_clear_scrolling_layer_) { 2981 if (pinch_gesture_end_should_clear_scrolling_layer_) {
2993 pinch_gesture_end_should_clear_scrolling_layer_ = false; 2982 pinch_gesture_end_should_clear_scrolling_layer_ = false;
2994 ClearCurrentlyScrollingLayer(); 2983 ClearCurrentlyScrollingLayer();
2995 } 2984 }
2996 if (top_controls_manager_) 2985 top_controls_manager_->PinchEnd();
2997 top_controls_manager_->PinchEnd();
2998 client_->SetNeedsCommitOnImplThread(); 2986 client_->SetNeedsCommitOnImplThread();
2999 // When a pinch ends, we may be displaying content cached at incorrect scales, 2987 // When a pinch ends, we may be displaying content cached at incorrect scales,
3000 // so updating draw properties and drawing will ensure we are using the right 2988 // so updating draw properties and drawing will ensure we are using the right
3001 // scales that we want when we're not inside a pinch. 2989 // scales that we want when we're not inside a pinch.
3002 active_tree_->set_needs_update_draw_properties(); 2990 active_tree_->set_needs_update_draw_properties();
3003 SetNeedsRedraw(); 2991 SetNeedsRedraw();
3004 } 2992 }
3005 2993
3006 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, 2994 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info,
3007 LayerImpl* layer_impl) { 2995 LayerImpl* layer_impl) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
3082 page_scale_animation_ = nullptr; 3070 page_scale_animation_ = nullptr;
3083 client_->SetNeedsCommitOnImplThread(); 3071 client_->SetNeedsCommitOnImplThread();
3084 client_->RenewTreePriority(); 3072 client_->RenewTreePriority();
3085 client_->DidCompletePageScaleAnimationOnImplThread(); 3073 client_->DidCompletePageScaleAnimationOnImplThread();
3086 } else { 3074 } else {
3087 SetNeedsAnimate(); 3075 SetNeedsAnimate();
3088 } 3076 }
3089 } 3077 }
3090 3078
3091 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) { 3079 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) {
3092 if (!top_controls_manager_ || !top_controls_manager_->animation()) 3080 if (!top_controls_manager_->animation())
3093 return; 3081 return;
3094 3082
3095 gfx::Vector2dF scroll = top_controls_manager_->Animate(time); 3083 gfx::Vector2dF scroll = top_controls_manager_->Animate(time);
3096 3084
3097 if (top_controls_manager_->animation()) 3085 if (top_controls_manager_->animation())
3098 SetNeedsAnimate(); 3086 SetNeedsAnimate();
3099 3087
3100 if (active_tree_->TotalScrollOffset().y() == 0.f) 3088 if (active_tree_->TotalScrollOffset().y() == 0.f)
3101 return; 3089 return;
3102 3090
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
3462 (*it)->OnSetNeedsRedrawOnImpl(); 3450 (*it)->OnSetNeedsRedrawOnImpl();
3463 } 3451 }
3464 3452
3465 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() { 3453 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() {
3466 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); 3454 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin();
3467 for (; it != swap_promise_monitor_.end(); it++) 3455 for (; it != swap_promise_monitor_.end(); it++)
3468 (*it)->OnForwardScrollUpdateToMainThreadOnImpl(); 3456 (*it)->OnForwardScrollUpdateToMainThreadOnImpl();
3469 } 3457 }
3470 3458
3471 } // namespace cc 3459 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698