| 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 | 264 |
| 265 if (scrollbar_needs_animation) { | 265 if (scrollbar_needs_animation) { |
| 266 ScrollbarAnimationController* controller = | 266 ScrollbarAnimationController* controller = |
| 267 layer_tree_host_impl_->ScrollbarAnimationControllerForId( | 267 layer_tree_host_impl_->ScrollbarAnimationControllerForId( |
| 268 scroll_layer_id); | 268 scroll_layer_id); |
| 269 if (controller) | 269 if (controller) |
| 270 controller->DidScrollUpdate(scroll_layer_size_did_change); | 270 controller->DidScrollUpdate(scroll_layer_size_did_change); |
| 271 } | 271 } |
| 272 } | 272 } |
| 273 | 273 |
| 274 void LayerTreeImpl::SetRootLayer(scoped_ptr<LayerImpl> layer) { | 274 void LayerTreeImpl::SetRootLayer(std::unique_ptr<LayerImpl> layer) { |
| 275 if (root_layer_ && layer.get() != root_layer_) | 275 if (root_layer_ && layer.get() != root_layer_) |
| 276 RemoveLayer(root_layer_->id()); | 276 RemoveLayer(root_layer_->id()); |
| 277 root_layer_ = layer.get(); | 277 root_layer_ = layer.get(); |
| 278 if (layer) | 278 if (layer) |
| 279 AddLayer(std::move(layer)); | 279 AddLayer(std::move(layer)); |
| 280 layer_tree_host_impl_->OnCanDrawStateChangedForTree(); | 280 layer_tree_host_impl_->OnCanDrawStateChangedForTree(); |
| 281 } | 281 } |
| 282 | 282 |
| 283 bool LayerTreeImpl::IsRootLayer(const LayerImpl* layer) const { | 283 bool LayerTreeImpl::IsRootLayer(const LayerImpl* layer) const { |
| 284 return root_layer_ == layer; | 284 return root_layer_ == layer; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 309 | 309 |
| 310 if (InnerViewportScrollLayer()) | 310 if (InnerViewportScrollLayer()) |
| 311 offset += InnerViewportScrollLayer()->MaxScrollOffset(); | 311 offset += InnerViewportScrollLayer()->MaxScrollOffset(); |
| 312 | 312 |
| 313 if (OuterViewportScrollLayer()) | 313 if (OuterViewportScrollLayer()) |
| 314 offset += OuterViewportScrollLayer()->MaxScrollOffset(); | 314 offset += OuterViewportScrollLayer()->MaxScrollOffset(); |
| 315 | 315 |
| 316 return offset; | 316 return offset; |
| 317 } | 317 } |
| 318 | 318 |
| 319 scoped_ptr<OwnedLayerImplList> LayerTreeImpl::DetachLayers() { | 319 std::unique_ptr<OwnedLayerImplList> LayerTreeImpl::DetachLayers() { |
| 320 root_layer_ = nullptr; | 320 root_layer_ = nullptr; |
| 321 render_surface_layer_list_.clear(); | 321 render_surface_layer_list_.clear(); |
| 322 set_needs_update_draw_properties(); | 322 set_needs_update_draw_properties(); |
| 323 scoped_ptr<OwnedLayerImplList> ret = std::move(layers_); | 323 std::unique_ptr<OwnedLayerImplList> ret = std::move(layers_); |
| 324 layers_.reset(new OwnedLayerImplList); | 324 layers_.reset(new OwnedLayerImplList); |
| 325 return ret; | 325 return ret; |
| 326 } | 326 } |
| 327 | 327 |
| 328 void LayerTreeImpl::ClearLayers() { | 328 void LayerTreeImpl::ClearLayers() { |
| 329 SetRootLayer(nullptr); | 329 SetRootLayer(nullptr); |
| 330 DCHECK(layers_->empty()); | 330 DCHECK(layers_->empty()); |
| 331 } | 331 } |
| 332 | 332 |
| 333 static void UpdateClipTreeForBoundsDeltaOnLayer(LayerImpl* layer, | 333 static void UpdateClipTreeForBoundsDeltaOnLayer(LayerImpl* layer, |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { | 1033 void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { |
| 1034 DCHECK(LayerById(layer->id())); | 1034 DCHECK(LayerById(layer->id())); |
| 1035 layer_tree_host_impl_->animation_host()->UnregisterLayer( | 1035 layer_tree_host_impl_->animation_host()->UnregisterLayer( |
| 1036 layer->id(), | 1036 layer->id(), |
| 1037 IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING); | 1037 IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING); |
| 1038 layer_id_map_.erase(layer->id()); | 1038 layer_id_map_.erase(layer->id()); |
| 1039 DCHECK_NE(root_layer_, layer); | 1039 DCHECK_NE(root_layer_, layer); |
| 1040 } | 1040 } |
| 1041 | 1041 |
| 1042 // These manage ownership of the LayerImpl. | 1042 // These manage ownership of the LayerImpl. |
| 1043 void LayerTreeImpl::AddLayer(scoped_ptr<LayerImpl> layer) { | 1043 void LayerTreeImpl::AddLayer(std::unique_ptr<LayerImpl> layer) { |
| 1044 DCHECK(std::find(layers_->begin(), layers_->end(), layer) == layers_->end()); | 1044 DCHECK(std::find(layers_->begin(), layers_->end(), layer) == layers_->end()); |
| 1045 layers_->push_back(std::move(layer)); | 1045 layers_->push_back(std::move(layer)); |
| 1046 set_needs_update_draw_properties(); | 1046 set_needs_update_draw_properties(); |
| 1047 } | 1047 } |
| 1048 | 1048 |
| 1049 scoped_ptr<LayerImpl> LayerTreeImpl::RemoveLayer(int id) { | 1049 std::unique_ptr<LayerImpl> LayerTreeImpl::RemoveLayer(int id) { |
| 1050 if (root_layer_ && root_layer_->id() == id) | 1050 if (root_layer_ && root_layer_->id() == id) |
| 1051 root_layer_ = nullptr; | 1051 root_layer_ = nullptr; |
| 1052 for (auto it = layers_->begin(); it != layers_->end(); ++it) { | 1052 for (auto it = layers_->begin(); it != layers_->end(); ++it) { |
| 1053 if ((*it) && (*it)->id() != id) | 1053 if ((*it) && (*it)->id() != id) |
| 1054 continue; | 1054 continue; |
| 1055 scoped_ptr<LayerImpl> ret = std::move(*it); | 1055 std::unique_ptr<LayerImpl> ret = std::move(*it); |
| 1056 set_needs_update_draw_properties(); | 1056 set_needs_update_draw_properties(); |
| 1057 layers_->erase(it); | 1057 layers_->erase(it); |
| 1058 return ret; | 1058 return ret; |
| 1059 } | 1059 } |
| 1060 return nullptr; | 1060 return nullptr; |
| 1061 } | 1061 } |
| 1062 | 1062 |
| 1063 size_t LayerTreeImpl::NumLayers() { | 1063 size_t LayerTreeImpl::NumLayers() { |
| 1064 return layer_id_map_.size(); | 1064 return layer_id_map_.size(); |
| 1065 } | 1065 } |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1202 } | 1202 } |
| 1203 | 1203 |
| 1204 gfx::Size LayerTreeImpl::DrawViewportSize() const { | 1204 gfx::Size LayerTreeImpl::DrawViewportSize() const { |
| 1205 return layer_tree_host_impl_->DrawViewportSize(); | 1205 return layer_tree_host_impl_->DrawViewportSize(); |
| 1206 } | 1206 } |
| 1207 | 1207 |
| 1208 const gfx::Rect LayerTreeImpl::ViewportRectForTilePriority() const { | 1208 const gfx::Rect LayerTreeImpl::ViewportRectForTilePriority() const { |
| 1209 return layer_tree_host_impl_->ViewportRectForTilePriority(); | 1209 return layer_tree_host_impl_->ViewportRectForTilePriority(); |
| 1210 } | 1210 } |
| 1211 | 1211 |
| 1212 scoped_ptr<ScrollbarAnimationController> | 1212 std::unique_ptr<ScrollbarAnimationController> |
| 1213 LayerTreeImpl::CreateScrollbarAnimationController(int scroll_layer_id) { | 1213 LayerTreeImpl::CreateScrollbarAnimationController(int scroll_layer_id) { |
| 1214 DCHECK(settings().scrollbar_fade_delay_ms); | 1214 DCHECK(settings().scrollbar_fade_delay_ms); |
| 1215 DCHECK(settings().scrollbar_fade_duration_ms); | 1215 DCHECK(settings().scrollbar_fade_duration_ms); |
| 1216 base::TimeDelta delay = | 1216 base::TimeDelta delay = |
| 1217 base::TimeDelta::FromMilliseconds(settings().scrollbar_fade_delay_ms); | 1217 base::TimeDelta::FromMilliseconds(settings().scrollbar_fade_delay_ms); |
| 1218 base::TimeDelta resize_delay = base::TimeDelta::FromMilliseconds( | 1218 base::TimeDelta resize_delay = base::TimeDelta::FromMilliseconds( |
| 1219 settings().scrollbar_fade_resize_delay_ms); | 1219 settings().scrollbar_fade_resize_delay_ms); |
| 1220 base::TimeDelta duration = | 1220 base::TimeDelta duration = |
| 1221 base::TimeDelta::FromMilliseconds(settings().scrollbar_fade_duration_ms); | 1221 base::TimeDelta::FromMilliseconds(settings().scrollbar_fade_duration_ms); |
| 1222 switch (settings().scrollbar_animator) { | 1222 switch (settings().scrollbar_animator) { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1323 outer_viewport_offset = root_offset - inner_viewport_offset; | 1323 outer_viewport_offset = root_offset - inner_viewport_offset; |
| 1324 outer_viewport_offset.SetToMin(max_outer_viewport_scroll_offset); | 1324 outer_viewport_offset.SetToMin(max_outer_viewport_scroll_offset); |
| 1325 outer_viewport_offset.SetToMax(gfx::ScrollOffset()); | 1325 outer_viewport_offset.SetToMax(gfx::ScrollOffset()); |
| 1326 | 1326 |
| 1327 OuterViewportScrollLayer()->SetCurrentScrollOffset(outer_viewport_offset); | 1327 OuterViewportScrollLayer()->SetCurrentScrollOffset(outer_viewport_offset); |
| 1328 inner_viewport_offset = root_offset - outer_viewport_offset; | 1328 inner_viewport_offset = root_offset - outer_viewport_offset; |
| 1329 InnerViewportScrollLayer()->SetCurrentScrollOffset(inner_viewport_offset); | 1329 InnerViewportScrollLayer()->SetCurrentScrollOffset(inner_viewport_offset); |
| 1330 return true; | 1330 return true; |
| 1331 } | 1331 } |
| 1332 | 1332 |
| 1333 void LayerTreeImpl::QueueSwapPromise(scoped_ptr<SwapPromise> swap_promise) { | 1333 void LayerTreeImpl::QueueSwapPromise( |
| 1334 std::unique_ptr<SwapPromise> swap_promise) { |
| 1334 DCHECK(swap_promise); | 1335 DCHECK(swap_promise); |
| 1335 swap_promise_list_.push_back(std::move(swap_promise)); | 1336 swap_promise_list_.push_back(std::move(swap_promise)); |
| 1336 } | 1337 } |
| 1337 | 1338 |
| 1338 void LayerTreeImpl::QueuePinnedSwapPromise( | 1339 void LayerTreeImpl::QueuePinnedSwapPromise( |
| 1339 scoped_ptr<SwapPromise> swap_promise) { | 1340 std::unique_ptr<SwapPromise> swap_promise) { |
| 1340 DCHECK(IsActiveTree()); | 1341 DCHECK(IsActiveTree()); |
| 1341 DCHECK(swap_promise); | 1342 DCHECK(swap_promise); |
| 1342 pinned_swap_promise_list_.push_back(std::move(swap_promise)); | 1343 pinned_swap_promise_list_.push_back(std::move(swap_promise)); |
| 1343 } | 1344 } |
| 1344 | 1345 |
| 1345 void LayerTreeImpl::PassSwapPromises( | 1346 void LayerTreeImpl::PassSwapPromises( |
| 1346 std::vector<scoped_ptr<SwapPromise>>* new_swap_promise) { | 1347 std::vector<std::unique_ptr<SwapPromise>>* new_swap_promise) { |
| 1347 for (const auto& swap_promise : swap_promise_list_) | 1348 for (const auto& swap_promise : swap_promise_list_) |
| 1348 swap_promise->DidNotSwap(SwapPromise::SWAP_FAILS); | 1349 swap_promise->DidNotSwap(SwapPromise::SWAP_FAILS); |
| 1349 swap_promise_list_.clear(); | 1350 swap_promise_list_.clear(); |
| 1350 swap_promise_list_.swap(*new_swap_promise); | 1351 swap_promise_list_.swap(*new_swap_promise); |
| 1351 } | 1352 } |
| 1352 | 1353 |
| 1353 void LayerTreeImpl::FinishSwapPromises(CompositorFrameMetadata* metadata) { | 1354 void LayerTreeImpl::FinishSwapPromises(CompositorFrameMetadata* metadata) { |
| 1354 for (const auto& swap_promise : swap_promise_list_) | 1355 for (const auto& swap_promise : swap_promise_list_) |
| 1355 swap_promise->DidSwap(metadata); | 1356 swap_promise->DidSwap(metadata); |
| 1356 swap_promise_list_.clear(); | 1357 swap_promise_list_.clear(); |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1933 bool LayerTreeImpl::SmoothnessTakesPriority() const { | 1934 bool LayerTreeImpl::SmoothnessTakesPriority() const { |
| 1934 return layer_tree_host_impl_->GetTreePriority() == SMOOTHNESS_TAKES_PRIORITY; | 1935 return layer_tree_host_impl_->GetTreePriority() == SMOOTHNESS_TAKES_PRIORITY; |
| 1935 } | 1936 } |
| 1936 | 1937 |
| 1937 VideoFrameControllerClient* LayerTreeImpl::GetVideoFrameControllerClient() | 1938 VideoFrameControllerClient* LayerTreeImpl::GetVideoFrameControllerClient() |
| 1938 const { | 1939 const { |
| 1939 return layer_tree_host_impl_; | 1940 return layer_tree_host_impl_; |
| 1940 } | 1941 } |
| 1941 | 1942 |
| 1942 void LayerTreeImpl::SetPendingPageScaleAnimation( | 1943 void LayerTreeImpl::SetPendingPageScaleAnimation( |
| 1943 scoped_ptr<PendingPageScaleAnimation> pending_animation) { | 1944 std::unique_ptr<PendingPageScaleAnimation> pending_animation) { |
| 1944 pending_page_scale_animation_ = std::move(pending_animation); | 1945 pending_page_scale_animation_ = std::move(pending_animation); |
| 1945 } | 1946 } |
| 1946 | 1947 |
| 1947 scoped_ptr<PendingPageScaleAnimation> | 1948 std::unique_ptr<PendingPageScaleAnimation> |
| 1948 LayerTreeImpl::TakePendingPageScaleAnimation() { | 1949 LayerTreeImpl::TakePendingPageScaleAnimation() { |
| 1949 return std::move(pending_page_scale_animation_); | 1950 return std::move(pending_page_scale_animation_); |
| 1950 } | 1951 } |
| 1951 | 1952 |
| 1952 bool LayerTreeImpl::IsAnimatingFilterProperty(const LayerImpl* layer) const { | 1953 bool LayerTreeImpl::IsAnimatingFilterProperty(const LayerImpl* layer) const { |
| 1953 LayerTreeType tree_type = | 1954 LayerTreeType tree_type = |
| 1954 IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING; | 1955 IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING; |
| 1955 return layer_tree_host_impl_->animation_host()->IsAnimatingFilterProperty( | 1956 return layer_tree_host_impl_->animation_host()->IsAnimatingFilterProperty( |
| 1956 layer->id(), tree_type); | 1957 layer->id(), tree_type); |
| 1957 } | 1958 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2093 } | 2094 } |
| 2094 | 2095 |
| 2095 void LayerTreeImpl::ResetAllChangeTracking(PropertyTrees::ResetFlags flag) { | 2096 void LayerTreeImpl::ResetAllChangeTracking(PropertyTrees::ResetFlags flag) { |
| 2096 layers_that_should_push_properties_.clear(); | 2097 layers_that_should_push_properties_.clear(); |
| 2097 for (auto* layer : *this) | 2098 for (auto* layer : *this) |
| 2098 layer->ResetChangeTracking(); | 2099 layer->ResetChangeTracking(); |
| 2099 property_trees_.ResetAllChangeTracking(flag); | 2100 property_trees_.ResetAllChangeTracking(flag); |
| 2100 } | 2101 } |
| 2101 | 2102 |
| 2102 } // namespace cc | 2103 } // namespace cc |
| OLD | NEW |