| 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 <limits> | 7 #include <limits> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 DCHECK(!root_layer_); | 115 DCHECK(!root_layer_); |
| 116 DCHECK(layers_with_copy_output_request_.empty()); | 116 DCHECK(layers_with_copy_output_request_.empty()); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void LayerTreeImpl::Shutdown() { | 119 void LayerTreeImpl::Shutdown() { |
| 120 root_layer_ = nullptr; | 120 root_layer_ = nullptr; |
| 121 } | 121 } |
| 122 | 122 |
| 123 void LayerTreeImpl::ReleaseResources() { | 123 void LayerTreeImpl::ReleaseResources() { |
| 124 if (root_layer_) | 124 if (root_layer_) |
| 125 ReleaseResourcesRecursive(root_layer_.get()); | 125 ProcessLayersRecursive(root_layer_.get(), &LayerImpl::ReleaseResources); |
| 126 } |
| 127 |
| 128 void LayerTreeImpl::RecreateResources() { |
| 129 if (root_layer_) |
| 130 ProcessLayersRecursive(root_layer_.get(), &LayerImpl::RecreateResources); |
| 126 } | 131 } |
| 127 | 132 |
| 128 void LayerTreeImpl::SetRootLayer(scoped_ptr<LayerImpl> layer) { | 133 void LayerTreeImpl::SetRootLayer(scoped_ptr<LayerImpl> layer) { |
| 129 if (inner_viewport_scroll_layer_) | 134 if (inner_viewport_scroll_layer_) |
| 130 inner_viewport_scroll_layer_->SetScrollOffsetDelegate(NULL); | 135 inner_viewport_scroll_layer_->SetScrollOffsetDelegate(NULL); |
| 131 if (outer_viewport_scroll_layer_) | 136 if (outer_viewport_scroll_layer_) |
| 132 outer_viewport_scroll_layer_->SetScrollOffsetDelegate(NULL); | 137 outer_viewport_scroll_layer_->SetScrollOffsetDelegate(NULL); |
| 133 inner_viewport_scroll_delegate_proxy_ = nullptr; | 138 inner_viewport_scroll_delegate_proxy_ = nullptr; |
| 134 outer_viewport_scroll_delegate_proxy_ = nullptr; | 139 outer_viewport_scroll_delegate_proxy_ = nullptr; |
| 135 | 140 |
| (...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1152 | 1157 |
| 1153 const std::vector<LayerImpl*>& LayerTreeImpl::LayersWithCopyOutputRequest() | 1158 const std::vector<LayerImpl*>& LayerTreeImpl::LayersWithCopyOutputRequest() |
| 1154 const { | 1159 const { |
| 1155 // Only the active tree needs to know about layers with copy requests, as | 1160 // Only the active tree needs to know about layers with copy requests, as |
| 1156 // they are aborted if not serviced during draw. | 1161 // they are aborted if not serviced during draw. |
| 1157 DCHECK(IsActiveTree()); | 1162 DCHECK(IsActiveTree()); |
| 1158 | 1163 |
| 1159 return layers_with_copy_output_request_; | 1164 return layers_with_copy_output_request_; |
| 1160 } | 1165 } |
| 1161 | 1166 |
| 1162 void LayerTreeImpl::ReleaseResourcesRecursive(LayerImpl* current) { | 1167 void LayerTreeImpl::ProcessLayersRecursive(LayerImpl* current, |
| 1168 void (LayerImpl::*function)()) { |
| 1163 DCHECK(current); | 1169 DCHECK(current); |
| 1164 current->ReleaseResources(); | 1170 (current->*function)(); |
| 1165 if (current->mask_layer()) | 1171 if (current->mask_layer()) |
| 1166 ReleaseResourcesRecursive(current->mask_layer()); | 1172 ProcessLayersRecursive(current->mask_layer(), function); |
| 1167 if (current->replica_layer()) | 1173 if (current->replica_layer()) |
| 1168 ReleaseResourcesRecursive(current->replica_layer()); | 1174 ProcessLayersRecursive(current->replica_layer(), function); |
| 1169 for (size_t i = 0; i < current->children().size(); ++i) | 1175 for (size_t i = 0; i < current->children().size(); ++i) |
| 1170 ReleaseResourcesRecursive(current->children()[i]); | 1176 ProcessLayersRecursive(current->children()[i], function); |
| 1171 } | 1177 } |
| 1172 | 1178 |
| 1173 template <typename LayerType> | 1179 template <typename LayerType> |
| 1174 static inline bool LayerClipsSubtree(LayerType* layer) { | 1180 static inline bool LayerClipsSubtree(LayerType* layer) { |
| 1175 return layer->masks_to_bounds() || layer->mask_layer(); | 1181 return layer->masks_to_bounds() || layer->mask_layer(); |
| 1176 } | 1182 } |
| 1177 | 1183 |
| 1178 static bool PointHitsRect( | 1184 static bool PointHitsRect( |
| 1179 const gfx::PointF& screen_space_point, | 1185 const gfx::PointF& screen_space_point, |
| 1180 const gfx::Transform& local_space_to_screen_space_transform, | 1186 const gfx::Transform& local_space_to_screen_space_transform, |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1550 scoped_ptr<PendingPageScaleAnimation> pending_animation) { | 1556 scoped_ptr<PendingPageScaleAnimation> pending_animation) { |
| 1551 pending_page_scale_animation_ = pending_animation.Pass(); | 1557 pending_page_scale_animation_ = pending_animation.Pass(); |
| 1552 } | 1558 } |
| 1553 | 1559 |
| 1554 scoped_ptr<PendingPageScaleAnimation> | 1560 scoped_ptr<PendingPageScaleAnimation> |
| 1555 LayerTreeImpl::TakePendingPageScaleAnimation() { | 1561 LayerTreeImpl::TakePendingPageScaleAnimation() { |
| 1556 return pending_page_scale_animation_.Pass(); | 1562 return pending_page_scale_animation_.Pass(); |
| 1557 } | 1563 } |
| 1558 | 1564 |
| 1559 } // namespace cc | 1565 } // namespace cc |
| OLD | NEW |