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

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

Issue 901813002: Normalize top controls offset to (0, 1), Chromium-side. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace more EXPECT_EQ with EXPECT_FLOAT_EQ for windows bots Created 5 years, 10 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_impl.h ('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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 is_likely_to_require_a_draw_(false), 228 is_likely_to_require_a_draw_(false),
229 frame_timing_tracker_(FrameTimingTracker::Create()) { 229 frame_timing_tracker_(FrameTimingTracker::Create()) {
230 DCHECK(proxy_->IsImplThread()); 230 DCHECK(proxy_->IsImplThread());
231 DidVisibilityChange(this, visible_); 231 DidVisibilityChange(this, visible_);
232 animation_registrar_->set_supports_scroll_animations( 232 animation_registrar_->set_supports_scroll_animations(
233 proxy_->SupportsImplScrolling()); 233 proxy_->SupportsImplScrolling());
234 234
235 SetDebugState(settings.initial_debug_state); 235 SetDebugState(settings.initial_debug_state);
236 236
237 // LTHI always has an active tree. 237 // LTHI always has an active tree.
238 active_tree_ = LayerTreeImpl::create(this, new SyncedProperty<ScaleGroup>(), 238 active_tree_ =
239 new SyncedElasticOverscroll); 239 LayerTreeImpl::create(this, new SyncedProperty<ScaleGroup>(),
240 new SyncedTopControls, new SyncedElasticOverscroll);
240 241
241 TRACE_EVENT_OBJECT_CREATED_WITH_ID( 242 TRACE_EVENT_OBJECT_CREATED_WITH_ID(
242 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); 243 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_);
243 244
244 if (settings.calculate_top_controls_position) { 245 if (settings.calculate_top_controls_position) {
245 top_controls_manager_ = 246 top_controls_manager_ =
246 TopControlsManager::Create(this, 247 TopControlsManager::Create(this,
247 settings.top_controls_show_threshold, 248 settings.top_controls_show_threshold,
248 settings.top_controls_hide_threshold); 249 settings.top_controls_hide_threshold);
249 } 250 }
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 EnforceManagedMemoryPolicy(ManagedMemoryPolicy(0)); 1107 EnforceManagedMemoryPolicy(ManagedMemoryPolicy(0));
1107 } 1108 }
1108 1109
1109 void LayerTreeHostImpl::BlockNotifyReadyToActivateForTesting(bool block) { 1110 void LayerTreeHostImpl::BlockNotifyReadyToActivateForTesting(bool block) {
1110 NOTREACHED(); 1111 NOTREACHED();
1111 } 1112 }
1112 1113
1113 void LayerTreeHostImpl::ResetTreesForTesting() { 1114 void LayerTreeHostImpl::ResetTreesForTesting() {
1114 if (active_tree_) 1115 if (active_tree_)
1115 active_tree_->DetachLayerTree(); 1116 active_tree_->DetachLayerTree();
1116 active_tree_ = LayerTreeImpl::create(this, active_tree()->page_scale_factor(), 1117 active_tree_ =
1117 active_tree()->elastic_overscroll()); 1118 LayerTreeImpl::create(this, active_tree()->page_scale_factor(),
1119 active_tree()->top_controls_shown_ratio(),
1120 active_tree()->elastic_overscroll());
1118 if (pending_tree_) 1121 if (pending_tree_)
1119 pending_tree_->DetachLayerTree(); 1122 pending_tree_->DetachLayerTree();
1120 pending_tree_ = nullptr; 1123 pending_tree_ = nullptr;
1121 if (recycle_tree_) 1124 if (recycle_tree_)
1122 recycle_tree_->DetachLayerTree(); 1125 recycle_tree_->DetachLayerTree();
1123 recycle_tree_ = nullptr; 1126 recycle_tree_ = nullptr;
1124 } 1127 }
1125 1128
1126 void LayerTreeHostImpl::EnforceManagedMemoryPolicy( 1129 void LayerTreeHostImpl::EnforceManagedMemoryPolicy(
1127 const ManagedMemoryPolicy& policy) { 1130 const ManagedMemoryPolicy& policy) {
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
1671 1674
1672 ViewportAnchor anchor(InnerViewportScrollLayer(), 1675 ViewportAnchor anchor(InnerViewportScrollLayer(),
1673 OuterViewportScrollLayer()); 1676 OuterViewportScrollLayer());
1674 1677
1675 // Adjust the inner viewport by shrinking/expanding the container to account 1678 // Adjust the inner viewport by shrinking/expanding the container to account
1676 // for the change in top controls height since the last Resize from Blink. 1679 // for the change in top controls height since the last Resize from Blink.
1677 float top_controls_layout_height = 1680 float top_controls_layout_height =
1678 active_tree_->top_controls_shrink_blink_size() 1681 active_tree_->top_controls_shrink_blink_size()
1679 ? active_tree_->top_controls_height() 1682 ? active_tree_->top_controls_height()
1680 : 0.f; 1683 : 0.f;
1681 inner_container->SetBoundsDelta( 1684 inner_container->SetBoundsDelta(gfx::Vector2dF(
1682 gfx::Vector2dF(0, top_controls_layout_height - 1685 0,
1683 active_tree_->total_top_controls_content_offset())); 1686 top_controls_layout_height - top_controls_manager_->ContentTopOffset()));
1684 1687
1685 if (!outer_container || outer_container->BoundsForScrolling().IsEmpty()) 1688 if (!outer_container || outer_container->BoundsForScrolling().IsEmpty())
1686 return; 1689 return;
1687 1690
1688 // Adjust the outer viewport container as well, since adjusting only the 1691 // Adjust the outer viewport container as well, since adjusting only the
1689 // inner may cause its bounds to exceed those of the outer, causing scroll 1692 // inner may cause its bounds to exceed those of the outer, causing scroll
1690 // clamping. We adjust it so it maintains the same aspect ratio as the 1693 // clamping. We adjust it so it maintains the same aspect ratio as the
1691 // inner viewport. 1694 // inner viewport.
1692 float aspect_ratio = inner_container->BoundsForScrolling().width() / 1695 float aspect_ratio = inner_container->BoundsForScrolling().width() /
1693 inner_container->BoundsForScrolling().height(); 1696 inner_container->BoundsForScrolling().height();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1761 return NULL; 1764 return NULL;
1762 } 1765 }
1763 1766
1764 void LayerTreeHostImpl::CreatePendingTree() { 1767 void LayerTreeHostImpl::CreatePendingTree() {
1765 CHECK(!pending_tree_); 1768 CHECK(!pending_tree_);
1766 if (recycle_tree_) 1769 if (recycle_tree_)
1767 recycle_tree_.swap(pending_tree_); 1770 recycle_tree_.swap(pending_tree_);
1768 else 1771 else
1769 pending_tree_ = 1772 pending_tree_ =
1770 LayerTreeImpl::create(this, active_tree()->page_scale_factor(), 1773 LayerTreeImpl::create(this, active_tree()->page_scale_factor(),
1774 active_tree()->top_controls_shown_ratio(),
1771 active_tree()->elastic_overscroll()); 1775 active_tree()->elastic_overscroll());
1772 1776
1773 // Update the delta from the active tree, which may have
1774 // adjusted its delta prior to the pending tree being created.
1775 DCHECK_EQ(0.f, pending_tree_->sent_top_controls_delta());
1776 pending_tree_->set_top_controls_delta(
1777 active_tree_->top_controls_delta() -
1778 active_tree_->sent_top_controls_delta());
1779 pending_tree_->set_top_controls_height(active_tree_->top_controls_height());
1780
1781 client_->OnCanDrawStateChanged(CanDraw()); 1777 client_->OnCanDrawStateChanged(CanDraw());
1782 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get()); 1778 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get());
1783 } 1779 }
1784 1780
1785 void LayerTreeHostImpl::ActivateSyncTree() { 1781 void LayerTreeHostImpl::ActivateSyncTree() {
1786 if (pending_tree_) { 1782 if (pending_tree_) {
1787 TRACE_EVENT_ASYNC_END0("cc", "PendingTree:waiting", pending_tree_.get()); 1783 TRACE_EVENT_ASYNC_END0("cc", "PendingTree:waiting", pending_tree_.get());
1788 1784
1789 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); 1785 active_tree_->SetRootLayerScrollOffsetDelegate(NULL);
1790 active_tree_->PushPersistedState(pending_tree_.get()); 1786 active_tree_->PushPersistedState(pending_tree_.get());
(...skipping 14 matching lines...) Expand all
1805 1801
1806 // Now that we've synced everything from the pending tree to the active 1802 // Now that we've synced everything from the pending tree to the active
1807 // tree, rename the pending tree the recycle tree so we can reuse it on the 1803 // tree, rename the pending tree the recycle tree so we can reuse it on the
1808 // next sync. 1804 // next sync.
1809 DCHECK(!recycle_tree_); 1805 DCHECK(!recycle_tree_);
1810 pending_tree_.swap(recycle_tree_); 1806 pending_tree_.swap(recycle_tree_);
1811 1807
1812 active_tree_->SetRootLayerScrollOffsetDelegate( 1808 active_tree_->SetRootLayerScrollOffsetDelegate(
1813 root_layer_scroll_offset_delegate_); 1809 root_layer_scroll_offset_delegate_);
1814 1810
1815 if (top_controls_manager_) {
1816 top_controls_manager_->SetTopControlsHeight(
1817 active_tree_->top_controls_height());
1818 top_controls_manager_->SetControlsTopOffset(
1819 active_tree_->total_top_controls_content_offset() -
1820 active_tree_->top_controls_height());
1821 }
1822
1823 UpdateViewportContainerSizes(); 1811 UpdateViewportContainerSizes();
1824 } else { 1812 } else {
1825 active_tree_->ProcessUIResourceRequestQueue(); 1813 active_tree_->ProcessUIResourceRequestQueue();
1826 } 1814 }
1827 1815
1828 active_tree_->DidBecomeActive(); 1816 active_tree_->DidBecomeActive();
1829 ActivateAnimations(); 1817 ActivateAnimations();
1830 if (settings_.impl_side_painting) { 1818 if (settings_.impl_side_painting) {
1831 client_->RenewTreePriority(); 1819 client_->RenewTreePriority();
1832 // If we have any picture layers, then by activating we also modified tile 1820 // If we have any picture layers, then by activating we also modified tile
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
2291 } 2279 }
2292 2280
2293 void LayerTreeHostImpl::DidChangeTopControlsPosition() { 2281 void LayerTreeHostImpl::DidChangeTopControlsPosition() {
2294 UpdateViewportContainerSizes(); 2282 UpdateViewportContainerSizes();
2295 SetNeedsRedraw(); 2283 SetNeedsRedraw();
2296 SetNeedsAnimate(); 2284 SetNeedsAnimate();
2297 active_tree_->set_needs_update_draw_properties(); 2285 active_tree_->set_needs_update_draw_properties();
2298 SetFullRootLayerDamage(); 2286 SetFullRootLayerDamage();
2299 } 2287 }
2300 2288
2301 void LayerTreeHostImpl::SetControlsTopOffset(float offset) { 2289 float LayerTreeHostImpl::TopControlsHeight() const {
2302 float current_top_offset = active_tree_->top_controls_content_offset() - 2290 return active_tree_->top_controls_height();
2303 active_tree_->top_controls_height();
2304 active_tree_->set_top_controls_delta(offset - current_top_offset);
2305 } 2291 }
2306 2292
2307 float LayerTreeHostImpl::ControlsTopOffset() const { 2293 void LayerTreeHostImpl::SetCurrentTopControlsShownRatio(float ratio) {
2308 return active_tree_->total_top_controls_content_offset() - 2294 if (active_tree_->SetCurrentTopControlsShownRatio(ratio))
2309 active_tree_->top_controls_height(); 2295 DidChangeTopControlsPosition();
2296 }
2297
2298 float LayerTreeHostImpl::CurrentTopControlsShownRatio() const {
2299 return active_tree_->CurrentTopControlsShownRatio();
2310 } 2300 }
2311 2301
2312 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { 2302 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) {
2313 DCHECK(input_handler_client_ == NULL); 2303 DCHECK(input_handler_client_ == NULL);
2314 input_handler_client_ = client; 2304 input_handler_client_ = client;
2315 } 2305 }
2316 2306
2317 LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint( 2307 LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint(
2318 const gfx::PointF& device_viewport_point, 2308 const gfx::PointF& device_viewport_point,
2319 InputHandler::ScrollInputType type, 2309 InputHandler::ScrollInputType type,
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
3052 for (size_t i = 0; i < layer_impl->children().size(); ++i) 3042 for (size_t i = 0; i < layer_impl->children().size(); ++i)
3053 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); 3043 CollectScrollDeltas(scroll_info, layer_impl->children()[i]);
3054 } 3044 }
3055 3045
3056 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { 3046 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() {
3057 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); 3047 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet());
3058 3048
3059 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); 3049 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer());
3060 scroll_info->page_scale_delta = 3050 scroll_info->page_scale_delta =
3061 active_tree_->page_scale_factor()->PullDeltaForMainThread(); 3051 active_tree_->page_scale_factor()->PullDeltaForMainThread();
3052 scroll_info->top_controls_delta =
3053 active_tree()->top_controls_shown_ratio()->PullDeltaForMainThread();
3062 scroll_info->elastic_overscroll_delta = 3054 scroll_info->elastic_overscroll_delta =
3063 active_tree_->elastic_overscroll()->PullDeltaForMainThread(); 3055 active_tree_->elastic_overscroll()->PullDeltaForMainThread();
3064 scroll_info->swap_promises.swap(swap_promises_for_main_thread_scroll_update_); 3056 scroll_info->swap_promises.swap(swap_promises_for_main_thread_scroll_update_);
3065 scroll_info->top_controls_delta = active_tree()->top_controls_delta();
3066 active_tree_->set_sent_top_controls_delta(scroll_info->top_controls_delta);
3067 3057
3068 return scroll_info.Pass(); 3058 return scroll_info.Pass();
3069 } 3059 }
3070 3060
3071 void LayerTreeHostImpl::SetFullRootLayerDamage() { 3061 void LayerTreeHostImpl::SetFullRootLayerDamage() {
3072 SetViewportDamage(gfx::Rect(DrawViewportSize())); 3062 SetViewportDamage(gfx::Rect(DrawViewportSize()));
3073 } 3063 }
3074 3064
3075 void LayerTreeHostImpl::ScrollViewportInnerFirst(gfx::Vector2dF scroll_delta) { 3065 void LayerTreeHostImpl::ScrollViewportInnerFirst(gfx::Vector2dF scroll_delta) {
3076 DCHECK(InnerViewportScrollLayer()); 3066 DCHECK(InnerViewportScrollLayer());
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
3516 } 3506 }
3517 3507
3518 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { 3508 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) {
3519 std::vector<PictureLayerImpl*>::iterator it = 3509 std::vector<PictureLayerImpl*>::iterator it =
3520 std::find(picture_layers_.begin(), picture_layers_.end(), layer); 3510 std::find(picture_layers_.begin(), picture_layers_.end(), layer);
3521 DCHECK(it != picture_layers_.end()); 3511 DCHECK(it != picture_layers_.end());
3522 picture_layers_.erase(it); 3512 picture_layers_.erase(it);
3523 } 3513 }
3524 3514
3525 } // namespace cc 3515 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698