| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 needs_full_tree_sync_(true), | 63 needs_full_tree_sync_(true), |
| 64 next_activation_forces_redraw_(false), | 64 next_activation_forces_redraw_(false), |
| 65 has_ever_been_drawn_(false), | 65 has_ever_been_drawn_(false), |
| 66 render_surface_layer_list_id_(0), | 66 render_surface_layer_list_id_(0), |
| 67 top_controls_shrink_blink_size_(false), | 67 top_controls_shrink_blink_size_(false), |
| 68 top_controls_height_(0), | 68 top_controls_height_(0), |
| 69 top_controls_shown_ratio_(top_controls_shown_ratio) { | 69 top_controls_shown_ratio_(top_controls_shown_ratio) { |
| 70 } | 70 } |
| 71 | 71 |
| 72 LayerTreeImpl::~LayerTreeImpl() { | 72 LayerTreeImpl::~LayerTreeImpl() { |
| 73 BreakSwapPromises(SwapPromise::SWAP_FAILS); | 73 BreakSwapPromises(IsActiveTree() ? SwapPromise::SWAP_FAILS |
| 74 : SwapPromise::ACTIVATION_FAILS); |
| 74 | 75 |
| 75 // Need to explicitly clear the tree prior to destroying this so that | 76 // Need to explicitly clear the tree prior to destroying this so that |
| 76 // the LayerTreeImpl pointer is still valid in the LayerImpl dtor. | 77 // the LayerTreeImpl pointer is still valid in the LayerImpl dtor. |
| 77 DCHECK(!root_layer_); | 78 DCHECK(!root_layer_); |
| 78 DCHECK(layers_with_copy_output_request_.empty()); | 79 DCHECK(layers_with_copy_output_request_.empty()); |
| 79 } | 80 } |
| 80 | 81 |
| 81 void LayerTreeImpl::Shutdown() { | 82 void LayerTreeImpl::Shutdown() { |
| 82 root_layer_ = nullptr; | 83 root_layer_ = nullptr; |
| 83 } | 84 } |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 | 738 |
| 738 // Always reset this flag on activation, as we would only have activated | 739 // Always reset this flag on activation, as we would only have activated |
| 739 // if we were in a good state. | 740 // if we were in a good state. |
| 740 layer_tree_host_impl_->ResetRequiresHighResToDraw(); | 741 layer_tree_host_impl_->ResetRequiresHighResToDraw(); |
| 741 | 742 |
| 742 if (root_layer()) { | 743 if (root_layer()) { |
| 743 LayerTreeHostCommon::CallFunctionForSubtree( | 744 LayerTreeHostCommon::CallFunctionForSubtree( |
| 744 root_layer(), [](LayerImpl* layer) { layer->DidBecomeActive(); }); | 745 root_layer(), [](LayerImpl* layer) { layer->DidBecomeActive(); }); |
| 745 } | 746 } |
| 746 | 747 |
| 748 for (auto* swap_promise : swap_promise_list_) |
| 749 swap_promise->DidActivate(); |
| 747 devtools_instrumentation::DidActivateLayerTree(layer_tree_host_impl_->id(), | 750 devtools_instrumentation::DidActivateLayerTree(layer_tree_host_impl_->id(), |
| 748 source_frame_number_); | 751 source_frame_number_); |
| 749 } | 752 } |
| 750 | 753 |
| 751 bool LayerTreeImpl::ContentsTexturesPurged() const { | 754 bool LayerTreeImpl::ContentsTexturesPurged() const { |
| 752 return contents_textures_purged_; | 755 return contents_textures_purged_; |
| 753 } | 756 } |
| 754 | 757 |
| 755 void LayerTreeImpl::SetContentsTexturesPurged() { | 758 void LayerTreeImpl::SetContentsTexturesPurged() { |
| 756 if (contents_textures_purged_) | 759 if (contents_textures_purged_) |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list_); | 986 LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list_); |
| 984 for (LayerIteratorType it = LayerIteratorType::Begin( | 987 for (LayerIteratorType it = LayerIteratorType::Begin( |
| 985 &render_surface_layer_list_); it != end; ++it) { | 988 &render_surface_layer_list_); it != end; ++it) { |
| 986 if (!it.represents_itself()) | 989 if (!it.represents_itself()) |
| 987 continue; | 990 continue; |
| 988 TracedValue::AppendIDRef(*it, state); | 991 TracedValue::AppendIDRef(*it, state); |
| 989 } | 992 } |
| 990 state->EndArray(); | 993 state->EndArray(); |
| 991 | 994 |
| 992 state->BeginArray("swap_promise_trace_ids"); | 995 state->BeginArray("swap_promise_trace_ids"); |
| 993 for (size_t i = 0; i < swap_promise_list_.size(); i++) | 996 for (auto* swap_promise : swap_promise_list_) |
| 994 state->AppendDouble(swap_promise_list_[i]->TraceId()); | 997 state->AppendDouble(swap_promise->TraceId()); |
| 995 state->EndArray(); | 998 state->EndArray(); |
| 996 } | 999 } |
| 997 | 1000 |
| 998 void LayerTreeImpl::SetRootLayerScrollOffsetDelegate( | 1001 void LayerTreeImpl::SetRootLayerScrollOffsetDelegate( |
| 999 LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate) { | 1002 LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate) { |
| 1000 if (root_layer_scroll_offset_delegate_ == root_layer_scroll_offset_delegate) | 1003 if (root_layer_scroll_offset_delegate_ == root_layer_scroll_offset_delegate) |
| 1001 return; | 1004 return; |
| 1002 | 1005 |
| 1003 root_layer_scroll_offset_delegate_ = root_layer_scroll_offset_delegate; | 1006 root_layer_scroll_offset_delegate_ = root_layer_scroll_offset_delegate; |
| 1004 | 1007 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 UpdateRootScrollOffsetDelegate(); | 1068 UpdateRootScrollOffsetDelegate(); |
| 1066 } | 1069 } |
| 1067 | 1070 |
| 1068 void LayerTreeImpl::QueueSwapPromise(scoped_ptr<SwapPromise> swap_promise) { | 1071 void LayerTreeImpl::QueueSwapPromise(scoped_ptr<SwapPromise> swap_promise) { |
| 1069 DCHECK(swap_promise); | 1072 DCHECK(swap_promise); |
| 1070 swap_promise_list_.push_back(swap_promise.Pass()); | 1073 swap_promise_list_.push_back(swap_promise.Pass()); |
| 1071 } | 1074 } |
| 1072 | 1075 |
| 1073 void LayerTreeImpl::PassSwapPromises( | 1076 void LayerTreeImpl::PassSwapPromises( |
| 1074 ScopedPtrVector<SwapPromise>* new_swap_promise) { | 1077 ScopedPtrVector<SwapPromise>* new_swap_promise) { |
| 1075 swap_promise_list_.insert_and_take(swap_promise_list_.end(), | 1078 // Any left over promises have failed to swap before the next frame. |
| 1076 new_swap_promise); | 1079 BreakSwapPromises(SwapPromise::SWAP_FAILS); |
| 1077 new_swap_promise->clear(); | 1080 swap_promise_list_.swap(*new_swap_promise); |
| 1078 } | 1081 } |
| 1079 | 1082 |
| 1080 void LayerTreeImpl::FinishSwapPromises(CompositorFrameMetadata* metadata) { | 1083 void LayerTreeImpl::FinishSwapPromises(CompositorFrameMetadata* metadata) { |
| 1081 for (size_t i = 0; i < swap_promise_list_.size(); i++) | 1084 for (auto* swap_promise : swap_promise_list_) |
| 1082 swap_promise_list_[i]->DidSwap(metadata); | 1085 swap_promise->DidSwap(metadata); |
| 1083 swap_promise_list_.clear(); | 1086 swap_promise_list_.clear(); |
| 1084 } | 1087 } |
| 1085 | 1088 |
| 1086 void LayerTreeImpl::BreakSwapPromises(SwapPromise::DidNotSwapReason reason) { | 1089 void LayerTreeImpl::BreakSwapPromises(SwapPromise::DidNotSwapReason reason) { |
| 1087 for (size_t i = 0; i < swap_promise_list_.size(); i++) | 1090 for (auto* swap_promise : swap_promise_list_) |
| 1088 swap_promise_list_[i]->DidNotSwap(reason); | 1091 swap_promise->DidNotSwap(reason); |
| 1089 swap_promise_list_.clear(); | 1092 swap_promise_list_.clear(); |
| 1090 } | 1093 } |
| 1091 | 1094 |
| 1092 void LayerTreeImpl::DidModifyTilePriorities() { | 1095 void LayerTreeImpl::DidModifyTilePriorities() { |
| 1093 layer_tree_host_impl_->DidModifyTilePriorities(); | 1096 layer_tree_host_impl_->DidModifyTilePriorities(); |
| 1094 } | 1097 } |
| 1095 | 1098 |
| 1096 void LayerTreeImpl::set_ui_resource_request_queue( | 1099 void LayerTreeImpl::set_ui_resource_request_queue( |
| 1097 const UIResourceRequestQueue& queue) { | 1100 const UIResourceRequestQueue& queue) { |
| 1098 ui_resource_request_queue_ = queue; | 1101 ui_resource_request_queue_ = queue; |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 scoped_ptr<PendingPageScaleAnimation> pending_animation) { | 1568 scoped_ptr<PendingPageScaleAnimation> pending_animation) { |
| 1566 pending_page_scale_animation_ = pending_animation.Pass(); | 1569 pending_page_scale_animation_ = pending_animation.Pass(); |
| 1567 } | 1570 } |
| 1568 | 1571 |
| 1569 scoped_ptr<PendingPageScaleAnimation> | 1572 scoped_ptr<PendingPageScaleAnimation> |
| 1570 LayerTreeImpl::TakePendingPageScaleAnimation() { | 1573 LayerTreeImpl::TakePendingPageScaleAnimation() { |
| 1571 return pending_page_scale_animation_.Pass(); | 1574 return pending_page_scale_animation_.Pass(); |
| 1572 } | 1575 } |
| 1573 | 1576 |
| 1574 } // namespace cc | 1577 } // namespace cc |
| OLD | NEW |