| 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/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/profiler/scoped_tracker.h" | 9 #include "base/profiler/scoped_tracker.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| 11 #include "cc/animation/animation_events.h" | 11 #include "cc/animation/animation_events.h" |
| 12 #include "cc/debug/benchmark_instrumentation.h" | 12 #include "cc/debug/benchmark_instrumentation.h" |
| 13 #include "cc/debug/devtools_instrumentation.h" | 13 #include "cc/debug/devtools_instrumentation.h" |
| 14 #include "cc/output/compositor_frame_sink.h" |
| 14 #include "cc/output/context_provider.h" | 15 #include "cc/output/context_provider.h" |
| 15 #include "cc/output/output_surface.h" | |
| 16 #include "cc/quads/draw_quad.h" | 16 #include "cc/quads/draw_quad.h" |
| 17 #include "cc/resources/ui_resource_manager.h" | 17 #include "cc/resources/ui_resource_manager.h" |
| 18 #include "cc/scheduler/commit_earlyout_reason.h" | 18 #include "cc/scheduler/commit_earlyout_reason.h" |
| 19 #include "cc/scheduler/compositor_timing_history.h" | 19 #include "cc/scheduler/compositor_timing_history.h" |
| 20 #include "cc/scheduler/delay_based_time_source.h" | 20 #include "cc/scheduler/delay_based_time_source.h" |
| 21 #include "cc/scheduler/scheduler.h" | 21 #include "cc/scheduler/scheduler.h" |
| 22 #include "cc/trees/layer_tree_host.h" | 22 #include "cc/trees/layer_tree_host.h" |
| 23 #include "cc/trees/layer_tree_host_common.h" | 23 #include "cc/trees/layer_tree_host_common.h" |
| 24 #include "cc/trees/layer_tree_host_single_thread_client.h" | 24 #include "cc/trees/layer_tree_host_single_thread_client.h" |
| 25 #include "cc/trees/layer_tree_impl.h" | 25 #include "cc/trees/layer_tree_impl.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 43 task_runner_provider_(task_runner_provider), | 43 task_runner_provider_(task_runner_provider), |
| 44 next_frame_is_newly_committed_frame_(false), | 44 next_frame_is_newly_committed_frame_(false), |
| 45 #if DCHECK_IS_ON() | 45 #if DCHECK_IS_ON() |
| 46 inside_impl_frame_(false), | 46 inside_impl_frame_(false), |
| 47 #endif | 47 #endif |
| 48 inside_draw_(false), | 48 inside_draw_(false), |
| 49 defer_commits_(false), | 49 defer_commits_(false), |
| 50 animate_requested_(false), | 50 animate_requested_(false), |
| 51 commit_requested_(false), | 51 commit_requested_(false), |
| 52 inside_synchronous_composite_(false), | 52 inside_synchronous_composite_(false), |
| 53 output_surface_creation_requested_(false), | 53 compositor_frame_sink_creation_requested_(false), |
| 54 output_surface_lost_(true), | 54 compositor_frame_sink_lost_(true), |
| 55 weak_factory_(this) { | 55 weak_factory_(this) { |
| 56 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); | 56 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); |
| 57 DCHECK(task_runner_provider_); | 57 DCHECK(task_runner_provider_); |
| 58 DCHECK(task_runner_provider_->IsMainThread()); | 58 DCHECK(task_runner_provider_->IsMainThread()); |
| 59 DCHECK(layer_tree_host); | 59 DCHECK(layer_tree_host); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void SingleThreadProxy::Start( | 62 void SingleThreadProxy::Start( |
| 63 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { | 63 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { |
| 64 DebugScopedSetImplThread impl(task_runner_provider_); | 64 DebugScopedSetImplThread impl(task_runner_provider_); |
| 65 external_begin_frame_source_ = std::move(external_begin_frame_source); | 65 external_begin_frame_source_ = std::move(external_begin_frame_source); |
| 66 | 66 |
| 67 const LayerTreeSettings& settings = layer_tree_host_->GetSettings(); | 67 const LayerTreeSettings& settings = layer_tree_host_->GetSettings(); |
| 68 if (settings.single_thread_proxy_scheduler && !scheduler_on_impl_thread_) { | 68 if (settings.single_thread_proxy_scheduler && !scheduler_on_impl_thread_) { |
| 69 SchedulerSettings scheduler_settings(settings.ToSchedulerSettings()); | 69 SchedulerSettings scheduler_settings(settings.ToSchedulerSettings()); |
| 70 scheduler_settings.commit_to_active_tree = CommitToActiveTree(); | 70 scheduler_settings.commit_to_active_tree = CommitToActiveTree(); |
| 71 | 71 |
| 72 std::unique_ptr<CompositorTimingHistory> compositor_timing_history( | 72 std::unique_ptr<CompositorTimingHistory> compositor_timing_history( |
| 73 new CompositorTimingHistory( | 73 new CompositorTimingHistory( |
| 74 scheduler_settings.using_synchronous_renderer_compositor, | 74 scheduler_settings.using_synchronous_renderer_compositor, |
| 75 CompositorTimingHistory::BROWSER_UMA, | 75 CompositorTimingHistory::BROWSER_UMA, |
| 76 layer_tree_host_->rendering_stats_instrumentation())); | 76 layer_tree_host_->rendering_stats_instrumentation())); |
| 77 | 77 |
| 78 // TODO(enne): remove these settings. | 78 // TODO(enne): remove these settings. |
| 79 DCHECK(!settings.use_external_begin_frame_source); | 79 DCHECK(!settings.use_external_begin_frame_source); |
| 80 DCHECK(settings.use_output_surface_begin_frame_source); | 80 DCHECK(settings.use_compositor_frame_sink_begin_frame_source); |
| 81 scheduler_on_impl_thread_ = | 81 scheduler_on_impl_thread_ = |
| 82 Scheduler::Create(this, scheduler_settings, layer_tree_host_->GetId(), | 82 Scheduler::Create(this, scheduler_settings, layer_tree_host_->GetId(), |
| 83 task_runner_provider_->MainThreadTaskRunner(), | 83 task_runner_provider_->MainThreadTaskRunner(), |
| 84 external_begin_frame_source_.get(), | 84 external_begin_frame_source_.get(), |
| 85 std::move(compositor_timing_history)); | 85 std::move(compositor_timing_history)); |
| 86 } | 86 } |
| 87 | 87 |
| 88 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); | 88 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); |
| 89 } | 89 } |
| 90 | 90 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 109 void SingleThreadProxy::SetVisible(bool visible) { | 109 void SingleThreadProxy::SetVisible(bool visible) { |
| 110 TRACE_EVENT1("cc", "SingleThreadProxy::SetVisible", "visible", visible); | 110 TRACE_EVENT1("cc", "SingleThreadProxy::SetVisible", "visible", visible); |
| 111 DebugScopedSetImplThread impl(task_runner_provider_); | 111 DebugScopedSetImplThread impl(task_runner_provider_); |
| 112 | 112 |
| 113 layer_tree_host_impl_->SetVisible(visible); | 113 layer_tree_host_impl_->SetVisible(visible); |
| 114 | 114 |
| 115 if (scheduler_on_impl_thread_) | 115 if (scheduler_on_impl_thread_) |
| 116 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); | 116 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void SingleThreadProxy::RequestNewOutputSurface() { | 119 void SingleThreadProxy::RequestNewCompositorFrameSink() { |
| 120 DCHECK(task_runner_provider_->IsMainThread()); | 120 DCHECK(task_runner_provider_->IsMainThread()); |
| 121 output_surface_creation_callback_.Cancel(); | 121 compositor_frame_sink_creation_callback_.Cancel(); |
| 122 if (output_surface_creation_requested_) | 122 if (compositor_frame_sink_creation_requested_) |
| 123 return; | 123 return; |
| 124 output_surface_creation_requested_ = true; | 124 compositor_frame_sink_creation_requested_ = true; |
| 125 layer_tree_host_->RequestNewOutputSurface(); | 125 layer_tree_host_->RequestNewCompositorFrameSink(); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void SingleThreadProxy::ReleaseOutputSurface() { | 128 void SingleThreadProxy::ReleaseCompositorFrameSink() { |
| 129 output_surface_lost_ = true; | 129 compositor_frame_sink_lost_ = true; |
| 130 if (scheduler_on_impl_thread_) | 130 if (scheduler_on_impl_thread_) |
| 131 scheduler_on_impl_thread_->DidLoseOutputSurface(); | 131 scheduler_on_impl_thread_->DidLoseCompositorFrameSink(); |
| 132 return layer_tree_host_impl_->ReleaseOutputSurface(); | 132 return layer_tree_host_impl_->ReleaseCompositorFrameSink(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void SingleThreadProxy::SetOutputSurface(OutputSurface* output_surface) { | 135 void SingleThreadProxy::SetCompositorFrameSink( |
| 136 CompositorFrameSink* compositor_frame_sink) { |
| 136 DCHECK(task_runner_provider_->IsMainThread()); | 137 DCHECK(task_runner_provider_->IsMainThread()); |
| 137 DCHECK(output_surface_creation_requested_); | 138 DCHECK(compositor_frame_sink_creation_requested_); |
| 138 | 139 |
| 139 bool success; | 140 bool success; |
| 140 { | 141 { |
| 141 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); | 142 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
| 142 DebugScopedSetImplThread impl(task_runner_provider_); | 143 DebugScopedSetImplThread impl(task_runner_provider_); |
| 143 success = layer_tree_host_impl_->InitializeRenderer(output_surface); | 144 success = layer_tree_host_impl_->InitializeRenderer(compositor_frame_sink); |
| 144 } | 145 } |
| 145 | 146 |
| 146 if (success) { | 147 if (success) { |
| 147 layer_tree_host_->DidInitializeOutputSurface(); | 148 layer_tree_host_->DidInitializeCompositorFrameSink(); |
| 148 if (scheduler_on_impl_thread_) | 149 if (scheduler_on_impl_thread_) |
| 149 scheduler_on_impl_thread_->DidCreateAndInitializeOutputSurface(); | 150 scheduler_on_impl_thread_->DidCreateAndInitializeCompositorFrameSink(); |
| 150 else if (!inside_synchronous_composite_) | 151 else if (!inside_synchronous_composite_) |
| 151 SetNeedsCommit(); | 152 SetNeedsCommit(); |
| 152 output_surface_creation_requested_ = false; | 153 compositor_frame_sink_creation_requested_ = false; |
| 153 output_surface_lost_ = false; | 154 compositor_frame_sink_lost_ = false; |
| 154 } else { | 155 } else { |
| 155 // DidFailToInitializeOutputSurface is treated as a RequestNewOutputSurface, | 156 // DidFailToInitializeCompositorFrameSink is treated as a |
| 156 // and so output_surface_creation_requested remains true. | 157 // RequestNewCompositorFrameSink, and so |
| 157 layer_tree_host_->DidFailToInitializeOutputSurface(); | 158 // compositor_frame_sink_creation_requested remains true. |
| 159 layer_tree_host_->DidFailToInitializeCompositorFrameSink(); |
| 158 } | 160 } |
| 159 } | 161 } |
| 160 | 162 |
| 161 void SingleThreadProxy::SetNeedsAnimate() { | 163 void SingleThreadProxy::SetNeedsAnimate() { |
| 162 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsAnimate"); | 164 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsAnimate"); |
| 163 DCHECK(task_runner_provider_->IsMainThread()); | 165 DCHECK(task_runner_provider_->IsMainThread()); |
| 164 client_->RequestScheduleAnimation(); | 166 client_->RequestScheduleAnimation(); |
| 165 if (animate_requested_) | 167 if (animate_requested_) |
| 166 return; | 168 return; |
| 167 animate_requested_ = true; | 169 animate_requested_ = true; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 return commit_requested_; | 289 return commit_requested_; |
| 288 } | 290 } |
| 289 | 291 |
| 290 void SingleThreadProxy::Stop() { | 292 void SingleThreadProxy::Stop() { |
| 291 TRACE_EVENT0("cc", "SingleThreadProxy::stop"); | 293 TRACE_EVENT0("cc", "SingleThreadProxy::stop"); |
| 292 DCHECK(task_runner_provider_->IsMainThread()); | 294 DCHECK(task_runner_provider_->IsMainThread()); |
| 293 { | 295 { |
| 294 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); | 296 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
| 295 DebugScopedSetImplThread impl(task_runner_provider_); | 297 DebugScopedSetImplThread impl(task_runner_provider_); |
| 296 | 298 |
| 297 // Take away the OutputSurface before destroying things so it doesn't try | 299 // Take away the CompositorFrameSink before destroying things so it doesn't |
| 298 // to call into its client mid-shutdown. | 300 // try to call into its client mid-shutdown. |
| 299 layer_tree_host_impl_->ReleaseOutputSurface(); | 301 layer_tree_host_impl_->ReleaseCompositorFrameSink(); |
| 300 | 302 |
| 301 BlockingTaskRunner::CapturePostTasks blocked( | 303 BlockingTaskRunner::CapturePostTasks blocked( |
| 302 task_runner_provider_->blocking_main_thread_task_runner()); | 304 task_runner_provider_->blocking_main_thread_task_runner()); |
| 303 scheduler_on_impl_thread_ = nullptr; | 305 scheduler_on_impl_thread_ = nullptr; |
| 304 layer_tree_host_impl_ = nullptr; | 306 layer_tree_host_impl_ = nullptr; |
| 305 } | 307 } |
| 306 layer_tree_host_ = NULL; | 308 layer_tree_host_ = NULL; |
| 307 } | 309 } |
| 308 | 310 |
| 309 void SingleThreadProxy::SetMutator(std::unique_ptr<LayerTreeMutator> mutator) { | 311 void SingleThreadProxy::SetMutator(std::unique_ptr<LayerTreeMutator> mutator) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 void SingleThreadProxy::DidPrepareTiles() { | 405 void SingleThreadProxy::DidPrepareTiles() { |
| 404 DCHECK(task_runner_provider_->IsImplThread()); | 406 DCHECK(task_runner_provider_->IsImplThread()); |
| 405 if (scheduler_on_impl_thread_) | 407 if (scheduler_on_impl_thread_) |
| 406 scheduler_on_impl_thread_->DidPrepareTiles(); | 408 scheduler_on_impl_thread_->DidPrepareTiles(); |
| 407 } | 409 } |
| 408 | 410 |
| 409 void SingleThreadProxy::DidCompletePageScaleAnimationOnImplThread() { | 411 void SingleThreadProxy::DidCompletePageScaleAnimationOnImplThread() { |
| 410 layer_tree_host_->DidCompletePageScaleAnimation(); | 412 layer_tree_host_->DidCompletePageScaleAnimation(); |
| 411 } | 413 } |
| 412 | 414 |
| 413 void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() { | 415 void SingleThreadProxy::DidLoseCompositorFrameSinkOnImplThread() { |
| 414 TRACE_EVENT0("cc", "SingleThreadProxy::DidLoseOutputSurfaceOnImplThread"); | 416 TRACE_EVENT0("cc", |
| 417 "SingleThreadProxy::DidLoseCompositorFrameSinkOnImplThread"); |
| 415 { | 418 { |
| 416 DebugScopedSetMainThread main(task_runner_provider_); | 419 DebugScopedSetMainThread main(task_runner_provider_); |
| 417 // This must happen before we notify the scheduler as it may try to recreate | 420 // This must happen before we notify the scheduler as it may try to recreate |
| 418 // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE. | 421 // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE. |
| 419 layer_tree_host_->DidLoseOutputSurface(); | 422 layer_tree_host_->DidLoseCompositorFrameSink(); |
| 420 } | 423 } |
| 421 client_->DidAbortSwapBuffers(); | 424 client_->DidAbortSwapBuffers(); |
| 422 if (scheduler_on_impl_thread_) | 425 if (scheduler_on_impl_thread_) |
| 423 scheduler_on_impl_thread_->DidLoseOutputSurface(); | 426 scheduler_on_impl_thread_->DidLoseCompositorFrameSink(); |
| 424 output_surface_lost_ = true; | 427 compositor_frame_sink_lost_ = true; |
| 425 } | 428 } |
| 426 | 429 |
| 427 void SingleThreadProxy::SetBeginFrameSource(BeginFrameSource* source) { | 430 void SingleThreadProxy::SetBeginFrameSource(BeginFrameSource* source) { |
| 428 DCHECK(layer_tree_host_->GetSettings().single_thread_proxy_scheduler); | 431 DCHECK(layer_tree_host_->GetSettings().single_thread_proxy_scheduler); |
| 429 // TODO(enne): this overrides any preexisting begin frame source. Those | 432 // TODO(enne): this overrides any preexisting begin frame source. Those |
| 430 // other sources will eventually be removed and this will be the only path. | 433 // other sources will eventually be removed and this will be the only path. |
| 431 if (!layer_tree_host_->GetSettings().use_output_surface_begin_frame_source) | 434 if (!layer_tree_host_->GetSettings() |
| 435 .use_compositor_frame_sink_begin_frame_source) |
| 432 return; | 436 return; |
| 433 if (scheduler_on_impl_thread_) | 437 if (scheduler_on_impl_thread_) |
| 434 scheduler_on_impl_thread_->SetBeginFrameSource(source); | 438 scheduler_on_impl_thread_->SetBeginFrameSource(source); |
| 435 } | 439 } |
| 436 | 440 |
| 437 void SingleThreadProxy::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { | 441 void SingleThreadProxy::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { |
| 438 if (scheduler_on_impl_thread_) | 442 if (scheduler_on_impl_thread_) |
| 439 scheduler_on_impl_thread_->SetEstimatedParentDrawTime(draw_time); | 443 scheduler_on_impl_thread_->SetEstimatedParentDrawTime(draw_time); |
| 440 } | 444 } |
| 441 | 445 |
| 442 void SingleThreadProxy::DidSwapBuffersCompleteOnImplThread() { | 446 void SingleThreadProxy::DidSwapBuffersCompleteOnImplThread() { |
| 443 TRACE_EVENT0("cc,benchmark", | 447 TRACE_EVENT0("cc,benchmark", |
| 444 "SingleThreadProxy::DidSwapBuffersCompleteOnImplThread"); | 448 "SingleThreadProxy::DidSwapBuffersCompleteOnImplThread"); |
| 445 if (scheduler_on_impl_thread_) | 449 if (scheduler_on_impl_thread_) |
| 446 scheduler_on_impl_thread_->DidSwapBuffersComplete(); | 450 scheduler_on_impl_thread_->DidSwapBuffersComplete(); |
| 447 layer_tree_host_->DidCompleteSwapBuffers(); | 451 layer_tree_host_->DidCompleteSwapBuffers(); |
| 448 } | 452 } |
| 449 | 453 |
| 450 void SingleThreadProxy::OnDrawForOutputSurface( | 454 void SingleThreadProxy::OnDrawForCompositorFrameSink( |
| 451 bool resourceless_software_draw) { | 455 bool resourceless_software_draw) { |
| 452 NOTREACHED() << "Implemented by ThreadProxy for synchronous compositor."; | 456 NOTREACHED() << "Implemented by ThreadProxy for synchronous compositor."; |
| 453 } | 457 } |
| 454 | 458 |
| 455 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { | 459 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { |
| 456 TRACE_EVENT0("cc,benchmark", "SingleThreadProxy::CompositeImmediately"); | 460 TRACE_EVENT0("cc,benchmark", "SingleThreadProxy::CompositeImmediately"); |
| 457 DCHECK(task_runner_provider_->IsMainThread()); | 461 DCHECK(task_runner_provider_->IsMainThread()); |
| 458 #if DCHECK_IS_ON() | 462 #if DCHECK_IS_ON() |
| 459 DCHECK(!inside_impl_frame_); | 463 DCHECK(!inside_impl_frame_); |
| 460 #endif | 464 #endif |
| 461 base::AutoReset<bool> inside_composite(&inside_synchronous_composite_, true); | 465 base::AutoReset<bool> inside_composite(&inside_synchronous_composite_, true); |
| 462 | 466 |
| 463 if (output_surface_lost_) { | 467 if (compositor_frame_sink_lost_) { |
| 464 RequestNewOutputSurface(); | 468 RequestNewCompositorFrameSink(); |
| 465 // RequestNewOutputSurface could have synchronously created an output | 469 // RequestNewCompositorFrameSink could have synchronously created an output |
| 466 // surface, so check again before returning. | 470 // surface, so check again before returning. |
| 467 if (output_surface_lost_) | 471 if (compositor_frame_sink_lost_) |
| 468 return; | 472 return; |
| 469 } | 473 } |
| 470 | 474 |
| 471 BeginFrameArgs begin_frame_args(BeginFrameArgs::Create( | 475 BeginFrameArgs begin_frame_args(BeginFrameArgs::Create( |
| 472 BEGINFRAME_FROM_HERE, frame_begin_time, base::TimeTicks(), | 476 BEGINFRAME_FROM_HERE, frame_begin_time, base::TimeTicks(), |
| 473 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL)); | 477 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL)); |
| 474 | 478 |
| 475 // Start the impl frame. | 479 // Start the impl frame. |
| 476 { | 480 { |
| 477 DebugScopedSetImplThread impl(task_runner_provider_); | 481 DebugScopedSetImplThread impl(task_runner_provider_); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 | 522 |
| 519 bool SingleThreadProxy::SupportsImplScrolling() const { | 523 bool SingleThreadProxy::SupportsImplScrolling() const { |
| 520 return false; | 524 return false; |
| 521 } | 525 } |
| 522 | 526 |
| 523 bool SingleThreadProxy::ShouldComposite() const { | 527 bool SingleThreadProxy::ShouldComposite() const { |
| 524 DCHECK(task_runner_provider_->IsImplThread()); | 528 DCHECK(task_runner_provider_->IsImplThread()); |
| 525 return layer_tree_host_impl_->visible() && layer_tree_host_impl_->CanDraw(); | 529 return layer_tree_host_impl_->visible() && layer_tree_host_impl_->CanDraw(); |
| 526 } | 530 } |
| 527 | 531 |
| 528 void SingleThreadProxy::ScheduleRequestNewOutputSurface() { | 532 void SingleThreadProxy::ScheduleRequestNewCompositorFrameSink() { |
| 529 if (output_surface_creation_callback_.IsCancelled() && | 533 if (compositor_frame_sink_creation_callback_.IsCancelled() && |
| 530 !output_surface_creation_requested_) { | 534 !compositor_frame_sink_creation_requested_) { |
| 531 output_surface_creation_callback_.Reset( | 535 compositor_frame_sink_creation_callback_.Reset( |
| 532 base::Bind(&SingleThreadProxy::RequestNewOutputSurface, | 536 base::Bind(&SingleThreadProxy::RequestNewCompositorFrameSink, |
| 533 weak_factory_.GetWeakPtr())); | 537 weak_factory_.GetWeakPtr())); |
| 534 task_runner_provider_->MainThreadTaskRunner()->PostTask( | 538 task_runner_provider_->MainThreadTaskRunner()->PostTask( |
| 535 FROM_HERE, output_surface_creation_callback_.callback()); | 539 FROM_HERE, compositor_frame_sink_creation_callback_.callback()); |
| 536 } | 540 } |
| 537 } | 541 } |
| 538 | 542 |
| 539 DrawResult SingleThreadProxy::DoComposite(LayerTreeHostImpl::FrameData* frame) { | 543 DrawResult SingleThreadProxy::DoComposite(LayerTreeHostImpl::FrameData* frame) { |
| 540 TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite"); | 544 TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite"); |
| 541 | 545 |
| 542 DrawResult draw_result; | 546 DrawResult draw_result; |
| 543 bool draw_frame; | 547 bool draw_frame; |
| 544 { | 548 { |
| 545 DebugScopedSetImplThread impl(task_runner_provider_); | 549 DebugScopedSetImplThread impl(task_runner_provider_); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 void SingleThreadProxy::ScheduledActionCommit() { | 725 void SingleThreadProxy::ScheduledActionCommit() { |
| 722 DebugScopedSetMainThread main(task_runner_provider_); | 726 DebugScopedSetMainThread main(task_runner_provider_); |
| 723 DoCommit(); | 727 DoCommit(); |
| 724 } | 728 } |
| 725 | 729 |
| 726 void SingleThreadProxy::ScheduledActionActivateSyncTree() { | 730 void SingleThreadProxy::ScheduledActionActivateSyncTree() { |
| 727 DebugScopedSetImplThread impl(task_runner_provider_); | 731 DebugScopedSetImplThread impl(task_runner_provider_); |
| 728 layer_tree_host_impl_->ActivateSyncTree(); | 732 layer_tree_host_impl_->ActivateSyncTree(); |
| 729 } | 733 } |
| 730 | 734 |
| 731 void SingleThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { | 735 void SingleThreadProxy::ScheduledActionBeginCompositorFrameSinkCreation() { |
| 732 DebugScopedSetMainThread main(task_runner_provider_); | 736 DebugScopedSetMainThread main(task_runner_provider_); |
| 733 DCHECK(scheduler_on_impl_thread_); | 737 DCHECK(scheduler_on_impl_thread_); |
| 734 // If possible, create the output surface in a post task. Synchronously | 738 // If possible, create the output surface in a post task. Synchronously |
| 735 // creating the output surface makes tests more awkward since this differs | 739 // creating the output surface makes tests more awkward since this differs |
| 736 // from the ThreadProxy behavior. However, sometimes there is no | 740 // from the ThreadProxy behavior. However, sometimes there is no |
| 737 // task runner. | 741 // task runner. |
| 738 if (task_runner_provider_->MainThreadTaskRunner()) { | 742 if (task_runner_provider_->MainThreadTaskRunner()) { |
| 739 ScheduleRequestNewOutputSurface(); | 743 ScheduleRequestNewCompositorFrameSink(); |
| 740 } else { | 744 } else { |
| 741 RequestNewOutputSurface(); | 745 RequestNewCompositorFrameSink(); |
| 742 } | 746 } |
| 743 } | 747 } |
| 744 | 748 |
| 745 void SingleThreadProxy::ScheduledActionPrepareTiles() { | 749 void SingleThreadProxy::ScheduledActionPrepareTiles() { |
| 746 TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionPrepareTiles"); | 750 TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionPrepareTiles"); |
| 747 DebugScopedSetImplThread impl(task_runner_provider_); | 751 DebugScopedSetImplThread impl(task_runner_provider_); |
| 748 layer_tree_host_impl_->PrepareTiles(); | 752 layer_tree_host_impl_->PrepareTiles(); |
| 749 } | 753 } |
| 750 | 754 |
| 751 void SingleThreadProxy::ScheduledActionInvalidateOutputSurface() { | 755 void SingleThreadProxy::ScheduledActionInvalidateCompositorFrameSink() { |
| 752 NOTREACHED(); | 756 NOTREACHED(); |
| 753 } | 757 } |
| 754 | 758 |
| 755 void SingleThreadProxy::UpdateTopControlsState(TopControlsState constraints, | 759 void SingleThreadProxy::UpdateTopControlsState(TopControlsState constraints, |
| 756 TopControlsState current, | 760 TopControlsState current, |
| 757 bool animate) { | 761 bool animate) { |
| 758 NOTREACHED() << "Top Controls are used only in threaded mode"; | 762 NOTREACHED() << "Top Controls are used only in threaded mode"; |
| 759 } | 763 } |
| 760 | 764 |
| 761 void SingleThreadProxy::DidFinishImplFrame() { | 765 void SingleThreadProxy::DidFinishImplFrame() { |
| 762 layer_tree_host_impl_->DidFinishImplFrame(); | 766 layer_tree_host_impl_->DidFinishImplFrame(); |
| 763 #if DCHECK_IS_ON() | 767 #if DCHECK_IS_ON() |
| 764 DCHECK(inside_impl_frame_) | 768 DCHECK(inside_impl_frame_) |
| 765 << "DidFinishImplFrame called while not inside an impl frame!"; | 769 << "DidFinishImplFrame called while not inside an impl frame!"; |
| 766 inside_impl_frame_ = false; | 770 inside_impl_frame_ = false; |
| 767 #endif | 771 #endif |
| 768 } | 772 } |
| 769 | 773 |
| 770 } // namespace cc | 774 } // namespace cc |
| OLD | NEW |