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_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <stack> | 8 #include <stack> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 content_is_suitable_for_gpu_rasterization_(true), | 121 content_is_suitable_for_gpu_rasterization_(true), |
122 gpu_rasterization_histogram_recorded_(false), | 122 gpu_rasterization_histogram_recorded_(false), |
123 background_color_(SK_ColorWHITE), | 123 background_color_(SK_ColorWHITE), |
124 has_transparent_background_(false), | 124 has_transparent_background_(false), |
125 partial_texture_update_requests_(0), | 125 partial_texture_update_requests_(0), |
126 in_paint_layer_contents_(false), | 126 in_paint_layer_contents_(false), |
127 total_frames_used_for_lcd_text_metrics_(0), | 127 total_frames_used_for_lcd_text_metrics_(0), |
128 id_(s_layer_tree_host_sequence_number.GetNext() + 1), | 128 id_(s_layer_tree_host_sequence_number.GetNext() + 1), |
129 next_commit_forces_redraw_(false), | 129 next_commit_forces_redraw_(false), |
130 shared_bitmap_manager_(shared_bitmap_manager), | 130 shared_bitmap_manager_(shared_bitmap_manager), |
131 gpu_memory_buffer_manager_(gpu_memory_buffer_manager) { | 131 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
| 132 surface_id_namespace_(0u), |
| 133 next_surface_sequence_(1u) { |
132 if (settings_.accelerated_animation_enabled) | 134 if (settings_.accelerated_animation_enabled) |
133 animation_registrar_ = AnimationRegistrar::Create(); | 135 animation_registrar_ = AnimationRegistrar::Create(); |
134 rendering_stats_instrumentation_->set_record_rendering_stats( | 136 rendering_stats_instrumentation_->set_record_rendering_stats( |
135 debug_state_.RecordRenderingStats()); | 137 debug_state_.RecordRenderingStats()); |
136 } | 138 } |
137 | 139 |
138 void LayerTreeHost::InitializeThreaded( | 140 void LayerTreeHost::InitializeThreaded( |
139 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 141 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
140 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 142 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
141 InitializeProxy( | 143 InitializeProxy( |
(...skipping 18 matching lines...) Expand all Loading... |
160 proxy_->Start(); | 162 proxy_->Start(); |
161 if (settings_.accelerated_animation_enabled) { | 163 if (settings_.accelerated_animation_enabled) { |
162 animation_registrar_->set_supports_scroll_animations( | 164 animation_registrar_->set_supports_scroll_animations( |
163 proxy_->SupportsImplScrolling()); | 165 proxy_->SupportsImplScrolling()); |
164 } | 166 } |
165 } | 167 } |
166 | 168 |
167 LayerTreeHost::~LayerTreeHost() { | 169 LayerTreeHost::~LayerTreeHost() { |
168 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); | 170 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); |
169 | 171 |
170 DCHECK(swap_promise_monitor_.empty()); | |
171 | |
172 BreakSwapPromises(SwapPromise::COMMIT_FAILS); | |
173 | |
174 overhang_ui_resource_ = nullptr; | 172 overhang_ui_resource_ = nullptr; |
175 | 173 |
176 if (root_layer_.get()) | 174 if (root_layer_.get()) |
177 root_layer_->SetLayerTreeHost(NULL); | 175 root_layer_->SetLayerTreeHost(NULL); |
178 | 176 |
| 177 DCHECK(swap_promise_monitor_.empty()); |
| 178 |
| 179 BreakSwapPromises(SwapPromise::COMMIT_FAILS); |
| 180 |
179 if (proxy_) { | 181 if (proxy_) { |
180 DCHECK(proxy_->IsMainThread()); | 182 DCHECK(proxy_->IsMainThread()); |
181 proxy_->Stop(); | 183 proxy_->Stop(); |
182 } | 184 } |
183 | 185 |
184 // We must clear any pointers into the layer tree prior to destroying it. | 186 // We must clear any pointers into the layer tree prior to destroying it. |
185 RegisterViewportLayers(NULL, NULL, NULL); | 187 RegisterViewportLayers(NULL, NULL, NULL); |
186 | 188 |
187 if (root_layer_.get()) { | 189 if (root_layer_.get()) { |
188 // The layer tree must be destroyed before the layer tree host. We've | 190 // The layer tree must be destroyed before the layer tree host. We've |
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 DCHECK(swap_promise); | 1331 DCHECK(swap_promise); |
1330 swap_promise_list_.push_back(swap_promise.Pass()); | 1332 swap_promise_list_.push_back(swap_promise.Pass()); |
1331 } | 1333 } |
1332 | 1334 |
1333 void LayerTreeHost::BreakSwapPromises(SwapPromise::DidNotSwapReason reason) { | 1335 void LayerTreeHost::BreakSwapPromises(SwapPromise::DidNotSwapReason reason) { |
1334 for (size_t i = 0; i < swap_promise_list_.size(); i++) | 1336 for (size_t i = 0; i < swap_promise_list_.size(); i++) |
1335 swap_promise_list_[i]->DidNotSwap(reason); | 1337 swap_promise_list_[i]->DidNotSwap(reason); |
1336 swap_promise_list_.clear(); | 1338 swap_promise_list_.clear(); |
1337 } | 1339 } |
1338 | 1340 |
| 1341 void LayerTreeHost::set_surface_id_namespace(uint32_t id_namespace) { |
| 1342 surface_id_namespace_ = id_namespace; |
| 1343 } |
| 1344 |
| 1345 SurfaceSequence LayerTreeHost::CreateSurfaceSequence() { |
| 1346 return SurfaceSequence(surface_id_namespace_, next_surface_sequence_++); |
| 1347 } |
| 1348 |
1339 } // namespace cc | 1349 } // namespace cc |
OLD | NEW |