Chromium Code Reviews| Index: content/browser/compositor/browser_compositor_output_surface.cc |
| diff --git a/content/browser/compositor/browser_compositor_output_surface.cc b/content/browser/compositor/browser_compositor_output_surface.cc |
| index f865702effe067a645bc434c72882385ed5195a5..b37f14ffd7249212deab6b7dbb308d7b5141c59e 100644 |
| --- a/content/browser/compositor/browser_compositor_output_surface.cc |
| +++ b/content/browser/compositor/browser_compositor_output_surface.cc |
| @@ -11,6 +11,7 @@ |
| #include "base/location.h" |
| #include "base/strings/string_number_conversions.h" |
| #include "cc/base/switches.h" |
| +#include "cc/output/output_surface_client.h" |
| #include "content/browser/compositor/browser_compositor_overlay_candidate_validator.h" |
| #include "content/browser/compositor/reflector_impl.h" |
| #include "content/common/gpu/client/context_provider_command_buffer.h" |
| @@ -21,27 +22,31 @@ BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( |
| const scoped_refptr<cc::ContextProvider>& context_provider, |
| const scoped_refptr<cc::ContextProvider>& worker_context_provider, |
| const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, |
| + scoped_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source, |
|
sunnyps
2016/03/28 23:09:48
BrowserCompositorOutputSurface can create and own
enne (OOO)
2016/03/29 20:39:52
It was passed in because creating a BFS required a
enne (OOO)
2016/03/30 17:34:41
Would you rather I just pass in a task runner?
sunnyps
2016/03/30 18:56:02
I think either way is fine. Don't have a strong op
|
| scoped_ptr<BrowserCompositorOverlayCandidateValidator> |
| overlay_candidate_validator) |
| : OutputSurface(context_provider, worker_context_provider), |
| vsync_manager_(vsync_manager), |
| + synthetic_begin_frame_source_(std::move(synthetic_begin_frame_source)), |
| reflector_(nullptr), |
| use_begin_frame_scheduling_( |
| - base::CommandLine::ForCurrentProcess() |
| - ->HasSwitch(cc::switches::kEnableBeginFrameScheduling)) { |
| + base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + cc::switches::kEnableBeginFrameScheduling)) { |
| overlay_candidate_validator_ = std::move(overlay_candidate_validator); |
| Initialize(); |
| } |
| BrowserCompositorOutputSurface::BrowserCompositorOutputSurface( |
| scoped_ptr<cc::SoftwareOutputDevice> software_device, |
| - const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager) |
| + const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager, |
| + scoped_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source) |
| : OutputSurface(std::move(software_device)), |
| vsync_manager_(vsync_manager), |
| + synthetic_begin_frame_source_(std::move(synthetic_begin_frame_source)), |
| reflector_(nullptr), |
| use_begin_frame_scheduling_( |
| - base::CommandLine::ForCurrentProcess() |
| - ->HasSwitch(cc::switches::kEnableBeginFrameScheduling)) { |
| + base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + cc::switches::kEnableBeginFrameScheduling)) { |
| Initialize(); |
| } |
| @@ -67,18 +72,34 @@ bool BrowserCompositorOutputSurface::BindToClient( |
| if (!OutputSurface::BindToClient(client)) |
| return false; |
| + // Pass begin frame source up to Display to use for DisplayScheduler. |
| + client->SetBeginFrameSource(synthetic_begin_frame_source_.get()); |
| + |
| // Don't want vsync notifications until there is a client. |
| if (!use_begin_frame_scheduling_) |
| vsync_manager_->AddObserver(this); |
| return true; |
| } |
| +void BrowserCompositorOutputSurface::UpdateVSyncParametersInternal( |
| + base::TimeTicks timebase, |
| + base::TimeDelta interval) { |
| + if (interval == base::TimeDelta()) { |
| + // TODO(brianderson): We should not be receiving 0 intervals. |
| + interval = cc::BeginFrameArgs::DefaultInterval(); |
| + } |
| + synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval); |
| + |
| + // TODO(enne): remove this once vsyncs are no longer used in the renderer. |
| + CommitVSyncParameters(timebase, interval); |
| +} |
| + |
| void BrowserCompositorOutputSurface::OnUpdateVSyncParameters( |
| base::TimeTicks timebase, |
| base::TimeDelta interval) { |
| DCHECK(HasClient()); |
| DCHECK(!use_begin_frame_scheduling_); |
| - CommitVSyncParameters(timebase, interval); |
| + UpdateVSyncParametersInternal(timebase, interval); |
| } |
| void BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu( |
| @@ -86,7 +107,7 @@ void BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu( |
| base::TimeDelta interval) { |
| DCHECK(HasClient()); |
| if (use_begin_frame_scheduling_) { |
| - CommitVSyncParameters(timebase, interval); |
| + UpdateVSyncParametersInternal(timebase, interval); |
| return; |
| } |