| 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" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 inside_synchronous_composite_(false), | 52 inside_synchronous_composite_(false), |
| 53 compositor_frame_sink_creation_requested_(false), | 53 compositor_frame_sink_creation_requested_(false), |
| 54 compositor_frame_sink_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) { | |
| 64 DebugScopedSetImplThread impl(task_runner_provider_); | 63 DebugScopedSetImplThread impl(task_runner_provider_); |
| 65 external_begin_frame_source_ = std::move(external_begin_frame_source); | |
| 66 | 64 |
| 67 const LayerTreeSettings& settings = layer_tree_host_->GetSettings(); | 65 const LayerTreeSettings& settings = layer_tree_host_->GetSettings(); |
| 68 if (settings.single_thread_proxy_scheduler && !scheduler_on_impl_thread_) { | 66 if (settings.single_thread_proxy_scheduler && !scheduler_on_impl_thread_) { |
| 69 SchedulerSettings scheduler_settings(settings.ToSchedulerSettings()); | 67 SchedulerSettings scheduler_settings(settings.ToSchedulerSettings()); |
| 70 scheduler_settings.commit_to_active_tree = CommitToActiveTree(); | 68 scheduler_settings.commit_to_active_tree = CommitToActiveTree(); |
| 71 | 69 |
| 72 std::unique_ptr<CompositorTimingHistory> compositor_timing_history( | 70 std::unique_ptr<CompositorTimingHistory> compositor_timing_history( |
| 73 new CompositorTimingHistory( | 71 new CompositorTimingHistory( |
| 74 scheduler_settings.using_synchronous_renderer_compositor, | 72 scheduler_settings.using_synchronous_renderer_compositor, |
| 75 CompositorTimingHistory::BROWSER_UMA, | 73 CompositorTimingHistory::BROWSER_UMA, |
| 76 layer_tree_host_->rendering_stats_instrumentation())); | 74 layer_tree_host_->rendering_stats_instrumentation())); |
| 77 | 75 scheduler_on_impl_thread_.reset( |
| 78 // TODO(enne): remove these settings. | 76 new Scheduler(this, scheduler_settings, layer_tree_host_->GetId(), |
| 79 DCHECK(!settings.use_external_begin_frame_source); | 77 task_runner_provider_->MainThreadTaskRunner(), |
| 80 DCHECK(settings.use_compositor_frame_sink_begin_frame_source); | 78 std::move(compositor_timing_history))); |
| 81 scheduler_on_impl_thread_ = | |
| 82 Scheduler::Create(this, scheduler_settings, layer_tree_host_->GetId(), | |
| 83 task_runner_provider_->MainThreadTaskRunner(), | |
| 84 external_begin_frame_source_.get(), | |
| 85 std::move(compositor_timing_history)); | |
| 86 } | 79 } |
| 87 | 80 |
| 88 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); | 81 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); |
| 89 } | 82 } |
| 90 | 83 |
| 91 SingleThreadProxy::~SingleThreadProxy() { | 84 SingleThreadProxy::~SingleThreadProxy() { |
| 92 TRACE_EVENT0("cc", "SingleThreadProxy::~SingleThreadProxy"); | 85 TRACE_EVENT0("cc", "SingleThreadProxy::~SingleThreadProxy"); |
| 93 DCHECK(task_runner_provider_->IsMainThread()); | 86 DCHECK(task_runner_provider_->IsMainThread()); |
| 94 // Make sure Stop() got called or never Started. | 87 // Make sure Stop() got called or never Started. |
| 95 DCHECK(!layer_tree_host_impl_); | 88 DCHECK(!layer_tree_host_impl_); |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE. | 414 // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE. |
| 422 layer_tree_host_->DidLoseCompositorFrameSink(); | 415 layer_tree_host_->DidLoseCompositorFrameSink(); |
| 423 } | 416 } |
| 424 client_->DidAbortSwapBuffers(); | 417 client_->DidAbortSwapBuffers(); |
| 425 if (scheduler_on_impl_thread_) | 418 if (scheduler_on_impl_thread_) |
| 426 scheduler_on_impl_thread_->DidLoseCompositorFrameSink(); | 419 scheduler_on_impl_thread_->DidLoseCompositorFrameSink(); |
| 427 compositor_frame_sink_lost_ = true; | 420 compositor_frame_sink_lost_ = true; |
| 428 } | 421 } |
| 429 | 422 |
| 430 void SingleThreadProxy::SetBeginFrameSource(BeginFrameSource* source) { | 423 void SingleThreadProxy::SetBeginFrameSource(BeginFrameSource* source) { |
| 431 DCHECK(layer_tree_host_->GetSettings().single_thread_proxy_scheduler); | |
| 432 // TODO(enne): this overrides any preexisting begin frame source. Those | |
| 433 // other sources will eventually be removed and this will be the only path. | |
| 434 if (!layer_tree_host_->GetSettings() | |
| 435 .use_compositor_frame_sink_begin_frame_source) | |
| 436 return; | |
| 437 if (scheduler_on_impl_thread_) | 424 if (scheduler_on_impl_thread_) |
| 438 scheduler_on_impl_thread_->SetBeginFrameSource(source); | 425 scheduler_on_impl_thread_->SetBeginFrameSource(source); |
| 439 } | 426 } |
| 440 | 427 |
| 441 void SingleThreadProxy::DidSwapBuffersCompleteOnImplThread() { | 428 void SingleThreadProxy::DidSwapBuffersCompleteOnImplThread() { |
| 442 TRACE_EVENT0("cc,benchmark", | 429 TRACE_EVENT0("cc,benchmark", |
| 443 "SingleThreadProxy::DidSwapBuffersCompleteOnImplThread"); | 430 "SingleThreadProxy::DidSwapBuffersCompleteOnImplThread"); |
| 444 if (scheduler_on_impl_thread_) | 431 if (scheduler_on_impl_thread_) |
| 445 scheduler_on_impl_thread_->DidSwapBuffersComplete(); | 432 scheduler_on_impl_thread_->DidSwapBuffersComplete(); |
| 446 layer_tree_host_->DidCompleteSwapBuffers(); | 433 layer_tree_host_->DidCompleteSwapBuffers(); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 void SingleThreadProxy::DidFinishImplFrame() { | 747 void SingleThreadProxy::DidFinishImplFrame() { |
| 761 layer_tree_host_impl_->DidFinishImplFrame(); | 748 layer_tree_host_impl_->DidFinishImplFrame(); |
| 762 #if DCHECK_IS_ON() | 749 #if DCHECK_IS_ON() |
| 763 DCHECK(inside_impl_frame_) | 750 DCHECK(inside_impl_frame_) |
| 764 << "DidFinishImplFrame called while not inside an impl frame!"; | 751 << "DidFinishImplFrame called while not inside an impl frame!"; |
| 765 inside_impl_frame_ = false; | 752 inside_impl_frame_ = false; |
| 766 #endif | 753 #endif |
| 767 } | 754 } |
| 768 | 755 |
| 769 } // namespace cc | 756 } // namespace cc |
| OLD | NEW |