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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 requires_high_res_to_draw_(false), | 230 requires_high_res_to_draw_(false), |
231 required_for_draw_tile_is_top_of_raster_queue_(false) { | 231 required_for_draw_tile_is_top_of_raster_queue_(false) { |
232 DCHECK(proxy_->IsImplThread()); | 232 DCHECK(proxy_->IsImplThread()); |
233 DidVisibilityChange(this, visible_); | 233 DidVisibilityChange(this, visible_); |
234 animation_registrar_->set_supports_scroll_animations( | 234 animation_registrar_->set_supports_scroll_animations( |
235 proxy_->SupportsImplScrolling()); | 235 proxy_->SupportsImplScrolling()); |
236 | 236 |
237 SetDebugState(settings.initial_debug_state); | 237 SetDebugState(settings.initial_debug_state); |
238 | 238 |
239 // LTHI always has an active tree. | 239 // LTHI always has an active tree. |
240 active_tree_ = LayerTreeImpl::create(this); | 240 active_tree_ = LayerTreeImpl::create(this, new SyncedProperty<ScaleGroup>()); |
| 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_height, | |
248 settings.top_controls_show_threshold, | 248 settings.top_controls_show_threshold, |
249 settings.top_controls_hide_threshold); | 249 settings.top_controls_hide_threshold); |
250 | |
251 // TODO(bokan): This is a quick fix. The browser should lock the top | |
252 // controls to shown on creation but this appears not to work. Tracked | |
253 // in crbug.com/417680. | |
254 // Initialize with top controls showing. | |
255 SetControlsTopOffset(0.f); | |
256 } | 250 } |
257 } | 251 } |
258 | 252 |
259 LayerTreeHostImpl::~LayerTreeHostImpl() { | 253 LayerTreeHostImpl::~LayerTreeHostImpl() { |
260 DCHECK(proxy_->IsImplThread()); | 254 DCHECK(proxy_->IsImplThread()); |
261 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); | 255 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); |
262 TRACE_EVENT_OBJECT_DELETED_WITH_ID( | 256 TRACE_EVENT_OBJECT_DELETED_WITH_ID( |
263 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); | 257 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); |
264 | 258 |
265 if (input_handler_client_) { | 259 if (input_handler_client_) { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 gfx::ScrollOffset scroll_total = active_tree_->TotalScrollOffset(); | 404 gfx::ScrollOffset scroll_total = active_tree_->TotalScrollOffset(); |
411 gfx::SizeF scaled_scrollable_size = active_tree_->ScrollableSize(); | 405 gfx::SizeF scaled_scrollable_size = active_tree_->ScrollableSize(); |
412 gfx::SizeF viewport_size = | 406 gfx::SizeF viewport_size = |
413 active_tree_->InnerViewportContainerLayer()->bounds(); | 407 active_tree_->InnerViewportContainerLayer()->bounds(); |
414 | 408 |
415 // Easing constants experimentally determined. | 409 // Easing constants experimentally determined. |
416 scoped_ptr<TimingFunction> timing_function = | 410 scoped_ptr<TimingFunction> timing_function = |
417 CubicBezierTimingFunction::Create(.8, 0, .3, .9); | 411 CubicBezierTimingFunction::Create(.8, 0, .3, .9); |
418 | 412 |
419 // TODO(miletus) : Pass in ScrollOffset. | 413 // TODO(miletus) : Pass in ScrollOffset. |
420 page_scale_animation_ = | 414 page_scale_animation_ = PageScaleAnimation::Create( |
421 PageScaleAnimation::Create(ScrollOffsetToVector2dF(scroll_total), | 415 ScrollOffsetToVector2dF(scroll_total), |
422 active_tree_->total_page_scale_factor(), | 416 active_tree_->current_page_scale_factor(), viewport_size, |
423 viewport_size, | 417 scaled_scrollable_size, timing_function.Pass()); |
424 scaled_scrollable_size, | |
425 timing_function.Pass()); | |
426 | 418 |
427 if (anchor_point) { | 419 if (anchor_point) { |
428 gfx::Vector2dF anchor(target_offset); | 420 gfx::Vector2dF anchor(target_offset); |
429 page_scale_animation_->ZoomWithAnchor(anchor, | 421 page_scale_animation_->ZoomWithAnchor(anchor, |
430 page_scale, | 422 page_scale, |
431 duration.InSecondsF()); | 423 duration.InSecondsF()); |
432 } else { | 424 } else { |
433 gfx::Vector2dF scaled_target_offset = target_offset; | 425 gfx::Vector2dF scaled_target_offset = target_offset; |
434 page_scale_animation_->ZoomTo(scaled_target_offset, | 426 page_scale_animation_->ZoomTo(scaled_target_offset, |
435 page_scale, | 427 page_scale, |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 false, | 660 false, |
669 gfx::PointF( | 661 gfx::PointF( |
670 screen_space_rect.x() / overhang_resource_scaled_size.width(), | 662 screen_space_rect.x() / overhang_resource_scaled_size.width(), |
671 screen_space_rect.y() / overhang_resource_scaled_size.height()), | 663 screen_space_rect.y() / overhang_resource_scaled_size.height()), |
672 gfx::PointF( | 664 gfx::PointF( |
673 screen_space_rect.right() / overhang_resource_scaled_size.width(), | 665 screen_space_rect.right() / overhang_resource_scaled_size.width(), |
674 screen_space_rect.bottom() / | 666 screen_space_rect.bottom() / |
675 overhang_resource_scaled_size.height()), | 667 overhang_resource_scaled_size.height()), |
676 screen_background_color, | 668 screen_background_color, |
677 vertex_opacity, | 669 vertex_opacity, |
| 670 false, |
678 false); | 671 false); |
679 } | 672 } |
680 } | 673 } |
681 | 674 |
682 DrawResult LayerTreeHostImpl::CalculateRenderPasses( | 675 DrawResult LayerTreeHostImpl::CalculateRenderPasses( |
683 FrameData* frame) { | 676 FrameData* frame) { |
684 DCHECK(frame->render_passes.empty()); | 677 DCHECK(frame->render_passes.empty()); |
685 DCHECK(CanDraw()); | 678 DCHECK(CanDraw()); |
686 DCHECK(active_tree_->root_layer()); | 679 DCHECK(active_tree_->root_layer()); |
687 | 680 |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 EnforceManagedMemoryPolicy(ManagedMemoryPolicy(0)); | 1094 EnforceManagedMemoryPolicy(ManagedMemoryPolicy(0)); |
1102 } | 1095 } |
1103 | 1096 |
1104 void LayerTreeHostImpl::BlockNotifyReadyToActivateForTesting(bool block) { | 1097 void LayerTreeHostImpl::BlockNotifyReadyToActivateForTesting(bool block) { |
1105 NOTREACHED(); | 1098 NOTREACHED(); |
1106 } | 1099 } |
1107 | 1100 |
1108 void LayerTreeHostImpl::ResetTreesForTesting() { | 1101 void LayerTreeHostImpl::ResetTreesForTesting() { |
1109 if (active_tree_) | 1102 if (active_tree_) |
1110 active_tree_->DetachLayerTree(); | 1103 active_tree_->DetachLayerTree(); |
1111 active_tree_ = LayerTreeImpl::create(this); | 1104 active_tree_ = |
| 1105 LayerTreeImpl::create(this, active_tree()->page_scale_factor()); |
1112 if (pending_tree_) | 1106 if (pending_tree_) |
1113 pending_tree_->DetachLayerTree(); | 1107 pending_tree_->DetachLayerTree(); |
1114 pending_tree_ = nullptr; | 1108 pending_tree_ = nullptr; |
1115 if (recycle_tree_) | 1109 if (recycle_tree_) |
1116 recycle_tree_->DetachLayerTree(); | 1110 recycle_tree_->DetachLayerTree(); |
1117 recycle_tree_ = nullptr; | 1111 recycle_tree_ = nullptr; |
1118 } | 1112 } |
1119 | 1113 |
1120 void LayerTreeHostImpl::EnforceManagedMemoryPolicy( | 1114 void LayerTreeHostImpl::EnforceManagedMemoryPolicy( |
1121 const ManagedMemoryPolicy& policy) { | 1115 const ManagedMemoryPolicy& policy) { |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1425 } | 1419 } |
1426 } | 1420 } |
1427 | 1421 |
1428 void LayerTreeHostImpl::OnCanDrawStateChangedForTree() { | 1422 void LayerTreeHostImpl::OnCanDrawStateChangedForTree() { |
1429 client_->OnCanDrawStateChanged(CanDraw()); | 1423 client_->OnCanDrawStateChanged(CanDraw()); |
1430 } | 1424 } |
1431 | 1425 |
1432 CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() const { | 1426 CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() const { |
1433 CompositorFrameMetadata metadata; | 1427 CompositorFrameMetadata metadata; |
1434 metadata.device_scale_factor = device_scale_factor_; | 1428 metadata.device_scale_factor = device_scale_factor_; |
1435 metadata.page_scale_factor = active_tree_->total_page_scale_factor(); | 1429 metadata.page_scale_factor = active_tree_->current_page_scale_factor(); |
1436 metadata.scrollable_viewport_size = active_tree_->ScrollableViewportSize(); | 1430 metadata.scrollable_viewport_size = active_tree_->ScrollableViewportSize(); |
1437 metadata.root_layer_size = active_tree_->ScrollableSize(); | 1431 metadata.root_layer_size = active_tree_->ScrollableSize(); |
1438 metadata.min_page_scale_factor = active_tree_->min_page_scale_factor(); | 1432 metadata.min_page_scale_factor = active_tree_->min_page_scale_factor(); |
1439 metadata.max_page_scale_factor = active_tree_->max_page_scale_factor(); | 1433 metadata.max_page_scale_factor = active_tree_->max_page_scale_factor(); |
1440 if (top_controls_manager_) { | 1434 if (top_controls_manager_) { |
1441 metadata.location_bar_offset = | 1435 metadata.location_bar_offset = |
1442 gfx::Vector2dF(0.f, top_controls_manager_->ControlsTopOffset()); | 1436 gfx::Vector2dF(0.f, top_controls_manager_->ControlsTopOffset()); |
1443 metadata.location_bar_content_translation = | 1437 metadata.location_bar_content_translation = |
1444 gfx::Vector2dF(0.f, top_controls_manager_->ContentTopOffset()); | 1438 gfx::Vector2dF(0.f, top_controls_manager_->ContentTopOffset()); |
1445 } | 1439 } |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1654 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); | 1648 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); |
1655 | 1649 |
1656 if (!inner_container || !top_controls_manager_) | 1650 if (!inner_container || !top_controls_manager_) |
1657 return; | 1651 return; |
1658 | 1652 |
1659 ViewportAnchor anchor(InnerViewportScrollLayer(), | 1653 ViewportAnchor anchor(InnerViewportScrollLayer(), |
1660 OuterViewportScrollLayer()); | 1654 OuterViewportScrollLayer()); |
1661 | 1655 |
1662 // Adjust the inner viewport by shrinking/expanding the container to account | 1656 // Adjust the inner viewport by shrinking/expanding the container to account |
1663 // for the change in top controls height since the last Resize from Blink. | 1657 // for the change in top controls height since the last Resize from Blink. |
| 1658 float top_controls_layout_height = |
| 1659 active_tree_->top_controls_shrink_blink_size() |
| 1660 ? active_tree_->top_controls_height() |
| 1661 : 0.f; |
1664 inner_container->SetBoundsDelta( | 1662 inner_container->SetBoundsDelta( |
1665 gfx::Vector2dF(0, active_tree_->top_controls_layout_height() - | 1663 gfx::Vector2dF(0, top_controls_layout_height - |
1666 active_tree_->total_top_controls_content_offset())); | 1664 active_tree_->total_top_controls_content_offset())); |
1667 | 1665 |
1668 if (!outer_container || outer_container->BoundsForScrolling().IsEmpty()) | 1666 if (!outer_container || outer_container->BoundsForScrolling().IsEmpty()) |
1669 return; | 1667 return; |
1670 | 1668 |
1671 // Adjust the outer viewport container as well, since adjusting only the | 1669 // Adjust the outer viewport container as well, since adjusting only the |
1672 // inner may cause its bounds to exceed those of the outer, causing scroll | 1670 // inner may cause its bounds to exceed those of the outer, causing scroll |
1673 // clamping. We adjust it so it maintains the same aspect ratio as the | 1671 // clamping. We adjust it so it maintains the same aspect ratio as the |
1674 // inner viewport. | 1672 // inner viewport. |
1675 float aspect_ratio = inner_container->BoundsForScrolling().width() / | 1673 float aspect_ratio = inner_container->BoundsForScrolling().width() / |
1676 inner_container->BoundsForScrolling().height(); | 1674 inner_container->BoundsForScrolling().height(); |
1677 float target_height = outer_container->BoundsForScrolling().width() / | 1675 float target_height = outer_container->BoundsForScrolling().width() / |
1678 aspect_ratio; | 1676 aspect_ratio; |
1679 float current_outer_height = outer_container->BoundsForScrolling().height() - | 1677 float current_outer_height = outer_container->BoundsForScrolling().height() - |
1680 outer_container->bounds_delta().y(); | 1678 outer_container->bounds_delta().y(); |
1681 gfx::Vector2dF delta(0, target_height - current_outer_height); | 1679 gfx::Vector2dF delta(0, target_height - current_outer_height); |
1682 | 1680 |
1683 outer_container->SetBoundsDelta(delta); | 1681 outer_container->SetBoundsDelta(delta); |
1684 active_tree_->InnerViewportScrollLayer()->SetBoundsDelta(delta); | 1682 active_tree_->InnerViewportScrollLayer()->SetBoundsDelta(delta); |
1685 | 1683 |
1686 anchor.ResetViewportToAnchoredPosition(); | 1684 anchor.ResetViewportToAnchoredPosition(); |
1687 } | 1685 } |
1688 | 1686 |
1689 void LayerTreeHostImpl::SetTopControlsLayoutHeight(float height) { | |
1690 if (active_tree_->top_controls_layout_height() == height) | |
1691 return; | |
1692 | |
1693 active_tree_->set_top_controls_layout_height(height); | |
1694 UpdateViewportContainerSizes(); | |
1695 SetFullRootLayerDamage(); | |
1696 } | |
1697 | |
1698 void LayerTreeHostImpl::SynchronouslyInitializeAllTiles() { | 1687 void LayerTreeHostImpl::SynchronouslyInitializeAllTiles() { |
1699 // Only valid for the single-threaded non-scheduled/synchronous case | 1688 // Only valid for the single-threaded non-scheduled/synchronous case |
1700 // using the zero copy raster worker pool. | 1689 // using the zero copy raster worker pool. |
1701 single_thread_synchronous_task_graph_runner_->RunUntilIdle(); | 1690 single_thread_synchronous_task_graph_runner_->RunUntilIdle(); |
1702 } | 1691 } |
1703 | 1692 |
1704 void LayerTreeHostImpl::DidLoseOutputSurface() { | 1693 void LayerTreeHostImpl::DidLoseOutputSurface() { |
1705 if (resource_provider_) | 1694 if (resource_provider_) |
1706 resource_provider_->DidLoseOutputSurface(); | 1695 resource_provider_->DidLoseOutputSurface(); |
1707 client_->DidLoseOutputSurfaceOnImplThread(); | 1696 client_->DidLoseOutputSurfaceOnImplThread(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1751 return layer_impl->parent(); | 1740 return layer_impl->parent(); |
1752 | 1741 |
1753 return NULL; | 1742 return NULL; |
1754 } | 1743 } |
1755 | 1744 |
1756 void LayerTreeHostImpl::CreatePendingTree() { | 1745 void LayerTreeHostImpl::CreatePendingTree() { |
1757 CHECK(!pending_tree_); | 1746 CHECK(!pending_tree_); |
1758 if (recycle_tree_) | 1747 if (recycle_tree_) |
1759 recycle_tree_.swap(pending_tree_); | 1748 recycle_tree_.swap(pending_tree_); |
1760 else | 1749 else |
1761 pending_tree_ = LayerTreeImpl::create(this); | 1750 pending_tree_ = |
| 1751 LayerTreeImpl::create(this, active_tree()->page_scale_factor()); |
1762 | 1752 |
1763 // Update the delta from the active tree, which may have | 1753 // Update the delta from the active tree, which may have |
1764 // adjusted its delta prior to the pending tree being created. | 1754 // adjusted its delta prior to the pending tree being created. |
1765 DCHECK_EQ(1.f, pending_tree_->sent_page_scale_delta()); | |
1766 DCHECK_EQ(0.f, pending_tree_->sent_top_controls_delta()); | 1755 DCHECK_EQ(0.f, pending_tree_->sent_top_controls_delta()); |
1767 pending_tree_->SetPageScaleDelta(active_tree_->page_scale_delta() / | |
1768 active_tree_->sent_page_scale_delta()); | |
1769 pending_tree_->set_top_controls_delta( | 1756 pending_tree_->set_top_controls_delta( |
1770 active_tree_->top_controls_delta() - | 1757 active_tree_->top_controls_delta() - |
1771 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()); |
1772 | 1760 |
1773 client_->OnCanDrawStateChanged(CanDraw()); | 1761 client_->OnCanDrawStateChanged(CanDraw()); |
1774 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get()); | 1762 TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get()); |
1775 } | 1763 } |
1776 | 1764 |
1777 void LayerTreeHostImpl::ActivateSyncTree() { | 1765 void LayerTreeHostImpl::ActivateSyncTree() { |
1778 if (pending_tree_) { | 1766 if (pending_tree_) { |
1779 TRACE_EVENT_ASYNC_END0("cc", "PendingTree:waiting", pending_tree_.get()); | 1767 TRACE_EVENT_ASYNC_END0("cc", "PendingTree:waiting", pending_tree_.get()); |
1780 | 1768 |
1781 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); | 1769 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); |
(...skipping 16 matching lines...) Expand all Loading... |
1798 // 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 |
1799 // 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 |
1800 // next sync. | 1788 // next sync. |
1801 DCHECK(!recycle_tree_); | 1789 DCHECK(!recycle_tree_); |
1802 pending_tree_.swap(recycle_tree_); | 1790 pending_tree_.swap(recycle_tree_); |
1803 | 1791 |
1804 active_tree_->SetRootLayerScrollOffsetDelegate( | 1792 active_tree_->SetRootLayerScrollOffsetDelegate( |
1805 root_layer_scroll_offset_delegate_); | 1793 root_layer_scroll_offset_delegate_); |
1806 | 1794 |
1807 if (top_controls_manager_) { | 1795 if (top_controls_manager_) { |
| 1796 top_controls_manager_->SetTopControlsHeight( |
| 1797 active_tree_->top_controls_height()); |
1808 top_controls_manager_->SetControlsTopOffset( | 1798 top_controls_manager_->SetControlsTopOffset( |
1809 active_tree_->total_top_controls_content_offset() - | 1799 active_tree_->total_top_controls_content_offset() - |
1810 top_controls_manager_->top_controls_height()); | 1800 active_tree_->top_controls_height()); |
1811 } | 1801 } |
1812 | 1802 |
1813 UpdateViewportContainerSizes(); | 1803 UpdateViewportContainerSizes(); |
1814 } else { | 1804 } else { |
1815 active_tree_->ProcessUIResourceRequestQueue(); | 1805 active_tree_->ProcessUIResourceRequestQueue(); |
1816 } | 1806 } |
1817 | 1807 |
1818 active_tree_->DidBecomeActive(); | 1808 active_tree_->DidBecomeActive(); |
1819 ActivateAnimations(); | 1809 ActivateAnimations(); |
1820 if (settings_.impl_side_painting) | 1810 if (settings_.impl_side_painting) |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2225 } | 2215 } |
2226 | 2216 |
2227 void LayerTreeHostImpl::SetDeviceScaleFactor(float device_scale_factor) { | 2217 void LayerTreeHostImpl::SetDeviceScaleFactor(float device_scale_factor) { |
2228 if (device_scale_factor == device_scale_factor_) | 2218 if (device_scale_factor == device_scale_factor_) |
2229 return; | 2219 return; |
2230 device_scale_factor_ = device_scale_factor; | 2220 device_scale_factor_ = device_scale_factor; |
2231 | 2221 |
2232 SetFullRootLayerDamage(); | 2222 SetFullRootLayerDamage(); |
2233 } | 2223 } |
2234 | 2224 |
| 2225 void LayerTreeHostImpl::SetPageScaleOnActiveTree(float page_scale_factor) { |
| 2226 active_tree_->SetPageScaleOnActiveTree(page_scale_factor); |
| 2227 } |
| 2228 |
2235 const gfx::Rect LayerTreeHostImpl::ViewportRectForTilePriority() const { | 2229 const gfx::Rect LayerTreeHostImpl::ViewportRectForTilePriority() const { |
2236 if (viewport_rect_for_tile_priority_.IsEmpty()) | 2230 if (viewport_rect_for_tile_priority_.IsEmpty()) |
2237 return DeviceViewport(); | 2231 return DeviceViewport(); |
2238 | 2232 |
2239 return viewport_rect_for_tile_priority_; | 2233 return viewport_rect_for_tile_priority_; |
2240 } | 2234 } |
2241 | 2235 |
2242 gfx::Size LayerTreeHostImpl::DrawViewportSize() const { | 2236 gfx::Size LayerTreeHostImpl::DrawViewportSize() const { |
2243 return DeviceViewport().size(); | 2237 return DeviceViewport().size(); |
2244 } | 2238 } |
(...skipping 19 matching lines...) Expand all Loading... |
2264 void LayerTreeHostImpl::DidChangeTopControlsPosition() { | 2258 void LayerTreeHostImpl::DidChangeTopControlsPosition() { |
2265 UpdateViewportContainerSizes(); | 2259 UpdateViewportContainerSizes(); |
2266 SetNeedsRedraw(); | 2260 SetNeedsRedraw(); |
2267 SetNeedsAnimate(); | 2261 SetNeedsAnimate(); |
2268 active_tree_->set_needs_update_draw_properties(); | 2262 active_tree_->set_needs_update_draw_properties(); |
2269 SetFullRootLayerDamage(); | 2263 SetFullRootLayerDamage(); |
2270 } | 2264 } |
2271 | 2265 |
2272 void LayerTreeHostImpl::SetControlsTopOffset(float offset) { | 2266 void LayerTreeHostImpl::SetControlsTopOffset(float offset) { |
2273 float current_top_offset = active_tree_->top_controls_content_offset() - | 2267 float current_top_offset = active_tree_->top_controls_content_offset() - |
2274 top_controls_manager_->top_controls_height(); | 2268 active_tree_->top_controls_height(); |
2275 active_tree_->set_top_controls_delta(offset - current_top_offset); | 2269 active_tree_->set_top_controls_delta(offset - current_top_offset); |
2276 } | 2270 } |
2277 | 2271 |
2278 float LayerTreeHostImpl::ControlsTopOffset() const { | 2272 float LayerTreeHostImpl::ControlsTopOffset() const { |
2279 return active_tree_->total_top_controls_content_offset() - | 2273 return active_tree_->total_top_controls_content_offset() - |
2280 top_controls_manager_->top_controls_height(); | 2274 active_tree_->top_controls_height(); |
2281 } | 2275 } |
2282 | 2276 |
2283 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { | 2277 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { |
2284 DCHECK(input_handler_client_ == NULL); | 2278 DCHECK(input_handler_client_ == NULL); |
2285 input_handler_client_ = client; | 2279 input_handler_client_ = client; |
2286 } | 2280 } |
2287 | 2281 |
2288 static LayerImpl* NextScrollLayer(LayerImpl* layer) { | 2282 static LayerImpl* NextScrollLayer(LayerImpl* layer) { |
2289 if (LayerImpl* scroll_parent = layer->scroll_parent()) | 2283 if (LayerImpl* scroll_parent = layer->scroll_parent()) |
2290 return scroll_parent; | 2284 return scroll_parent; |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2640 // scrolling so we can just apply them directly, but the page scale factor | 2634 // scrolling so we can just apply them directly, but the page scale factor |
2641 // is applied to the scroll delta. | 2635 // is applied to the scroll delta. |
2642 if (!wheel_scrolling_) { | 2636 if (!wheel_scrolling_) { |
2643 float scale_from_viewport_to_screen_space = device_scale_factor_; | 2637 float scale_from_viewport_to_screen_space = device_scale_factor_; |
2644 applied_delta = | 2638 applied_delta = |
2645 ScrollLayerWithViewportSpaceDelta(layer_impl, | 2639 ScrollLayerWithViewportSpaceDelta(layer_impl, |
2646 scale_from_viewport_to_screen_space, | 2640 scale_from_viewport_to_screen_space, |
2647 viewport_point, pending_delta); | 2641 viewport_point, pending_delta); |
2648 } else { | 2642 } else { |
2649 applied_delta = ScrollLayerWithLocalDelta( | 2643 applied_delta = ScrollLayerWithLocalDelta( |
2650 layer_impl, pending_delta, active_tree_->total_page_scale_factor()); | 2644 layer_impl, pending_delta, active_tree_->current_page_scale_factor()); |
2651 } | 2645 } |
2652 | 2646 |
2653 const float kEpsilon = 0.1f; | 2647 const float kEpsilon = 0.1f; |
2654 if (layer_impl == InnerViewportScrollLayer()) { | 2648 if (layer_impl == InnerViewportScrollLayer()) { |
2655 unused_root_delta.Subtract(applied_delta); | 2649 unused_root_delta.Subtract(applied_delta); |
2656 if (std::abs(unused_root_delta.x()) < kEpsilon) | 2650 if (std::abs(unused_root_delta.x()) < kEpsilon) |
2657 unused_root_delta.set_x(0.0f); | 2651 unused_root_delta.set_x(0.0f); |
2658 if (std::abs(unused_root_delta.y()) < kEpsilon) | 2652 if (std::abs(unused_root_delta.y()) < kEpsilon) |
2659 unused_root_delta.set_y(0.0f); | 2653 unused_root_delta.set_y(0.0f); |
2660 // Disable overscroll on axes which is impossible to scroll. | 2654 // Disable overscroll on axes which is impossible to scroll. |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2944 | 2938 |
2945 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); | 2939 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); |
2946 | 2940 |
2947 // For a moment the scroll offset ends up being outside of the max range. This | 2941 // For a moment the scroll offset ends up being outside of the max range. This |
2948 // confuses the delegate so we switch it off till after we're done processing | 2942 // confuses the delegate so we switch it off till after we're done processing |
2949 // the pinch update. | 2943 // the pinch update. |
2950 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); | 2944 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); |
2951 | 2945 |
2952 // Keep the center-of-pinch anchor specified by (x, y) in a stable | 2946 // Keep the center-of-pinch anchor specified by (x, y) in a stable |
2953 // position over the course of the magnify. | 2947 // position over the course of the magnify. |
2954 float page_scale_delta = active_tree_->page_scale_delta(); | 2948 float page_scale = active_tree_->current_page_scale_factor(); |
2955 gfx::PointF previous_scale_anchor = | 2949 gfx::PointF previous_scale_anchor = gfx::ScalePoint(anchor, 1.f / page_scale); |
2956 gfx::ScalePoint(anchor, 1.f / page_scale_delta); | 2950 active_tree_->SetPageScaleOnActiveTree(page_scale * magnify_delta); |
2957 active_tree_->SetPageScaleDelta(page_scale_delta * magnify_delta); | 2951 page_scale = active_tree_->current_page_scale_factor(); |
2958 page_scale_delta = active_tree_->page_scale_delta(); | 2952 gfx::PointF new_scale_anchor = gfx::ScalePoint(anchor, 1.f / page_scale); |
2959 gfx::PointF new_scale_anchor = | |
2960 gfx::ScalePoint(anchor, 1.f / page_scale_delta); | |
2961 gfx::Vector2dF move = previous_scale_anchor - new_scale_anchor; | 2953 gfx::Vector2dF move = previous_scale_anchor - new_scale_anchor; |
2962 | 2954 |
2963 previous_pinch_anchor_ = anchor; | 2955 previous_pinch_anchor_ = anchor; |
2964 | 2956 |
2965 move.Scale(1 / active_tree_->page_scale_factor()); | |
2966 // If clamping the inner viewport scroll offset causes a change, it should | 2957 // If clamping the inner viewport scroll offset causes a change, it should |
2967 // be accounted for from the intended move. | 2958 // be accounted for from the intended move. |
2968 move -= InnerViewportScrollLayer()->ClampScrollToMaxScrollOffset(); | 2959 move -= InnerViewportScrollLayer()->ClampScrollToMaxScrollOffset(); |
2969 | 2960 |
2970 // We manually manage the bubbling behaviour here as it is different to that | 2961 // We manually manage the bubbling behaviour here as it is different to that |
2971 // implemented in LayerTreeHostImpl::ScrollBy(). Specifically: | 2962 // implemented in LayerTreeHostImpl::ScrollBy(). Specifically: |
2972 // 1) we want to explicit limit the bubbling to the outer/inner viewports, | 2963 // 1) we want to explicit limit the bubbling to the outer/inner viewports, |
2973 // 2) we don't want the directional limitations on the unused parts that | 2964 // 2) we don't want the directional limitations on the unused parts that |
2974 // ScrollBy() implements, and | 2965 // ScrollBy() implements, and |
2975 // 3) pinching should not engage the top controls manager. | 2966 // 3) pinching should not engage the top controls manager. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3022 } | 3013 } |
3023 | 3014 |
3024 for (size_t i = 0; i < layer_impl->children().size(); ++i) | 3015 for (size_t i = 0; i < layer_impl->children().size(); ++i) |
3025 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); | 3016 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); |
3026 } | 3017 } |
3027 | 3018 |
3028 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { | 3019 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { |
3029 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); | 3020 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); |
3030 | 3021 |
3031 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); | 3022 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); |
3032 scroll_info->page_scale_delta = active_tree_->page_scale_delta(); | 3023 scroll_info->page_scale_delta = |
3033 active_tree_->set_sent_page_scale_delta(scroll_info->page_scale_delta); | 3024 active_tree_->page_scale_factor()->PullDeltaForMainThread(); |
3034 scroll_info->swap_promises.swap(swap_promises_for_main_thread_scroll_update_); | 3025 scroll_info->swap_promises.swap(swap_promises_for_main_thread_scroll_update_); |
3035 scroll_info->top_controls_delta = active_tree()->top_controls_delta(); | 3026 scroll_info->top_controls_delta = active_tree()->top_controls_delta(); |
3036 active_tree_->set_sent_top_controls_delta(scroll_info->top_controls_delta); | 3027 active_tree_->set_sent_top_controls_delta(scroll_info->top_controls_delta); |
3037 | 3028 |
3038 return scroll_info.Pass(); | 3029 return scroll_info.Pass(); |
3039 } | 3030 } |
3040 | 3031 |
3041 void LayerTreeHostImpl::SetFullRootLayerDamage() { | 3032 void LayerTreeHostImpl::SetFullRootLayerDamage() { |
3042 SetViewportDamage(gfx::Rect(DrawViewportSize())); | 3033 SetViewportDamage(gfx::Rect(DrawViewportSize())); |
3043 } | 3034 } |
(...skipping 21 matching lines...) Expand all Loading... |
3065 | 3056 |
3066 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { | 3057 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { |
3067 if (!page_scale_animation_) | 3058 if (!page_scale_animation_) |
3068 return; | 3059 return; |
3069 | 3060 |
3070 gfx::ScrollOffset scroll_total = active_tree_->TotalScrollOffset(); | 3061 gfx::ScrollOffset scroll_total = active_tree_->TotalScrollOffset(); |
3071 | 3062 |
3072 if (!page_scale_animation_->IsAnimationStarted()) | 3063 if (!page_scale_animation_->IsAnimationStarted()) |
3073 page_scale_animation_->StartAnimation(monotonic_time); | 3064 page_scale_animation_->StartAnimation(monotonic_time); |
3074 | 3065 |
3075 active_tree_->SetPageScaleDelta( | 3066 active_tree_->SetPageScaleOnActiveTree( |
3076 page_scale_animation_->PageScaleFactorAtTime(monotonic_time) / | 3067 page_scale_animation_->PageScaleFactorAtTime(monotonic_time)); |
3077 active_tree_->page_scale_factor()); | |
3078 gfx::ScrollOffset next_scroll = gfx::ScrollOffset( | 3068 gfx::ScrollOffset next_scroll = gfx::ScrollOffset( |
3079 page_scale_animation_->ScrollOffsetAtTime(monotonic_time)); | 3069 page_scale_animation_->ScrollOffsetAtTime(monotonic_time)); |
3080 | 3070 |
3081 ScrollViewportInnerFirst(next_scroll.DeltaFrom(scroll_total)); | 3071 ScrollViewportInnerFirst(next_scroll.DeltaFrom(scroll_total)); |
3082 SetNeedsRedraw(); | 3072 SetNeedsRedraw(); |
3083 | 3073 |
3084 if (page_scale_animation_->IsAnimationCompleteAtTime(monotonic_time)) { | 3074 if (page_scale_animation_->IsAnimationCompleteAtTime(monotonic_time)) { |
3085 page_scale_animation_ = nullptr; | 3075 page_scale_animation_ = nullptr; |
3086 client_->SetNeedsCommitOnImplThread(); | 3076 client_->SetNeedsCommitOnImplThread(); |
3087 client_->RenewTreePriority(); | 3077 client_->RenewTreePriority(); |
(...skipping 11 matching lines...) Expand all Loading... |
3099 if (top_controls_manager_->animation()) | 3089 if (top_controls_manager_->animation()) |
3100 SetNeedsAnimate(); | 3090 SetNeedsAnimate(); |
3101 | 3091 |
3102 if (active_tree_->TotalScrollOffset().y() == 0.f) | 3092 if (active_tree_->TotalScrollOffset().y() == 0.f) |
3103 return; | 3093 return; |
3104 | 3094 |
3105 if (scroll.IsZero()) | 3095 if (scroll.IsZero()) |
3106 return; | 3096 return; |
3107 | 3097 |
3108 ScrollViewportBy(gfx::ScaleVector2d( | 3098 ScrollViewportBy(gfx::ScaleVector2d( |
3109 scroll, 1.f / active_tree_->total_page_scale_factor())); | 3099 scroll, 1.f / active_tree_->current_page_scale_factor())); |
3110 SetNeedsRedraw(); | 3100 SetNeedsRedraw(); |
3111 client_->SetNeedsCommitOnImplThread(); | 3101 client_->SetNeedsCommitOnImplThread(); |
3112 client_->RenewTreePriority(); | 3102 client_->RenewTreePriority(); |
3113 } | 3103 } |
3114 | 3104 |
3115 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { | 3105 void LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { |
3116 if (!settings_.accelerated_animation_enabled || | 3106 if (!settings_.accelerated_animation_enabled || |
3117 !needs_animate_layers() || | 3107 !needs_animate_layers() || |
3118 !active_tree_->root_layer()) | 3108 !active_tree_->root_layer()) |
3119 return; | 3109 return; |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3487 } | 3477 } |
3488 | 3478 |
3489 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3479 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3490 std::vector<PictureLayerImpl*>::iterator it = | 3480 std::vector<PictureLayerImpl*>::iterator it = |
3491 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3481 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3492 DCHECK(it != picture_layers_.end()); | 3482 DCHECK(it != picture_layers_.end()); |
3493 picture_layers_.erase(it); | 3483 picture_layers_.erase(it); |
3494 } | 3484 } |
3495 | 3485 |
3496 } // namespace cc | 3486 } // namespace cc |
OLD | NEW |