| 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 // made a contract with our animation controllers that the registrar | 187 // made a contract with our animation controllers that the registrar |
| 188 // will outlive them, and we must make good. | 188 // will outlive them, and we must make good. |
| 189 root_layer_ = NULL; | 189 root_layer_ = NULL; |
| 190 } | 190 } |
| 191 } | 191 } |
| 192 | 192 |
| 193 void LayerTreeHost::SetLayerTreeHostClientReady() { | 193 void LayerTreeHost::SetLayerTreeHostClientReady() { |
| 194 proxy_->SetLayerTreeHostClientReady(); | 194 proxy_->SetLayerTreeHostClientReady(); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void LayerTreeHost::DeleteContentsTexturesOnImplThread( | |
| 198 ResourceProvider* resource_provider) { | |
| 199 DCHECK(proxy_->IsImplThread()); | |
| 200 if (contents_texture_manager_) | |
| 201 contents_texture_manager_->ClearAllMemory(resource_provider); | |
| 202 } | |
| 203 | |
| 204 void LayerTreeHost::WillBeginMainFrame() { | 197 void LayerTreeHost::WillBeginMainFrame() { |
| 205 devtools_instrumentation::WillBeginMainThreadFrame(id(), | 198 devtools_instrumentation::WillBeginMainThreadFrame(id(), |
| 206 source_frame_number()); | 199 source_frame_number()); |
| 207 client_->WillBeginMainFrame(); | 200 client_->WillBeginMainFrame(); |
| 208 } | 201 } |
| 209 | 202 |
| 210 void LayerTreeHost::DidBeginMainFrame() { | 203 void LayerTreeHost::DidBeginMainFrame() { |
| 211 client_->DidBeginMainFrame(); | 204 client_->DidBeginMainFrame(); |
| 212 } | 205 } |
| 213 | 206 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 235 } | 228 } |
| 236 | 229 |
| 237 // This function commits the LayerTreeHost to an impl tree. When modifying | 230 // This function commits the LayerTreeHost to an impl tree. When modifying |
| 238 // this function, keep in mind that the function *runs* on the impl thread! Any | 231 // this function, keep in mind that the function *runs* on the impl thread! Any |
| 239 // code that is logically a main thread operation, e.g. deletion of a Layer, | 232 // code that is logically a main thread operation, e.g. deletion of a Layer, |
| 240 // should be delayed until the LayerTreeHost::CommitComplete, which will run | 233 // should be delayed until the LayerTreeHost::CommitComplete, which will run |
| 241 // after the commit, but on the main thread. | 234 // after the commit, but on the main thread. |
| 242 void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { | 235 void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { |
| 243 DCHECK(proxy_->IsImplThread()); | 236 DCHECK(proxy_->IsImplThread()); |
| 244 | 237 |
| 245 // If there are linked evicted backings, these backings' resources may be put | |
| 246 // into the impl tree, so we can't draw yet. Determine this before clearing | |
| 247 // all evicted backings. | |
| 248 bool new_impl_tree_has_no_evicted_resources = false; | |
| 249 if (contents_texture_manager_) { | |
| 250 new_impl_tree_has_no_evicted_resources = | |
| 251 !contents_texture_manager_->LinkedEvictedBackingsExist(); | |
| 252 | |
| 253 // If the memory limit has been increased since this now-finishing | |
| 254 // commit began, and the extra now-available memory would have been used, | |
| 255 // then request another commit. | |
| 256 if (contents_texture_manager_->MaxMemoryLimitBytes() < | |
| 257 host_impl->memory_allocation_limit_bytes() && | |
| 258 contents_texture_manager_->MaxMemoryLimitBytes() < | |
| 259 contents_texture_manager_->MaxMemoryNeededBytes()) { | |
| 260 host_impl->SetNeedsCommit(); | |
| 261 } | |
| 262 | |
| 263 host_impl->set_max_memory_needed_bytes( | |
| 264 contents_texture_manager_->MaxMemoryNeededBytes()); | |
| 265 | |
| 266 contents_texture_manager_->UpdateBackingsState( | |
| 267 host_impl->resource_provider()); | |
| 268 contents_texture_manager_->ReduceMemory(host_impl->resource_provider()); | |
| 269 } | |
| 270 | |
| 271 bool is_new_trace; | 238 bool is_new_trace; |
| 272 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); | 239 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); |
| 273 if (is_new_trace && | 240 if (is_new_trace && |
| 274 frame_viewer_instrumentation::IsTracingLayerTreeSnapshots() && | 241 frame_viewer_instrumentation::IsTracingLayerTreeSnapshots() && |
| 275 root_layer()) { | 242 root_layer()) { |
| 276 LayerTreeHostCommon::CallFunctionForSubtree( | 243 LayerTreeHostCommon::CallFunctionForSubtree( |
| 277 root_layer(), [](Layer* layer) { layer->DidBeginTracing(); }); | 244 root_layer(), [](Layer* layer) { layer->DidBeginTracing(); }); |
| 278 } | 245 } |
| 279 | 246 |
| 280 LayerTreeImpl* sync_tree = host_impl->sync_tree(); | 247 LayerTreeImpl* sync_tree = host_impl->sync_tree(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 pending_page_scale_animation_.Pass()); | 313 pending_page_scale_animation_.Pass()); |
| 347 } | 314 } |
| 348 | 315 |
| 349 if (!ui_resource_request_queue_.empty()) { | 316 if (!ui_resource_request_queue_.empty()) { |
| 350 sync_tree->set_ui_resource_request_queue(ui_resource_request_queue_); | 317 sync_tree->set_ui_resource_request_queue(ui_resource_request_queue_); |
| 351 ui_resource_request_queue_.clear(); | 318 ui_resource_request_queue_.clear(); |
| 352 } | 319 } |
| 353 | 320 |
| 354 DCHECK(!sync_tree->ViewportSizeInvalid()); | 321 DCHECK(!sync_tree->ViewportSizeInvalid()); |
| 355 | 322 |
| 356 if (new_impl_tree_has_no_evicted_resources) { | |
| 357 if (sync_tree->ContentsTexturesPurged()) | |
| 358 sync_tree->ResetContentsTexturesPurged(); | |
| 359 } | |
| 360 | |
| 361 sync_tree->set_has_ever_been_drawn(false); | 323 sync_tree->set_has_ever_been_drawn(false); |
| 362 | 324 |
| 363 { | 325 { |
| 364 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); | 326 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); |
| 365 TreeSynchronizer::PushProperties(root_layer(), sync_tree->root_layer()); | 327 TreeSynchronizer::PushProperties(root_layer(), sync_tree->root_layer()); |
| 366 } | 328 } |
| 367 | 329 |
| 368 // This must happen after synchronizing property trees and after push | 330 // This must happen after synchronizing property trees and after push |
| 369 // properties, which updates property tree indices. | 331 // properties, which updates property tree indices. |
| 370 sync_tree->UpdatePropertyTreeScrollingFromMainThread(); | 332 sync_tree->UpdatePropertyTreeScrollingFromMainThread(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 | 372 |
| 411 proxy_->SetOutputSurface(surface.Pass()); | 373 proxy_->SetOutputSurface(surface.Pass()); |
| 412 } | 374 } |
| 413 | 375 |
| 414 void LayerTreeHost::RequestNewOutputSurface() { | 376 void LayerTreeHost::RequestNewOutputSurface() { |
| 415 client_->RequestNewOutputSurface(); | 377 client_->RequestNewOutputSurface(); |
| 416 } | 378 } |
| 417 | 379 |
| 418 void LayerTreeHost::DidInitializeOutputSurface() { | 380 void LayerTreeHost::DidInitializeOutputSurface() { |
| 419 output_surface_lost_ = false; | 381 output_surface_lost_ = false; |
| 420 | |
| 421 if (!contents_texture_manager_ && !settings_.impl_side_painting) { | |
| 422 contents_texture_manager_ = | |
| 423 PrioritizedResourceManager::Create(proxy_.get()); | |
| 424 surface_memory_placeholder_ = | |
| 425 contents_texture_manager_->CreateTexture(gfx::Size(), RGBA_8888); | |
| 426 } | |
| 427 | |
| 428 if (root_layer()) { | 382 if (root_layer()) { |
| 429 LayerTreeHostCommon::CallFunctionForSubtree( | 383 LayerTreeHostCommon::CallFunctionForSubtree( |
| 430 root_layer(), [](Layer* layer) { layer->OnOutputSurfaceCreated(); }); | 384 root_layer(), [](Layer* layer) { layer->OnOutputSurfaceCreated(); }); |
| 431 } | 385 } |
| 432 | |
| 433 client_->DidInitializeOutputSurface(); | 386 client_->DidInitializeOutputSurface(); |
| 434 } | 387 } |
| 435 | 388 |
| 436 void LayerTreeHost::DidFailToInitializeOutputSurface() { | 389 void LayerTreeHost::DidFailToInitializeOutputSurface() { |
| 437 DCHECK(output_surface_lost_); | 390 DCHECK(output_surface_lost_); |
| 438 client_->DidFailToInitializeOutputSurface(); | 391 client_->DidFailToInitializeOutputSurface(); |
| 439 } | 392 } |
| 440 | 393 |
| 441 scoped_ptr<LayerTreeHostImpl> LayerTreeHost::CreateLayerTreeHostImpl( | 394 scoped_ptr<LayerTreeHostImpl> LayerTreeHost::CreateLayerTreeHostImpl( |
| 442 LayerTreeHostImplClient* client) { | 395 LayerTreeHostImplClient* client) { |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 } | 1070 } |
| 1118 | 1071 |
| 1119 void LayerTreeHost::RecordFrameTimingEvents( | 1072 void LayerTreeHost::RecordFrameTimingEvents( |
| 1120 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | 1073 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
| 1121 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { | 1074 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
| 1122 client_->RecordFrameTimingEvents(composite_events.Pass(), | 1075 client_->RecordFrameTimingEvents(composite_events.Pass(), |
| 1123 main_frame_events.Pass()); | 1076 main_frame_events.Pass()); |
| 1124 } | 1077 } |
| 1125 | 1078 |
| 1126 } // namespace cc | 1079 } // namespace cc |
| OLD | NEW |