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

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: Fixing bad patch (Patches since "rebase" were from wrong branch) 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
« no previous file with comments | « cc/trees/layer_tree_host.cc ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
1659 // TODO(bokan): This code is currently specific to top controls. It should be
1660 // made general. crbug.com/464814.
1661 if (!TopControlsHeight()) {
1662 if (outer_container)
1663 outer_container->SetBoundsDelta(gfx::Vector2dF());
1664
1665 inner_container->SetBoundsDelta(gfx::Vector2dF());
1666 active_tree_->InnerViewportScrollLayer()->SetBoundsDelta(gfx::Vector2dF());
1667
1668 return;
1669 }
1670
1664 ViewportAnchor anchor(InnerViewportScrollLayer(), 1671 ViewportAnchor anchor(InnerViewportScrollLayer(),
1665 OuterViewportScrollLayer()); 1672 OuterViewportScrollLayer());
1666 1673
1667 // Adjust the inner viewport by shrinking/expanding the container to account 1674 // 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. 1675 // for the change in top controls height since the last Resize from Blink.
1669 float top_controls_layout_height = 1676 float top_controls_layout_height =
1670 active_tree_->top_controls_shrink_blink_size() 1677 active_tree_->top_controls_shrink_blink_size()
1671 ? active_tree_->top_controls_height() 1678 ? active_tree_->top_controls_height()
1672 : 0.f; 1679 : 0.f;
1673 inner_container->SetBoundsDelta(gfx::Vector2dF( 1680 inner_container->SetBoundsDelta(gfx::Vector2dF(
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
2354 return ancestor == scroll_ancestor; 2361 return ancestor == scroll_ancestor;
2355 } 2362 }
2356 return false; 2363 return false;
2357 } 2364 }
2358 2365
2359 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( 2366 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin(
2360 const gfx::Point& viewport_point, 2367 const gfx::Point& viewport_point,
2361 InputHandler::ScrollInputType type) { 2368 InputHandler::ScrollInputType type) {
2362 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin"); 2369 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin");
2363 2370
2364 if (top_controls_manager_) 2371 top_controls_manager_->ScrollBegin();
2365 top_controls_manager_->ScrollBegin();
2366 2372
2367 DCHECK(!CurrentlyScrollingLayer()); 2373 DCHECK(!CurrentlyScrollingLayer());
2368 ClearCurrentlyScrollingLayer(); 2374 ClearCurrentlyScrollingLayer();
2369 2375
2370 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, 2376 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point,
2371 device_scale_factor_); 2377 device_scale_factor_);
2372 LayerImpl* layer_impl = 2378 LayerImpl* layer_impl =
2373 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); 2379 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point);
2374 2380
2375 if (layer_impl) { 2381 if (layer_impl) {
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
2566 layer_impl->ScrollBy(delta); 2572 layer_impl->ScrollBy(delta);
2567 gfx::ScrollOffset scrolled = 2573 gfx::ScrollOffset scrolled =
2568 layer_impl->CurrentScrollOffset() - previous_offset; 2574 layer_impl->CurrentScrollOffset() - previous_offset;
2569 return gfx::Vector2dF(scrolled.x(), scrolled.y()); 2575 return gfx::Vector2dF(scrolled.x(), scrolled.y());
2570 } 2576 }
2571 2577
2572 bool LayerTreeHostImpl::ShouldTopControlsConsumeScroll( 2578 bool LayerTreeHostImpl::ShouldTopControlsConsumeScroll(
2573 const gfx::Vector2dF& scroll_delta) const { 2579 const gfx::Vector2dF& scroll_delta) const {
2574 DCHECK(CurrentlyScrollingLayer()); 2580 DCHECK(CurrentlyScrollingLayer());
2575 2581
2576 if (!top_controls_manager_)
2577 return false;
2578
2579 // Always consume if it's in the direction to show the top controls. 2582 // Always consume if it's in the direction to show the top controls.
2580 if (scroll_delta.y() < 0) 2583 if (scroll_delta.y() < 0)
2581 return true; 2584 return true;
2582 2585
2583 if (active_tree()->TotalScrollOffset().y() < 2586 if (active_tree()->TotalScrollOffset().y() <
2584 active_tree()->TotalMaxScrollOffset().y()) 2587 active_tree()->TotalMaxScrollOffset().y())
2585 return true; 2588 return true;
2586 2589
2587 return false; 2590 return false;
2588 } 2591 }
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
2809 } 2812 }
2810 2813
2811 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() { 2814 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() {
2812 active_tree_->ClearCurrentlyScrollingLayer(); 2815 active_tree_->ClearCurrentlyScrollingLayer();
2813 did_lock_scrolling_layer_ = false; 2816 did_lock_scrolling_layer_ = false;
2814 scroll_affects_scroll_handler_ = false; 2817 scroll_affects_scroll_handler_ = false;
2815 accumulated_root_overscroll_ = gfx::Vector2dF(); 2818 accumulated_root_overscroll_ = gfx::Vector2dF();
2816 } 2819 }
2817 2820
2818 void LayerTreeHostImpl::ScrollEnd() { 2821 void LayerTreeHostImpl::ScrollEnd() {
2819 if (top_controls_manager_) 2822 top_controls_manager_->ScrollEnd();
2820 top_controls_manager_->ScrollEnd();
2821 ClearCurrentlyScrollingLayer(); 2823 ClearCurrentlyScrollingLayer();
2822 } 2824 }
2823 2825
2824 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { 2826 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() {
2825 if (!active_tree_->CurrentlyScrollingLayer()) 2827 if (!active_tree_->CurrentlyScrollingLayer())
2826 return SCROLL_IGNORED; 2828 return SCROLL_IGNORED;
2827 2829
2828 if (settings_.ignore_root_layer_flings && 2830 if (settings_.ignore_root_layer_flings &&
2829 (active_tree_->CurrentlyScrollingLayer() == InnerViewportScrollLayer() || 2831 (active_tree_->CurrentlyScrollingLayer() == InnerViewportScrollLayer() ||
2830 active_tree_->CurrentlyScrollingLayer() == OuterViewportScrollLayer())) { 2832 active_tree_->CurrentlyScrollingLayer() == OuterViewportScrollLayer())) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
2931 previous_pinch_anchor_ = gfx::Point(); 2933 previous_pinch_anchor_ = gfx::Point();
2932 client_->RenewTreePriority(); 2934 client_->RenewTreePriority();
2933 pinch_gesture_end_should_clear_scrolling_layer_ = !CurrentlyScrollingLayer(); 2935 pinch_gesture_end_should_clear_scrolling_layer_ = !CurrentlyScrollingLayer();
2934 if (active_tree_->OuterViewportScrollLayer()) { 2936 if (active_tree_->OuterViewportScrollLayer()) {
2935 active_tree_->SetCurrentlyScrollingLayer( 2937 active_tree_->SetCurrentlyScrollingLayer(
2936 active_tree_->OuterViewportScrollLayer()); 2938 active_tree_->OuterViewportScrollLayer());
2937 } else { 2939 } else {
2938 active_tree_->SetCurrentlyScrollingLayer( 2940 active_tree_->SetCurrentlyScrollingLayer(
2939 active_tree_->InnerViewportScrollLayer()); 2941 active_tree_->InnerViewportScrollLayer());
2940 } 2942 }
2941 if (top_controls_manager_) 2943 top_controls_manager_->PinchBegin();
2942 top_controls_manager_->PinchBegin();
2943 } 2944 }
2944 2945
2945 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, 2946 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta,
2946 const gfx::Point& anchor) { 2947 const gfx::Point& anchor) {
2947 if (!InnerViewportScrollLayer()) 2948 if (!InnerViewportScrollLayer())
2948 return; 2949 return;
2949 2950
2950 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); 2951 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate");
2951 2952
2952 // For a moment the scroll offset ends up being outside of the max range. This 2953 // 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
2991 SetNeedsRedraw(); 2992 SetNeedsRedraw();
2992 client_->RenewTreePriority(); 2993 client_->RenewTreePriority();
2993 } 2994 }
2994 2995
2995 void LayerTreeHostImpl::PinchGestureEnd() { 2996 void LayerTreeHostImpl::PinchGestureEnd() {
2996 pinch_gesture_active_ = false; 2997 pinch_gesture_active_ = false;
2997 if (pinch_gesture_end_should_clear_scrolling_layer_) { 2998 if (pinch_gesture_end_should_clear_scrolling_layer_) {
2998 pinch_gesture_end_should_clear_scrolling_layer_ = false; 2999 pinch_gesture_end_should_clear_scrolling_layer_ = false;
2999 ClearCurrentlyScrollingLayer(); 3000 ClearCurrentlyScrollingLayer();
3000 } 3001 }
3001 if (top_controls_manager_) 3002 top_controls_manager_->PinchEnd();
3002 top_controls_manager_->PinchEnd();
3003 client_->SetNeedsCommitOnImplThread(); 3003 client_->SetNeedsCommitOnImplThread();
3004 // When a pinch ends, we may be displaying content cached at incorrect scales, 3004 // When a pinch ends, we may be displaying content cached at incorrect scales,
3005 // so updating draw properties and drawing will ensure we are using the right 3005 // so updating draw properties and drawing will ensure we are using the right
3006 // scales that we want when we're not inside a pinch. 3006 // scales that we want when we're not inside a pinch.
3007 active_tree_->set_needs_update_draw_properties(); 3007 active_tree_->set_needs_update_draw_properties();
3008 SetNeedsRedraw(); 3008 SetNeedsRedraw();
3009 } 3009 }
3010 3010
3011 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, 3011 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info,
3012 LayerImpl* layer_impl) { 3012 LayerImpl* layer_impl) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
3087 page_scale_animation_ = nullptr; 3087 page_scale_animation_ = nullptr;
3088 client_->SetNeedsCommitOnImplThread(); 3088 client_->SetNeedsCommitOnImplThread();
3089 client_->RenewTreePriority(); 3089 client_->RenewTreePriority();
3090 client_->DidCompletePageScaleAnimationOnImplThread(); 3090 client_->DidCompletePageScaleAnimationOnImplThread();
3091 } else { 3091 } else {
3092 SetNeedsAnimate(); 3092 SetNeedsAnimate();
3093 } 3093 }
3094 } 3094 }
3095 3095
3096 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) { 3096 void LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) {
3097 if (!top_controls_manager_ || !top_controls_manager_->animation()) 3097 if (!top_controls_manager_->animation())
3098 return; 3098 return;
3099 3099
3100 gfx::Vector2dF scroll = top_controls_manager_->Animate(time); 3100 gfx::Vector2dF scroll = top_controls_manager_->Animate(time);
3101 3101
3102 if (top_controls_manager_->animation()) 3102 if (top_controls_manager_->animation())
3103 SetNeedsAnimate(); 3103 SetNeedsAnimate();
3104 3104
3105 if (active_tree_->TotalScrollOffset().y() == 0.f) 3105 if (active_tree_->TotalScrollOffset().y() == 0.f)
3106 return; 3106 return;
3107 3107
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
3450 (*it)->OnSetNeedsRedrawOnImpl(); 3450 (*it)->OnSetNeedsRedrawOnImpl();
3451 } 3451 }
3452 3452
3453 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() { 3453 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() {
3454 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); 3454 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin();
3455 for (; it != swap_promise_monitor_.end(); it++) 3455 for (; it != swap_promise_monitor_.end(); it++)
3456 (*it)->OnForwardScrollUpdateToMainThreadOnImpl(); 3456 (*it)->OnForwardScrollUpdateToMainThreadOnImpl();
3457 } 3457 }
3458 3458
3459 } // namespace cc 3459 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host.cc ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698