| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 scheduler_settings.using_synchronous_renderer_compositor, | 73 scheduler_settings.using_synchronous_renderer_compositor, |
| 73 CompositorTimingHistory::BROWSER_UMA, | 74 CompositorTimingHistory::BROWSER_UMA, |
| 74 layer_tree_host_->rendering_stats_instrumentation())); | 75 layer_tree_host_->rendering_stats_instrumentation())); |
| 75 | 76 |
| 76 BeginFrameSource* frame_source = nullptr; | 77 BeginFrameSource* frame_source = nullptr; |
| 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 base::MakeUnique<DelayBasedTimeSource>( |
| 84 task_runner_provider_->MainThreadTaskRunner()))); |
| 83 frame_source = unthrottled_begin_frame_source_.get(); | 85 frame_source = unthrottled_begin_frame_source_.get(); |
| 84 } | 86 } |
| 85 if (!frame_source) { | 87 if (!frame_source) { |
| 86 synthetic_begin_frame_source_.reset(new SyntheticBeginFrameSource( | 88 synthetic_begin_frame_source_.reset(new DelayBasedBeginFrameSource( |
| 87 task_runner_provider_->MainThreadTaskRunner(), | 89 base::MakeUnique<DelayBasedTimeSource>( |
| 88 BeginFrameArgs::DefaultInterval())); | 90 task_runner_provider_->MainThreadTaskRunner()))); |
| 89 frame_source = synthetic_begin_frame_source_.get(); | 91 frame_source = synthetic_begin_frame_source_.get(); |
| 90 } | 92 } |
| 91 } | 93 } |
| 92 | 94 |
| 93 scheduler_on_impl_thread_ = | 95 scheduler_on_impl_thread_ = |
| 94 Scheduler::Create(this, scheduler_settings, layer_tree_host_->id(), | 96 Scheduler::Create(this, scheduler_settings, layer_tree_host_->id(), |
| 95 task_runner_provider_->MainThreadTaskRunner(), | 97 task_runner_provider_->MainThreadTaskRunner(), |
| 96 frame_source, std::move(compositor_timing_history)); | 98 frame_source, std::move(compositor_timing_history)); |
| 97 } | 99 } |
| 98 | 100 |
| (...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. | 487 // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE. |
| 486 layer_tree_host_->DidLoseOutputSurface(); | 488 layer_tree_host_->DidLoseOutputSurface(); |
| 487 } | 489 } |
| 488 client_->DidAbortSwapBuffers(); | 490 client_->DidAbortSwapBuffers(); |
| 489 if (scheduler_on_impl_thread_) | 491 if (scheduler_on_impl_thread_) |
| 490 scheduler_on_impl_thread_->DidLoseOutputSurface(); | 492 scheduler_on_impl_thread_->DidLoseOutputSurface(); |
| 491 } | 493 } |
| 492 | 494 |
| 493 void SingleThreadProxy::CommitVSyncParameters(base::TimeTicks timebase, | 495 void SingleThreadProxy::CommitVSyncParameters(base::TimeTicks timebase, |
| 494 base::TimeDelta interval) { | 496 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_) | 497 if (synthetic_begin_frame_source_) |
| 501 synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval); | 498 synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval); |
| 502 } | 499 } |
| 503 | 500 |
| 504 void SingleThreadProxy::SetBeginFrameSource(BeginFrameSource* source) { | 501 void SingleThreadProxy::SetBeginFrameSource(BeginFrameSource* source) { |
| 505 DCHECK(layer_tree_host_->settings().single_thread_proxy_scheduler); | 502 DCHECK(layer_tree_host_->settings().single_thread_proxy_scheduler); |
| 506 // TODO(enne): this overrides any preexisting begin frame source. Those | 503 // TODO(enne): this overrides any preexisting begin frame source. Those |
| 507 // other sources will eventually be removed and this will be the only path. | 504 // 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) | 505 if (!layer_tree_host_->settings().use_output_surface_begin_frame_source) |
| 509 return; | 506 return; |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 void SingleThreadProxy::DidFinishImplFrame() { | 886 void SingleThreadProxy::DidFinishImplFrame() { |
| 890 layer_tree_host_impl_->DidFinishImplFrame(); | 887 layer_tree_host_impl_->DidFinishImplFrame(); |
| 891 #if DCHECK_IS_ON() | 888 #if DCHECK_IS_ON() |
| 892 DCHECK(inside_impl_frame_) | 889 DCHECK(inside_impl_frame_) |
| 893 << "DidFinishImplFrame called while not inside an impl frame!"; | 890 << "DidFinishImplFrame called while not inside an impl frame!"; |
| 894 inside_impl_frame_ = false; | 891 inside_impl_frame_ = false; |
| 895 #endif | 892 #endif |
| 896 } | 893 } |
| 897 | 894 |
| 898 } // namespace cc | 895 } // namespace cc |
| OLD | NEW |