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_impl.h" | 5 #include "cc/trees/layer_tree_impl.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "cc/animation/animation.h" | 8 #include "cc/animation/animation.h" |
9 #include "cc/animation/animation_id_provider.h" | 9 #include "cc/animation/animation_id_provider.h" |
10 #include "cc/animation/keyframed_animation_curve.h" | 10 #include "cc/animation/keyframed_animation_curve.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 root_scroll_layer_ = NULL; | 69 root_scroll_layer_ = NULL; |
70 currently_scrolling_layer_ = NULL; | 70 currently_scrolling_layer_ = NULL; |
71 | 71 |
72 layer_tree_host_impl_->OnCanDrawStateChangedForTree(); | 72 layer_tree_host_impl_->OnCanDrawStateChangedForTree(); |
73 } | 73 } |
74 | 74 |
75 void LayerTreeImpl::FindRootScrollLayer() { | 75 void LayerTreeImpl::FindRootScrollLayer() { |
76 root_scroll_layer_ = FindRootScrollLayerRecursive(root_layer_.get()); | 76 root_scroll_layer_ = FindRootScrollLayerRecursive(root_layer_.get()); |
77 | 77 |
78 if (root_layer_ && scrolling_layer_id_from_previous_tree_) { | 78 if (root_layer_ && scrolling_layer_id_from_previous_tree_) { |
79 currently_scrolling_layer_ = LayerTreeHostCommon::findLayerInSubtree( | 79 currently_scrolling_layer_ = LayerTreeHostCommon::FindLayerInSubtree( |
80 root_layer_.get(), | 80 root_layer_.get(), |
81 scrolling_layer_id_from_previous_tree_); | 81 scrolling_layer_id_from_previous_tree_); |
82 } | 82 } |
83 | 83 |
84 scrolling_layer_id_from_previous_tree_ = 0; | 84 scrolling_layer_id_from_previous_tree_ = 0; |
85 } | 85 } |
86 | 86 |
87 scoped_ptr<LayerImpl> LayerTreeImpl::DetachLayerTree() { | 87 scoped_ptr<LayerImpl> LayerTreeImpl::DetachLayerTree() { |
88 // Clear all data structures that have direct references to the layer tree. | 88 // Clear all data structures that have direct references to the layer tree. |
89 scrolling_layer_id_from_previous_tree_ = | 89 scrolling_layer_id_from_previous_tree_ = |
(...skipping 24 matching lines...) Expand all Loading... |
114 else | 114 else |
115 target_tree->ResetContentsTexturesPurged(); | 115 target_tree->ResetContentsTexturesPurged(); |
116 | 116 |
117 if (ViewportSizeInvalid()) | 117 if (ViewportSizeInvalid()) |
118 target_tree->SetViewportSizeInvalid(); | 118 target_tree->SetViewportSizeInvalid(); |
119 else | 119 else |
120 target_tree->ResetViewportSizeInvalid(); | 120 target_tree->ResetViewportSizeInvalid(); |
121 | 121 |
122 if (hud_layer()) | 122 if (hud_layer()) |
123 target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>( | 123 target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>( |
124 LayerTreeHostCommon::findLayerInSubtree( | 124 LayerTreeHostCommon::FindLayerInSubtree( |
125 target_tree->root_layer(), hud_layer()->id()))); | 125 target_tree->root_layer(), hud_layer()->id()))); |
126 else | 126 else |
127 target_tree->set_hud_layer(NULL); | 127 target_tree->set_hud_layer(NULL); |
128 | 128 |
129 target_tree->SetPinchZoomHorizontalLayerId( | 129 target_tree->SetPinchZoomHorizontalLayerId( |
130 pinch_zoom_scrollbar_horizontal_layer_id_); | 130 pinch_zoom_scrollbar_horizontal_layer_id_); |
131 target_tree->SetPinchZoomVerticalLayerId( | 131 target_tree->SetPinchZoomVerticalLayerId( |
132 pinch_zoom_scrollbar_vertical_layer_id_); | 132 pinch_zoom_scrollbar_vertical_layer_id_); |
133 } | 133 } |
134 | 134 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 // The top controls manager is incompatible with the WebKit-created cliprect | 263 // The top controls manager is incompatible with the WebKit-created cliprect |
264 // because it can bring into view a larger amount of content when it | 264 // because it can bring into view a larger amount of content when it |
265 // hides. It's safe to deactivate the clip rect if no non-overlay scrollbars | 265 // hides. It's safe to deactivate the clip rect if no non-overlay scrollbars |
266 // are present. | 266 // are present. |
267 if (RootClipLayer() && layer_tree_host_impl_->top_controls_manager()) | 267 if (RootClipLayer() && layer_tree_host_impl_->top_controls_manager()) |
268 RootClipLayer()->SetMasksToBounds(false); | 268 RootClipLayer()->SetMasksToBounds(false); |
269 } | 269 } |
270 | 270 |
271 if (!needs_update_draw_properties_) { | 271 if (!needs_update_draw_properties_) { |
272 if (reason == UPDATE_ACTIVE_TREE_FOR_DRAW && root_layer()) | 272 if (reason == UPDATE_ACTIVE_TREE_FOR_DRAW && root_layer()) |
273 LayerTreeHostCommon::callFunctionForSubtree<UpdateTilePrioritiesForLayer>( | 273 LayerTreeHostCommon::CallFunctionForSubtree<UpdateTilePrioritiesForLayer>( |
274 root_layer()); | 274 root_layer()); |
275 return; | 275 return; |
276 } | 276 } |
277 | 277 |
278 needs_update_draw_properties_ = false; | 278 needs_update_draw_properties_ = false; |
279 render_surface_layer_list_.clear(); | 279 render_surface_layer_list_.clear(); |
280 | 280 |
281 // For maxTextureSize. | 281 // For maxTextureSize. |
282 if (!layer_tree_host_impl_->renderer()) | 282 if (!layer_tree_host_impl_->renderer()) |
283 return; | 283 return; |
284 | 284 |
285 if (!root_layer()) | 285 if (!root_layer()) |
286 return; | 286 return; |
287 | 287 |
288 if (root_scroll_layer_) { | 288 if (root_scroll_layer_) { |
289 root_scroll_layer_->SetImplTransform(ImplTransform()); | 289 root_scroll_layer_->SetImplTransform(ImplTransform()); |
290 // Setting the impl transform re-sets this. | 290 // Setting the impl transform re-sets this. |
291 needs_update_draw_properties_ = false; | 291 needs_update_draw_properties_ = false; |
292 } | 292 } |
293 | 293 |
294 { | 294 { |
295 TRACE_EVENT1("cc", | 295 TRACE_EVENT1("cc", |
296 "LayerTreeImpl::UpdateDrawProperties", | 296 "LayerTreeImpl::UpdateDrawProperties", |
297 "IsActive", | 297 "IsActive", |
298 IsActiveTree()); | 298 IsActiveTree()); |
299 bool update_tile_priorities = | 299 bool update_tile_priorities = |
300 reason == UPDATE_PENDING_TREE || | 300 reason == UPDATE_PENDING_TREE || |
301 reason == UPDATE_ACTIVE_TREE_FOR_DRAW; | 301 reason == UPDATE_ACTIVE_TREE_FOR_DRAW; |
302 LayerTreeHostCommon::calculateDrawProperties( | 302 LayerTreeHostCommon::CalculateDrawProperties( |
303 root_layer(), | 303 root_layer(), |
304 device_viewport_size(), | 304 device_viewport_size(), |
305 device_scale_factor(), | 305 device_scale_factor(), |
306 total_page_scale_factor(), | 306 total_page_scale_factor(), |
307 MaxTextureSize(), | 307 MaxTextureSize(), |
308 settings().can_use_lcd_text, | 308 settings().can_use_lcd_text, |
309 render_surface_layer_list_, | 309 &render_surface_layer_list_, |
310 update_tile_priorities); | 310 update_tile_priorities); |
311 } | 311 } |
312 | 312 |
313 DCHECK(!needs_update_draw_properties_) << | 313 DCHECK(!needs_update_draw_properties_) << |
314 "calcDrawProperties should not set_needs_update_draw_properties()"; | 314 "calcDrawProperties should not set_needs_update_draw_properties()"; |
315 } | 315 } |
316 | 316 |
317 static void ClearRenderSurfacesOnLayerImplRecursive(LayerImpl* current) { | 317 static void ClearRenderSurfacesOnLayerImplRecursive(LayerImpl* current) { |
318 DCHECK(current); | 318 DCHECK(current); |
319 for (size_t i = 0; i < current->children().size(); ++i) | 319 for (size_t i = 0; i < current->children().size(); ++i) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 } | 367 } |
368 | 368 |
369 void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { | 369 void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { |
370 DCHECK(LayerById(layer->id())); | 370 DCHECK(LayerById(layer->id())); |
371 layer_id_map_.erase(layer->id()); | 371 layer_id_map_.erase(layer->id()); |
372 } | 372 } |
373 | 373 |
374 void LayerTreeImpl::PushPersistedState(LayerTreeImpl* pendingTree) { | 374 void LayerTreeImpl::PushPersistedState(LayerTreeImpl* pendingTree) { |
375 int id = currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0; | 375 int id = currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0; |
376 pendingTree->SetCurrentlyScrollingLayer( | 376 pendingTree->SetCurrentlyScrollingLayer( |
377 LayerTreeHostCommon::findLayerInSubtree(pendingTree->root_layer(), id)); | 377 LayerTreeHostCommon::FindLayerInSubtree(pendingTree->root_layer(), id)); |
378 } | 378 } |
379 | 379 |
380 static void DidBecomeActiveRecursive(LayerImpl* layer) { | 380 static void DidBecomeActiveRecursive(LayerImpl* layer) { |
381 layer->DidBecomeActive(); | 381 layer->DidBecomeActive(); |
382 for (size_t i = 0; i < layer->children().size(); ++i) | 382 for (size_t i = 0; i < layer->children().size(); ++i) |
383 DidBecomeActiveRecursive(layer->children()[i]); | 383 DidBecomeActiveRecursive(layer->children()[i]); |
384 } | 384 } |
385 | 385 |
386 void LayerTreeImpl::DidBecomeActive() { | 386 void LayerTreeImpl::DidBecomeActive() { |
387 if (root_layer()) | 387 if (root_layer()) |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 StartFadeOutAnimation(PinchZoomScrollbarVertical()); | 652 StartFadeOutAnimation(PinchZoomScrollbarVertical()); |
653 } | 653 } |
654 | 654 |
655 bool LayerTreeImpl::HasPinchZoomScrollbars() const { | 655 bool LayerTreeImpl::HasPinchZoomScrollbars() const { |
656 return pinch_zoom_scrollbar_horizontal_layer_id_ != Layer::INVALID_ID && | 656 return pinch_zoom_scrollbar_horizontal_layer_id_ != Layer::INVALID_ID && |
657 pinch_zoom_scrollbar_vertical_layer_id_ != Layer::INVALID_ID; | 657 pinch_zoom_scrollbar_vertical_layer_id_ != Layer::INVALID_ID; |
658 } | 658 } |
659 | 659 |
660 | 660 |
661 } // namespace cc | 661 } // namespace cc |
OLD | NEW |