summaryrefslogtreecommitdiffstats
path: root/cc/trees
diff options
context:
space:
mode:
authorenne <enne@chromium.org>2016-03-16 14:51:11 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-16 21:52:59 +0000
commitb9bf377e238af579e4b6dd01cb4007ba712da742 (patch)
tree0bcff2210f32f89249a0255b9d4a04af787d19d2 /cc/trees
parent6b03d171d4137691637129ebad5cab20f4babbbb (diff)
downloadchromium_src-b9bf377e238af579e4b6dd01cb4007ba712da742.zip
chromium_src-b9bf377e238af579e4b6dd01cb4007ba712da742.tar.gz
chromium_src-b9bf377e238af579e4b6dd01cb4007ba712da742.tar.bz2
Hoist begin frame sources out of scheduler
To avoid cc::Scheduler having to sometimes own / sometimes create / switch between sources / manage parameters on sources, hoist all this logic up to the owners of cc::Scheduler. This refactoring makes it possible to eventually allow an OutputSurface to set a BeginFrameSource on its client and then forward that to the scheduler to use. That future is made easier by the scheduler having a single begin frame source managed by its owner. This patch adds a bit of duplicated logic in three places (single thread proxy / threaded proxy / tests) for the creation of the begin frame source. However, the single thread and threaded versions were already doing different things (re: authoritative vsync signals). The hope is that the vsync information and begin frame source creation for the synthetic sources can get further hoisted into OutputSurface itself. Depends on https://codereview.chromium.org/1762823002 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1765723002 Cr-Commit-Position: refs/heads/master@{#381558}
Diffstat (limited to 'cc/trees')
-rw-r--r--cc/trees/proxy_impl.cc32
-rw-r--r--cc/trees/proxy_impl.h2
-rw-r--r--cc/trees/single_thread_proxy.cc36
-rw-r--r--cc/trees/single_thread_proxy.h5
4 files changed, 65 insertions, 10 deletions
diff --git a/cc/trees/proxy_impl.cc b/cc/trees/proxy_impl.cc
index 3f5a01e..db52685 100644
--- a/cc/trees/proxy_impl.cc
+++ b/cc/trees/proxy_impl.cc
@@ -79,10 +79,23 @@ ProxyImpl::ProxyImpl(ChannelImpl* channel_impl,
CompositorTimingHistory::RENDERER_UMA,
rendering_stats_instrumentation_));
- scheduler_ = Scheduler::Create(this, scheduler_settings, layer_tree_host_id_,
- task_runner_provider_->ImplThreadTaskRunner(),
- external_begin_frame_source_.get(),
- std::move(compositor_timing_history));
+ BeginFrameSource* frame_source = external_begin_frame_source_.get();
+ if (!scheduler_settings.throttle_frame_production) {
+ // Unthrottled source takes precedence over external sources.
+ unthrottled_begin_frame_source_ = BackToBackBeginFrameSource::Create(
+ task_runner_provider_->ImplThreadTaskRunner());
+ frame_source = unthrottled_begin_frame_source_.get();
+ }
+ if (!frame_source) {
+ synthetic_begin_frame_source_ = SyntheticBeginFrameSource::Create(
+ task_runner_provider_->ImplThreadTaskRunner(),
+ BeginFrameArgs::DefaultInterval());
+ frame_source = synthetic_begin_frame_source_.get();
+ }
+ scheduler_ =
+ Scheduler::Create(this, scheduler_settings, layer_tree_host_id_,
+ task_runner_provider_->ImplThreadTaskRunner(),
+ frame_source, std::move(compositor_timing_history));
DCHECK_EQ(scheduler_->visible(), layer_tree_host_impl_->visible());
}
@@ -99,6 +112,8 @@ ProxyImpl::~ProxyImpl() {
scheduler_ = nullptr;
external_begin_frame_source_ = nullptr;
+ unthrottled_begin_frame_source_ = nullptr;
+ synthetic_begin_frame_source_ = nullptr;
layer_tree_host_impl_ = nullptr;
// We need to explicitly shutdown the notifier to destroy any weakptrs it is
// holding while still on the compositor thread. This also ensures any
@@ -276,7 +291,14 @@ void ProxyImpl::DidLoseOutputSurfaceOnImplThread() {
void ProxyImpl::CommitVSyncParameters(base::TimeTicks timebase,
base::TimeDelta interval) {
DCHECK(IsImplThread());
- scheduler_->CommitVSyncParameters(timebase, interval);
+ if (!synthetic_begin_frame_source_)
+ return;
+
+ if (interval == base::TimeDelta()) {
+ // TODO(brianderson): We should not be receiving 0 intervals.
+ interval = BeginFrameArgs::DefaultInterval();
+ }
+ synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval);
}
void ProxyImpl::SetEstimatedParentDrawTime(base::TimeDelta draw_time) {
diff --git a/cc/trees/proxy_impl.h b/cc/trees/proxy_impl.h
index 0d96643..a335d8a 100644
--- a/cc/trees/proxy_impl.h
+++ b/cc/trees/proxy_impl.h
@@ -152,6 +152,8 @@ class CC_EXPORT ProxyImpl : public NON_EXPORTED_BASE(LayerTreeHostImplClient),
DelayedUniqueNotifier smoothness_priority_expiration_notifier_;
scoped_ptr<BeginFrameSource> external_begin_frame_source_;
+ scoped_ptr<BeginFrameSource> unthrottled_begin_frame_source_;
+ scoped_ptr<SyntheticBeginFrameSource> synthetic_begin_frame_source_;
RenderingStatsInstrumentation* rendering_stats_instrumentation_;
diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc
index 2735029..7c1d821 100644
--- a/cc/trees/single_thread_proxy.cc
+++ b/cc/trees/single_thread_proxy.cc
@@ -71,11 +71,24 @@ void SingleThreadProxy::Start(
CompositorTimingHistory::BROWSER_UMA,
layer_tree_host_->rendering_stats_instrumentation()));
+ BeginFrameSource* frame_source = external_begin_frame_source_.get();
+ if (!scheduler_settings.throttle_frame_production) {
+ // Unthrottled source takes precedence over external sources.
+ unthrottled_begin_frame_source_ = BackToBackBeginFrameSource::Create(
+ task_runner_provider_->MainThreadTaskRunner());
+ frame_source = unthrottled_begin_frame_source_.get();
+ }
+ if (!frame_source) {
+ synthetic_begin_frame_source_ = SyntheticBeginFrameSource::Create(
+ task_runner_provider_->MainThreadTaskRunner(),
+ BeginFrameArgs::DefaultInterval());
+ frame_source = synthetic_begin_frame_source_.get();
+ }
+
scheduler_on_impl_thread_ =
Scheduler::Create(this, scheduler_settings, layer_tree_host_->id(),
task_runner_provider_->MainThreadTaskRunner(),
- external_begin_frame_source_.get(),
- std::move(compositor_timing_history));
+ frame_source, std::move(compositor_timing_history));
}
layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this);
@@ -463,8 +476,17 @@ void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() {
void SingleThreadProxy::CommitVSyncParameters(base::TimeTicks timebase,
base::TimeDelta interval) {
- if (scheduler_on_impl_thread_)
- scheduler_on_impl_thread_->CommitVSyncParameters(timebase, interval);
+ if (authoritative_vsync_interval_ != base::TimeDelta()) {
+ interval = authoritative_vsync_interval_;
+ } else if (interval == base::TimeDelta()) {
+ // TODO(brianderson): We should not be receiving 0 intervals.
+ interval = BeginFrameArgs::DefaultInterval();
+ }
+
+ last_vsync_timebase_ = timebase;
+
+ if (synthetic_begin_frame_source_)
+ synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval);
}
void SingleThreadProxy::SetEstimatedParentDrawTime(base::TimeDelta draw_time) {
@@ -699,7 +721,11 @@ void SingleThreadProxy::SetChildrenNeedBeginFrames(
void SingleThreadProxy::SetAuthoritativeVSyncInterval(
const base::TimeDelta& interval) {
- scheduler_on_impl_thread_->SetAuthoritativeVSyncInterval(interval);
+ authoritative_vsync_interval_ = interval;
+ if (synthetic_begin_frame_source_) {
+ synthetic_begin_frame_source_->OnUpdateVSyncParameters(last_vsync_timebase_,
+ interval);
+ }
}
void SingleThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) {
diff --git a/cc/trees/single_thread_proxy.h b/cc/trees/single_thread_proxy.h
index 3b69668..66e0075 100644
--- a/cc/trees/single_thread_proxy.h
+++ b/cc/trees/single_thread_proxy.h
@@ -145,8 +145,13 @@ class CC_EXPORT SingleThreadProxy : public Proxy,
// Accessed from both threads.
scoped_ptr<BeginFrameSource> external_begin_frame_source_;
+ scoped_ptr<BeginFrameSource> unthrottled_begin_frame_source_;
+ scoped_ptr<SyntheticBeginFrameSource> synthetic_begin_frame_source_;
scoped_ptr<Scheduler> scheduler_on_impl_thread_;
+ base::TimeDelta authoritative_vsync_interval_;
+ base::TimeTicks last_vsync_timebase_;
+
scoped_ptr<BlockingTaskRunner::CapturePostTasks> commit_blocking_task_runner_;
bool next_frame_is_newly_committed_frame_;