diff options
Diffstat (limited to '0001-ozone-wayland-Prepare-WaylandCanvasSurface-for-compl.patch')
-rw-r--r-- | 0001-ozone-wayland-Prepare-WaylandCanvasSurface-for-compl.patch | 655 |
1 files changed, 655 insertions, 0 deletions
diff --git a/0001-ozone-wayland-Prepare-WaylandCanvasSurface-for-compl.patch b/0001-ozone-wayland-Prepare-WaylandCanvasSurface-for-compl.patch new file mode 100644 index 000000000000..461293033f96 --- /dev/null +++ b/0001-ozone-wayland-Prepare-WaylandCanvasSurface-for-compl.patch @@ -0,0 +1,655 @@ +From a3ca8acd6582c0169ad3e2d94dd9fcd423810a56 Mon Sep 17 00:00:00 2001 +From: Maksim Sisov <msisov@igalia.com> +Date: Tue, 4 Jun 2019 06:24:59 +0000 +Subject: [PATCH 1/5] [ozone/wayland] Prepare WaylandCanvasSurface for + completion callbacks + +This is a prerequisite CL to make WaylandCanvasSurface listen +to OnSubmission and OnPresentation callbacks. + +The following changes have been made to avoid code duplicates: +* Added WaylandSurfaceGpu interface, which has two methods: + OnSubmission and OnPresentation. +* Moved RegisterSurface, UnregisterSurface, GetSurface from + WaylandSurfaceFactory to WaylandBufferManagerGpu +* Overrode WaylandSurfaceGpu methods in: + ** GbmSurfacelessWayland and removed usage of WaylandSurfaceFactory. Now, everything + is managed by the WaylandBufferManagerGpu instead. + ** WaylandCanvasSurface and added NOTIMPLEMENTED. The idea + is to propagate the results to a VSyncProvider and avoid + tearing when submitting new frames. + +Bug: 963854 +Change-Id: Ia91b359e505c152512db244b540d175ce1eeb0aa +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1640977 +Reviewed-by: Michael Spang <spang@chromium.org> +Commit-Queue: Maksim Sisov <msisov@igalia.com> +Cr-Commit-Position: refs/heads/master@{#665830} +--- + ui/ozone/platform/wayland/BUILD.gn | 1 + + .../wayland/gpu/gbm_pixmap_wayland.cc | 14 +++--- + .../platform/wayland/gpu/gbm_pixmap_wayland.h | 6 +-- + .../wayland/gpu/gbm_surfaceless_wayland.cc | 7 +-- + .../wayland/gpu/gbm_surfaceless_wayland.h | 19 +++---- + .../wayland/gpu/wayland_buffer_manager_gpu.cc | 29 ++++++++--- + .../wayland/gpu/wayland_buffer_manager_gpu.h | 19 ++++--- + .../wayland/gpu/wayland_canvas_surface.cc | 22 +++++++-- + .../wayland/gpu/wayland_canvas_surface.h | 10 +++- + .../wayland/gpu/wayland_surface_factory.cc | 49 ++++--------------- + .../wayland/gpu/wayland_surface_factory.h | 17 ++----- + .../wayland/gpu/wayland_surface_gpu.h | 38 ++++++++++++++ + .../wayland/ozone_platform_wayland.cc | 8 ++- + .../platform/wayland/test/wayland_test.cc | 7 ++- + 14 files changed, 141 insertions(+), 105 deletions(-) + create mode 100644 ui/ozone/platform/wayland/gpu/wayland_surface_gpu.h + +diff --git a/ui/ozone/platform/wayland/BUILD.gn b/ui/ozone/platform/wayland/BUILD.gn +index 757349686e67..303173b4ba6c 100644 +--- a/ui/ozone/platform/wayland/BUILD.gn ++++ b/ui/ozone/platform/wayland/BUILD.gn +@@ -30,6 +30,7 @@ source_set("wayland") { + "gpu/wayland_canvas_surface.h", + "gpu/wayland_surface_factory.cc", + "gpu/wayland_surface_factory.h", ++ "gpu/wayland_surface_gpu.h", + "host/wayland_buffer_manager_connector.cc", + "host/wayland_buffer_manager_connector.h", + "host/wayland_buffer_manager_host.cc", +diff --git a/ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.cc b/ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.cc +index ee088672f871..5d8167bdfd89 100644 +--- a/ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.cc ++++ b/ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.cc +@@ -22,18 +22,14 @@ + #include "ui/ozone/common/linux/gbm_device.h" + #include "ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.h" + #include "ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.h" +-#include "ui/ozone/platform/wayland/gpu/wayland_surface_factory.h" + #include "ui/ozone/public/overlay_plane.h" + #include "ui/ozone/public/ozone_platform.h" + + namespace ui { + +-GbmPixmapWayland::GbmPixmapWayland(WaylandSurfaceFactory* surface_manager, +- WaylandBufferManagerGpu* buffer_manager, ++GbmPixmapWayland::GbmPixmapWayland(WaylandBufferManagerGpu* buffer_manager, + gfx::AcceleratedWidget widget) +- : surface_manager_(surface_manager), +- buffer_manager_(buffer_manager), +- widget_(widget) {} ++ : buffer_manager_(buffer_manager), widget_(widget) {} + + GbmPixmapWayland::~GbmPixmapWayland() { + if (gbm_bo_ && widget_ != gfx::kNullAcceleratedWidget) +@@ -130,8 +126,12 @@ bool GbmPixmapWayland::ScheduleOverlayPlane( + const gfx::RectF& crop_rect, + bool enable_blend, + std::unique_ptr<gfx::GpuFence> gpu_fence) { +- GbmSurfacelessWayland* surfaceless = surface_manager_->GetSurface(widget); ++ auto* surface = buffer_manager_->GetSurface(widget); ++ DCHECK(surface); ++ GbmSurfacelessWayland* surfaceless = ++ static_cast<GbmSurfacelessWayland*>(surface); + DCHECK(surfaceless); ++ + surfaceless->QueueOverlayPlane( + OverlayPlane(this, std::move(gpu_fence), plane_z_order, plane_transform, + display_bounds, crop_rect, enable_blend)); +diff --git a/ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.h b/ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.h +index 566ffdcde4ff..b6051207d0f7 100644 +--- a/ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.h ++++ b/ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.h +@@ -17,13 +17,11 @@ + + namespace ui { + +-class WaylandSurfaceFactory; + class WaylandBufferManagerGpu; + + class GbmPixmapWayland : public gfx::NativePixmap { + public: +- GbmPixmapWayland(WaylandSurfaceFactory* surface_manager, +- WaylandBufferManagerGpu* buffer_manager, ++ GbmPixmapWayland(WaylandBufferManagerGpu* buffer_manager, + gfx::AcceleratedWidget widget); + + // Creates a buffer object and initializes the pixmap buffer. +@@ -58,8 +56,6 @@ class GbmPixmapWayland : public gfx::NativePixmap { + // gbm_bo wrapper for struct gbm_bo. + std::unique_ptr<GbmBuffer> gbm_bo_; + +- WaylandSurfaceFactory* const surface_manager_; +- + // Represents a connection to Wayland. + WaylandBufferManagerGpu* const buffer_manager_; + +diff --git a/ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.cc b/ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.cc +index 71e810c6c31c..70ea08acfa11 100644 +--- a/ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.cc ++++ b/ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.cc +@@ -12,7 +12,6 @@ + #include "ui/gfx/gpu_fence.h" + #include "ui/ozone/common/egl_util.h" + #include "ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.h" +-#include "ui/ozone/platform/wayland/gpu/wayland_surface_factory.h" + + namespace ui { + +@@ -27,17 +26,15 @@ void WaitForFence(EGLDisplay display, EGLSyncKHR fence) { + } // namespace + + GbmSurfacelessWayland::GbmSurfacelessWayland( +- WaylandSurfaceFactory* surface_factory, + WaylandBufferManagerGpu* buffer_manager, + gfx::AcceleratedWidget widget) + : SurfacelessEGL(gfx::Size()), +- surface_factory_(surface_factory), + buffer_manager_(buffer_manager), + widget_(widget), + has_implicit_external_sync_( + HasEGLExtension("EGL_ARM_implicit_external_sync")), + weak_factory_(this) { +- surface_factory_->RegisterSurface(widget_, this); ++ buffer_manager_->RegisterSurface(widget_, this); + unsubmitted_frames_.push_back(std::make_unique<PendingFrame>()); + } + +@@ -168,7 +165,7 @@ void GbmSurfacelessWayland::SetRelyOnImplicitSync() { + } + + GbmSurfacelessWayland::~GbmSurfacelessWayland() { +- surface_factory_->UnregisterSurface(widget_); ++ buffer_manager_->UnregisterSurface(widget_); + } + + GbmSurfacelessWayland::PendingFrame::PendingFrame() {} +diff --git a/ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.h b/ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.h +index 69fc2c17479f..0f584991f60c 100644 +--- a/ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.h ++++ b/ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.h +@@ -11,22 +11,22 @@ + #include "base/memory/weak_ptr.h" + #include "ui/gfx/native_widget_types.h" + #include "ui/gl/gl_surface_egl.h" ++#include "ui/ozone/platform/wayland/gpu/wayland_surface_gpu.h" + #include "ui/ozone/public/overlay_plane.h" + #include "ui/ozone/public/swap_completion_callback.h" + + namespace ui { + + class WaylandBufferManagerGpu; +-class WaylandSurfaceFactory; + + // A GLSurface for Wayland Ozone platform that uses surfaceless drawing. Drawing + // and displaying happens directly through NativePixmap buffers. CC would call + // into SurfaceFactoryOzone to allocate the buffers and then call + // ScheduleOverlayPlane(..) to schedule the buffer for presentation. +-class GbmSurfacelessWayland : public gl::SurfacelessEGL { ++class GbmSurfacelessWayland : public gl::SurfacelessEGL, ++ public WaylandSurfaceGpu { + public: +- GbmSurfacelessWayland(WaylandSurfaceFactory* surface_factory, +- WaylandBufferManagerGpu* buffer_manager, ++ GbmSurfacelessWayland(WaylandBufferManagerGpu* buffer_manager, + gfx::AcceleratedWidget widget); + + void QueueOverlayPlane(OverlayPlane plane); +@@ -58,13 +58,15 @@ class GbmSurfacelessWayland : public gl::SurfacelessEGL { + EGLConfig GetConfig() override; + void SetRelyOnImplicitSync() override; + +- void OnSubmission(uint32_t buffer_id, const gfx::SwapResult& swap_result); +- void OnPresentation(uint32_t buffer_id, +- const gfx::PresentationFeedback& feedback); +- + private: + ~GbmSurfacelessWayland() override; + ++ // WaylandSurfaceGpu overrides: ++ void OnSubmission(uint32_t buffer_id, ++ const gfx::SwapResult& swap_result) override; ++ void OnPresentation(uint32_t buffer_id, ++ const gfx::PresentationFeedback& feedback) override; ++ + struct PendingFrame { + PendingFrame(); + ~PendingFrame(); +@@ -91,7 +93,6 @@ class GbmSurfacelessWayland : public gl::SurfacelessEGL { + EGLSyncKHR InsertFence(bool implicit); + void FenceRetired(PendingFrame* frame); + +- WaylandSurfaceFactory* const surface_factory_; + WaylandBufferManagerGpu* const buffer_manager_; + std::vector<OverlayPlane> planes_; + +diff --git a/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.cc b/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.cc +index fd619bf0a852..49c4903270bd 100644 +--- a/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.cc ++++ b/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.cc +@@ -12,13 +12,12 @@ + #include "mojo/public/cpp/system/platform_handle.h" + #include "ui/ozone/common/linux/drm_util_linux.h" + #include "ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.h" +-#include "ui/ozone/platform/wayland/gpu/wayland_surface_factory.h" ++#include "ui/ozone/platform/wayland/gpu/wayland_surface_gpu.h" + + namespace ui { + +-WaylandBufferManagerGpu::WaylandBufferManagerGpu(WaylandSurfaceFactory* factory) +- : factory_(factory), +- associated_binding_(this), ++WaylandBufferManagerGpu::WaylandBufferManagerGpu() ++ : associated_binding_(this), + gpu_thread_runner_(base::ThreadTaskRunnerHandle::Get()) {} + + WaylandBufferManagerGpu::~WaylandBufferManagerGpu() = default; +@@ -43,7 +42,7 @@ void WaylandBufferManagerGpu::OnSubmission(gfx::AcceleratedWidget widget, + gfx::SwapResult swap_result) { + DCHECK(gpu_thread_runner_->BelongsToCurrentThread()); + DCHECK_NE(widget, gfx::kNullAcceleratedWidget); +- auto* surface = factory_->GetSurface(widget); ++ auto* surface = GetSurface(widget); + // There can be a race between destruction and submitting the last frames. The + // surface can be destroyed by the time the host receives a request to destroy + // a buffer, and is able to call the OnSubmission for that specific buffer. +@@ -57,7 +56,7 @@ void WaylandBufferManagerGpu::OnPresentation( + const gfx::PresentationFeedback& feedback) { + DCHECK(gpu_thread_runner_->BelongsToCurrentThread()); + DCHECK_NE(widget, gfx::kNullAcceleratedWidget); +- auto* surface = factory_->GetSurface(widget); ++ auto* surface = GetSurface(widget); + // There can be a race between destruction and presenting the last frames. The + // surface can be destroyed by the time the host receives a request to destroy + // a buffer, and is able to call the OnPresentation for that specific buffer. +@@ -65,6 +64,24 @@ void WaylandBufferManagerGpu::OnPresentation( + surface->OnPresentation(buffer_id, feedback); + } + ++void WaylandBufferManagerGpu::RegisterSurface(gfx::AcceleratedWidget widget, ++ WaylandSurfaceGpu* surface) { ++ widget_to_surface_map_.insert(std::make_pair(widget, surface)); ++} ++ ++void WaylandBufferManagerGpu::UnregisterSurface(gfx::AcceleratedWidget widget) { ++ widget_to_surface_map_.erase(widget); ++} ++ ++WaylandSurfaceGpu* WaylandBufferManagerGpu::GetSurface( ++ gfx::AcceleratedWidget widget) const { ++ WaylandSurfaceGpu* surface = nullptr; ++ auto it = widget_to_surface_map_.find(widget); ++ if (it != widget_to_surface_map_.end()) ++ surface = it->second; ++ return surface; ++} ++ + void WaylandBufferManagerGpu::CreateDmabufBasedBuffer( + gfx::AcceleratedWidget widget, + base::ScopedFD dmabuf_fd, +diff --git a/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.h b/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.h +index 85daf467a3fe..d2185c8308fb 100644 +--- a/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.h ++++ b/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.h +@@ -28,7 +28,7 @@ class Rect; + namespace ui { + + class WaylandConnection; +-class WaylandSurfaceFactory; ++class WaylandSurfaceGpu; + class WaylandWindow; + + // Forwards calls through an associated mojo connection to WaylandBufferManager +@@ -40,7 +40,7 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu { + public: + using BufferManagerHostPtr = ozone::mojom::WaylandBufferManagerHostPtr; + +- explicit WaylandBufferManagerGpu(WaylandSurfaceFactory* factory); ++ WaylandBufferManagerGpu(); + ~WaylandBufferManagerGpu() override; + + // WaylandBufferManagerGpu overrides: +@@ -59,6 +59,15 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu { + uint32_t buffer_id, + const gfx::PresentationFeedback& feedback) override; + ++ // If the client, which uses this manager and implements WaylandSurfaceGpu, ++ // wants to receive OnSubmission and OnPresentation callbacks and know the ++ // result of the below operations, they must register themselves with the ++ // below APIs. ++ void RegisterSurface(gfx::AcceleratedWidget widget, ++ WaylandSurfaceGpu* surface); ++ void UnregisterSurface(gfx::AcceleratedWidget widget); ++ WaylandSurfaceGpu* GetSurface(gfx::AcceleratedWidget widget) const; ++ + // Methods, which can be used when in both in-process-gpu and out of process + // modes. These calls are forwarded to the browser process through the + // WaylandConnection mojo interface. See more in +@@ -133,10 +142,6 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu { + + void BindHostInterface(); + +- // Non-owned. Only used to get registered surfaces and notify them about +- // submission and presentation of buffers. +- WaylandSurfaceFactory* const factory_; +- + #if defined(WAYLAND_GBM) + // A DRM render node based gbm device. + std::unique_ptr<GbmDevice> gbm_device_; +@@ -160,6 +165,8 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu { + // CommitBuffer call. + scoped_refptr<base::SingleThreadTaskRunner> gpu_thread_runner_; + ++ std::map<gfx::AcceleratedWidget, WaylandSurfaceGpu*> widget_to_surface_map_; ++ + DISALLOW_COPY_AND_ASSIGN(WaylandBufferManagerGpu); + }; + +diff --git a/ui/ozone/platform/wayland/gpu/wayland_canvas_surface.cc b/ui/ozone/platform/wayland/gpu/wayland_canvas_surface.cc +index c71c904ea5f6..6de24d7fd177 100644 +--- a/ui/ozone/platform/wayland/gpu/wayland_canvas_surface.cc ++++ b/ui/ozone/platform/wayland/gpu/wayland_canvas_surface.cc +@@ -28,9 +28,13 @@ void DeleteSharedMemoryMapping(void* pixels, void* context) { + WaylandCanvasSurface::WaylandCanvasSurface( + WaylandBufferManagerGpu* buffer_manager, + gfx::AcceleratedWidget widget) +- : buffer_manager_(buffer_manager), widget_(widget) {} ++ : buffer_manager_(buffer_manager), widget_(widget) { ++ buffer_manager_->RegisterSurface(widget_, this); ++} + + WaylandCanvasSurface::~WaylandCanvasSurface() { ++ buffer_manager_->UnregisterSurface(widget_); ++ + if (sk_surface_) + buffer_manager_->DestroyBuffer(widget_, buffer_id_); + } +@@ -86,17 +90,27 @@ void WaylandCanvasSurface::ResizeCanvas(const gfx::Size& viewport_size) { + } + + void WaylandCanvasSurface::PresentCanvas(const gfx::Rect& damage) { +- // TODO(https://crbug.com/930664): add support for submission and presentation +- // callbacks. + buffer_manager_->CommitBuffer(widget_, buffer_id_, damage); + } + + std::unique_ptr<gfx::VSyncProvider> + WaylandCanvasSurface::CreateVSyncProvider() { + // TODO(https://crbug.com/930662): This can be implemented with information +- // from frame callbacks, and possibly output refresh rate. ++ // from presentation feedback. + NOTIMPLEMENTED_LOG_ONCE(); + return nullptr; + } + ++void WaylandCanvasSurface::OnSubmission(uint32_t buffer_id, ++ const gfx::SwapResult& swap_result) { ++ NOTIMPLEMENTED_LOG_ONCE(); ++} ++ ++void WaylandCanvasSurface::OnPresentation( ++ uint32_t buffer_id, ++ const gfx::PresentationFeedback& feedback) { ++ // TODO(https://crbug.com/930662): this can be used for the vsync provider. ++ NOTIMPLEMENTED_LOG_ONCE(); ++} ++ + } // namespace ui +diff --git a/ui/ozone/platform/wayland/gpu/wayland_canvas_surface.h b/ui/ozone/platform/wayland/gpu/wayland_canvas_surface.h +index 4c73f63e0ca8..baa29a8baf65 100644 +--- a/ui/ozone/platform/wayland/gpu/wayland_canvas_surface.h ++++ b/ui/ozone/platform/wayland/gpu/wayland_canvas_surface.h +@@ -12,13 +12,15 @@ + #include "third_party/skia/include/core/SkSurface.h" + #include "ui/gfx/geometry/size.h" + #include "ui/gfx/native_widget_types.h" ++#include "ui/ozone/platform/wayland/gpu/wayland_surface_gpu.h" + #include "ui/ozone/public/surface_ozone_canvas.h" + + namespace ui { + + class WaylandBufferManagerGpu; + +-class WaylandCanvasSurface : public SurfaceOzoneCanvas { ++class WaylandCanvasSurface : public SurfaceOzoneCanvas, ++ public WaylandSurfaceGpu { + public: + WaylandCanvasSurface(WaylandBufferManagerGpu* buffer_manager, + gfx::AcceleratedWidget widget); +@@ -31,6 +33,12 @@ class WaylandCanvasSurface : public SurfaceOzoneCanvas { + std::unique_ptr<gfx::VSyncProvider> CreateVSyncProvider() override; + + private: ++ // WaylandSurfaceGpu overrides: ++ void OnSubmission(uint32_t buffer_id, ++ const gfx::SwapResult& swap_result) override; ++ void OnPresentation(uint32_t buffer_id, ++ const gfx::PresentationFeedback& feedback) override; ++ + void OnGetSizeForWidget(const gfx::Size& widget_size) { size_ = widget_size; } + + WaylandBufferManagerGpu* const buffer_manager_; +diff --git a/ui/ozone/platform/wayland/gpu/wayland_surface_factory.cc b/ui/ozone/platform/wayland/gpu/wayland_surface_factory.cc +index 2464437a46cf..b5dba5fd525b 100644 +--- a/ui/ozone/platform/wayland/gpu/wayland_surface_factory.cc ++++ b/ui/ozone/platform/wayland/gpu/wayland_surface_factory.cc +@@ -30,11 +30,8 @@ namespace { + class GLOzoneEGLWayland : public GLOzoneEGL { + public: + GLOzoneEGLWayland(WaylandConnection* connection, +- WaylandBufferManagerGpu* buffer_manager, +- WaylandSurfaceFactory* factory) +- : connection_(connection), +- buffer_manager_(buffer_manager), +- factory_(factory) {} ++ WaylandBufferManagerGpu* buffer_manager) ++ : connection_(connection), buffer_manager_(buffer_manager) {} + ~GLOzoneEGLWayland() override {} + + scoped_refptr<gl::GLSurface> CreateViewGLSurface( +@@ -53,7 +50,6 @@ class GLOzoneEGLWayland : public GLOzoneEGL { + private: + WaylandConnection* const connection_; + WaylandBufferManagerGpu* const buffer_manager_; +- WaylandSurfaceFactory* const factory_; + + DISALLOW_COPY_AND_ASSIGN(GLOzoneEGLWayland); + }; +@@ -79,8 +75,6 @@ scoped_refptr<gl::GLSurface> GLOzoneEGLWayland::CreateViewGLSurface( + + scoped_refptr<gl::GLSurface> GLOzoneEGLWayland::CreateSurfacelessViewGLSurface( + gfx::AcceleratedWidget window) { +- DCHECK(factory_); +- + // Only EGLGLES2 is supported with surfaceless view gl. + if (gl::GetGLImplementation() != gl::kGLImplementationEGLGLES2) + return nullptr; +@@ -90,7 +84,7 @@ scoped_refptr<gl::GLSurface> GLOzoneEGLWayland::CreateSurfacelessViewGLSurface( + if (!buffer_manager_->gbm_device()) + return nullptr; + return gl::InitializeGLSurface( +- new GbmSurfacelessWayland(factory_, buffer_manager_, window)); ++ new GbmSurfacelessWayland(buffer_manager_, window)); + #else + return nullptr; + #endif +@@ -121,38 +115,15 @@ bool GLOzoneEGLWayland::LoadGLES2Bindings(gl::GLImplementation impl) { + + } // namespace + +-WaylandSurfaceFactory::WaylandSurfaceFactory(WaylandConnection* connection) +- : connection_(connection) {} +- +-WaylandSurfaceFactory::~WaylandSurfaceFactory() = default; +- +-void WaylandSurfaceFactory::SetBufferManager( +- WaylandBufferManagerGpu* buffer_manager) { +- DCHECK(!buffer_manager_ && buffer_manager); +- buffer_manager_ = buffer_manager; +- ++WaylandSurfaceFactory::WaylandSurfaceFactory( ++ WaylandConnection* connection, ++ WaylandBufferManagerGpu* buffer_manager) ++ : connection_(connection), buffer_manager_(buffer_manager) { + egl_implementation_ = +- std::make_unique<GLOzoneEGLWayland>(connection_, buffer_manager_, this); +-} +- +-void WaylandSurfaceFactory::RegisterSurface(gfx::AcceleratedWidget widget, +- GbmSurfacelessWayland* surface) { +- widget_to_surface_map_.insert(std::make_pair(widget, surface)); +-} +- +-void WaylandSurfaceFactory::UnregisterSurface(gfx::AcceleratedWidget widget) { +- widget_to_surface_map_.erase(widget); +-} +- +-GbmSurfacelessWayland* WaylandSurfaceFactory::GetSurface( +- gfx::AcceleratedWidget widget) const { +- GbmSurfacelessWayland* surface = nullptr; +- auto it = widget_to_surface_map_.find(widget); +- if (it != widget_to_surface_map_.end()) +- surface = it->second; +- return surface; ++ std::make_unique<GLOzoneEGLWayland>(connection_, buffer_manager_); + } + ++WaylandSurfaceFactory::~WaylandSurfaceFactory() = default; + + std::unique_ptr<SurfaceOzoneCanvas> + WaylandSurfaceFactory::CreateCanvasForWidget(gfx::AcceleratedWidget widget) { +@@ -188,7 +159,7 @@ scoped_refptr<gfx::NativePixmap> WaylandSurfaceFactory::CreateNativePixmap( + gfx::BufferUsage usage) { + #if defined(WAYLAND_GBM) + scoped_refptr<GbmPixmapWayland> pixmap = +- base::MakeRefCounted<GbmPixmapWayland>(this, buffer_manager_, widget); ++ base::MakeRefCounted<GbmPixmapWayland>(buffer_manager_, widget); + if (!pixmap->InitializeBuffer(size, format, usage)) + return nullptr; + return pixmap; +diff --git a/ui/ozone/platform/wayland/gpu/wayland_surface_factory.h b/ui/ozone/platform/wayland/gpu/wayland_surface_factory.h +index 1db6ee72d406..23f4f92a5959 100644 +--- a/ui/ozone/platform/wayland/gpu/wayland_surface_factory.h ++++ b/ui/ozone/platform/wayland/gpu/wayland_surface_factory.h +@@ -17,23 +17,15 @@ + + namespace ui { + +-class GbmSurfacelessWayland; + class WaylandConnection; + class WaylandBufferManagerGpu; + + class WaylandSurfaceFactory : public SurfaceFactoryOzone { + public: +- explicit WaylandSurfaceFactory(WaylandConnection* connection); ++ WaylandSurfaceFactory(WaylandConnection* connection, ++ WaylandBufferManagerGpu* buffer_manager); + ~WaylandSurfaceFactory() override; + +- void SetBufferManager(WaylandBufferManagerGpu* buffer_manager); +- +- // These methods are used, when a dmabuf based approach is used. +- void RegisterSurface(gfx::AcceleratedWidget widget, +- GbmSurfacelessWayland* surface); +- void UnregisterSurface(gfx::AcceleratedWidget widget); +- GbmSurfacelessWayland* GetSurface(gfx::AcceleratedWidget widget) const; +- + // SurfaceFactoryOzone overrides: + std::vector<gl::GLImplementation> GetAllowedGLImplementations() override; + GLOzone* GetGLOzone(gl::GLImplementation implementation) override; +@@ -53,12 +45,9 @@ class WaylandSurfaceFactory : public SurfaceFactoryOzone { + + private: + WaylandConnection* const connection_; +- WaylandBufferManagerGpu* buffer_manager_ = nullptr; ++ WaylandBufferManagerGpu* const buffer_manager_; + std::unique_ptr<GLOzone> egl_implementation_; + +- std::map<gfx::AcceleratedWidget, GbmSurfacelessWayland*> +- widget_to_surface_map_; +- + DISALLOW_COPY_AND_ASSIGN(WaylandSurfaceFactory); + }; + +diff --git a/ui/ozone/platform/wayland/gpu/wayland_surface_gpu.h b/ui/ozone/platform/wayland/gpu/wayland_surface_gpu.h +new file mode 100644 +index 000000000000..f3593766eed8 +--- /dev/null ++++ b/ui/ozone/platform/wayland/gpu/wayland_surface_gpu.h +@@ -0,0 +1,38 @@ ++// Copyright 2019 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef UI_OZONE_PLATFORM_WAYLAND_GPU_WAYLAND_SURFACE_GPU_H_ ++#define UI_OZONE_PLATFORM_WAYLAND_GPU_WAYLAND_SURFACE_GPU_H_ ++ ++#include <memory> ++ ++#include "base/macros.h" ++ ++namespace gfx { ++enum class SwapResult; ++struct PresentationFeedback; ++} // namespace gfx ++ ++namespace ui { ++ ++// This is a common interface for surfaces created in the GPU process. The ++// purpose of this is receiving submission and presentation callbacks from the ++// WaylandBufferManagerGpu whenever the browser process has completed presenting ++// the buffer. ++class WaylandSurfaceGpu { ++ public: ++ // Tells the surface the result of the last swap of buffer with the ++ // |buffer_id|. ++ virtual void OnSubmission(uint32_t buffer_id, ++ const gfx::SwapResult& swap_result) = 0; ++ ++ // Tells the surface the result of the last presentation of buffer with the ++ // |buffer_id|. ++ virtual void OnPresentation(uint32_t buffer_id, ++ const gfx::PresentationFeedback& feedback) = 0; ++}; ++ ++} // namespace ui ++ ++#endif // UI_OZONE_PLATFORM_WAYLAND_GPU_WAYLAND_SURFACE_GPU_H_ +diff --git a/ui/ozone/platform/wayland/ozone_platform_wayland.cc b/ui/ozone/platform/wayland/ozone_platform_wayland.cc +index 61a0e5b27bfc..26d8b49dab25 100644 +--- a/ui/ozone/platform/wayland/ozone_platform_wayland.cc ++++ b/ui/ozone/platform/wayland/ozone_platform_wayland.cc +@@ -169,11 +169,9 @@ class OzonePlatformWayland : public OzonePlatform { + } + + void InitializeGPU(const InitParams& args) override { +- surface_factory_ = +- std::make_unique<WaylandSurfaceFactory>(connection_.get()); +- buffer_manager_ = +- std::make_unique<WaylandBufferManagerGpu>(surface_factory_.get()); +- surface_factory_->SetBufferManager(buffer_manager_.get()); ++ buffer_manager_ = std::make_unique<WaylandBufferManagerGpu>(); ++ surface_factory_ = std::make_unique<WaylandSurfaceFactory>( ++ connection_.get(), buffer_manager_.get()); + #if defined(WAYLAND_GBM) + const base::FilePath drm_node_path = path_finder_.GetDrmRenderNodePath(); + if (drm_node_path.empty()) { +diff --git a/ui/ozone/platform/wayland/test/wayland_test.cc b/ui/ozone/platform/wayland/test/wayland_test.cc +index 7c78473a0f94..f8946442ecaa 100644 +--- a/ui/ozone/platform/wayland/test/wayland_test.cc ++++ b/ui/ozone/platform/wayland/test/wayland_test.cc +@@ -31,10 +31,9 @@ WaylandTest::WaylandTest() + std::make_unique<StubKeyboardLayoutEngine>()); + #endif + connection_ = std::make_unique<WaylandConnection>(); +- surface_factory_ = std::make_unique<WaylandSurfaceFactory>(connection_.get()); +- buffer_manager_gpu_ = +- std::make_unique<WaylandBufferManagerGpu>(surface_factory_.get()); +- surface_factory_->SetBufferManager(buffer_manager_gpu_.get()); ++ buffer_manager_gpu_ = std::make_unique<WaylandBufferManagerGpu>(); ++ surface_factory_ = std::make_unique<WaylandSurfaceFactory>( ++ connection_.get(), buffer_manager_gpu_.get()); + window_ = std::make_unique<WaylandWindow>(&delegate_, connection_.get()); + } + +-- +2.22.0 + |