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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
252 SetDebugState(settings.initial_debug_state); | 252 SetDebugState(settings.initial_debug_state); |
253 | 253 |
254 // LTHI always has an active tree. | 254 // LTHI always has an active tree. |
255 active_tree_ = LayerTreeImpl::create(this); | 255 active_tree_ = LayerTreeImpl::create(this); |
256 TRACE_EVENT_OBJECT_CREATED_WITH_ID( | 256 TRACE_EVENT_OBJECT_CREATED_WITH_ID( |
257 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); | 257 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); |
258 | 258 |
259 if (settings.calculate_top_controls_position) { | 259 if (settings.calculate_top_controls_position) { |
260 top_controls_manager_ = | 260 top_controls_manager_ = |
261 TopControlsManager::Create(this, | 261 TopControlsManager::Create(this, |
262 settings.top_controls_height, | |
263 settings.top_controls_show_threshold, | 262 settings.top_controls_show_threshold, |
264 settings.top_controls_hide_threshold); | 263 settings.top_controls_hide_threshold); |
265 | 264 |
266 // TODO(bokan): This is a quick fix. The browser should lock the top | 265 // TODO(bokan): This is a quick fix. The browser should lock the top |
267 // controls to shown on creation but this appears not to work. Tracked | 266 // controls to shown on creation but this appears not to work. Tracked |
268 // in crbug.com/417680. | 267 // in crbug.com/417680. |
269 // Initialize with top controls showing. | 268 // Initialize with top controls showing. |
270 SetControlsTopOffset(0.f); | 269 SetControlsTopOffset(0.f); |
bokan
2014/11/20 15:09:32
This should become a no-op now so it should be rem
David Trainor- moved to gerrit
2014/11/20 20:57:27
Good point. Commented this out and tested it and
bokan
2014/11/20 21:31:38
I would try the repro steps for crbug.com/416944 a
| |
271 } | 270 } |
272 } | 271 } |
273 | 272 |
274 LayerTreeHostImpl::~LayerTreeHostImpl() { | 273 LayerTreeHostImpl::~LayerTreeHostImpl() { |
275 DCHECK(proxy_->IsImplThread()); | 274 DCHECK(proxy_->IsImplThread()); |
276 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); | 275 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); |
277 TRACE_EVENT_OBJECT_DELETED_WITH_ID( | 276 TRACE_EVENT_OBJECT_DELETED_WITH_ID( |
278 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); | 277 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); |
279 | 278 |
280 if (input_handler_client_) { | 279 if (input_handler_client_) { |
(...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1626 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); | 1625 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); |
1627 | 1626 |
1628 if (!inner_container || !top_controls_manager_) | 1627 if (!inner_container || !top_controls_manager_) |
1629 return; | 1628 return; |
1630 | 1629 |
1631 ViewportAnchor anchor(InnerViewportScrollLayer(), | 1630 ViewportAnchor anchor(InnerViewportScrollLayer(), |
1632 OuterViewportScrollLayer()); | 1631 OuterViewportScrollLayer()); |
1633 | 1632 |
1634 // Adjust the inner viewport by shrinking/expanding the container to account | 1633 // Adjust the inner viewport by shrinking/expanding the container to account |
1635 // for the change in top controls height since the last Resize from Blink. | 1634 // for the change in top controls height since the last Resize from Blink. |
1635 float top_controls_layout_height = | |
1636 active_tree_->top_controls_shrink_blink_size() | |
1637 ? active_tree_->top_controls_height() | |
1638 : 0.f; | |
1636 inner_container->SetBoundsDelta( | 1639 inner_container->SetBoundsDelta( |
1637 gfx::Vector2dF(0, active_tree_->top_controls_layout_height() - | 1640 gfx::Vector2dF(0, top_controls_layout_height - |
1638 active_tree_->total_top_controls_content_offset())); | 1641 active_tree_->total_top_controls_content_offset())); |
1639 | 1642 |
1640 if (!outer_container || outer_container->BoundsForScrolling().IsEmpty()) | 1643 if (!outer_container || outer_container->BoundsForScrolling().IsEmpty()) |
1641 return; | 1644 return; |
1642 | 1645 |
1643 // Adjust the outer viewport container as well, since adjusting only the | 1646 // Adjust the outer viewport container as well, since adjusting only the |
1644 // inner may cause its bounds to exceed those of the outer, causing scroll | 1647 // inner may cause its bounds to exceed those of the outer, causing scroll |
1645 // clamping. We adjust it so it maintains the same aspect ratio as the | 1648 // clamping. We adjust it so it maintains the same aspect ratio as the |
1646 // inner viewport. | 1649 // inner viewport. |
1647 float aspect_ratio = inner_container->BoundsForScrolling().width() / | 1650 float aspect_ratio = inner_container->BoundsForScrolling().width() / |
1648 inner_container->BoundsForScrolling().height(); | 1651 inner_container->BoundsForScrolling().height(); |
1649 float target_height = outer_container->BoundsForScrolling().width() / | 1652 float target_height = outer_container->BoundsForScrolling().width() / |
1650 aspect_ratio; | 1653 aspect_ratio; |
1651 float current_outer_height = outer_container->BoundsForScrolling().height() - | 1654 float current_outer_height = outer_container->BoundsForScrolling().height() - |
1652 outer_container->bounds_delta().y(); | 1655 outer_container->bounds_delta().y(); |
1653 gfx::Vector2dF delta(0, target_height - current_outer_height); | 1656 gfx::Vector2dF delta(0, target_height - current_outer_height); |
1654 | 1657 |
1655 outer_container->SetBoundsDelta(delta); | 1658 outer_container->SetBoundsDelta(delta); |
1656 active_tree_->InnerViewportScrollLayer()->SetBoundsDelta(delta); | 1659 active_tree_->InnerViewportScrollLayer()->SetBoundsDelta(delta); |
1657 | 1660 |
1658 anchor.ResetViewportToAnchoredPosition(); | 1661 anchor.ResetViewportToAnchoredPosition(); |
1659 } | 1662 } |
1660 | 1663 |
1661 void LayerTreeHostImpl::SetTopControlsLayoutHeight(float height) { | 1664 void LayerTreeHostImpl::SetTopControlsHeight(float height) { |
1662 if (active_tree_->top_controls_layout_height() == height) | 1665 if (active_tree_->top_controls_height() == height) |
1663 return; | 1666 return; |
1664 | 1667 |
1665 active_tree_->set_top_controls_layout_height(height); | 1668 // Adjust the delta to maintain the current top controls offset. |
1669 active_tree_->set_top_controls_delta(active_tree_->top_controls_delta() - | |
1670 active_tree_->top_controls_height() + | |
1671 height); | |
1672 active_tree_->set_top_controls_height(height); | |
1666 UpdateViewportContainerSizes(); | 1673 UpdateViewportContainerSizes(); |
1667 SetFullRootLayerDamage(); | 1674 SetFullRootLayerDamage(); |
1668 } | 1675 } |
1676 | |
1677 void LayerTreeHostImpl::SetTopControlsShrinkBlinkSize(bool shrink) { | |
1678 if (active_tree_->top_controls_shrink_blink_size() == shrink) | |
1679 return; | |
1680 | |
1681 active_tree_->set_top_controls_shrink_blink_size(shrink); | |
1682 UpdateViewportContainerSizes(); | |
1683 SetFullRootLayerDamage(); | |
1684 } | |
1669 | 1685 |
1670 void LayerTreeHostImpl::SynchronouslyInitializeAllTiles() { | 1686 void LayerTreeHostImpl::SynchronouslyInitializeAllTiles() { |
1671 // Only valid for the single-threaded non-scheduled/synchronous case | 1687 // Only valid for the single-threaded non-scheduled/synchronous case |
1672 // using the zero copy raster worker pool. | 1688 // using the zero copy raster worker pool. |
1673 single_thread_synchronous_task_graph_runner_->RunUntilIdle(); | 1689 single_thread_synchronous_task_graph_runner_->RunUntilIdle(); |
1674 } | 1690 } |
1675 | 1691 |
1676 void LayerTreeHostImpl::DidLoseOutputSurface() { | 1692 void LayerTreeHostImpl::DidLoseOutputSurface() { |
1677 if (resource_provider_) | 1693 if (resource_provider_) |
1678 resource_provider_->DidLoseOutputSurface(); | 1694 resource_provider_->DidLoseOutputSurface(); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1770 // Now that we've synced everything from the pending tree to the active | 1786 // Now that we've synced everything from the pending tree to the active |
1771 // tree, rename the pending tree the recycle tree so we can reuse it on the | 1787 // tree, rename the pending tree the recycle tree so we can reuse it on the |
1772 // next sync. | 1788 // next sync. |
1773 DCHECK(!recycle_tree_); | 1789 DCHECK(!recycle_tree_); |
1774 pending_tree_.swap(recycle_tree_); | 1790 pending_tree_.swap(recycle_tree_); |
1775 | 1791 |
1776 active_tree_->SetRootLayerScrollOffsetDelegate( | 1792 active_tree_->SetRootLayerScrollOffsetDelegate( |
1777 root_layer_scroll_offset_delegate_); | 1793 root_layer_scroll_offset_delegate_); |
1778 | 1794 |
1779 if (top_controls_manager_) { | 1795 if (top_controls_manager_) { |
1796 top_controls_manager_->SetTopControlsHeight( | |
1797 active_tree_->top_controls_height()); | |
1780 top_controls_manager_->SetControlsTopOffset( | 1798 top_controls_manager_->SetControlsTopOffset( |
1781 active_tree_->total_top_controls_content_offset() - | 1799 active_tree_->total_top_controls_content_offset() - |
1782 top_controls_manager_->top_controls_height()); | 1800 top_controls_manager_->top_controls_height()); |
1783 } | 1801 } |
1784 | 1802 |
1785 UpdateViewportContainerSizes(); | 1803 UpdateViewportContainerSizes(); |
1786 } else { | 1804 } else { |
1787 active_tree_->ProcessUIResourceRequestQueue(); | 1805 active_tree_->ProcessUIResourceRequestQueue(); |
1788 } | 1806 } |
1789 | 1807 |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2235 void LayerTreeHostImpl::DidChangeTopControlsPosition() { | 2253 void LayerTreeHostImpl::DidChangeTopControlsPosition() { |
2236 UpdateViewportContainerSizes(); | 2254 UpdateViewportContainerSizes(); |
2237 SetNeedsRedraw(); | 2255 SetNeedsRedraw(); |
2238 SetNeedsAnimate(); | 2256 SetNeedsAnimate(); |
2239 active_tree_->set_needs_update_draw_properties(); | 2257 active_tree_->set_needs_update_draw_properties(); |
2240 SetFullRootLayerDamage(); | 2258 SetFullRootLayerDamage(); |
2241 } | 2259 } |
2242 | 2260 |
2243 void LayerTreeHostImpl::SetControlsTopOffset(float offset) { | 2261 void LayerTreeHostImpl::SetControlsTopOffset(float offset) { |
2244 float current_top_offset = active_tree_->top_controls_content_offset() - | 2262 float current_top_offset = active_tree_->top_controls_content_offset() - |
2245 top_controls_manager_->top_controls_height(); | 2263 active_tree_->top_controls_height(); |
2246 active_tree_->set_top_controls_delta(offset - current_top_offset); | 2264 active_tree_->set_top_controls_delta(offset - current_top_offset); |
2247 } | 2265 } |
2248 | 2266 |
2249 float LayerTreeHostImpl::ControlsTopOffset() const { | 2267 float LayerTreeHostImpl::ControlsTopOffset() const { |
2250 return active_tree_->total_top_controls_content_offset() - | 2268 return active_tree_->total_top_controls_content_offset() - |
2251 top_controls_manager_->top_controls_height(); | 2269 active_tree_->top_controls_height(); |
2252 } | 2270 } |
2253 | 2271 |
2254 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { | 2272 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { |
2255 DCHECK(input_handler_client_ == NULL); | 2273 DCHECK(input_handler_client_ == NULL); |
2256 input_handler_client_ = client; | 2274 input_handler_client_ = client; |
2257 } | 2275 } |
2258 | 2276 |
2259 static LayerImpl* NextScrollLayer(LayerImpl* layer) { | 2277 static LayerImpl* NextScrollLayer(LayerImpl* layer) { |
2260 if (LayerImpl* scroll_parent = layer->scroll_parent()) | 2278 if (LayerImpl* scroll_parent = layer->scroll_parent()) |
2261 return scroll_parent; | 2279 return scroll_parent; |
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3442 } | 3460 } |
3443 | 3461 |
3444 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3462 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3445 std::vector<PictureLayerImpl*>::iterator it = | 3463 std::vector<PictureLayerImpl*>::iterator it = |
3446 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3464 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3447 DCHECK(it != picture_layers_.end()); | 3465 DCHECK(it != picture_layers_.end()); |
3448 picture_layers_.erase(it); | 3466 picture_layers_.erase(it); |
3449 } | 3467 } |
3450 | 3468 |
3451 } // namespace cc | 3469 } // namespace cc |
OLD | NEW |