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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 SetDebugState(settings.initial_debug_state); | 236 SetDebugState(settings.initial_debug_state); |
237 | 237 |
238 // LTHI always has an active tree. | 238 // LTHI always has an active tree. |
239 active_tree_ = LayerTreeImpl::create(this); | 239 active_tree_ = LayerTreeImpl::create(this); |
240 TRACE_EVENT_OBJECT_CREATED_WITH_ID( | 240 TRACE_EVENT_OBJECT_CREATED_WITH_ID( |
241 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); | 241 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); |
242 | 242 |
243 if (settings.calculate_top_controls_position) { | 243 if (settings.calculate_top_controls_position) { |
244 top_controls_manager_ = | 244 top_controls_manager_ = |
245 TopControlsManager::Create(this, | 245 TopControlsManager::Create(this, |
246 settings.top_controls_height, | |
247 settings.top_controls_show_threshold, | 246 settings.top_controls_show_threshold, |
248 settings.top_controls_hide_threshold); | 247 settings.top_controls_hide_threshold); |
249 | |
250 // TODO(bokan): This is a quick fix. The browser should lock the top | |
251 // controls to shown on creation but this appears not to work. Tracked | |
252 // in crbug.com/417680. | |
253 // Initialize with top controls showing. | |
254 SetControlsTopOffset(0.f); | |
255 } | 248 } |
256 } | 249 } |
257 | 250 |
258 LayerTreeHostImpl::~LayerTreeHostImpl() { | 251 LayerTreeHostImpl::~LayerTreeHostImpl() { |
259 DCHECK(proxy_->IsImplThread()); | 252 DCHECK(proxy_->IsImplThread()); |
260 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); | 253 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); |
261 TRACE_EVENT_OBJECT_DELETED_WITH_ID( | 254 TRACE_EVENT_OBJECT_DELETED_WITH_ID( |
262 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); | 255 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); |
263 | 256 |
264 if (input_handler_client_) { | 257 if (input_handler_client_) { |
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1653 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); | 1646 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); |
1654 | 1647 |
1655 if (!inner_container || !top_controls_manager_) | 1648 if (!inner_container || !top_controls_manager_) |
1656 return; | 1649 return; |
1657 | 1650 |
1658 ViewportAnchor anchor(InnerViewportScrollLayer(), | 1651 ViewportAnchor anchor(InnerViewportScrollLayer(), |
1659 OuterViewportScrollLayer()); | 1652 OuterViewportScrollLayer()); |
1660 | 1653 |
1661 // Adjust the inner viewport by shrinking/expanding the container to account | 1654 // Adjust the inner viewport by shrinking/expanding the container to account |
1662 // for the change in top controls height since the last Resize from Blink. | 1655 // for the change in top controls height since the last Resize from Blink. |
| 1656 float top_controls_layout_height = |
| 1657 active_tree_->top_controls_shrink_blink_size() |
| 1658 ? active_tree_->top_controls_height() |
| 1659 : 0.f; |
1663 inner_container->SetBoundsDelta( | 1660 inner_container->SetBoundsDelta( |
1664 gfx::Vector2dF(0, active_tree_->top_controls_layout_height() - | 1661 gfx::Vector2dF(0, top_controls_layout_height - |
1665 active_tree_->total_top_controls_content_offset())); | 1662 active_tree_->total_top_controls_content_offset())); |
1666 | 1663 |
1667 if (!outer_container || outer_container->BoundsForScrolling().IsEmpty()) | 1664 if (!outer_container || outer_container->BoundsForScrolling().IsEmpty()) |
1668 return; | 1665 return; |
1669 | 1666 |
1670 // Adjust the outer viewport container as well, since adjusting only the | 1667 // Adjust the outer viewport container as well, since adjusting only the |
1671 // inner may cause its bounds to exceed those of the outer, causing scroll | 1668 // inner may cause its bounds to exceed those of the outer, causing scroll |
1672 // clamping. We adjust it so it maintains the same aspect ratio as the | 1669 // clamping. We adjust it so it maintains the same aspect ratio as the |
1673 // inner viewport. | 1670 // inner viewport. |
1674 float aspect_ratio = inner_container->BoundsForScrolling().width() / | 1671 float aspect_ratio = inner_container->BoundsForScrolling().width() / |
1675 inner_container->BoundsForScrolling().height(); | 1672 inner_container->BoundsForScrolling().height(); |
1676 float target_height = outer_container->BoundsForScrolling().width() / | 1673 float target_height = outer_container->BoundsForScrolling().width() / |
1677 aspect_ratio; | 1674 aspect_ratio; |
1678 float current_outer_height = outer_container->BoundsForScrolling().height() - | 1675 float current_outer_height = outer_container->BoundsForScrolling().height() - |
1679 outer_container->bounds_delta().y(); | 1676 outer_container->bounds_delta().y(); |
1680 gfx::Vector2dF delta(0, target_height - current_outer_height); | 1677 gfx::Vector2dF delta(0, target_height - current_outer_height); |
1681 | 1678 |
1682 outer_container->SetBoundsDelta(delta); | 1679 outer_container->SetBoundsDelta(delta); |
1683 active_tree_->InnerViewportScrollLayer()->SetBoundsDelta(delta); | 1680 active_tree_->InnerViewportScrollLayer()->SetBoundsDelta(delta); |
1684 | 1681 |
1685 anchor.ResetViewportToAnchoredPosition(); | 1682 anchor.ResetViewportToAnchoredPosition(); |
1686 } | 1683 } |
1687 | 1684 |
1688 void LayerTreeHostImpl::SetTopControlsLayoutHeight(float height) { | |
1689 if (active_tree_->top_controls_layout_height() == height) | |
1690 return; | |
1691 | |
1692 active_tree_->set_top_controls_layout_height(height); | |
1693 UpdateViewportContainerSizes(); | |
1694 SetFullRootLayerDamage(); | |
1695 } | |
1696 | |
1697 void LayerTreeHostImpl::SynchronouslyInitializeAllTiles() { | 1685 void LayerTreeHostImpl::SynchronouslyInitializeAllTiles() { |
1698 // Only valid for the single-threaded non-scheduled/synchronous case | 1686 // Only valid for the single-threaded non-scheduled/synchronous case |
1699 // using the zero copy raster worker pool. | 1687 // using the zero copy raster worker pool. |
1700 single_thread_synchronous_task_graph_runner_->RunUntilIdle(); | 1688 single_thread_synchronous_task_graph_runner_->RunUntilIdle(); |
1701 } | 1689 } |
1702 | 1690 |
1703 void LayerTreeHostImpl::DidLoseOutputSurface() { | 1691 void LayerTreeHostImpl::DidLoseOutputSurface() { |
1704 if (resource_provider_) | 1692 if (resource_provider_) |
1705 resource_provider_->DidLoseOutputSurface(); | 1693 resource_provider_->DidLoseOutputSurface(); |
1706 client_->DidLoseOutputSurfaceOnImplThread(); | 1694 client_->DidLoseOutputSurfaceOnImplThread(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1761 | 1749 |
1762 // Update the delta from the active tree, which may have | 1750 // Update the delta from the active tree, which may have |
1763 // adjusted its delta prior to the pending tree being created. | 1751 // adjusted its delta prior to the pending tree being created. |
1764 DCHECK_EQ(1.f, pending_tree_->sent_page_scale_delta()); | 1752 DCHECK_EQ(1.f, pending_tree_->sent_page_scale_delta()); |
1765 DCHECK_EQ(0.f, pending_tree_->sent_top_controls_delta()); | 1753 DCHECK_EQ(0.f, pending_tree_->sent_top_controls_delta()); |
1766 pending_tree_->SetPageScaleDelta(active_tree_->page_scale_delta() / | 1754 pending_tree_->SetPageScaleDelta(active_tree_->page_scale_delta() / |
1767 active_tree_->sent_page_scale_delta()); | 1755 active_tree_->sent_page_scale_delta()); |
1768 pending_tree_->set_top_controls_delta( | 1756 pending_tree_->set_top_controls_delta( |
1769 active_tree_->top_controls_delta() - | 1757 active_tree_->top_controls_delta() - |
1770 active_tree_->sent_top_controls_delta()); | 1758 active_tree_->sent_top_controls_delta()); |
| 1759 pending_tree_->set_top_controls_height(active_tree_->top_controls_height()); |
1771 | 1760 |
1772 client_->OnCanDrawStateChanged(CanDraw()); | 1761 client_->OnCanDrawStateChanged(CanDraw()); |
1773 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get()); | 1762 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get()); |
1774 } | 1763 } |
1775 | 1764 |
1776 void LayerTreeHostImpl::ActivateSyncTree() { | 1765 void LayerTreeHostImpl::ActivateSyncTree() { |
1777 if (pending_tree_) { | 1766 if (pending_tree_) { |
1778 TRACE_EVENT_ASYNC_END0("cc", "PendingTree:waiting", pending_tree_.get()); | 1767 TRACE_EVENT_ASYNC_END0("cc", "PendingTree:waiting", pending_tree_.get()); |
1779 | 1768 |
1780 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); | 1769 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); |
(...skipping 16 matching lines...) Expand all Loading... |
1797 // 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 |
1798 // 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 |
1799 // next sync. | 1788 // next sync. |
1800 DCHECK(!recycle_tree_); | 1789 DCHECK(!recycle_tree_); |
1801 pending_tree_.swap(recycle_tree_); | 1790 pending_tree_.swap(recycle_tree_); |
1802 | 1791 |
1803 active_tree_->SetRootLayerScrollOffsetDelegate( | 1792 active_tree_->SetRootLayerScrollOffsetDelegate( |
1804 root_layer_scroll_offset_delegate_); | 1793 root_layer_scroll_offset_delegate_); |
1805 | 1794 |
1806 if (top_controls_manager_) { | 1795 if (top_controls_manager_) { |
| 1796 top_controls_manager_->SetTopControlsHeight( |
| 1797 active_tree_->top_controls_height()); |
1807 top_controls_manager_->SetControlsTopOffset( | 1798 top_controls_manager_->SetControlsTopOffset( |
1808 active_tree_->total_top_controls_content_offset() - | 1799 active_tree_->total_top_controls_content_offset() - |
1809 top_controls_manager_->top_controls_height()); | 1800 active_tree_->top_controls_height()); |
1810 } | 1801 } |
1811 | 1802 |
1812 UpdateViewportContainerSizes(); | 1803 UpdateViewportContainerSizes(); |
1813 } else { | 1804 } else { |
1814 active_tree_->ProcessUIResourceRequestQueue(); | 1805 active_tree_->ProcessUIResourceRequestQueue(); |
1815 } | 1806 } |
1816 | 1807 |
1817 active_tree_->DidBecomeActive(); | 1808 active_tree_->DidBecomeActive(); |
1818 ActivateAnimations(); | 1809 ActivateAnimations(); |
1819 if (settings_.impl_side_painting) | 1810 if (settings_.impl_side_painting) |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2263 void LayerTreeHostImpl::DidChangeTopControlsPosition() { | 2254 void LayerTreeHostImpl::DidChangeTopControlsPosition() { |
2264 UpdateViewportContainerSizes(); | 2255 UpdateViewportContainerSizes(); |
2265 SetNeedsRedraw(); | 2256 SetNeedsRedraw(); |
2266 SetNeedsAnimate(); | 2257 SetNeedsAnimate(); |
2267 active_tree_->set_needs_update_draw_properties(); | 2258 active_tree_->set_needs_update_draw_properties(); |
2268 SetFullRootLayerDamage(); | 2259 SetFullRootLayerDamage(); |
2269 } | 2260 } |
2270 | 2261 |
2271 void LayerTreeHostImpl::SetControlsTopOffset(float offset) { | 2262 void LayerTreeHostImpl::SetControlsTopOffset(float offset) { |
2272 float current_top_offset = active_tree_->top_controls_content_offset() - | 2263 float current_top_offset = active_tree_->top_controls_content_offset() - |
2273 top_controls_manager_->top_controls_height(); | 2264 active_tree_->top_controls_height(); |
2274 active_tree_->set_top_controls_delta(offset - current_top_offset); | 2265 active_tree_->set_top_controls_delta(offset - current_top_offset); |
2275 } | 2266 } |
2276 | 2267 |
2277 float LayerTreeHostImpl::ControlsTopOffset() const { | 2268 float LayerTreeHostImpl::ControlsTopOffset() const { |
2278 return active_tree_->total_top_controls_content_offset() - | 2269 return active_tree_->total_top_controls_content_offset() - |
2279 top_controls_manager_->top_controls_height(); | 2270 active_tree_->top_controls_height(); |
2280 } | 2271 } |
2281 | 2272 |
2282 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { | 2273 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { |
2283 DCHECK(input_handler_client_ == NULL); | 2274 DCHECK(input_handler_client_ == NULL); |
2284 input_handler_client_ = client; | 2275 input_handler_client_ = client; |
2285 } | 2276 } |
2286 | 2277 |
2287 static LayerImpl* NextScrollLayer(LayerImpl* layer) { | 2278 static LayerImpl* NextScrollLayer(LayerImpl* layer) { |
2288 if (LayerImpl* scroll_parent = layer->scroll_parent()) | 2279 if (LayerImpl* scroll_parent = layer->scroll_parent()) |
2289 return scroll_parent; | 2280 return scroll_parent; |
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3486 } | 3477 } |
3487 | 3478 |
3488 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3479 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3489 std::vector<PictureLayerImpl*>::iterator it = | 3480 std::vector<PictureLayerImpl*>::iterator it = |
3490 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3481 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3491 DCHECK(it != picture_layers_.end()); | 3482 DCHECK(it != picture_layers_.end()); |
3492 picture_layers_.erase(it); | 3483 picture_layers_.erase(it); |
3493 } | 3484 } |
3494 | 3485 |
3495 } // namespace cc | 3486 } // namespace cc |
OLD | NEW |