| 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 shared_bitmap_manager_(manager), | 266 shared_bitmap_manager_(manager), |
| 267 id_(id), | 267 id_(id), |
| 268 transfer_buffer_memory_limit_(0u) { | 268 transfer_buffer_memory_limit_(0u) { |
| 269 DCHECK(proxy_->IsImplThread()); | 269 DCHECK(proxy_->IsImplThread()); |
| 270 DidVisibilityChange(this, visible_); | 270 DidVisibilityChange(this, visible_); |
| 271 animation_registrar_->set_supports_scroll_animations( | 271 animation_registrar_->set_supports_scroll_animations( |
| 272 proxy_->SupportsImplScrolling()); | 272 proxy_->SupportsImplScrolling()); |
| 273 | 273 |
| 274 SetDebugState(settings.initial_debug_state); | 274 SetDebugState(settings.initial_debug_state); |
| 275 | 275 |
| 276 // LTHI always has an active tree. |
| 277 active_tree_ = LayerTreeImpl::create(this); |
| 278 TRACE_EVENT_OBJECT_CREATED_WITH_ID( |
| 279 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); |
| 280 |
| 276 if (settings.calculate_top_controls_position) { | 281 if (settings.calculate_top_controls_position) { |
| 277 top_controls_manager_ = | 282 top_controls_manager_ = |
| 278 TopControlsManager::Create(this, | 283 TopControlsManager::Create(this, |
| 279 settings.top_controls_height, | 284 settings.top_controls_height, |
| 280 settings.top_controls_show_threshold, | 285 settings.top_controls_show_threshold, |
| 281 settings.top_controls_hide_threshold); | 286 settings.top_controls_hide_threshold); |
| 282 } | 287 } |
| 283 | |
| 284 SetDebugState(settings.initial_debug_state); | |
| 285 | |
| 286 // LTHI always has an active tree. | |
| 287 active_tree_ = LayerTreeImpl::create(this); | |
| 288 TRACE_EVENT_OBJECT_CREATED_WITH_ID( | |
| 289 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); | |
| 290 } | 288 } |
| 291 | 289 |
| 292 LayerTreeHostImpl::~LayerTreeHostImpl() { | 290 LayerTreeHostImpl::~LayerTreeHostImpl() { |
| 293 DCHECK(proxy_->IsImplThread()); | 291 DCHECK(proxy_->IsImplThread()); |
| 294 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); | 292 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); |
| 295 TRACE_EVENT_OBJECT_DELETED_WITH_ID( | 293 TRACE_EVENT_OBJECT_DELETED_WITH_ID( |
| 296 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); | 294 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); |
| 297 | 295 |
| 298 if (input_handler_client_) { | 296 if (input_handler_client_) { |
| 299 input_handler_client_->WillShutdown(); | 297 input_handler_client_->WillShutdown(); |
| (...skipping 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1687 } | 1685 } |
| 1688 | 1686 |
| 1689 void LayerTreeHostImpl::UpdateInnerViewportContainerSize() { | 1687 void LayerTreeHostImpl::UpdateInnerViewportContainerSize() { |
| 1690 LayerImpl* container_layer = active_tree_->InnerViewportContainerLayer(); | 1688 LayerImpl* container_layer = active_tree_->InnerViewportContainerLayer(); |
| 1691 if (!container_layer) | 1689 if (!container_layer) |
| 1692 return; | 1690 return; |
| 1693 | 1691 |
| 1694 if (top_controls_manager_) { | 1692 if (top_controls_manager_) { |
| 1695 container_layer->SetBoundsDelta( | 1693 container_layer->SetBoundsDelta( |
| 1696 gfx::Vector2dF(0, active_tree_->top_controls_layout_height() - | 1694 gfx::Vector2dF(0, active_tree_->top_controls_layout_height() - |
| 1697 active_tree_->total_top_controls_top_offset() - | 1695 active_tree_->total_top_controls_content_offset())); |
| 1698 top_controls_manager_->controls_height())); | |
| 1699 } | 1696 } |
| 1700 } | 1697 } |
| 1701 | 1698 |
| 1702 void LayerTreeHostImpl::SetTopControlsLayoutHeight(float height) { | 1699 void LayerTreeHostImpl::SetTopControlsLayoutHeight(float height) { |
| 1703 if (active_tree_->top_controls_layout_height() == height) | 1700 if (active_tree_->top_controls_layout_height() == height) |
| 1704 return; | 1701 return; |
| 1705 | 1702 |
| 1706 active_tree_->set_top_controls_layout_height(height); | 1703 active_tree_->set_top_controls_layout_height(height); |
| 1707 UpdateInnerViewportContainerSize(); | 1704 UpdateInnerViewportContainerSize(); |
| 1708 SetFullRootLayerDamage(); | 1705 SetFullRootLayerDamage(); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1814 // tree, rename the pending tree the recycle tree so we can reuse it on the | 1811 // tree, rename the pending tree the recycle tree so we can reuse it on the |
| 1815 // next sync. | 1812 // next sync. |
| 1816 DCHECK(!recycle_tree_); | 1813 DCHECK(!recycle_tree_); |
| 1817 pending_tree_.swap(recycle_tree_); | 1814 pending_tree_.swap(recycle_tree_); |
| 1818 | 1815 |
| 1819 active_tree_->SetRootLayerScrollOffsetDelegate( | 1816 active_tree_->SetRootLayerScrollOffsetDelegate( |
| 1820 root_layer_scroll_offset_delegate_); | 1817 root_layer_scroll_offset_delegate_); |
| 1821 | 1818 |
| 1822 if (top_controls_manager_) { | 1819 if (top_controls_manager_) { |
| 1823 top_controls_manager_->SetControlsTopOffset( | 1820 top_controls_manager_->SetControlsTopOffset( |
| 1824 active_tree_->total_top_controls_top_offset()); | 1821 active_tree_->total_top_controls_content_offset() - |
| 1822 top_controls_manager_->top_controls_height()); |
| 1825 } | 1823 } |
| 1826 | 1824 |
| 1827 UpdateInnerViewportContainerSize(); | 1825 UpdateInnerViewportContainerSize(); |
| 1828 } else { | 1826 } else { |
| 1829 active_tree_->ProcessUIResourceRequestQueue(); | 1827 active_tree_->ProcessUIResourceRequestQueue(); |
| 1830 } | 1828 } |
| 1831 | 1829 |
| 1832 active_tree_->DidBecomeActive(); | 1830 active_tree_->DidBecomeActive(); |
| 1833 ActivateAnimations(); | 1831 ActivateAnimations(); |
| 1834 if (settings_.impl_side_painting) | 1832 if (settings_.impl_side_painting) |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2223 | 2221 |
| 2224 void LayerTreeHostImpl::DidChangeTopControlsPosition() { | 2222 void LayerTreeHostImpl::DidChangeTopControlsPosition() { |
| 2225 UpdateInnerViewportContainerSize(); | 2223 UpdateInnerViewportContainerSize(); |
| 2226 SetNeedsRedraw(); | 2224 SetNeedsRedraw(); |
| 2227 SetNeedsAnimate(); | 2225 SetNeedsAnimate(); |
| 2228 active_tree_->set_needs_update_draw_properties(); | 2226 active_tree_->set_needs_update_draw_properties(); |
| 2229 SetFullRootLayerDamage(); | 2227 SetFullRootLayerDamage(); |
| 2230 } | 2228 } |
| 2231 | 2229 |
| 2232 void LayerTreeHostImpl::SetControlsTopOffset(float offset) { | 2230 void LayerTreeHostImpl::SetControlsTopOffset(float offset) { |
| 2233 active_tree_->set_top_controls_delta( | 2231 float current_top_offset = active_tree_->top_controls_content_offset() - |
| 2234 offset - active_tree_->top_controls_top_offset()); | 2232 top_controls_manager_->top_controls_height(); |
| 2233 active_tree_->set_top_controls_delta(offset - current_top_offset); |
| 2235 } | 2234 } |
| 2236 | 2235 |
| 2237 float LayerTreeHostImpl::ControlsTopOffset() const { | 2236 float LayerTreeHostImpl::ControlsTopOffset() const { |
| 2238 return active_tree_->total_top_controls_top_offset(); | 2237 return active_tree_->total_top_controls_content_offset() - |
| 2238 top_controls_manager_->top_controls_height(); |
| 2239 } | 2239 } |
| 2240 | 2240 |
| 2241 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { | 2241 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { |
| 2242 DCHECK(input_handler_client_ == NULL); | 2242 DCHECK(input_handler_client_ == NULL); |
| 2243 input_handler_client_ = client; | 2243 input_handler_client_ = client; |
| 2244 } | 2244 } |
| 2245 | 2245 |
| 2246 static LayerImpl* NextScrollLayer(LayerImpl* layer) { | 2246 static LayerImpl* NextScrollLayer(LayerImpl* layer) { |
| 2247 if (LayerImpl* scroll_parent = layer->scroll_parent()) | 2247 if (LayerImpl* scroll_parent = layer->scroll_parent()) |
| 2248 return scroll_parent; | 2248 return scroll_parent; |
| (...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3378 } | 3378 } |
| 3379 | 3379 |
| 3380 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3380 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
| 3381 std::vector<PictureLayerImpl*>::iterator it = | 3381 std::vector<PictureLayerImpl*>::iterator it = |
| 3382 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3382 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
| 3383 DCHECK(it != picture_layers_.end()); | 3383 DCHECK(it != picture_layers_.end()); |
| 3384 picture_layers_.erase(it); | 3384 picture_layers_.erase(it); |
| 3385 } | 3385 } |
| 3386 | 3386 |
| 3387 } // namespace cc | 3387 } // namespace cc |
| OLD | NEW |