| 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/single_thread_proxy.h" | 5 #include "cc/trees/single_thread_proxy.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/profiler/scoped_tracker.h" | 8 #include "base/profiler/scoped_tracker.h" |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "cc/debug/benchmark_instrumentation.h" | 10 #include "cc/debug/benchmark_instrumentation.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 scoped_ptr<OutputSurface> output_surface) { | 145 scoped_ptr<OutputSurface> output_surface) { |
| 146 DCHECK(Proxy::IsMainThread()); | 146 DCHECK(Proxy::IsMainThread()); |
| 147 DCHECK(layer_tree_host_->output_surface_lost()); | 147 DCHECK(layer_tree_host_->output_surface_lost()); |
| 148 DCHECK(output_surface_creation_requested_); | 148 DCHECK(output_surface_creation_requested_); |
| 149 renderer_capabilities_for_main_thread_ = RendererCapabilities(); | 149 renderer_capabilities_for_main_thread_ = RendererCapabilities(); |
| 150 | 150 |
| 151 bool success; | 151 bool success; |
| 152 { | 152 { |
| 153 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 153 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 154 DebugScopedSetImplThread impl(this); | 154 DebugScopedSetImplThread impl(this); |
| 155 layer_tree_host_->DeleteContentsTexturesOnImplThread( | |
| 156 layer_tree_host_impl_->resource_provider()); | |
| 157 success = layer_tree_host_impl_->InitializeRenderer(output_surface.Pass()); | 155 success = layer_tree_host_impl_->InitializeRenderer(output_surface.Pass()); |
| 158 } | 156 } |
| 159 | 157 |
| 160 if (success) { | 158 if (success) { |
| 161 layer_tree_host_->DidInitializeOutputSurface(); | 159 layer_tree_host_->DidInitializeOutputSurface(); |
| 162 if (scheduler_on_impl_thread_) | 160 if (scheduler_on_impl_thread_) |
| 163 scheduler_on_impl_thread_->DidCreateAndInitializeOutputSurface(); | 161 scheduler_on_impl_thread_->DidCreateAndInitializeOutputSurface(); |
| 164 else if (!inside_synchronous_composite_) | 162 else if (!inside_synchronous_composite_) |
| 165 SetNeedsCommit(); | 163 SetNeedsCommit(); |
| 166 output_surface_creation_requested_ = false; | 164 output_surface_creation_requested_ = false; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 233 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 236 DebugScopedSetImplThread impl(this); | 234 DebugScopedSetImplThread impl(this); |
| 237 | 235 |
| 238 // This CapturePostTasks should be destroyed before CommitComplete() is | 236 // This CapturePostTasks should be destroyed before CommitComplete() is |
| 239 // called since that goes out to the embedder, and we want the embedder | 237 // called since that goes out to the embedder, and we want the embedder |
| 240 // to receive its callbacks before that. | 238 // to receive its callbacks before that. |
| 241 commit_blocking_task_runner_.reset(new BlockingTaskRunner::CapturePostTasks( | 239 commit_blocking_task_runner_.reset(new BlockingTaskRunner::CapturePostTasks( |
| 242 blocking_main_thread_task_runner())); | 240 blocking_main_thread_task_runner())); |
| 243 | 241 |
| 244 layer_tree_host_impl_->BeginCommit(); | 242 layer_tree_host_impl_->BeginCommit(); |
| 245 | |
| 246 if (PrioritizedResourceManager* contents_texture_manager = | |
| 247 layer_tree_host_->contents_texture_manager()) { | |
| 248 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 | |
| 249 // is fixed. | |
| 250 tracked_objects::ScopedTracker tracking_profile3( | |
| 251 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 252 "461509 SingleThreadProxy::DoCommit3")); | |
| 253 contents_texture_manager->PushTexturePrioritiesToBackings(); | |
| 254 } | |
| 255 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get()); | 243 layer_tree_host_->BeginCommitOnImplThread(layer_tree_host_impl_.get()); |
| 256 | 244 |
| 257 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 | 245 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 |
| 258 // is fixed. | 246 // is fixed. |
| 259 tracked_objects::ScopedTracker tracking_profile4( | 247 tracked_objects::ScopedTracker tracking_profile4( |
| 260 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 248 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 261 "461509 SingleThreadProxy::DoCommit4")); | 249 "461509 SingleThreadProxy::DoCommit4")); |
| 262 scoped_ptr<ResourceUpdateController> update_controller = | 250 scoped_ptr<ResourceUpdateController> update_controller = |
| 263 ResourceUpdateController::Create( | 251 ResourceUpdateController::Create( |
| 264 NULL, | 252 NULL, |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 | 387 |
| 400 void SingleThreadProxy::Stop() { | 388 void SingleThreadProxy::Stop() { |
| 401 TRACE_EVENT0("cc", "SingleThreadProxy::stop"); | 389 TRACE_EVENT0("cc", "SingleThreadProxy::stop"); |
| 402 DCHECK(Proxy::IsMainThread()); | 390 DCHECK(Proxy::IsMainThread()); |
| 403 { | 391 { |
| 404 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 392 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 405 DebugScopedSetImplThread impl(this); | 393 DebugScopedSetImplThread impl(this); |
| 406 | 394 |
| 407 BlockingTaskRunner::CapturePostTasks blocked( | 395 BlockingTaskRunner::CapturePostTasks blocked( |
| 408 blocking_main_thread_task_runner()); | 396 blocking_main_thread_task_runner()); |
| 409 layer_tree_host_->DeleteContentsTexturesOnImplThread( | |
| 410 layer_tree_host_impl_->resource_provider()); | |
| 411 scheduler_on_impl_thread_ = nullptr; | 397 scheduler_on_impl_thread_ = nullptr; |
| 412 layer_tree_host_impl_ = nullptr; | 398 layer_tree_host_impl_ = nullptr; |
| 413 } | 399 } |
| 414 layer_tree_host_ = NULL; | 400 layer_tree_host_ = NULL; |
| 415 } | 401 } |
| 416 | 402 |
| 417 void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) { | 403 void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) { |
| 418 TRACE_EVENT1( | 404 TRACE_EVENT1( |
| 419 "cc", "SingleThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); | 405 "cc", "SingleThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); |
| 420 DCHECK(Proxy::IsImplThread()); | 406 DCHECK(Proxy::IsImplThread()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 | 462 |
| 477 void SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread( | 463 void SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread( |
| 478 scoped_ptr<AnimationEventsVector> events) { | 464 scoped_ptr<AnimationEventsVector> events) { |
| 479 TRACE_EVENT0( | 465 TRACE_EVENT0( |
| 480 "cc", "SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); | 466 "cc", "SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); |
| 481 DCHECK(Proxy::IsImplThread()); | 467 DCHECK(Proxy::IsImplThread()); |
| 482 DebugScopedSetMainThread main(this); | 468 DebugScopedSetMainThread main(this); |
| 483 layer_tree_host_->SetAnimationEvents(events.Pass()); | 469 layer_tree_host_->SetAnimationEvents(events.Pass()); |
| 484 } | 470 } |
| 485 | 471 |
| 486 bool SingleThreadProxy::ReduceContentsTextureMemoryOnImplThread( | |
| 487 size_t limit_bytes, | |
| 488 int priority_cutoff) { | |
| 489 DCHECK(IsImplThread()); | |
| 490 PrioritizedResourceManager* contents_texture_manager = | |
| 491 layer_tree_host_->contents_texture_manager(); | |
| 492 | |
| 493 ResourceProvider* resource_provider = | |
| 494 layer_tree_host_impl_->resource_provider(); | |
| 495 | |
| 496 if (!contents_texture_manager || !resource_provider) | |
| 497 return false; | |
| 498 | |
| 499 return contents_texture_manager->ReduceMemoryOnImplThread( | |
| 500 limit_bytes, priority_cutoff, resource_provider); | |
| 501 } | |
| 502 | |
| 503 bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; } | 472 bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; } |
| 504 | 473 |
| 505 void SingleThreadProxy::DidActivateSyncTree() { | 474 void SingleThreadProxy::DidActivateSyncTree() { |
| 506 // Non-impl-side painting finishes commit in DoCommit. Impl-side painting | 475 // Non-impl-side painting finishes commit in DoCommit. Impl-side painting |
| 507 // defers until here to simulate SetNextCommitWaitsForActivation. | 476 // defers until here to simulate SetNextCommitWaitsForActivation. |
| 508 if (layer_tree_host_impl_->settings().impl_side_painting) { | 477 if (layer_tree_host_impl_->settings().impl_side_painting) { |
| 509 // This is required because NotifyReadyToActivate gets called immediately | 478 // This is required because NotifyReadyToActivate gets called immediately |
| 510 // after commit since single thread commits directly to the active tree. | 479 // after commit since single thread commits directly to the active tree. |
| 511 if (scheduler_on_impl_thread_) | 480 if (scheduler_on_impl_thread_) |
| 512 scheduler_on_impl_thread_->SetWaitForReadyToDraw(); | 481 scheduler_on_impl_thread_->SetWaitForReadyToDraw(); |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 DoBeginMainFrame(begin_frame_args); | 851 DoBeginMainFrame(begin_frame_args); |
| 883 } | 852 } |
| 884 | 853 |
| 885 void SingleThreadProxy::DoBeginMainFrame( | 854 void SingleThreadProxy::DoBeginMainFrame( |
| 886 const BeginFrameArgs& begin_frame_args) { | 855 const BeginFrameArgs& begin_frame_args) { |
| 887 layer_tree_host_->WillBeginMainFrame(); | 856 layer_tree_host_->WillBeginMainFrame(); |
| 888 layer_tree_host_->BeginMainFrame(begin_frame_args); | 857 layer_tree_host_->BeginMainFrame(begin_frame_args); |
| 889 layer_tree_host_->AnimateLayers(begin_frame_args.frame_time); | 858 layer_tree_host_->AnimateLayers(begin_frame_args.frame_time); |
| 890 layer_tree_host_->Layout(); | 859 layer_tree_host_->Layout(); |
| 891 | 860 |
| 892 if (PrioritizedResourceManager* contents_texture_manager = | |
| 893 layer_tree_host_->contents_texture_manager()) { | |
| 894 contents_texture_manager->UnlinkAndClearEvictedBackings(); | |
| 895 contents_texture_manager->SetMaxMemoryLimitBytes( | |
| 896 layer_tree_host_impl_->memory_allocation_limit_bytes()); | |
| 897 contents_texture_manager->SetExternalPriorityCutoff( | |
| 898 layer_tree_host_impl_->memory_allocation_priority_cutoff()); | |
| 899 } | |
| 900 | |
| 901 DCHECK(!queue_for_commit_); | 861 DCHECK(!queue_for_commit_); |
| 902 queue_for_commit_ = make_scoped_ptr(new ResourceUpdateQueue); | 862 queue_for_commit_ = make_scoped_ptr(new ResourceUpdateQueue); |
| 903 | 863 |
| 904 // New commits requested inside UpdateLayers should be respected. | 864 // New commits requested inside UpdateLayers should be respected. |
| 905 commit_requested_ = false; | 865 commit_requested_ = false; |
| 906 | 866 |
| 907 layer_tree_host_->UpdateLayers(); | 867 layer_tree_host_->UpdateLayers(); |
| 908 | 868 |
| 909 timing_history_.DidBeginMainFrame(); | 869 timing_history_.DidBeginMainFrame(); |
| 910 | 870 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 << "DidFinishImplFrame called while not inside an impl frame!"; | 961 << "DidFinishImplFrame called while not inside an impl frame!"; |
| 1002 inside_impl_frame_ = false; | 962 inside_impl_frame_ = false; |
| 1003 #endif | 963 #endif |
| 1004 } | 964 } |
| 1005 | 965 |
| 1006 void SingleThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) { | 966 void SingleThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) { |
| 1007 layer_tree_host_->SendBeginFramesToChildren(args); | 967 layer_tree_host_->SendBeginFramesToChildren(args); |
| 1008 } | 968 } |
| 1009 | 969 |
| 1010 } // namespace cc | 970 } // namespace cc |
| OLD | NEW |