Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1224)

Unified Diff: content/browser/renderer_host/compositor_impl_android.cc

Issue 1921533008: Add support for OutputSurface for Vulkan on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Inherit from OutputSurface instead of OutputSurfaceWithoutParent Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698