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/keyframed_animation_curve.h" | 8 #include "cc/animation/keyframed_animation_curve.h" |
9 #include "cc/animation/scrollbar_animation_controller.h" | 9 #include "cc/animation/scrollbar_animation_controller.h" |
10 #include "cc/animation/scrollbar_animation_controller_linear_fade.h" | 10 #include "cc/animation/scrollbar_animation_controller_linear_fade.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 has_transparent_background_(false), | 85 has_transparent_background_(false), |
86 page_scale_layer_(NULL), | 86 page_scale_layer_(NULL), |
87 inner_viewport_scroll_layer_(NULL), | 87 inner_viewport_scroll_layer_(NULL), |
88 outer_viewport_scroll_layer_(NULL), | 88 outer_viewport_scroll_layer_(NULL), |
89 page_scale_factor_(1), | 89 page_scale_factor_(1), |
90 page_scale_delta_(1), | 90 page_scale_delta_(1), |
91 sent_page_scale_delta_(1), | 91 sent_page_scale_delta_(1), |
92 min_page_scale_factor_(0), | 92 min_page_scale_factor_(0), |
93 max_page_scale_factor_(0), | 93 max_page_scale_factor_(0), |
94 scrolling_layer_id_from_previous_tree_(0), | 94 scrolling_layer_id_from_previous_tree_(0), |
| 95 use_gpu_rasterization_(false), |
95 contents_textures_purged_(false), | 96 contents_textures_purged_(false), |
96 requires_high_res_to_draw_(false), | 97 requires_high_res_to_draw_(false), |
97 viewport_size_invalid_(false), | 98 viewport_size_invalid_(false), |
98 needs_update_draw_properties_(true), | 99 needs_update_draw_properties_(true), |
99 needs_full_tree_sync_(true), | 100 needs_full_tree_sync_(true), |
100 next_activation_forces_redraw_(false), | 101 next_activation_forces_redraw_(false), |
101 render_surface_layer_list_id_(0) { | 102 render_surface_layer_list_id_(0) { |
102 } | 103 } |
103 | 104 |
104 LayerTreeImpl::~LayerTreeImpl() { | 105 LayerTreeImpl::~LayerTreeImpl() { |
105 // Need to explicitly clear the tree prior to destroying this so that | 106 // Need to explicitly clear the tree prior to destroying this so that |
106 // the LayerTreeImpl pointer is still valid in the LayerImpl dtor. | 107 // the LayerTreeImpl pointer is still valid in the LayerImpl dtor. |
107 DCHECK(!root_layer_); | 108 DCHECK(!root_layer_); |
108 DCHECK(layers_with_copy_output_request_.empty()); | 109 DCHECK(layers_with_copy_output_request_.empty()); |
109 } | 110 } |
110 | 111 |
111 void LayerTreeImpl::Shutdown() { root_layer_.reset(); } | 112 void LayerTreeImpl::Shutdown() { root_layer_.reset(); } |
112 | 113 |
| 114 void LayerTreeImpl::ReleaseResources() { |
| 115 if (root_layer_) |
| 116 ReleaseResourcesRecursive(root_layer_.get()); |
| 117 } |
| 118 |
113 void LayerTreeImpl::SetRootLayer(scoped_ptr<LayerImpl> layer) { | 119 void LayerTreeImpl::SetRootLayer(scoped_ptr<LayerImpl> layer) { |
114 if (inner_viewport_scroll_layer_) | 120 if (inner_viewport_scroll_layer_) |
115 inner_viewport_scroll_layer_->SetScrollOffsetDelegate(NULL); | 121 inner_viewport_scroll_layer_->SetScrollOffsetDelegate(NULL); |
116 if (outer_viewport_scroll_layer_) | 122 if (outer_viewport_scroll_layer_) |
117 outer_viewport_scroll_layer_->SetScrollOffsetDelegate(NULL); | 123 outer_viewport_scroll_layer_->SetScrollOffsetDelegate(NULL); |
118 inner_viewport_scroll_delegate_proxy_.reset(); | 124 inner_viewport_scroll_delegate_proxy_.reset(); |
119 outer_viewport_scroll_delegate_proxy_.reset(); | 125 outer_viewport_scroll_delegate_proxy_.reset(); |
120 | 126 |
121 root_layer_ = layer.Pass(); | 127 root_layer_ = layer.Pass(); |
122 currently_scrolling_layer_ = NULL; | 128 currently_scrolling_layer_ = NULL; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 : Layer::INVALID_ID); | 219 : Layer::INVALID_ID); |
214 } else { | 220 } else { |
215 target_tree->ClearViewportLayers(); | 221 target_tree->ClearViewportLayers(); |
216 } | 222 } |
217 // This should match the property synchronization in | 223 // This should match the property synchronization in |
218 // LayerTreeHost::finishCommitOnImplThread(). | 224 // LayerTreeHost::finishCommitOnImplThread(). |
219 target_tree->set_source_frame_number(source_frame_number()); | 225 target_tree->set_source_frame_number(source_frame_number()); |
220 target_tree->set_background_color(background_color()); | 226 target_tree->set_background_color(background_color()); |
221 target_tree->set_has_transparent_background(has_transparent_background()); | 227 target_tree->set_has_transparent_background(has_transparent_background()); |
222 | 228 |
| 229 target_tree->use_gpu_rasterization_ = use_gpu_rasterization(); |
| 230 |
223 if (ContentsTexturesPurged()) | 231 if (ContentsTexturesPurged()) |
224 target_tree->SetContentsTexturesPurged(); | 232 target_tree->SetContentsTexturesPurged(); |
225 else | 233 else |
226 target_tree->ResetContentsTexturesPurged(); | 234 target_tree->ResetContentsTexturesPurged(); |
227 | 235 |
228 // Always reset this flag on activation, as we would only have activated | 236 // Always reset this flag on activation, as we would only have activated |
229 // if we were in a good state. | 237 // if we were in a good state. |
230 target_tree->ResetRequiresHighResToDraw(); | 238 target_tree->ResetRequiresHighResToDraw(); |
231 | 239 |
232 if (ViewportSizeInvalid()) | 240 if (ViewportSizeInvalid()) |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 root_layer_scroll_offset_delegate_, | 438 root_layer_scroll_offset_delegate_, |
431 this)); | 439 this)); |
432 } | 440 } |
433 | 441 |
434 void LayerTreeImpl::ClearViewportLayers() { | 442 void LayerTreeImpl::ClearViewportLayers() { |
435 page_scale_layer_ = NULL; | 443 page_scale_layer_ = NULL; |
436 inner_viewport_scroll_layer_ = NULL; | 444 inner_viewport_scroll_layer_ = NULL; |
437 outer_viewport_scroll_layer_ = NULL; | 445 outer_viewport_scroll_layer_ = NULL; |
438 } | 446 } |
439 | 447 |
| 448 void LayerTreeImpl::SetUseGpuRasterization(bool use_gpu) { |
| 449 if (use_gpu == use_gpu_rasterization_) |
| 450 return; |
| 451 |
| 452 use_gpu_rasterization_ = use_gpu; |
| 453 ReleaseResources(); |
| 454 } |
| 455 |
440 void LayerTreeImpl::UpdateDrawProperties() { | 456 void LayerTreeImpl::UpdateDrawProperties() { |
441 needs_update_draw_properties_ = false; | 457 needs_update_draw_properties_ = false; |
442 render_surface_layer_list_.clear(); | 458 render_surface_layer_list_.clear(); |
443 | 459 |
444 // For max_texture_size. | 460 // For max_texture_size. |
445 if (!layer_tree_host_impl_->renderer()) | 461 if (!layer_tree_host_impl_->renderer()) |
446 return; | 462 return; |
447 | 463 |
448 if (!root_layer()) | 464 if (!root_layer()) |
449 return; | 465 return; |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 | 1004 |
989 const std::vector<LayerImpl*>& LayerTreeImpl::LayersWithCopyOutputRequest() | 1005 const std::vector<LayerImpl*>& LayerTreeImpl::LayersWithCopyOutputRequest() |
990 const { | 1006 const { |
991 // Only the active tree needs to know about layers with copy requests, as | 1007 // Only the active tree needs to know about layers with copy requests, as |
992 // they are aborted if not serviced during draw. | 1008 // they are aborted if not serviced during draw. |
993 DCHECK(IsActiveTree()); | 1009 DCHECK(IsActiveTree()); |
994 | 1010 |
995 return layers_with_copy_output_request_; | 1011 return layers_with_copy_output_request_; |
996 } | 1012 } |
997 | 1013 |
| 1014 void LayerTreeImpl::ReleaseResourcesRecursive(LayerImpl* current) { |
| 1015 DCHECK(current); |
| 1016 current->ReleaseResources(); |
| 1017 if (current->mask_layer()) |
| 1018 ReleaseResourcesRecursive(current->mask_layer()); |
| 1019 if (current->replica_layer()) |
| 1020 ReleaseResourcesRecursive(current->replica_layer()); |
| 1021 for (size_t i = 0; i < current->children().size(); ++i) |
| 1022 ReleaseResourcesRecursive(current->children()[i]); |
| 1023 } |
| 1024 |
998 } // namespace cc | 1025 } // namespace cc |
OLD | NEW |