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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 | 268 |
269 if (scrollbar_needs_animation) { | 269 if (scrollbar_needs_animation) { |
270 ScrollbarAnimationController* controller = | 270 ScrollbarAnimationController* controller = |
271 layer_tree_host_impl_->ScrollbarAnimationControllerForId( | 271 layer_tree_host_impl_->ScrollbarAnimationControllerForId( |
272 scroll_layer_id); | 272 scroll_layer_id); |
273 if (controller) | 273 if (controller) |
274 controller->DidScrollUpdate(scroll_layer_size_did_change); | 274 controller->DidScrollUpdate(scroll_layer_size_did_change); |
275 } | 275 } |
276 } | 276 } |
277 | 277 |
278 void LayerTreeImpl::SetRootLayer(scoped_ptr<LayerImpl> layer) { | 278 void LayerTreeImpl::SetRootLayer(std::unique_ptr<LayerImpl> layer) { |
279 if (root_layer_ && layer.get() != root_layer_) | 279 if (root_layer_ && layer.get() != root_layer_) |
280 RemoveLayer(root_layer_->id()); | 280 RemoveLayer(root_layer_->id()); |
281 root_layer_ = layer.get(); | 281 root_layer_ = layer.get(); |
282 if (layer) | 282 if (layer) |
283 AddLayer(std::move(layer)); | 283 AddLayer(std::move(layer)); |
284 layer_tree_host_impl_->OnCanDrawStateChangedForTree(); | 284 layer_tree_host_impl_->OnCanDrawStateChangedForTree(); |
285 } | 285 } |
286 | 286 |
287 bool LayerTreeImpl::IsRootLayer(const LayerImpl* layer) const { | 287 bool LayerTreeImpl::IsRootLayer(const LayerImpl* layer) const { |
288 return root_layer_ == layer; | 288 return root_layer_ == layer; |
(...skipping 24 matching lines...) Expand all Loading... |
313 | 313 |
314 if (InnerViewportScrollLayer()) | 314 if (InnerViewportScrollLayer()) |
315 offset += InnerViewportScrollLayer()->MaxScrollOffset(); | 315 offset += InnerViewportScrollLayer()->MaxScrollOffset(); |
316 | 316 |
317 if (OuterViewportScrollLayer()) | 317 if (OuterViewportScrollLayer()) |
318 offset += OuterViewportScrollLayer()->MaxScrollOffset(); | 318 offset += OuterViewportScrollLayer()->MaxScrollOffset(); |
319 | 319 |
320 return offset; | 320 return offset; |
321 } | 321 } |
322 | 322 |
323 scoped_ptr<OwnedLayerImplList> LayerTreeImpl::DetachLayers() { | 323 std::unique_ptr<OwnedLayerImplList> LayerTreeImpl::DetachLayers() { |
324 root_layer_ = nullptr; | 324 root_layer_ = nullptr; |
325 render_surface_layer_list_.clear(); | 325 render_surface_layer_list_.clear(); |
326 set_needs_update_draw_properties(); | 326 set_needs_update_draw_properties(); |
327 scoped_ptr<OwnedLayerImplList> ret = std::move(layers_); | 327 std::unique_ptr<OwnedLayerImplList> ret = std::move(layers_); |
328 layers_.reset(new OwnedLayerImplList); | 328 layers_.reset(new OwnedLayerImplList); |
329 return ret; | 329 return ret; |
330 } | 330 } |
331 | 331 |
332 void LayerTreeImpl::ClearLayers() { | 332 void LayerTreeImpl::ClearLayers() { |
333 SetRootLayer(nullptr); | 333 SetRootLayer(nullptr); |
334 DCHECK(layers_->empty()); | 334 DCHECK(layers_->empty()); |
335 } | 335 } |
336 | 336 |
337 static void UpdateClipTreeForBoundsDeltaOnLayer(LayerImpl* layer, | 337 static void UpdateClipTreeForBoundsDeltaOnLayer(LayerImpl* layer, |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { | 1040 void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { |
1041 DCHECK(LayerById(layer->id())); | 1041 DCHECK(LayerById(layer->id())); |
1042 layer_tree_host_impl_->animation_host()->UnregisterLayer( | 1042 layer_tree_host_impl_->animation_host()->UnregisterLayer( |
1043 layer->id(), | 1043 layer->id(), |
1044 IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING); | 1044 IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING); |
1045 layer_id_map_.erase(layer->id()); | 1045 layer_id_map_.erase(layer->id()); |
1046 DCHECK_NE(root_layer_, layer); | 1046 DCHECK_NE(root_layer_, layer); |
1047 } | 1047 } |
1048 | 1048 |
1049 // These manage ownership of the LayerImpl. | 1049 // These manage ownership of the LayerImpl. |
1050 void LayerTreeImpl::AddLayer(scoped_ptr<LayerImpl> layer) { | 1050 void LayerTreeImpl::AddLayer(std::unique_ptr<LayerImpl> layer) { |
1051 DCHECK(std::find(layers_->begin(), layers_->end(), layer) == layers_->end()); | 1051 DCHECK(std::find(layers_->begin(), layers_->end(), layer) == layers_->end()); |
1052 layers_->push_back(std::move(layer)); | 1052 layers_->push_back(std::move(layer)); |
1053 set_needs_update_draw_properties(); | 1053 set_needs_update_draw_properties(); |
1054 } | 1054 } |
1055 | 1055 |
1056 scoped_ptr<LayerImpl> LayerTreeImpl::RemoveLayer(int id) { | 1056 std::unique_ptr<LayerImpl> LayerTreeImpl::RemoveLayer(int id) { |
1057 if (root_layer_ && root_layer_->id() == id) | 1057 if (root_layer_ && root_layer_->id() == id) |
1058 root_layer_ = nullptr; | 1058 root_layer_ = nullptr; |
1059 for (auto it = layers_->begin(); it != layers_->end(); ++it) { | 1059 for (auto it = layers_->begin(); it != layers_->end(); ++it) { |
1060 if ((*it) && (*it)->id() != id) | 1060 if ((*it) && (*it)->id() != id) |
1061 continue; | 1061 continue; |
1062 scoped_ptr<LayerImpl> ret = std::move(*it); | 1062 std::unique_ptr<LayerImpl> ret = std::move(*it); |
1063 set_needs_update_draw_properties(); | 1063 set_needs_update_draw_properties(); |
1064 layers_->erase(it); | 1064 layers_->erase(it); |
1065 return ret; | 1065 return ret; |
1066 } | 1066 } |
1067 return nullptr; | 1067 return nullptr; |
1068 } | 1068 } |
1069 | 1069 |
1070 size_t LayerTreeImpl::NumLayers() { | 1070 size_t LayerTreeImpl::NumLayers() { |
1071 return layer_id_map_.size(); | 1071 return layer_id_map_.size(); |
1072 } | 1072 } |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 } | 1210 } |
1211 | 1211 |
1212 gfx::Size LayerTreeImpl::DrawViewportSize() const { | 1212 gfx::Size LayerTreeImpl::DrawViewportSize() const { |
1213 return layer_tree_host_impl_->DrawViewportSize(); | 1213 return layer_tree_host_impl_->DrawViewportSize(); |
1214 } | 1214 } |
1215 | 1215 |
1216 const gfx::Rect LayerTreeImpl::ViewportRectForTilePriority() const { | 1216 const gfx::Rect LayerTreeImpl::ViewportRectForTilePriority() const { |
1217 return layer_tree_host_impl_->ViewportRectForTilePriority(); | 1217 return layer_tree_host_impl_->ViewportRectForTilePriority(); |
1218 } | 1218 } |
1219 | 1219 |
1220 scoped_ptr<ScrollbarAnimationController> | 1220 std::unique_ptr<ScrollbarAnimationController> |
1221 LayerTreeImpl::CreateScrollbarAnimationController(int scroll_layer_id) { | 1221 LayerTreeImpl::CreateScrollbarAnimationController(int scroll_layer_id) { |
1222 DCHECK(settings().scrollbar_fade_delay_ms); | 1222 DCHECK(settings().scrollbar_fade_delay_ms); |
1223 DCHECK(settings().scrollbar_fade_duration_ms); | 1223 DCHECK(settings().scrollbar_fade_duration_ms); |
1224 base::TimeDelta delay = | 1224 base::TimeDelta delay = |
1225 base::TimeDelta::FromMilliseconds(settings().scrollbar_fade_delay_ms); | 1225 base::TimeDelta::FromMilliseconds(settings().scrollbar_fade_delay_ms); |
1226 base::TimeDelta resize_delay = base::TimeDelta::FromMilliseconds( | 1226 base::TimeDelta resize_delay = base::TimeDelta::FromMilliseconds( |
1227 settings().scrollbar_fade_resize_delay_ms); | 1227 settings().scrollbar_fade_resize_delay_ms); |
1228 base::TimeDelta duration = | 1228 base::TimeDelta duration = |
1229 base::TimeDelta::FromMilliseconds(settings().scrollbar_fade_duration_ms); | 1229 base::TimeDelta::FromMilliseconds(settings().scrollbar_fade_duration_ms); |
1230 switch (settings().scrollbar_animator) { | 1230 switch (settings().scrollbar_animator) { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 outer_viewport_offset = root_offset - inner_viewport_offset; | 1331 outer_viewport_offset = root_offset - inner_viewport_offset; |
1332 outer_viewport_offset.SetToMin(max_outer_viewport_scroll_offset); | 1332 outer_viewport_offset.SetToMin(max_outer_viewport_scroll_offset); |
1333 outer_viewport_offset.SetToMax(gfx::ScrollOffset()); | 1333 outer_viewport_offset.SetToMax(gfx::ScrollOffset()); |
1334 | 1334 |
1335 OuterViewportScrollLayer()->SetCurrentScrollOffset(outer_viewport_offset); | 1335 OuterViewportScrollLayer()->SetCurrentScrollOffset(outer_viewport_offset); |
1336 inner_viewport_offset = root_offset - outer_viewport_offset; | 1336 inner_viewport_offset = root_offset - outer_viewport_offset; |
1337 InnerViewportScrollLayer()->SetCurrentScrollOffset(inner_viewport_offset); | 1337 InnerViewportScrollLayer()->SetCurrentScrollOffset(inner_viewport_offset); |
1338 return true; | 1338 return true; |
1339 } | 1339 } |
1340 | 1340 |
1341 void LayerTreeImpl::QueueSwapPromise(scoped_ptr<SwapPromise> swap_promise) { | 1341 void LayerTreeImpl::QueueSwapPromise( |
| 1342 std::unique_ptr<SwapPromise> swap_promise) { |
1342 DCHECK(swap_promise); | 1343 DCHECK(swap_promise); |
1343 swap_promise_list_.push_back(std::move(swap_promise)); | 1344 swap_promise_list_.push_back(std::move(swap_promise)); |
1344 } | 1345 } |
1345 | 1346 |
1346 void LayerTreeImpl::QueuePinnedSwapPromise( | 1347 void LayerTreeImpl::QueuePinnedSwapPromise( |
1347 scoped_ptr<SwapPromise> swap_promise) { | 1348 std::unique_ptr<SwapPromise> swap_promise) { |
1348 DCHECK(IsActiveTree()); | 1349 DCHECK(IsActiveTree()); |
1349 DCHECK(swap_promise); | 1350 DCHECK(swap_promise); |
1350 pinned_swap_promise_list_.push_back(std::move(swap_promise)); | 1351 pinned_swap_promise_list_.push_back(std::move(swap_promise)); |
1351 } | 1352 } |
1352 | 1353 |
1353 void LayerTreeImpl::PassSwapPromises( | 1354 void LayerTreeImpl::PassSwapPromises( |
1354 std::vector<scoped_ptr<SwapPromise>>* new_swap_promise) { | 1355 std::vector<std::unique_ptr<SwapPromise>>* new_swap_promise) { |
1355 for (const auto& swap_promise : swap_promise_list_) | 1356 for (const auto& swap_promise : swap_promise_list_) |
1356 swap_promise->DidNotSwap(SwapPromise::SWAP_FAILS); | 1357 swap_promise->DidNotSwap(SwapPromise::SWAP_FAILS); |
1357 swap_promise_list_.clear(); | 1358 swap_promise_list_.clear(); |
1358 swap_promise_list_.swap(*new_swap_promise); | 1359 swap_promise_list_.swap(*new_swap_promise); |
1359 } | 1360 } |
1360 | 1361 |
1361 void LayerTreeImpl::FinishSwapPromises(CompositorFrameMetadata* metadata) { | 1362 void LayerTreeImpl::FinishSwapPromises(CompositorFrameMetadata* metadata) { |
1362 for (const auto& swap_promise : swap_promise_list_) | 1363 for (const auto& swap_promise : swap_promise_list_) |
1363 swap_promise->DidSwap(metadata); | 1364 swap_promise->DidSwap(metadata); |
1364 swap_promise_list_.clear(); | 1365 swap_promise_list_.clear(); |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1941 bool LayerTreeImpl::SmoothnessTakesPriority() const { | 1942 bool LayerTreeImpl::SmoothnessTakesPriority() const { |
1942 return layer_tree_host_impl_->GetTreePriority() == SMOOTHNESS_TAKES_PRIORITY; | 1943 return layer_tree_host_impl_->GetTreePriority() == SMOOTHNESS_TAKES_PRIORITY; |
1943 } | 1944 } |
1944 | 1945 |
1945 VideoFrameControllerClient* LayerTreeImpl::GetVideoFrameControllerClient() | 1946 VideoFrameControllerClient* LayerTreeImpl::GetVideoFrameControllerClient() |
1946 const { | 1947 const { |
1947 return layer_tree_host_impl_; | 1948 return layer_tree_host_impl_; |
1948 } | 1949 } |
1949 | 1950 |
1950 void LayerTreeImpl::SetPendingPageScaleAnimation( | 1951 void LayerTreeImpl::SetPendingPageScaleAnimation( |
1951 scoped_ptr<PendingPageScaleAnimation> pending_animation) { | 1952 std::unique_ptr<PendingPageScaleAnimation> pending_animation) { |
1952 pending_page_scale_animation_ = std::move(pending_animation); | 1953 pending_page_scale_animation_ = std::move(pending_animation); |
1953 } | 1954 } |
1954 | 1955 |
1955 scoped_ptr<PendingPageScaleAnimation> | 1956 std::unique_ptr<PendingPageScaleAnimation> |
1956 LayerTreeImpl::TakePendingPageScaleAnimation() { | 1957 LayerTreeImpl::TakePendingPageScaleAnimation() { |
1957 return std::move(pending_page_scale_animation_); | 1958 return std::move(pending_page_scale_animation_); |
1958 } | 1959 } |
1959 | 1960 |
1960 bool LayerTreeImpl::IsAnimatingFilterProperty(const LayerImpl* layer) const { | 1961 bool LayerTreeImpl::IsAnimatingFilterProperty(const LayerImpl* layer) const { |
1961 LayerTreeType tree_type = | 1962 LayerTreeType tree_type = |
1962 IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING; | 1963 IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING; |
1963 return layer_tree_host_impl_->animation_host()->IsAnimatingFilterProperty( | 1964 return layer_tree_host_impl_->animation_host()->IsAnimatingFilterProperty( |
1964 layer->id(), tree_type); | 1965 layer->id(), tree_type); |
1965 } | 1966 } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2101 } | 2102 } |
2102 | 2103 |
2103 void LayerTreeImpl::ResetAllChangeTracking(PropertyTrees::ResetFlags flag) { | 2104 void LayerTreeImpl::ResetAllChangeTracking(PropertyTrees::ResetFlags flag) { |
2104 layers_that_should_push_properties_.clear(); | 2105 layers_that_should_push_properties_.clear(); |
2105 for (auto* layer : *this) | 2106 for (auto* layer : *this) |
2106 layer->ResetChangeTracking(); | 2107 layer->ResetChangeTracking(); |
2107 property_trees_.ResetAllChangeTracking(flag); | 2108 property_trees_.ResetAllChangeTracking(flag); |
2108 } | 2109 } |
2109 | 2110 |
2110 } // namespace cc | 2111 } // namespace cc |
OLD | NEW |