Chromium Code Reviews| 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 abbef9d9dc4b172d9967640af980da57e741694a..3f1ed93614a28dd6aefb4af5dc959d80f94aab12 100644 |
| --- a/content/browser/compositor/gpu_process_transport_factory.cc |
| +++ b/content/browser/compositor/gpu_process_transport_factory.cc |
| @@ -19,6 +19,7 @@ |
| #include "cc/base/histograms.h" |
| #include "cc/output/compositor_frame.h" |
| #include "cc/output/output_surface.h" |
| +#include "cc/output/vulkan_in_process_context_provider.h" |
| #include "cc/raster/single_thread_task_graph_runner.h" |
| #include "cc/raster/task_graph_runner.h" |
| #include "cc/surfaces/onscreen_display_client.h" |
| @@ -78,6 +79,10 @@ |
| #include "content/browser/compositor/browser_compositor_overlay_candidate_validator_android.h" |
| #endif |
| +#if defined(ENABLE_VULKAN) |
| +#include "content/browser/compositor/vulkan_browser_compositor_output_surface.h" |
| +#endif |
| + |
| using cc::ContextProvider; |
| using gpu::gles2::GLES2Interface; |
| @@ -256,9 +261,11 @@ void GpuProcessTransportFactory::CreateOutputSurface( |
| compositor->widget()); |
| #endif |
| - bool create_gpu_output_surface = |
| + const bool use_vulkan = SharedVulkanContextProvider(); |
| + |
| + const bool create_gpu_output_surface = |
| ShouldCreateGpuOutputSurface(compositor.get()); |
| - if (create_gpu_output_surface) { |
| + if (create_gpu_output_surface && !use_vulkan) { |
| CauseForGpuLaunch cause = |
| CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; |
| BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel( |
| @@ -299,8 +306,11 @@ void GpuProcessTransportFactory::EstablishedGpuChannel( |
| compositor->widget()); |
| #endif |
| + scoped_refptr<cc::VulkanInProcessContextProvider> vulkan_context_provider = |
| + SharedVulkanContextProvider(); |
| + |
| scoped_refptr<ContextProviderCommandBuffer> context_provider; |
| - if (create_gpu_output_surface) { |
| + if (create_gpu_output_surface && !vulkan_context_provider) { |
| // Try to reuse existing worker context provider. |
| if (shared_worker_context_provider_) { |
| bool lost; |
| @@ -370,7 +380,22 @@ void GpuProcessTransportFactory::EstablishedGpuChannel( |
| } |
| std::unique_ptr<BrowserCompositorOutputSurface> surface; |
| - if (!create_gpu_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())); |
| + if (!vulkan_surface->Initialize(compositor.get()->widget())) { |
| + vulkan_surface->Destroy(); |
| + vulkan_surface.reset(); |
| + } |
| + } |
| + |
| + if (vulkan_surface) { |
| + surface = std::move(vulkan_surface); |
| + } else |
| +#endif |
|
piman
2016/04/19 23:42:02
I would really prefer not to interleave compile-ti
David Yen
2016/04/20 17:37:38
Done.
|
| + if (!create_gpu_output_surface) { |
| surface = base::WrapUnique(new SoftwareBrowserCompositorOutputSurface( |
| CreateSoftwareOutputDevice(compositor.get()), |
| compositor->vsync_manager(), compositor->task_runner().get())); |
| @@ -435,9 +460,17 @@ void GpuProcessTransportFactory::EstablishedGpuChannel( |
| compositor->surface_id_allocator()->id_namespace())); |
| std::unique_ptr<cc::SurfaceDisplayOutputSurface> output_surface( |
| - new cc::SurfaceDisplayOutputSurface( |
| - manager, compositor->surface_id_allocator(), context_provider, |
| - shared_worker_context_provider_)); |
| +#if defined(ENABLE_VULKAN) |
| + vulkan_context_provider |
| + ? new cc::SurfaceDisplayOutputSurface( |
| + manager, compositor->surface_id_allocator(), |
| + static_cast<scoped_refptr<cc::VulkanContextProvider>>( |
| + vulkan_context_provider)) |
| + : |
| +#endif |
|
piman
2016/04/19 23:42:02
Ditto. If we remove the #ifdef for the SurfaceDisp
David Yen
2016/04/20 17:37:38
Done.
|
| + new cc::SurfaceDisplayOutputSurface( |
| + manager, compositor->surface_id_allocator(), context_provider, |
| + shared_worker_context_provider_)); |
| display_client->set_surface_output_surface(output_surface.get()); |
| output_surface->set_display_client(display_client.get()); |
| display_client->display()->Resize(compositor->size()); |
| @@ -686,4 +719,18 @@ void GpuProcessTransportFactory::OnLostMainThreadSharedContext() { |
| lost_shared_main_thread_contexts = NULL; |
| } |
| +scoped_refptr<cc::VulkanInProcessContextProvider> |
| +GpuProcessTransportFactory::SharedVulkanContextProvider() { |
| + if (!shared_vulkan_context_provider_initialized_) { |
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableVulkan)) { |
| + shared_vulkan_context_provider_ = |
| + cc::VulkanInProcessContextProvider::Create(); |
| + } |
| + |
| + shared_vulkan_context_provider_initialized_ = true; |
| + } |
| + return shared_vulkan_context_provider_; |
| +} |
| + |
| } // namespace content |