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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE. | 408 // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE. |
416 layer_tree_host_->DidLoseCompositorFrameSink(); | 409 layer_tree_host_->DidLoseCompositorFrameSink(); |
417 } | 410 } |
418 client_->DidAbortSwapBuffers(); | 411 client_->DidAbortSwapBuffers(); |
419 if (scheduler_on_impl_thread_) | 412 if (scheduler_on_impl_thread_) |
420 scheduler_on_impl_thread_->DidLoseCompositorFrameSink(); | 413 scheduler_on_impl_thread_->DidLoseCompositorFrameSink(); |
421 compositor_frame_sink_lost_ = true; | 414 compositor_frame_sink_lost_ = true; |
422 } | 415 } |
423 | 416 |
424 void SingleThreadProxy::SetBeginFrameSource(BeginFrameSource* source) { | 417 void SingleThreadProxy::SetBeginFrameSource(BeginFrameSource* source) { |
425 DCHECK(layer_tree_host_->GetSettings().single_thread_proxy_scheduler); | |
426 // TODO(enne): this overrides any preexisting begin frame source. Those | |
427 // other sources will eventually be removed and this will be the only path. | |
428 if (!layer_tree_host_->GetSettings() | |
429 .use_compositor_frame_sink_begin_frame_source) | |
430 return; | |
431 if (scheduler_on_impl_thread_) | 418 if (scheduler_on_impl_thread_) |
432 scheduler_on_impl_thread_->SetBeginFrameSource(source); | 419 scheduler_on_impl_thread_->SetBeginFrameSource(source); |
433 } | 420 } |
434 | 421 |
435 void SingleThreadProxy::DidSwapBuffersCompleteOnImplThread() { | 422 void SingleThreadProxy::DidSwapBuffersCompleteOnImplThread() { |
436 TRACE_EVENT0("cc,benchmark", | 423 TRACE_EVENT0("cc,benchmark", |
437 "SingleThreadProxy::DidSwapBuffersCompleteOnImplThread"); | 424 "SingleThreadProxy::DidSwapBuffersCompleteOnImplThread"); |
438 if (scheduler_on_impl_thread_) | 425 if (scheduler_on_impl_thread_) |
439 scheduler_on_impl_thread_->DidSwapBuffersComplete(); | 426 scheduler_on_impl_thread_->DidSwapBuffersComplete(); |
440 layer_tree_host_->DidCompleteSwapBuffers(); | 427 layer_tree_host_->DidCompleteSwapBuffers(); |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 void SingleThreadProxy::DidFinishImplFrame() { | 741 void SingleThreadProxy::DidFinishImplFrame() { |
755 layer_tree_host_impl_->DidFinishImplFrame(); | 742 layer_tree_host_impl_->DidFinishImplFrame(); |
756 #if DCHECK_IS_ON() | 743 #if DCHECK_IS_ON() |
757 DCHECK(inside_impl_frame_) | 744 DCHECK(inside_impl_frame_) |
758 << "DidFinishImplFrame called while not inside an impl frame!"; | 745 << "DidFinishImplFrame called while not inside an impl frame!"; |
759 inside_impl_frame_ = false; | 746 inside_impl_frame_ = false; |
760 #endif | 747 #endif |
761 } | 748 } |
762 | 749 |
763 } // namespace cc | 750 } // namespace cc |
OLD | NEW |