Hook up ui::Compositor to Display's BeginFrameSource
This hooks up the first SurfaceFactoryClient to the real
BeginFrameSource owned by the OnScreenDisplayClient. This is done by
adding an OutputSurfaceClient::SetBeginFrameSource method. As the
SurfaceDisplayOutputSurface is also a SurfaceFactoryClient, it can hand
the real begin frame source directly to ui::Compositor's scheduler.
This allows the removal of some of the browser vsync plumbing, but not
all of it. Once the renderer compositors have been hooked up to use
this path as well, then this and all of the VSyncObserver code can be
ripped out.
The BeginFrameSource is created by the BrowserCompositorOutputSurface
which updates it based on vsync information that it receives. This
BeginFrameSource is passed to the Display (via OutputSurfaceClient),
which informs the SurfaceManager that the compositor using
that Display should be driven by that BeginFrameSource. The
SurfaceManager then informs the SurfaceDisplayOutputSurface about
the BeginFrameSource, which passes it into the single thread proxy's
cc::Scheduler for that ui::Compositor's instance. Plumbing!
The path from SurfaceManager to SurfaceDisplayOutputSurface was
added in https://codereview.chromium.org/1673783004, but the rest
of the plumbing is new to this patch.
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1821863002
Cr-Commit-Position: refs/heads/master@{#387228}
diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc
index 8194f38..3d991c0 100644
--- a/cc/trees/single_thread_proxy.cc
+++ b/cc/trees/single_thread_proxy.cc
@@ -73,18 +73,21 @@
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_.reset(new BackToBackBeginFrameSource(
- task_runner_provider_->MainThreadTaskRunner()));
- frame_source = unthrottled_begin_frame_source_.get();
- }
- if (!frame_source) {
- synthetic_begin_frame_source_.reset(new SyntheticBeginFrameSource(
- task_runner_provider_->MainThreadTaskRunner(),
- BeginFrameArgs::DefaultInterval()));
- frame_source = synthetic_begin_frame_source_.get();
+ BeginFrameSource* frame_source = nullptr;
+ if (!layer_tree_host_->settings().use_output_surface_begin_frame_source) {
+ frame_source = external_begin_frame_source_.get();
+ if (!scheduler_settings.throttle_frame_production) {
+ // Unthrottled source takes precedence over external sources.
+ unthrottled_begin_frame_source_.reset(new BackToBackBeginFrameSource(
+ task_runner_provider_->MainThreadTaskRunner()));
+ frame_source = unthrottled_begin_frame_source_.get();
+ }
+ if (!frame_source) {
+ synthetic_begin_frame_source_.reset(new SyntheticBeginFrameSource(
+ task_runner_provider_->MainThreadTaskRunner(),
+ BeginFrameArgs::DefaultInterval()));
+ frame_source = synthetic_begin_frame_source_.get();
+ }
}
scheduler_on_impl_thread_ =
@@ -491,6 +494,16 @@
synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval);
}
+void SingleThreadProxy::SetBeginFrameSource(BeginFrameSource* source) {
+ DCHECK(layer_tree_host_->settings().single_thread_proxy_scheduler);
+ // TODO(enne): this overrides any preexisting begin frame source. Those
+ // other sources will eventually be removed and this will be the only path.
+ if (!layer_tree_host_->settings().use_output_surface_begin_frame_source)
+ return;
+ if (scheduler_on_impl_thread_)
+ scheduler_on_impl_thread_->SetBeginFrameSource(source);
+}
+
void SingleThreadProxy::SetEstimatedParentDrawTime(base::TimeDelta draw_time) {
if (scheduler_on_impl_thread_)
scheduler_on_impl_thread_->SetEstimatedParentDrawTime(draw_time);