| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 SchedulerSettings scheduler_settings( | 68 SchedulerSettings scheduler_settings( |
| 69 layer_tree_host_->settings().ToSchedulerSettings()); | 69 layer_tree_host_->settings().ToSchedulerSettings()); |
| 70 scheduler_settings.commit_to_active_tree = CommitToActiveTree(); | 70 scheduler_settings.commit_to_active_tree = CommitToActiveTree(); |
| 71 | 71 |
| 72 std::unique_ptr<CompositorTimingHistory> compositor_timing_history( | 72 std::unique_ptr<CompositorTimingHistory> compositor_timing_history( |
| 73 new CompositorTimingHistory( | 73 new CompositorTimingHistory( |
| 74 scheduler_settings.using_synchronous_renderer_compositor, | 74 scheduler_settings.using_synchronous_renderer_compositor, |
| 75 CompositorTimingHistory::BROWSER_UMA, | 75 CompositorTimingHistory::BROWSER_UMA, |
| 76 layer_tree_host_->rendering_stats_instrumentation())); | 76 layer_tree_host_->rendering_stats_instrumentation())); |
| 77 | 77 |
| 78 // BFS must either be external or come from the output surface. If | 78 BeginFrameSource* frame_source = nullptr; |
| 79 // external, it must be provided. If from the output surface, it must | 79 if (!layer_tree_host_->settings().use_output_surface_begin_frame_source) { |
| 80 // not be provided. | 80 frame_source = external_begin_frame_source_.get(); |
| 81 // TODO(enne): Make all BFS come from the output surface. | 81 if (!scheduler_settings.throttle_frame_production) { |
| 82 DCHECK(layer_tree_host_->settings().use_external_begin_frame_source ^ | 82 // Unthrottled source takes precedence over external sources. |
| 83 layer_tree_host_->settings().use_output_surface_begin_frame_source); | 83 unthrottled_begin_frame_source_.reset(new BackToBackBeginFrameSource( |
| 84 DCHECK(!layer_tree_host_->settings().use_external_begin_frame_source || | 84 base::MakeUnique<DelayBasedTimeSource>( |
| 85 external_begin_frame_source_); | 85 task_runner_provider_->MainThreadTaskRunner()))); |
| 86 DCHECK( | 86 frame_source = unthrottled_begin_frame_source_.get(); |
| 87 !layer_tree_host_->settings().use_output_surface_begin_frame_source || | 87 } |
| 88 !external_begin_frame_source_); | 88 if (!frame_source) { |
| 89 synthetic_begin_frame_source_.reset(new DelayBasedBeginFrameSource( |
| 90 base::MakeUnique<DelayBasedTimeSource>( |
| 91 task_runner_provider_->MainThreadTaskRunner()))); |
| 92 frame_source = synthetic_begin_frame_source_.get(); |
| 93 } |
| 94 } |
| 95 |
| 89 scheduler_on_impl_thread_ = | 96 scheduler_on_impl_thread_ = |
| 90 Scheduler::Create(this, scheduler_settings, layer_tree_host_->id(), | 97 Scheduler::Create(this, scheduler_settings, layer_tree_host_->id(), |
| 91 task_runner_provider_->MainThreadTaskRunner(), | 98 task_runner_provider_->MainThreadTaskRunner(), |
| 92 external_begin_frame_source_.get(), | 99 frame_source, std::move(compositor_timing_history)); |
| 93 std::move(compositor_timing_history)); | |
| 94 } | 100 } |
| 95 | 101 |
| 96 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); | 102 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); |
| 97 } | 103 } |
| 98 | 104 |
| 99 SingleThreadProxy::~SingleThreadProxy() { | 105 SingleThreadProxy::~SingleThreadProxy() { |
| 100 TRACE_EVENT0("cc", "SingleThreadProxy::~SingleThreadProxy"); | 106 TRACE_EVENT0("cc", "SingleThreadProxy::~SingleThreadProxy"); |
| 101 DCHECK(task_runner_provider_->IsMainThread()); | 107 DCHECK(task_runner_provider_->IsMainThread()); |
| 102 // Make sure Stop() got called or never Started. | 108 // Make sure Stop() got called or never Started. |
| 103 DCHECK(!layer_tree_host_impl_); | 109 DCHECK(!layer_tree_host_impl_); |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 // This must happen before we notify the scheduler as it may try to recreate | 455 // This must happen before we notify the scheduler as it may try to recreate |
| 450 // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE. | 456 // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE. |
| 451 layer_tree_host_->DidLoseOutputSurface(); | 457 layer_tree_host_->DidLoseOutputSurface(); |
| 452 } | 458 } |
| 453 client_->DidAbortSwapBuffers(); | 459 client_->DidAbortSwapBuffers(); |
| 454 if (scheduler_on_impl_thread_) | 460 if (scheduler_on_impl_thread_) |
| 455 scheduler_on_impl_thread_->DidLoseOutputSurface(); | 461 scheduler_on_impl_thread_->DidLoseOutputSurface(); |
| 456 output_surface_lost_ = true; | 462 output_surface_lost_ = true; |
| 457 } | 463 } |
| 458 | 464 |
| 465 void SingleThreadProxy::CommitVSyncParameters(base::TimeTicks timebase, |
| 466 base::TimeDelta interval) { |
| 467 if (synthetic_begin_frame_source_) |
| 468 synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval); |
| 469 } |
| 470 |
| 459 void SingleThreadProxy::SetBeginFrameSource(BeginFrameSource* source) { | 471 void SingleThreadProxy::SetBeginFrameSource(BeginFrameSource* source) { |
| 460 DCHECK(layer_tree_host_->settings().single_thread_proxy_scheduler); | 472 DCHECK(layer_tree_host_->settings().single_thread_proxy_scheduler); |
| 461 // TODO(enne): this overrides any preexisting begin frame source. Those | 473 // TODO(enne): this overrides any preexisting begin frame source. Those |
| 462 // other sources will eventually be removed and this will be the only path. | 474 // other sources will eventually be removed and this will be the only path. |
| 463 if (!layer_tree_host_->settings().use_output_surface_begin_frame_source) | 475 if (!layer_tree_host_->settings().use_output_surface_begin_frame_source) |
| 464 return; | 476 return; |
| 465 if (scheduler_on_impl_thread_) | 477 if (scheduler_on_impl_thread_) |
| 466 scheduler_on_impl_thread_->SetBeginFrameSource(source); | 478 scheduler_on_impl_thread_->SetBeginFrameSource(source); |
| 467 } | 479 } |
| 468 | 480 |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 void SingleThreadProxy::DidFinishImplFrame() { | 851 void SingleThreadProxy::DidFinishImplFrame() { |
| 840 layer_tree_host_impl_->DidFinishImplFrame(); | 852 layer_tree_host_impl_->DidFinishImplFrame(); |
| 841 #if DCHECK_IS_ON() | 853 #if DCHECK_IS_ON() |
| 842 DCHECK(inside_impl_frame_) | 854 DCHECK(inside_impl_frame_) |
| 843 << "DidFinishImplFrame called while not inside an impl frame!"; | 855 << "DidFinishImplFrame called while not inside an impl frame!"; |
| 844 inside_impl_frame_ = false; | 856 inside_impl_frame_ = false; |
| 845 #endif | 857 #endif |
| 846 } | 858 } |
| 847 | 859 |
| 848 } // namespace cc | 860 } // namespace cc |
| OLD | NEW |