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 | |
266 // 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 | |
268 // in crbug.com/417680. | |
269 // Initialize with top controls showing. | |
270 SetControlsTopOffset(0.f); | |
271 } | 264 } |
272 } | 265 } |
273 | 266 |
274 LayerTreeHostImpl::~LayerTreeHostImpl() { | 267 LayerTreeHostImpl::~LayerTreeHostImpl() { |
275 DCHECK(proxy_->IsImplThread()); | 268 DCHECK(proxy_->IsImplThread()); |
276 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); | 269 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); |
277 TRACE_EVENT_OBJECT_DELETED_WITH_ID( | 270 TRACE_EVENT_OBJECT_DELETED_WITH_ID( |
278 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); | 271 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); |
279 | 272 |
280 if (input_handler_client_) { | 273 if (input_handler_client_) { |
(...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1626 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); | 1619 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); |
1627 | 1620 |
1628 if (!inner_container || !top_controls_manager_) | 1621 if (!inner_container || !top_controls_manager_) |
1629 return; | 1622 return; |
1630 | 1623 |
1631 ViewportAnchor anchor(InnerViewportScrollLayer(), | 1624 ViewportAnchor anchor(InnerViewportScrollLayer(), |
1632 OuterViewportScrollLayer()); | 1625 OuterViewportScrollLayer()); |
1633 | 1626 |
1634 // Adjust the inner viewport by shrinking/expanding the container to account | 1627 // 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. | 1628 // for the change in top controls height since the last Resize from Blink. |
1629 float top_controls_layout_height = | |
1630 active_tree_->top_controls_shrink_blink_size() | |
1631 ? active_tree_->top_controls_height() | |
1632 : 0.f; | |
1636 inner_container->SetBoundsDelta( | 1633 inner_container->SetBoundsDelta( |
1637 gfx::Vector2dF(0, active_tree_->top_controls_layout_height() - | 1634 gfx::Vector2dF(0, top_controls_layout_height - |
1638 active_tree_->total_top_controls_content_offset())); | 1635 active_tree_->total_top_controls_content_offset())); |
1639 | 1636 |
1640 if (!outer_container || outer_container->BoundsForScrolling().IsEmpty()) | 1637 if (!outer_container || outer_container->BoundsForScrolling().IsEmpty()) |
1641 return; | 1638 return; |
1642 | 1639 |
1643 // Adjust the outer viewport container as well, since adjusting only the | 1640 // 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 | 1641 // 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 | 1642 // clamping. We adjust it so it maintains the same aspect ratio as the |
1646 // inner viewport. | 1643 // inner viewport. |
1647 float aspect_ratio = inner_container->BoundsForScrolling().width() / | 1644 float aspect_ratio = inner_container->BoundsForScrolling().width() / |
1648 inner_container->BoundsForScrolling().height(); | 1645 inner_container->BoundsForScrolling().height(); |
1649 float target_height = outer_container->BoundsForScrolling().width() / | 1646 float target_height = outer_container->BoundsForScrolling().width() / |
1650 aspect_ratio; | 1647 aspect_ratio; |
1651 float current_outer_height = outer_container->BoundsForScrolling().height() - | 1648 float current_outer_height = outer_container->BoundsForScrolling().height() - |
1652 outer_container->bounds_delta().y(); | 1649 outer_container->bounds_delta().y(); |
1653 gfx::Vector2dF delta(0, target_height - current_outer_height); | 1650 gfx::Vector2dF delta(0, target_height - current_outer_height); |
1654 | 1651 |
1655 outer_container->SetBoundsDelta(delta); | 1652 outer_container->SetBoundsDelta(delta); |
1656 active_tree_->InnerViewportScrollLayer()->SetBoundsDelta(delta); | 1653 active_tree_->InnerViewportScrollLayer()->SetBoundsDelta(delta); |
1657 | 1654 |
1658 anchor.ResetViewportToAnchoredPosition(); | 1655 anchor.ResetViewportToAnchoredPosition(); |
1659 } | 1656 } |
1660 | 1657 |
1661 void LayerTreeHostImpl::SetTopControlsLayoutHeight(float height) { | 1658 void LayerTreeHostImpl::SetTopControlsHeight(float height) { |
1662 if (active_tree_->top_controls_layout_height() == height) | 1659 if (active_tree_->top_controls_height() == height) |
1663 return; | 1660 return; |
1664 | 1661 |
1665 active_tree_->set_top_controls_layout_height(height); | 1662 // Adjust the delta to maintain the current top controls offset. |
1663 active_tree_->set_top_controls_delta(active_tree_->top_controls_delta() - | |
1664 active_tree_->top_controls_height() + | |
1665 height); | |
1666 active_tree_->set_top_controls_height(height); | |
1667 UpdateViewportContainerSizes(); | |
1668 SetNeedsRedraw(); | |
1669 active_tree_->set_needs_update_draw_properties(); | |
1670 SetFullRootLayerDamage(); | |
1671 } | |
1672 | |
1673 void LayerTreeHostImpl::SetTopControlsShrinkBlinkSize(bool shrink) { | |
aelias_OOO_until_Jul13
2014/11/21 04:19:21
I don't see any calls to this method in this patch
aelias_OOO_until_Jul13
2014/11/21 04:19:21
I don't see any calls to this method in this patch
David Trainor- moved to gerrit
2014/11/22 00:35:30
Good call. Removed.
| |
1674 if (active_tree_->top_controls_shrink_blink_size() == shrink) | |
1675 return; | |
1676 | |
1677 active_tree_->set_top_controls_shrink_blink_size(shrink); | |
1666 UpdateViewportContainerSizes(); | 1678 UpdateViewportContainerSizes(); |
1667 SetFullRootLayerDamage(); | 1679 SetFullRootLayerDamage(); |
1668 } | 1680 } |
1669 | 1681 |
1670 void LayerTreeHostImpl::SynchronouslyInitializeAllTiles() { | 1682 void LayerTreeHostImpl::SynchronouslyInitializeAllTiles() { |
1671 // Only valid for the single-threaded non-scheduled/synchronous case | 1683 // Only valid for the single-threaded non-scheduled/synchronous case |
1672 // using the zero copy raster worker pool. | 1684 // using the zero copy raster worker pool. |
1673 single_thread_synchronous_task_graph_runner_->RunUntilIdle(); | 1685 single_thread_synchronous_task_graph_runner_->RunUntilIdle(); |
1674 } | 1686 } |
1675 | 1687 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1734 | 1746 |
1735 // Update the delta from the active tree, which may have | 1747 // Update the delta from the active tree, which may have |
1736 // adjusted its delta prior to the pending tree being created. | 1748 // adjusted its delta prior to the pending tree being created. |
1737 DCHECK_EQ(1.f, pending_tree_->sent_page_scale_delta()); | 1749 DCHECK_EQ(1.f, pending_tree_->sent_page_scale_delta()); |
1738 DCHECK_EQ(0.f, pending_tree_->sent_top_controls_delta()); | 1750 DCHECK_EQ(0.f, pending_tree_->sent_top_controls_delta()); |
1739 pending_tree_->SetPageScaleDelta(active_tree_->page_scale_delta() / | 1751 pending_tree_->SetPageScaleDelta(active_tree_->page_scale_delta() / |
1740 active_tree_->sent_page_scale_delta()); | 1752 active_tree_->sent_page_scale_delta()); |
1741 pending_tree_->set_top_controls_delta( | 1753 pending_tree_->set_top_controls_delta( |
1742 active_tree_->top_controls_delta() - | 1754 active_tree_->top_controls_delta() - |
1743 active_tree_->sent_top_controls_delta()); | 1755 active_tree_->sent_top_controls_delta()); |
1756 pending_tree_->set_top_controls_height(active_tree_->top_controls_height()); | |
1744 | 1757 |
1745 client_->OnCanDrawStateChanged(CanDraw()); | 1758 client_->OnCanDrawStateChanged(CanDraw()); |
1746 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get()); | 1759 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get()); |
1747 } | 1760 } |
1748 | 1761 |
1749 void LayerTreeHostImpl::ActivateSyncTree() { | 1762 void LayerTreeHostImpl::ActivateSyncTree() { |
1750 if (pending_tree_) { | 1763 if (pending_tree_) { |
1751 TRACE_EVENT_ASYNC_END0("cc", "PendingTree:waiting", pending_tree_.get()); | 1764 TRACE_EVENT_ASYNC_END0("cc", "PendingTree:waiting", pending_tree_.get()); |
1752 | 1765 |
1753 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); | 1766 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); |
(...skipping 16 matching lines...) Expand all Loading... | |
1770 // Now that we've synced everything from the pending tree to the active | 1783 // 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 | 1784 // tree, rename the pending tree the recycle tree so we can reuse it on the |
1772 // next sync. | 1785 // next sync. |
1773 DCHECK(!recycle_tree_); | 1786 DCHECK(!recycle_tree_); |
1774 pending_tree_.swap(recycle_tree_); | 1787 pending_tree_.swap(recycle_tree_); |
1775 | 1788 |
1776 active_tree_->SetRootLayerScrollOffsetDelegate( | 1789 active_tree_->SetRootLayerScrollOffsetDelegate( |
1777 root_layer_scroll_offset_delegate_); | 1790 root_layer_scroll_offset_delegate_); |
1778 | 1791 |
1779 if (top_controls_manager_) { | 1792 if (top_controls_manager_) { |
1793 top_controls_manager_->SetTopControlsHeight( | |
1794 active_tree_->top_controls_height()); | |
1780 top_controls_manager_->SetControlsTopOffset( | 1795 top_controls_manager_->SetControlsTopOffset( |
1781 active_tree_->total_top_controls_content_offset() - | 1796 active_tree_->total_top_controls_content_offset() - |
1782 top_controls_manager_->top_controls_height()); | 1797 top_controls_manager_->top_controls_height()); |
1783 } | 1798 } |
1784 | 1799 |
1785 UpdateViewportContainerSizes(); | 1800 UpdateViewportContainerSizes(); |
1786 } else { | 1801 } else { |
1787 active_tree_->ProcessUIResourceRequestQueue(); | 1802 active_tree_->ProcessUIResourceRequestQueue(); |
1788 } | 1803 } |
1789 | 1804 |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2235 void LayerTreeHostImpl::DidChangeTopControlsPosition() { | 2250 void LayerTreeHostImpl::DidChangeTopControlsPosition() { |
2236 UpdateViewportContainerSizes(); | 2251 UpdateViewportContainerSizes(); |
2237 SetNeedsRedraw(); | 2252 SetNeedsRedraw(); |
2238 SetNeedsAnimate(); | 2253 SetNeedsAnimate(); |
2239 active_tree_->set_needs_update_draw_properties(); | 2254 active_tree_->set_needs_update_draw_properties(); |
2240 SetFullRootLayerDamage(); | 2255 SetFullRootLayerDamage(); |
2241 } | 2256 } |
2242 | 2257 |
2243 void LayerTreeHostImpl::SetControlsTopOffset(float offset) { | 2258 void LayerTreeHostImpl::SetControlsTopOffset(float offset) { |
2244 float current_top_offset = active_tree_->top_controls_content_offset() - | 2259 float current_top_offset = active_tree_->top_controls_content_offset() - |
2245 top_controls_manager_->top_controls_height(); | 2260 active_tree_->top_controls_height(); |
2246 active_tree_->set_top_controls_delta(offset - current_top_offset); | 2261 active_tree_->set_top_controls_delta(offset - current_top_offset); |
2247 } | 2262 } |
2248 | 2263 |
2249 float LayerTreeHostImpl::ControlsTopOffset() const { | 2264 float LayerTreeHostImpl::ControlsTopOffset() const { |
2250 return active_tree_->total_top_controls_content_offset() - | 2265 return active_tree_->total_top_controls_content_offset() - |
2251 top_controls_manager_->top_controls_height(); | 2266 active_tree_->top_controls_height(); |
2252 } | 2267 } |
2253 | 2268 |
2254 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { | 2269 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { |
2255 DCHECK(input_handler_client_ == NULL); | 2270 DCHECK(input_handler_client_ == NULL); |
2256 input_handler_client_ = client; | 2271 input_handler_client_ = client; |
2257 } | 2272 } |
2258 | 2273 |
2259 static LayerImpl* NextScrollLayer(LayerImpl* layer) { | 2274 static LayerImpl* NextScrollLayer(LayerImpl* layer) { |
2260 if (LayerImpl* scroll_parent = layer->scroll_parent()) | 2275 if (LayerImpl* scroll_parent = layer->scroll_parent()) |
2261 return scroll_parent; | 2276 return scroll_parent; |
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3442 } | 3457 } |
3443 | 3458 |
3444 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3459 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3445 std::vector<PictureLayerImpl*>::iterator it = | 3460 std::vector<PictureLayerImpl*>::iterator it = |
3446 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3461 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3447 DCHECK(it != picture_layers_.end()); | 3462 DCHECK(it != picture_layers_.end()); |
3448 picture_layers_.erase(it); | 3463 picture_layers_.erase(it); |
3449 } | 3464 } |
3450 | 3465 |
3451 } // namespace cc | 3466 } // namespace cc |
OLD | NEW |