OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/proxy_impl.h" | 5 #include "cc/trees/proxy_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
13 #include "base/trace_event/trace_event_argument.h" | 13 #include "base/trace_event/trace_event_argument.h" |
14 #include "base/trace_event/trace_event_synthetic_delay.h" | 14 #include "base/trace_event/trace_event_synthetic_delay.h" |
15 #include "cc/animation/animation_events.h" | 15 #include "cc/animation/animation_events.h" |
16 #include "cc/debug/benchmark_instrumentation.h" | 16 #include "cc/debug/benchmark_instrumentation.h" |
17 #include "cc/debug/devtools_instrumentation.h" | 17 #include "cc/debug/devtools_instrumentation.h" |
18 #include "cc/input/top_controls_manager.h" | 18 #include "cc/input/top_controls_manager.h" |
19 #include "cc/output/context_provider.h" | 19 #include "cc/output/context_provider.h" |
20 #include "cc/output/output_surface.h" | 20 #include "cc/output/output_surface.h" |
21 #include "cc/scheduler/compositor_timing_history.h" | 21 #include "cc/scheduler/compositor_timing_history.h" |
| 22 #include "cc/scheduler/delay_based_time_source.h" |
22 #include "cc/trees/layer_tree_host.h" | 23 #include "cc/trees/layer_tree_host.h" |
23 #include "cc/trees/layer_tree_impl.h" | 24 #include "cc/trees/layer_tree_impl.h" |
24 #include "cc/trees/task_runner_provider.h" | 25 #include "cc/trees/task_runner_provider.h" |
25 #include "gpu/command_buffer/client/gles2_interface.h" | 26 #include "gpu/command_buffer/client/gles2_interface.h" |
26 | 27 |
27 namespace cc { | 28 namespace cc { |
28 | 29 |
29 namespace { | 30 namespace { |
30 | 31 |
31 // Measured in seconds. | 32 // Measured in seconds. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 rendering_stats_instrumentation_)); | 84 rendering_stats_instrumentation_)); |
84 | 85 |
85 BeginFrameSource* frame_source = external_begin_frame_source_.get(); | 86 BeginFrameSource* frame_source = external_begin_frame_source_.get(); |
86 if (!scheduler_settings.throttle_frame_production) { | 87 if (!scheduler_settings.throttle_frame_production) { |
87 // Unthrottled source takes precedence over external sources. | 88 // Unthrottled source takes precedence over external sources. |
88 unthrottled_begin_frame_source_.reset(new BackToBackBeginFrameSource( | 89 unthrottled_begin_frame_source_.reset(new BackToBackBeginFrameSource( |
89 task_runner_provider_->ImplThreadTaskRunner())); | 90 task_runner_provider_->ImplThreadTaskRunner())); |
90 frame_source = unthrottled_begin_frame_source_.get(); | 91 frame_source = unthrottled_begin_frame_source_.get(); |
91 } | 92 } |
92 if (!frame_source) { | 93 if (!frame_source) { |
93 synthetic_begin_frame_source_.reset(new SyntheticBeginFrameSource( | 94 synthetic_begin_frame_source_.reset( |
94 task_runner_provider_->ImplThreadTaskRunner(), | 95 new SyntheticBeginFrameSource(base::MakeUnique<DelayBasedTimeSource>( |
95 BeginFrameArgs::DefaultInterval())); | 96 task_runner_provider_->ImplThreadTaskRunner()))); |
96 frame_source = synthetic_begin_frame_source_.get(); | 97 frame_source = synthetic_begin_frame_source_.get(); |
97 } | 98 } |
98 scheduler_ = | 99 scheduler_ = |
99 Scheduler::Create(this, scheduler_settings, layer_tree_host_id_, | 100 Scheduler::Create(this, scheduler_settings, layer_tree_host_id_, |
100 task_runner_provider_->ImplThreadTaskRunner(), | 101 task_runner_provider_->ImplThreadTaskRunner(), |
101 frame_source, std::move(compositor_timing_history)); | 102 frame_source, std::move(compositor_timing_history)); |
102 | 103 |
103 DCHECK_EQ(scheduler_->visible(), layer_tree_host_impl_->visible()); | 104 DCHECK_EQ(scheduler_->visible(), layer_tree_host_impl_->visible()); |
104 } | 105 } |
105 | 106 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 void ProxyImpl::DidLoseOutputSurfaceOnImplThread() { | 299 void ProxyImpl::DidLoseOutputSurfaceOnImplThread() { |
299 TRACE_EVENT0("cc", "ProxyImpl::DidLoseOutputSurfaceOnImplThread"); | 300 TRACE_EVENT0("cc", "ProxyImpl::DidLoseOutputSurfaceOnImplThread"); |
300 DCHECK(IsImplThread()); | 301 DCHECK(IsImplThread()); |
301 channel_impl_->DidLoseOutputSurface(); | 302 channel_impl_->DidLoseOutputSurface(); |
302 scheduler_->DidLoseOutputSurface(); | 303 scheduler_->DidLoseOutputSurface(); |
303 } | 304 } |
304 | 305 |
305 void ProxyImpl::CommitVSyncParameters(base::TimeTicks timebase, | 306 void ProxyImpl::CommitVSyncParameters(base::TimeTicks timebase, |
306 base::TimeDelta interval) { | 307 base::TimeDelta interval) { |
307 DCHECK(IsImplThread()); | 308 DCHECK(IsImplThread()); |
308 if (!synthetic_begin_frame_source_) | 309 if (synthetic_begin_frame_source_) |
309 return; | 310 synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval); |
310 | |
311 if (interval.is_zero()) { | |
312 // TODO(brianderson): We should not be receiving 0 intervals. | |
313 interval = BeginFrameArgs::DefaultInterval(); | |
314 } | |
315 synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval); | |
316 } | 311 } |
317 | 312 |
318 void ProxyImpl::SetBeginFrameSource(BeginFrameSource* source) { | 313 void ProxyImpl::SetBeginFrameSource(BeginFrameSource* source) { |
319 // During shutdown, destroying the OutputSurface may unset the | 314 // During shutdown, destroying the OutputSurface may unset the |
320 // BeginFrameSource. | 315 // BeginFrameSource. |
321 if (scheduler_) { | 316 if (scheduler_) { |
322 // TODO(enne): this overrides any preexisting begin frame source. Those | 317 // TODO(enne): this overrides any preexisting begin frame source. Those |
323 // other sources will eventually be removed and this will be the only path. | 318 // other sources will eventually be removed and this will be the only path. |
324 scheduler_->SetBeginFrameSource(source); | 319 scheduler_->SetBeginFrameSource(source); |
325 } | 320 } |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 bool ProxyImpl::IsMainThreadBlocked() const { | 680 bool ProxyImpl::IsMainThreadBlocked() const { |
686 return task_runner_provider_->IsMainThreadBlocked(); | 681 return task_runner_provider_->IsMainThreadBlocked(); |
687 } | 682 } |
688 | 683 |
689 ProxyImpl::BlockedMainCommitOnly& ProxyImpl::blocked_main_commit() { | 684 ProxyImpl::BlockedMainCommitOnly& ProxyImpl::blocked_main_commit() { |
690 DCHECK(IsMainThreadBlocked() && commit_completion_event_); | 685 DCHECK(IsMainThreadBlocked() && commit_completion_event_); |
691 return main_thread_blocked_commit_vars_unsafe_; | 686 return main_thread_blocked_commit_vars_unsafe_; |
692 } | 687 } |
693 | 688 |
694 } // namespace cc | 689 } // namespace cc |
OLD | NEW |