Chromium Code Reviews| Index: content/browser/renderer_host/compositor_impl_android.cc |
| diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc |
| index 0c8c5b4316637176f943c74276088997fe5f868e..7998708edfbd8e82094deac45aa4e87b0681093f 100644 |
| --- a/content/browser/renderer_host/compositor_impl_android.cc |
| +++ b/content/browser/renderer_host/compositor_impl_android.cc |
| @@ -35,6 +35,7 @@ |
| #include "cc/output/context_provider.h" |
| #include "cc/output/output_surface.h" |
| #include "cc/output/output_surface_client.h" |
| +#include "cc/output/vulkan_in_process_context_provider.h" |
| #include "cc/raster/single_thread_task_graph_runner.h" |
| #include "cc/scheduler/begin_frame_source.h" |
| #include "cc/surfaces/onscreen_display_client.h" |
| @@ -62,6 +63,7 @@ |
| #include "gpu/command_buffer/client/gles2_interface.h" |
| #include "gpu/ipc/client/command_buffer_proxy_impl.h" |
| #include "gpu/ipc/client/gpu_channel_host.h" |
| +#include "gpu/vulkan/vulkan_surface.h" |
| #include "third_party/khronos/GLES2/gl2.h" |
| #include "third_party/khronos/GLES2/gl2ext.h" |
| #include "third_party/skia/include/core/SkMallocPixelRef.h" |
| @@ -69,6 +71,10 @@ |
| #include "ui/gfx/android/device_display_info.h" |
| #include "ui/gfx/swap_result.h" |
| +namespace gpu { |
| +class VulkanSurface; |
| +} |
| + |
| namespace content { |
| namespace { |
| @@ -221,6 +227,50 @@ class OutputSurfaceWithoutParent : public cc::OutputSurface, |
| std::unique_ptr<ExternalBeginFrameSource> begin_frame_source_; |
| }; |
| +class VulkanOutputSurface : public cc::OutputSurface { |
|
piman
2016/04/28 21:29:40
I think this whole class needs to be inside #if de
sohanjg
2016/04/29 11:49:58
Done.
|
| + public: |
| + VulkanOutputSurface( |
| + const scoped_refptr<cc::VulkanContextProvider>& vulkan_context_provider) |
|
piman
2016/04/28 21:29:40
nit: scoped_refptr<cc::VulkanContextProvider> (not
sohanjg
2016/04/29 11:49:58
Done.
|
| + : OutputSurface(nullptr, nullptr, vulkan_context_provider, nullptr) {} |
|
piman
2016/04/28 21:29:40
nit: std::move(vulkan_context_provider)
sohanjg
2016/04/29 11:49:58
Done.
|
| + |
| + ~VulkanOutputSurface() override { Destroy(); } |
| + |
| + bool Initialize(gfx::AcceleratedWidget widget) { |
| + DCHECK(!surface_); |
| + std::unique_ptr<gpu::VulkanSurface> surface( |
| + gpu::VulkanSurface::CreateViewSurface(widget)); |
| + if (!surface->Initialize(vulkan_context_provider()->GetDeviceQueue(), |
| + gpu::VulkanSurface::DEFAULT_SURFACE_FORMAT)) { |
| + return false; |
| + } |
| + surface_ = std::move(surface); |
| + |
| + return true; |
| + } |
| + |
| + void SwapBuffers(cc::CompositorFrame* frame) override { |
| + surface_->SwapBuffers(); |
| + PostSwapBuffersComplete(); |
| + client_->DidSwapBuffers(); |
| + } |
| + |
| + void Destroy() { |
| + if (surface_) { |
| + surface_->Destroy(); |
| + surface_.reset(); |
| + } |
| + } |
| + |
| + void OnSwapBuffersCompleted(const std::vector<ui::LatencyInfo>& latency_info, |
| + gfx::SwapResult result) { |
| + RenderWidgetHostImpl::CompositorFrameDrawn(latency_info); |
| + OutputSurface::OnSwapBuffersComplete(); |
| + } |
| + |
| + private: |
| + std::unique_ptr<gpu::VulkanSurface> surface_; |
|
piman
2016/04/28 21:29:40
nit: DISALLOW_COPY_AND_ASSIGN()
sohanjg
2016/04/29 11:49:58
Done.
|
| +}; |
| + |
| static bool g_initialized = false; |
| base::LazyInstance<cc::SurfaceManager> g_surface_manager = |
| @@ -581,12 +631,29 @@ void CompositorImpl::CreateOutputSurface() { |
| limits, DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT)); |
| DCHECK(context_provider.get()); |
|
piman
2016/04/28 21:29:40
All this code (from l.560 to here) should only exe
sohanjg
2016/04/29 11:49:58
Done.
|
| - std::unique_ptr<cc::OutputSurface> real_output_surface( |
| - new OutputSurfaceWithoutParent( |
| - this, context_provider, |
| - base::Bind(&CompositorImpl::PopulateGpuCapabilities, |
| - base::Unretained(this)), |
| - base::WrapUnique(new ExternalBeginFrameSource(this)))); |
| + scoped_refptr<cc::VulkanInProcessContextProvider> vulkan_context_provider = |
| + cc::VulkanInProcessContextProvider::Create(); |
|
piman
2016/04/28 21:29:40
I think we would want to share this across multipl
sohanjg
2016/04/29 11:49:58
Done.
|
| + std::unique_ptr<cc::OutputSurface> real_output_surface; |
| +#if defined(ENABLE_VULKAN) |
| + std::unique_ptr<VulkanOutputSurface> vulkan_surface; |
| + if (vulkan_context_provider) { |
| + vulkan_surface.reset(new VulkanOutputSurface(vulkan_context_provider)); |
|
piman
2016/04/28 21:29:40
nit: std::move(vulkan_context_provider)
sohanjg
2016/04/29 11:49:58
Done.
|
| + if (!vulkan_surface->Initialize(window_)) { |
| + vulkan_surface->Destroy(); |
| + vulkan_surface.reset(); |
| + } else { |
| + real_output_surface = std::move(vulkan_surface); |
| + } |
| + } |
| +#endif |
| + |
| + if (!real_output_surface) { |
| + real_output_surface = base::WrapUnique(new OutputSurfaceWithoutParent( |
| + this, context_provider, |
| + base::Bind(&CompositorImpl::PopulateGpuCapabilities, |
| + base::Unretained(this)), |
| + base::WrapUnique(new ExternalBeginFrameSource(this)))); |
| + } |
| cc::SurfaceManager* manager = GetSurfaceManager(); |
| display_client_.reset(new cc::OnscreenDisplayClient( |