Index: content/browser/compositor/gpu_process_transport_factory.cc |
diff --git a/content/browser/compositor/gpu_process_transport_factory.cc b/content/browser/compositor/gpu_process_transport_factory.cc |
index 7d1cf0c2d283a6620d1de210bc8fc8348d66ee4d..33383a84812f9fead30efb7101b65571d4e4d254 100644 |
--- a/content/browser/compositor/gpu_process_transport_factory.cc |
+++ b/content/browser/compositor/gpu_process_transport_factory.cc |
@@ -283,6 +283,11 @@ void GpuProcessTransportFactory::CreateCompositorFrameSink( |
if (!data) { |
data = CreatePerCompositorData(compositor.get()); |
} else { |
+ // TODO: is this the right place to remove data->begin_frame_source from |
+ // the compositor VSync manager? |
+ if (data->begin_frame_source) |
+ compositor->vsync_manager()->RemoveObserver(data->begin_frame_source); |
+ |
// TODO(danakj): We can destroy the |data->display| here when the compositor |
// destroys its CompositorFrameSink before calling back here. |
data->display_output_surface = nullptr; |
@@ -447,13 +452,14 @@ void GpuProcessTransportFactory::EstablishedGpuChannel( |
compositor->task_runner().get()))); |
} |
+ compositor->vsync_manager()->AddObserver(begin_frame_source.get()); |
danakj
2016/11/21 22:32:11
I think there are at least 3 ways to do this:
1.
stanisc
2016/11/21 22:52:31
Thanks for the suggestion! The idea was that a new
danakj
2016/11/21 23:06:36
Ok so one problem with this approach is that we're
stanisc
2016/11/22 19:55:43
How about passing a pointer to VSyncObserver to Br
|
+ |
std::unique_ptr<BrowserCompositorOutputSurface> display_output_surface; |
#if defined(ENABLE_VULKAN) |
std::unique_ptr<VulkanBrowserCompositorOutputSurface> vulkan_surface; |
if (vulkan_context_provider) { |
vulkan_surface.reset(new VulkanBrowserCompositorOutputSurface( |
- vulkan_context_provider, compositor->vsync_manager(), |
- begin_frame_source.get())); |
+ vulkan_context_provider, compositor->vsync_manager())); |
if (!vulkan_surface->Initialize(compositor.get()->widget())) { |
vulkan_surface->Destroy(); |
vulkan_surface.reset(); |
@@ -468,8 +474,7 @@ void GpuProcessTransportFactory::EstablishedGpuChannel( |
display_output_surface = |
base::MakeUnique<SoftwareBrowserCompositorOutputSurface>( |
CreateSoftwareOutputDevice(compositor.get()), |
- compositor->vsync_manager(), begin_frame_source.get(), |
- compositor->task_runner()); |
+ compositor->vsync_manager(), compositor->task_runner()); |
} else { |
DCHECK(context_provider); |
const auto& capabilities = context_provider->ContextCapabilities(); |
@@ -477,21 +482,20 @@ void GpuProcessTransportFactory::EstablishedGpuChannel( |
display_output_surface = |
base::MakeUnique<OffscreenBrowserCompositorOutputSurface>( |
context_provider, compositor->vsync_manager(), |
- begin_frame_source.get(), |
std::unique_ptr< |
display_compositor::CompositorOverlayCandidateValidator>()); |
} else if (capabilities.surfaceless) { |
#if defined(OS_MACOSX) |
display_output_surface = base::MakeUnique<GpuOutputSurfaceMac>( |
compositor->widget(), context_provider, data->surface_handle, |
- compositor->vsync_manager(), begin_frame_source.get(), |
+ compositor->vsync_manager(), |
CreateOverlayCandidateValidator(compositor->widget()), |
GetGpuMemoryBufferManager()); |
#else |
display_output_surface = |
base::MakeUnique<GpuSurfacelessBrowserCompositorOutputSurface>( |
context_provider, data->surface_handle, |
- compositor->vsync_manager(), begin_frame_source.get(), |
+ compositor->vsync_manager(), |
CreateOverlayCandidateValidator(compositor->widget()), |
GL_TEXTURE_2D, GL_RGB, ui::DisplaySnapshot::PrimaryFormat(), |
GetGpuMemoryBufferManager()); |
@@ -509,7 +513,7 @@ void GpuProcessTransportFactory::EstablishedGpuChannel( |
display_output_surface = |
base::MakeUnique<GpuBrowserCompositorOutputSurface>( |
context_provider, compositor->vsync_manager(), |
- begin_frame_source.get(), std::move(validator)); |
+ std::move(validator)); |
} else { |
#if defined(USE_AURA) |
if (compositor->window()) { |
@@ -519,7 +523,7 @@ void GpuProcessTransportFactory::EstablishedGpuChannel( |
base::MakeUnique<MusBrowserCompositorOutputSurface>( |
compositor->window(), context_provider, |
GetGpuMemoryBufferManager(), compositor->vsync_manager(), |
- begin_frame_source.get(), std::move(validator)); |
+ std::move(validator)); |
} else { |
aura::WindowTreeHost* host = |
aura::WindowTreeHost::GetForAcceleratedWidget( |
@@ -528,7 +532,7 @@ void GpuProcessTransportFactory::EstablishedGpuChannel( |
base::MakeUnique<MusBrowserCompositorOutputSurface>( |
host->window(), context_provider, |
GetGpuMemoryBufferManager(), compositor->vsync_manager(), |
- begin_frame_source.get(), std::move(validator)); |
+ std::move(validator)); |
} |
#else |
NOTREACHED(); |
@@ -539,6 +543,7 @@ void GpuProcessTransportFactory::EstablishedGpuChannel( |
} |
data->display_output_surface = display_output_surface.get(); |
+ // TODO: is this still needed? |
data->begin_frame_source = begin_frame_source.get(); |
if (data->reflector) |
data->reflector->OnSourceSurfaceReady(data->display_output_surface); |
@@ -614,6 +619,12 @@ void GpuProcessTransportFactory::RemoveCompositor(ui::Compositor* compositor) { |
if (data->surface_handle) |
gpu::GpuSurfaceTracker::Get()->RemoveSurface(data->surface_handle); |
#endif |
+ |
+ // TODO: is this the right place to remove data->begin_frame_source from |
+ // the compositor VSync manager? |
+ if (data->begin_frame_source) |
+ compositor->vsync_manager()->RemoveObserver(data->begin_frame_source); |
+ |
per_compositor_data_.erase(it); |
if (per_compositor_data_.empty()) { |
// Destroying the GLHelper may cause some async actions to be cancelled, |