| 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/context_provider.h" | 14 #include "cc/output/context_provider.h" |
| 15 #include "cc/output/output_surface.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/scheduler/commit_earlyout_reason.h" | 17 #include "cc/scheduler/commit_earlyout_reason.h" |
| 18 #include "cc/scheduler/compositor_timing_history.h" | 18 #include "cc/scheduler/compositor_timing_history.h" |
| 19 #include "cc/scheduler/delay_based_time_source.h" |
| 19 #include "cc/scheduler/scheduler.h" | 20 #include "cc/scheduler/scheduler.h" |
| 20 #include "cc/trees/layer_tree_host.h" | 21 #include "cc/trees/layer_tree_host.h" |
| 21 #include "cc/trees/layer_tree_host_common.h" | 22 #include "cc/trees/layer_tree_host_common.h" |
| 22 #include "cc/trees/layer_tree_host_single_thread_client.h" | 23 #include "cc/trees/layer_tree_host_single_thread_client.h" |
| 23 #include "cc/trees/layer_tree_impl.h" | 24 #include "cc/trees/layer_tree_impl.h" |
| 24 #include "cc/trees/scoped_abort_remaining_swap_promises.h" | 25 #include "cc/trees/scoped_abort_remaining_swap_promises.h" |
| 25 | 26 |
| 26 namespace cc { | 27 namespace cc { |
| 27 | 28 |
| 28 std::unique_ptr<Proxy> SingleThreadProxy::Create( | 29 std::unique_ptr<Proxy> SingleThreadProxy::Create( |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 if (!layer_tree_host_->settings().use_output_surface_begin_frame_source) { | 78 if (!layer_tree_host_->settings().use_output_surface_begin_frame_source) { |
| 78 frame_source = external_begin_frame_source_.get(); | 79 frame_source = external_begin_frame_source_.get(); |
| 79 if (!scheduler_settings.throttle_frame_production) { | 80 if (!scheduler_settings.throttle_frame_production) { |
| 80 // Unthrottled source takes precedence over external sources. | 81 // Unthrottled source takes precedence over external sources. |
| 81 unthrottled_begin_frame_source_.reset(new BackToBackBeginFrameSource( | 82 unthrottled_begin_frame_source_.reset(new BackToBackBeginFrameSource( |
| 82 task_runner_provider_->MainThreadTaskRunner())); | 83 task_runner_provider_->MainThreadTaskRunner())); |
| 83 frame_source = unthrottled_begin_frame_source_.get(); | 84 frame_source = unthrottled_begin_frame_source_.get(); |
| 84 } | 85 } |
| 85 if (!frame_source) { | 86 if (!frame_source) { |
| 86 synthetic_begin_frame_source_.reset(new SyntheticBeginFrameSource( | 87 synthetic_begin_frame_source_.reset(new SyntheticBeginFrameSource( |
| 87 task_runner_provider_->MainThreadTaskRunner(), | 88 base::MakeUnique<DelayBasedTimeSource>( |
| 88 BeginFrameArgs::DefaultInterval())); | 89 task_runner_provider_->MainThreadTaskRunner()))); |
| 89 frame_source = synthetic_begin_frame_source_.get(); | 90 frame_source = synthetic_begin_frame_source_.get(); |
| 90 } | 91 } |
| 91 } | 92 } |
| 92 | 93 |
| 93 scheduler_on_impl_thread_ = | 94 scheduler_on_impl_thread_ = |
| 94 Scheduler::Create(this, scheduler_settings, layer_tree_host_->id(), | 95 Scheduler::Create(this, scheduler_settings, layer_tree_host_->id(), |
| 95 task_runner_provider_->MainThreadTaskRunner(), | 96 task_runner_provider_->MainThreadTaskRunner(), |
| 96 frame_source, std::move(compositor_timing_history)); | 97 frame_source, std::move(compositor_timing_history)); |
| 97 } | 98 } |
| 98 | 99 |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE. | 486 // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE. |
| 486 layer_tree_host_->DidLoseOutputSurface(); | 487 layer_tree_host_->DidLoseOutputSurface(); |
| 487 } | 488 } |
| 488 client_->DidAbortSwapBuffers(); | 489 client_->DidAbortSwapBuffers(); |
| 489 if (scheduler_on_impl_thread_) | 490 if (scheduler_on_impl_thread_) |
| 490 scheduler_on_impl_thread_->DidLoseOutputSurface(); | 491 scheduler_on_impl_thread_->DidLoseOutputSurface(); |
| 491 } | 492 } |
| 492 | 493 |
| 493 void SingleThreadProxy::CommitVSyncParameters(base::TimeTicks timebase, | 494 void SingleThreadProxy::CommitVSyncParameters(base::TimeTicks timebase, |
| 494 base::TimeDelta interval) { | 495 base::TimeDelta interval) { |
| 495 if (interval.is_zero()) { | |
| 496 // TODO(brianderson): We should not be receiving 0 intervals. | |
| 497 interval = BeginFrameArgs::DefaultInterval(); | |
| 498 } | |
| 499 | |
| 500 if (synthetic_begin_frame_source_) | 496 if (synthetic_begin_frame_source_) |
| 501 synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval); | 497 synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval); |
| 502 } | 498 } |
| 503 | 499 |
| 504 void SingleThreadProxy::SetBeginFrameSource(BeginFrameSource* source) { | 500 void SingleThreadProxy::SetBeginFrameSource(BeginFrameSource* source) { |
| 505 DCHECK(layer_tree_host_->settings().single_thread_proxy_scheduler); | 501 DCHECK(layer_tree_host_->settings().single_thread_proxy_scheduler); |
| 506 // TODO(enne): this overrides any preexisting begin frame source. Those | 502 // TODO(enne): this overrides any preexisting begin frame source. Those |
| 507 // other sources will eventually be removed and this will be the only path. | 503 // other sources will eventually be removed and this will be the only path. |
| 508 if (!layer_tree_host_->settings().use_output_surface_begin_frame_source) | 504 if (!layer_tree_host_->settings().use_output_surface_begin_frame_source) |
| 509 return; | 505 return; |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 void SingleThreadProxy::DidFinishImplFrame() { | 885 void SingleThreadProxy::DidFinishImplFrame() { |
| 890 layer_tree_host_impl_->DidFinishImplFrame(); | 886 layer_tree_host_impl_->DidFinishImplFrame(); |
| 891 #if DCHECK_IS_ON() | 887 #if DCHECK_IS_ON() |
| 892 DCHECK(inside_impl_frame_) | 888 DCHECK(inside_impl_frame_) |
| 893 << "DidFinishImplFrame called while not inside an impl frame!"; | 889 << "DidFinishImplFrame called while not inside an impl frame!"; |
| 894 inside_impl_frame_ = false; | 890 inside_impl_frame_ = false; |
| 895 #endif | 891 #endif |
| 896 } | 892 } |
| 897 | 893 |
| 898 } // namespace cc | 894 } // namespace cc |
| OLD | NEW |