summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Playfair Cal2019-08-07 02:06:57 +1000
committerDaniel Playfair Cal2019-08-07 02:06:57 +1000
commit0db39279ff5e4fc60ce4a51f2fe4e488c6bf710a (patch)
treef7a096c7d6928547e0ebb037f7435d1d3c302d45
parentc983bc3007fc25f4f9fabd6380fc1e977257b1f0 (diff)
downloadaur-0db39279ff5e4fc60ce4a51f2fe4e488c6bf710a.tar.gz
76.0.3809.87-1
-rw-r--r--.SRCINFO30
-rw-r--r--0001-ozone-wayland-Prepare-WaylandCanvasSurface-for-compl.patch655
-rw-r--r--0002-ozone-wayland-Sway-avoid-sending-presentation-early.patch380
-rw-r--r--0003-Ozone-Wayland-Manager-make-mojo-calls-on-IO-thread.patch271
-rw-r--r--0004-ozone-wayland-Fix-broken-software-rendering-path.patch108
-rw-r--r--0005-ozone-wayland-Use-mutex-before-accessing-surfaces-ma.patch276
-rw-r--r--PKGBUILD102
-rw-r--r--chromium-fix-window-flash-for-some-WMs.patch98
-rw-r--r--chromium-mutex-surfaces.patch123
-rw-r--r--chromium-skia-harmony.patch9
-rw-r--r--chromium-sway-presentation.patch71
11 files changed, 1751 insertions, 372 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 9462d8e22cc0..26d8237d6d13 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,6 +1,6 @@
pkgbase = chromium-ozone
pkgdesc = Chromium built with patches for wayland support via Ozone
- pkgver = 75.0.3770.142
+ pkgver = 76.0.3809.87
pkgrel = 1
url = https://www.chromium.org/Home
install = chromium.install
@@ -55,27 +55,29 @@ pkgbase = chromium-ozone
optdepends = kwallet: for storing passwords in KWallet
provides = chromium
conflicts = chromium
- source = https://commondatastorage.googleapis.com/chromium-browser-official/chromium-75.0.3770.142.tar.xz
+ source = https://commondatastorage.googleapis.com/chromium-browser-official/chromium-76.0.3809.87.tar.xz
source = chromium-launcher-6.tar.gz::https://github.com/foutrelis/chromium-launcher/archive/v6.tar.gz
- source = meta-browser-3a0df19242cddda96efd91f195fe0df53fe4f955.tar.gz::https://github.com/OSSystems/meta-browser/archive/3a0df19242cddda96efd91f195fe0df53fe4f955.tar.gz
+ source = meta-browser-38b36f421f8d984c7004c9d9a6d514ed2fb6cf8e.tar.gz::https://github.com/OSSystems/meta-browser/archive/38b36f421f8d984c7004c9d9a6d514ed2fb6cf8e.tar.gz
source = chromium-system-icu.patch
- source = chromium-fix-window-flash-for-some-WMs.patch
source = chromium-widevine.patch
source = chromium-skia-harmony.patch
- source = chromium-sway-presentation.patch
- source = chromium-mutex-surfaces.patch
- source = https://git.nightly.network/Exherbo/desktop/raw/de0a391d9e7442dce614553835ef599119826387/packages/net-www/chromium-stable/files/chromium-remove-const.patch
+ source = 0001-ozone-wayland-Prepare-WaylandCanvasSurface-for-compl.patch
+ source = 0002-ozone-wayland-Sway-avoid-sending-presentation-early.patch
+ source = 0003-Ozone-Wayland-Manager-make-mojo-calls-on-IO-thread.patch
+ source = 0004-ozone-wayland-Fix-broken-software-rendering-path.patch
+ source = 0005-ozone-wayland-Use-mutex-before-accessing-surfaces-ma.patch
source = Added-HiDPI-support-for-Ozone-Wayland.patch
- sha256sums = 510e6ca7ccc218b401b375c13656f6aecab196b03142026dc3602b9d1804a5ac
+ sha256sums = 215ca6acee7b4fd3c95fe796260af4dc5454dbba3b701aa43afeb98a06dc4194
sha256sums = 04917e3cd4307d8e31bfb0027a5dce6d086edb10ff8a716024fbb8bb0c7dccf1
- sha256sums = 6bacd62414282999a5631e06cd3fa1eca787ee5b20a41fd3499668eead55f4d1
+ sha256sums = d87957d01be9fb59faf5fde523eb87a8256605b1533171416b7a56bfcbd6d056
sha256sums = e2d284311f49c529ea45083438a768db390bde52949995534034d2a814beab89
- sha256sums = 183d8cc712f0bcf1afcb01ce90c4c104a4c8d8070a06f94974a28b007d9e2ce4
sha256sums = d081f2ef8793544685aad35dea75a7e6264a2cb987ff3541e6377f4a3650a28b
- sha256sums = 5887f78b55c4ecbbcba5930f3f0bb7bc0117c2a41c2f761805fcf7f46f1ca2b3
- sha256sums = 279b9558a466d96bc7dcba96a9f41efaed98ede1cd69e1562689ee4409940fe8
- sha256sums = dcf01e0d630eb107e5efb56bb00c140269a0c9711b3ae90a3fd289ad5153ac08
- sha256sums = 005f7db8acc774e2c66f99d900f2263abf495ccd5eda33c45a957fce2ed30f8d
+ sha256sums = 771292942c0901092a402cc60ee883877a99fb804cb54d568c8c6c94565a48e1
+ sha256sums = a16afeb448fc49904f4bb4f679db1a79b3305a04399d672787e708a32516ac91
+ sha256sums = bddf821069a8037ce91c35787aa942d35ef880ca5e28dae1ddeb224c2d008548
+ sha256sums = 1455cc2bb36f4247b3c16b805328b277c8538ad96f50d1e7f5fb816d5cad2d6d
+ sha256sums = deba5fa9ebd64ca48bab71d51c3bf50a6c10e2704e60b7b50268fc2de15afb61
+ sha256sums = 907be76f0906452b3327b0d469bf5bcff31eec9d9e6d6829c6a0159da73af68a
sha256sums = b6b258a6d3b42731c9375395b4e6e896edef00617d5b7028c348a5d2dbb14eb7
pkgname = chromium-ozone
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
+
diff --git a/0002-ozone-wayland-Sway-avoid-sending-presentation-early.patch b/0002-ozone-wayland-Sway-avoid-sending-presentation-early.patch
new file mode 100644
index 000000000000..4e5204c6fd26
--- /dev/null
+++ b/0002-ozone-wayland-Sway-avoid-sending-presentation-early.patch
@@ -0,0 +1,380 @@
+From c644b4aba05233a8a78d7708a98d9a583ff78a27 Mon Sep 17 00:00:00 2001
+From: Maksim Sisov <msisov@igalia.com>
+Date: Tue, 30 Jul 2019 05:53:48 +0000
+Subject: [PATCH 2/5] [ozone/wayland] Sway: avoid sending presentation early.
+
+In Sway, presentation callbacks may come much earlier than we send
+submission callbacks. That results in unexpected crashes in
+GbmSurfacelessWayland, because of early presentation callbacks.
+Briefly, a submitted frame may not receive the submission
+callback and not be moved to the list waiting for presentation
+frames. That means GbmSurfacelessWayland::OnPresentation accesses
+an invalid pointer to a frame when the presentation feedback comes.
+
+Bug: 974456
+Change-Id: Iae7ab57a00d06f0dde6057ed05df885239e099bd
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1719013
+Reviewed-by: Robert Kroeger <rjkroege@chromium.org>
+Commit-Queue: Maksim Sisov <msisov@igalia.com>
+Cr-Commit-Position: refs/heads/master@{#682157}
+---
+ ui/ozone/platform/wayland/BUILD.gn | 3 ++
+ .../wayland/gpu/wayland_surface_gpu.h | 2 +
+ .../host/wayland_buffer_manager_host.cc | 25 +++++++--
+ .../platform/wayland/test/mock_surface.cc | 44 ++++++++++++++-
+ ui/ozone/platform/wayland/test/mock_surface.h | 14 +++++
+ .../wayland/test/mock_wp_presentation.cc | 53 +++++++++++++++++++
+ .../wayland/test/mock_wp_presentation.h | 47 ++++++++++++++++
+ .../test/test_wayland_server_thread.cc | 6 +++
+ .../wayland/test/test_wayland_server_thread.h | 5 ++
+ 9 files changed, 194 insertions(+), 5 deletions(-)
+ create mode 100644 ui/ozone/platform/wayland/test/mock_wp_presentation.cc
+ create mode 100644 ui/ozone/platform/wayland/test/mock_wp_presentation.h
+
+diff --git a/ui/ozone/platform/wayland/BUILD.gn b/ui/ozone/platform/wayland/BUILD.gn
+index 303173b4ba6c..686138bb614a 100644
+--- a/ui/ozone/platform/wayland/BUILD.gn
++++ b/ui/ozone/platform/wayland/BUILD.gn
+@@ -173,6 +173,8 @@ source_set("test_support") {
+ "test/mock_pointer.h",
+ "test/mock_surface.cc",
+ "test/mock_surface.h",
++ "test/mock_wp_presentation.cc",
++ "test/mock_wp_presentation.h",
+ "test/mock_xdg_popup.cc",
+ "test/mock_xdg_popup.h",
+ "test/mock_xdg_shell.cc",
+@@ -225,6 +227,7 @@ source_set("test_support") {
+ "//testing/gmock",
+ "//third_party/wayland:wayland_server",
+ "//third_party/wayland-protocols:linux_dmabuf_protocol",
++ "//third_party/wayland-protocols:presentation_time_protocol",
+ "//third_party/wayland-protocols:text_input_protocol",
+ "//third_party/wayland-protocols:xdg_shell_protocol",
+ "//ui/gfx/geometry:geometry",
+diff --git a/ui/ozone/platform/wayland/gpu/wayland_surface_gpu.h b/ui/ozone/platform/wayland/gpu/wayland_surface_gpu.h
+index f3593766eed8..ace5279e838e 100644
+--- a/ui/ozone/platform/wayland/gpu/wayland_surface_gpu.h
++++ b/ui/ozone/platform/wayland/gpu/wayland_surface_gpu.h
+@@ -22,6 +22,8 @@ namespace ui {
+ // the buffer.
+ class WaylandSurfaceGpu {
+ public:
++ virtual ~WaylandSurfaceGpu() {}
++
+ // Tells the surface the result of the last swap of buffer with the
+ // |buffer_id|.
+ virtual void OnSubmission(uint32_t buffer_id,
+diff --git a/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.cc b/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.cc
+index bbcfa84016f9..5f7efebac400 100644
+--- a/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.cc
++++ b/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.cc
+@@ -207,6 +207,12 @@ class WaylandBufferManagerHost::Surface {
+ // surface can tell the gpu about successful swap.
+ bool released = true;
+
++ // In some cases, a presentation feedback can come earlier than we fire a
++ // submission callback. Thus, instead of sending it immediately to the GPU
++ // process, we store it and fire as soon as the submission callback is
++ // fired.
++ bool needs_send_feedback = false;
++
+ gfx::PresentationFeedback feedback;
+
+ DISALLOW_COPY_AND_ASSIGN(WaylandBuffer);
+@@ -334,6 +340,11 @@ class WaylandBufferManagerHost::Surface {
+ void CompleteSubmission() {
+ DCHECK(submitted_buffer_);
+ auto id = submitted_buffer_->buffer_id;
++
++ auto feedback = std::move(submitted_buffer_->feedback);
++ bool needs_send_feedback = submitted_buffer_->needs_send_feedback;
++ submitted_buffer_->needs_send_feedback = false;
++
+ prev_submitted_buffer_ = submitted_buffer_;
+ submitted_buffer_ = nullptr;
+ // We can now complete the latest submission. We had to wait for this
+@@ -349,14 +360,22 @@ class WaylandBufferManagerHost::Surface {
+ OnPresentation(id, gfx::PresentationFeedback(
+ base::TimeTicks::Now(), base::TimeDelta(),
+ GetPresentationKindFlags(0)));
++ } else if (needs_send_feedback) {
++ OnPresentation(id, std::move(feedback));
+ }
+ }
+
+ void OnPresentation(uint32_t buffer_id,
+ const gfx::PresentationFeedback& feedback) {
+- // The order of submission and presentation callbacks is checked on the GPU
+- // side, but it must never happen, because the Submission is called
+- // immediately after the buffer is swapped.
++ // The order of submission and presentation callbacks cannot be controlled.
++ // Some Wayland compositors may fire presentation callbacks earlier than we
++ // are able to send submission callbacks and this is bad. Thus, handle it here.
++ if (submitted_buffer_ && submitted_buffer_->buffer_id == buffer_id) {
++ submitted_buffer_->needs_send_feedback = true;
++ submitted_buffer_->feedback = feedback;
++ return;
++ }
++
+ buffer_manager_->OnPresentation(window_->GetWidget(), buffer_id, feedback);
+ }
+
+diff --git a/ui/ozone/platform/wayland/test/mock_surface.cc b/ui/ozone/platform/wayland/test/mock_surface.cc
+index 9d2333683a41..6ee1c0a9c543 100644
+--- a/ui/ozone/platform/wayland/test/mock_surface.cc
++++ b/ui/ozone/platform/wayland/test/mock_surface.cc
+@@ -13,7 +13,8 @@ void Attach(wl_client* client,
+ wl_resource* buffer_resource,
+ int32_t x,
+ int32_t y) {
+- GetUserDataAs<MockSurface>(resource)->Attach(buffer_resource, x, y);
++ auto* surface = GetUserDataAs<MockSurface>(resource);
++ surface->AttachNewBuffer(buffer_resource, x, y);
+ }
+
+ void SetOpaqueRegion(wl_client* client,
+@@ -40,7 +41,13 @@ void Damage(wl_client* client,
+ void Frame(struct wl_client* client,
+ struct wl_resource* resource,
+ uint32_t callback) {
+- GetUserDataAs<MockSurface>(resource)->Frame(callback);
++ auto* surface = GetUserDataAs<MockSurface>(resource);
++
++ wl_resource* callback_resource =
++ wl_resource_create(client, &wl_callback_interface, 1, callback);
++ surface->set_frame_callback(callback_resource);
++
++ surface->Frame(callback);
+ }
+
+ void Commit(wl_client* client, wl_resource* resource) {
+@@ -85,4 +92,37 @@ MockSurface* MockSurface::FromResource(wl_resource* resource) {
+ return GetUserDataAs<MockSurface>(resource);
+ }
+
++void MockSurface::AttachNewBuffer(wl_resource* buffer_resource,
++ int32_t x,
++ int32_t y) {
++ if (attached_buffer_) {
++ DCHECK(!prev_attached_buffer_);
++ prev_attached_buffer_ = attached_buffer_;
++ }
++ attached_buffer_ = buffer_resource;
++
++ Attach(buffer_resource, x, y);
++}
++
++void MockSurface::ReleasePrevAttachedBuffer() {
++ if (!prev_attached_buffer_)
++ return;
++
++ wl_buffer_send_release(prev_attached_buffer_);
++ wl_client_flush(wl_resource_get_client(prev_attached_buffer_));
++ prev_attached_buffer_ = nullptr;
++}
++
++void MockSurface::SendFrameCallback() {
++ if (!frame_callback_)
++ return;
++
++ wl_callback_send_done(
++ frame_callback_,
++ 0 /* trequest-specific data for the callback. not used */);
++ wl_client_flush(wl_resource_get_client(frame_callback_));
++ wl_resource_destroy(frame_callback_);
++ frame_callback_ = nullptr;
++}
++
+ } // namespace wl
+diff --git a/ui/ozone/platform/wayland/test/mock_surface.h b/ui/ozone/platform/wayland/test/mock_surface.h
+index 1ea9c52dea27..0b44ba090187 100644
+--- a/ui/ozone/platform/wayland/test/mock_surface.h
++++ b/ui/ozone/platform/wayland/test/mock_surface.h
+@@ -50,10 +50,24 @@ class MockSurface : public ServerObject {
+ }
+ MockXdgPopup* xdg_popup() const { return xdg_popup_.get(); }
+
++ void set_frame_callback(wl_resource* callback_resource) {
++ DCHECK(!frame_callback_);
++ frame_callback_ = callback_resource;
++ }
++
++ void AttachNewBuffer(wl_resource* buffer_resource, int32_t x, int32_t y);
++ void ReleasePrevAttachedBuffer();
++ void SendFrameCallback();
++
+ private:
+ std::unique_ptr<MockXdgSurface> xdg_surface_;
+ std::unique_ptr<MockXdgPopup> xdg_popup_;
+
++ wl_resource* frame_callback_ = nullptr;
++
++ wl_resource* attached_buffer_ = nullptr;
++ wl_resource* prev_attached_buffer_ = nullptr;
++
+ DISALLOW_COPY_AND_ASSIGN(MockSurface);
+ };
+
+diff --git a/ui/ozone/platform/wayland/test/mock_wp_presentation.cc b/ui/ozone/platform/wayland/test/mock_wp_presentation.cc
+new file mode 100644
+index 000000000000..d24c13658aa4
+--- /dev/null
++++ b/ui/ozone/platform/wayland/test/mock_wp_presentation.cc
+@@ -0,0 +1,53 @@
++// 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.
++
++#include "ui/ozone/platform/wayland/test/mock_wp_presentation.h"
++
++#include <wayland-server-core.h>
++
++#include "ui/ozone/platform/wayland/test/server_object.h"
++
++namespace wl {
++
++namespace {
++
++void Feedback(struct wl_client* client,
++ struct wl_resource* resource,
++ struct wl_resource* surface,
++ uint32_t callback) {
++ auto* wp_presentation = GetUserDataAs<MockWpPresentation>(resource);
++ wl_resource* presentation_feedback_resource =
++ wl_resource_create(client, &wp_presentation_feedback_interface,
++ wl_resource_get_version(resource), callback);
++ wp_presentation->set_presentation_callback(presentation_feedback_resource);
++ wp_presentation->Feedback(client, resource, surface, callback);
++}
++
++} // namespace
++
++const struct wp_presentation_interface kMockWpPresentationImpl = {
++ &DestroyResource, // destroy
++ &Feedback, // feedback
++};
++
++MockWpPresentation::MockWpPresentation()
++ : GlobalObject(&wp_presentation_interface, &kMockWpPresentationImpl, 1) {}
++
++MockWpPresentation::~MockWpPresentation() {}
++
++void MockWpPresentation::SendPresentationCallback() {
++ if (!presentation_callback_)
++ return;
++
++ // TODO(msisov): add support for test provided presentation feedback values.
++ wp_presentation_feedback_send_presented(
++ presentation_callback_, 0 /* tv_sec_hi */, 0 /* tv_sec_lo */,
++ 0 /* tv_nsec */, 0 /* refresh */, 0 /* seq_hi */, 0 /* seq_lo */,
++ 0 /* flags */);
++ wl_client_flush(wl_resource_get_client(presentation_callback_));
++ wl_resource_destroy(presentation_callback_);
++ presentation_callback_ = nullptr;
++}
++
++} // namespace wl
+diff --git a/ui/ozone/platform/wayland/test/mock_wp_presentation.h b/ui/ozone/platform/wayland/test/mock_wp_presentation.h
+new file mode 100644
+index 000000000000..a1bb344fd5f1
+--- /dev/null
++++ b/ui/ozone/platform/wayland/test/mock_wp_presentation.h
+@@ -0,0 +1,47 @@
++// 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_TEST_MOCK_WP_PRESENTATION_H_
++#define UI_OZONE_PLATFORM_WAYLAND_TEST_MOCK_WP_PRESENTATION_H_
++
++#include <presentation-time-server-protocol.h>
++
++#include "base/logging.h"
++#include "base/macros.h"
++#include "testing/gmock/include/gmock/gmock.h"
++#include "ui/ozone/platform/wayland/test/global_object.h"
++
++namespace wl {
++
++extern const struct wp_presentation_interface kMockWpPresentationImpl;
++
++class MockWpPresentation : public GlobalObject {
++ public:
++ MockWpPresentation();
++ ~MockWpPresentation() override;
++
++ MOCK_METHOD2(Destroy,
++ void(struct wl_client* client, struct wl_resource* resource));
++ MOCK_METHOD4(Feedback,
++ void(struct wl_client* client,
++ struct wl_resource* resource,
++ struct wl_resource* surface,
++ uint32_t callback));
++
++ void set_presentation_callback(wl_resource* callback_resource) {
++ DCHECK(!presentation_callback_);
++ presentation_callback_ = callback_resource;
++ }
++
++ void SendPresentationCallback();
++
++ private:
++ wl_resource* presentation_callback_ = nullptr;
++
++ DISALLOW_COPY_AND_ASSIGN(MockWpPresentation);
++};
++
++} // namespace wl
++
++#endif // UI_OZONE_PLATFORM_WAYLAND_TEST_MOCK_WP_PRESENTATION_H_
+diff --git a/ui/ozone/platform/wayland/test/test_wayland_server_thread.cc b/ui/ozone/platform/wayland/test/test_wayland_server_thread.cc
+index 22b1776ebc4e..1101cccb6922 100644
+--- a/ui/ozone/platform/wayland/test/test_wayland_server_thread.cc
++++ b/ui/ozone/platform/wayland/test/test_wayland_server_thread.cc
+@@ -107,6 +107,12 @@ void TestWaylandServerThread::Resume() {
+ resume_event_.Signal();
+ }
+
++MockWpPresentation* TestWaylandServerThread::EnsureWpPresentation() {
++ if (wp_presentation_.Initialize(display_.get()))
++ return &wp_presentation_;
++ return nullptr;
++}
++
+ void TestWaylandServerThread::DoPause() {
+ base::RunLoop().RunUntilIdle();
+ pause_event_.Signal();
+diff --git a/ui/ozone/platform/wayland/test/test_wayland_server_thread.h b/ui/ozone/platform/wayland/test/test_wayland_server_thread.h
+index fddd426db690..110e3ffbc1c2 100644
+--- a/ui/ozone/platform/wayland/test/test_wayland_server_thread.h
++++ b/ui/ozone/platform/wayland/test/test_wayland_server_thread.h
+@@ -13,6 +13,7 @@
+ #include "base/synchronization/waitable_event.h"
+ #include "base/threading/thread.h"
+ #include "ui/ozone/platform/wayland/test/global_object.h"
++#include "ui/ozone/platform/wayland/test/mock_wp_presentation.h"
+ #include "ui/ozone/platform/wayland/test/mock_xdg_shell.h"
+ #include "ui/ozone/platform/wayland/test/mock_zwp_linux_dmabuf.h"
+ #include "ui/ozone/platform/wayland/test/test_compositor.h"
+@@ -53,6 +54,9 @@ class TestWaylandServerThread : public base::Thread,
+ // Resumes the server thread after flushing client connections.
+ void Resume();
+
++ // Initializes and returns WpPresentation.
++ MockWpPresentation* EnsureWpPresentation();
++
+ template <typename T>
+ T* GetObject(uint32_t id) {
+ wl_resource* resource = wl_client_get_object(client_, id);
+@@ -104,6 +108,7 @@ class TestWaylandServerThread : public base::Thread,
+ MockZxdgShellV6 zxdg_shell_v6_;
+ TestZwpTextInputManagerV1 zwp_text_input_manager_v1_;
+ MockZwpLinuxDmabufV1 zwp_linux_dmabuf_v1_;
++ MockWpPresentation wp_presentation_;
+
+ std::vector<std::unique_ptr<GlobalObject>> globals_;
+
+--
+2.22.0
+
diff --git a/0003-Ozone-Wayland-Manager-make-mojo-calls-on-IO-thread.patch b/0003-Ozone-Wayland-Manager-make-mojo-calls-on-IO-thread.patch
new file mode 100644
index 000000000000..f0c378c64ffd
--- /dev/null
+++ b/0003-Ozone-Wayland-Manager-make-mojo-calls-on-IO-thread.patch
@@ -0,0 +1,271 @@
+From 3be83bcae17f547f58b41640451471ab840c70c0 Mon Sep 17 00:00:00 2001
+From: Maksim Sisov <msisov@igalia.com>
+Date: Tue, 4 Jun 2019 07:56:29 +0000
+Subject: [PATCH 3/5] [Ozone/Wayland] Manager: make mojo calls on IO thread.
+
+Previously, the manager had been rerouting calls to GpuMainThread
+to make mojo calls. That thread is not really meant for IPC.
+Instead, make calls on IOChildThread for consistency.
+
+Bug: 969603
+Change-Id: I351768c4a36973bd791c02c1f65080c65b9a0a7b
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1640398
+Commit-Queue: Maksim Sisov <msisov@igalia.com>
+Reviewed-by: Michael Spang <spang@chromium.org>
+Cr-Commit-Position: refs/heads/master@{#665836}
+---
+ .../wayland/gpu/wayland_buffer_manager_gpu.cc | 95 +++++++++----------
+ .../wayland/gpu/wayland_buffer_manager_gpu.h | 21 ++--
+ 2 files changed, 59 insertions(+), 57 deletions(-)
+
+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 49c4903270bd..c37289f9179e 100644
+--- a/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.cc
++++ b/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.cc
+@@ -7,11 +7,11 @@
+ #include <utility>
+
+ #include "base/bind.h"
++#include "base/message_loop/message_loop_current.h"
+ #include "base/process/process.h"
+ #include "mojo/public/cpp/bindings/associated_interface_ptr.h"
+ #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_gpu.h"
+
+ namespace ui {
+@@ -24,9 +24,11 @@ WaylandBufferManagerGpu::~WaylandBufferManagerGpu() = default;
+
+ void WaylandBufferManagerGpu::SetWaylandBufferManagerHost(
+ BufferManagerHostPtr buffer_manager_host_ptr) {
+- // This is an IO child thread. To satisfy our needs, we pass interface here
+- // and bind it again on a gpu main thread, where buffer swaps happen.
+- buffer_manager_host_ptr_info_ = buffer_manager_host_ptr.PassInterface();
++ // This is an IO child thread meant for IPC. Bind interface in this thread and
++ // do all the mojo calls on the same thread.
++ BindHostInterface(std::move(buffer_manager_host_ptr));
++
++ io_thread_runner_ = base::ThreadTaskRunnerHandle::Get();
+ }
+
+ void WaylandBufferManagerGpu::ResetGbmDevice() {
+@@ -40,28 +42,41 @@ void WaylandBufferManagerGpu::ResetGbmDevice() {
+ void WaylandBufferManagerGpu::OnSubmission(gfx::AcceleratedWidget widget,
+ uint32_t buffer_id,
+ gfx::SwapResult swap_result) {
+- DCHECK(gpu_thread_runner_->BelongsToCurrentThread());
++ DCHECK(io_thread_runner_->BelongsToCurrentThread());
+ DCHECK_NE(widget, gfx::kNullAcceleratedWidget);
+ 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.
+- if (surface)
+- surface->OnSubmission(buffer_id, swap_result);
++ if (surface) {
++ // As long as mojo calls rerouted to the IO child thread, we have to reroute
++ // them back to the gpu main thread, where the original commit buffer call
++ // came from.
++ gpu_thread_runner_->PostTask(
++ FROM_HERE,
++ base::Bind(&WaylandSurfaceGpu::OnSubmission, base::Unretained(surface),
++ buffer_id, swap_result));
++ }
+ }
+
+ void WaylandBufferManagerGpu::OnPresentation(
+ gfx::AcceleratedWidget widget,
+ uint32_t buffer_id,
+ const gfx::PresentationFeedback& feedback) {
+- DCHECK(gpu_thread_runner_->BelongsToCurrentThread());
++ DCHECK(io_thread_runner_->BelongsToCurrentThread());
+ DCHECK_NE(widget, gfx::kNullAcceleratedWidget);
+ 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.
+- if (surface)
+- surface->OnPresentation(buffer_id, feedback);
++ if (surface) {
++ // As long as mojo calls rerouted to the IO child thread, we have to reroute
++ // them back to the gpu main thread, where the original commit buffer call
++ // came from.
++ gpu_thread_runner_->PostTask(
++ FROM_HERE, base::Bind(&WaylandSurfaceGpu::OnPresentation,
++ base::Unretained(surface), buffer_id, feedback));
++ }
+ }
+
+ void WaylandBufferManagerGpu::RegisterSurface(gfx::AcceleratedWidget widget,
+@@ -92,10 +107,10 @@ void WaylandBufferManagerGpu::CreateDmabufBasedBuffer(
+ uint32_t current_format,
+ uint32_t planes_count,
+ uint32_t buffer_id) {
+- DCHECK(gpu_thread_runner_);
+- // Do a mojo call on the GpuMainThread instead of the io child thread to
+- // ensure proper functionality.
+- gpu_thread_runner_->PostTask(
++ DCHECK(io_thread_runner_);
++
++ // Do the mojo call on the IO child thread.
++ io_thread_runner_->PostTask(
+ FROM_HERE,
+ base::BindOnce(&WaylandBufferManagerGpu::CreateDmabufBasedBufferInternal,
+ base::Unretained(this), widget, std::move(dmabuf_fd),
+@@ -110,10 +125,10 @@ void WaylandBufferManagerGpu::CreateShmBasedBuffer(
+ size_t length,
+ gfx::Size size,
+ uint32_t buffer_id) {
+- DCHECK(gpu_thread_runner_);
+- // Do a mojo call on the GpuMainThread instead of the io child thread to
+- // ensure proper functionality.
+- gpu_thread_runner_->PostTask(
++ DCHECK(io_thread_runner_);
++
++ // Do the mojo call on the IO child thread.
++ io_thread_runner_->PostTask(
+ FROM_HERE,
+ base::BindOnce(&WaylandBufferManagerGpu::CreateShmBasedBufferInternal,
+ base::Unretained(this), widget, std::move(shm_fd), length,
+@@ -123,11 +138,11 @@ void WaylandBufferManagerGpu::CreateShmBasedBuffer(
+ void WaylandBufferManagerGpu::CommitBuffer(gfx::AcceleratedWidget widget,
+ uint32_t buffer_id,
+ const gfx::Rect& damage_region) {
+- DCHECK(gpu_thread_runner_);
++ DCHECK(gpu_thread_runner_ && gpu_thread_runner_->BelongsToCurrentThread());
++ DCHECK(io_thread_runner_);
+
+- // Do a mojo call on the GpuMainThread instead of the io child thread to
+- // ensure proper functionality.
+- gpu_thread_runner_->PostTask(
++ // Do the mojo call on the IO child thread.
++ io_thread_runner_->PostTask(
+ FROM_HERE,
+ base::BindOnce(&WaylandBufferManagerGpu::CommitBufferInternal,
+ base::Unretained(this), widget, buffer_id, damage_region));
+@@ -135,11 +150,10 @@ void WaylandBufferManagerGpu::CommitBuffer(gfx::AcceleratedWidget widget,
+
+ void WaylandBufferManagerGpu::DestroyBuffer(gfx::AcceleratedWidget widget,
+ uint32_t buffer_id) {
+- DCHECK(gpu_thread_runner_);
++ DCHECK(io_thread_runner_);
+
+- // Do a mojo call on the GpuMainThread instead of the io child thread to
+- // ensure proper functionality.
+- gpu_thread_runner_->PostTask(
++ // Do the mojo call on the IO child thread.
++ io_thread_runner_->PostTask(
+ FROM_HERE, base::BindOnce(&WaylandBufferManagerGpu::DestroyBufferInternal,
+ base::Unretained(this), widget, buffer_id));
+ }
+@@ -159,14 +173,7 @@ void WaylandBufferManagerGpu::CreateDmabufBasedBufferInternal(
+ uint32_t current_format,
+ uint32_t planes_count,
+ uint32_t buffer_id) {
+- // The interface pointer is passed on an IO child thread, which is different
+- // from the thread, which is used to call these methods. Thus, rebind the
+- // interface on a first call to ensure mojo calls will always happen on a
+- // sequence we want.
+- if (!buffer_manager_host_ptr_.is_bound())
+- BindHostInterface();
+-
+- DCHECK(gpu_thread_runner_->BelongsToCurrentThread());
++ DCHECK(io_thread_runner_->BelongsToCurrentThread());
+ DCHECK(buffer_manager_host_ptr_);
+ buffer_manager_host_ptr_->CreateDmabufBasedBuffer(
+ widget,
+@@ -181,15 +188,7 @@ void WaylandBufferManagerGpu::CreateShmBasedBufferInternal(
+ size_t length,
+ gfx::Size size,
+ uint32_t buffer_id) {
+- DCHECK(gpu_thread_runner_->BelongsToCurrentThread());
+-
+- // The interface pointer is passed on an IO child thread, which is different
+- // from the thread, which is used to call these methods. Thus, rebind the
+- // interface on a first call to ensure mojo calls will always happen on a
+- // sequence we want.
+- if (!buffer_manager_host_ptr_.is_bound())
+- BindHostInterface();
+-
++ DCHECK(io_thread_runner_->BelongsToCurrentThread());
+ DCHECK(buffer_manager_host_ptr_);
+ buffer_manager_host_ptr_->CreateShmBasedBuffer(
+ widget, mojo::WrapPlatformHandle(mojo::PlatformHandle(std::move(shm_fd))),
+@@ -200,7 +199,7 @@ void WaylandBufferManagerGpu::CommitBufferInternal(
+ gfx::AcceleratedWidget widget,
+ uint32_t buffer_id,
+ const gfx::Rect& damage_region) {
+- DCHECK(gpu_thread_runner_->BelongsToCurrentThread());
++ DCHECK(io_thread_runner_->BelongsToCurrentThread());
+ DCHECK(buffer_manager_host_ptr_);
+
+ buffer_manager_host_ptr_->CommitBuffer(widget, buffer_id, damage_region);
+@@ -209,15 +208,15 @@ void WaylandBufferManagerGpu::CommitBufferInternal(
+ void WaylandBufferManagerGpu::DestroyBufferInternal(
+ gfx::AcceleratedWidget widget,
+ uint32_t buffer_id) {
+- DCHECK(gpu_thread_runner_->BelongsToCurrentThread());
++ DCHECK(io_thread_runner_->BelongsToCurrentThread());
+ DCHECK(buffer_manager_host_ptr_);
+
+ buffer_manager_host_ptr_->DestroyBuffer(widget, buffer_id);
+ }
+
+-void WaylandBufferManagerGpu::BindHostInterface() {
+- DCHECK(!buffer_manager_host_ptr_.is_bound());
+- buffer_manager_host_ptr_.Bind(std::move(buffer_manager_host_ptr_info_));
++void WaylandBufferManagerGpu::BindHostInterface(
++ BufferManagerHostPtr buffer_manager_host_ptr) {
++ buffer_manager_host_ptr_.Bind(buffer_manager_host_ptr.PassInterface());
+
+ // Setup associated interface.
+ ozone::mojom::WaylandBufferManagerGpuAssociatedPtrInfo client_ptr_info;
+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 d2185c8308fb..deeb8d0f097f 100644
+--- a/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.h
++++ b/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.h
+@@ -140,7 +140,7 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu {
+ const gfx::Rect& damage_region);
+ void DestroyBufferInternal(gfx::AcceleratedWidget widget, uint32_t buffer_id);
+
+- void BindHostInterface();
++ void BindHostInterface(BufferManagerHostPtr buffer_manager_host_ptr);
+
+ #if defined(WAYLAND_GBM)
+ // A DRM render node based gbm device.
+@@ -152,20 +152,23 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu {
+ // A pointer to a WaylandBufferManagerHost object, which always lives on a
+ // browser process side. It's used for a multi-process mode.
+ BufferManagerHostPtr buffer_manager_host_ptr_;
+- ozone::mojom::WaylandBufferManagerHostPtrInfo buffer_manager_host_ptr_info_;
+
+ mojo::AssociatedBinding<ozone::mojom::WaylandBufferManagerGpu>
+ associated_binding_;
+
+- // A task runner, which is initialized in a multi-process mode. It is used to
+- // ensure all the methods of this class are run on GpuMainThread. This is
+- // needed to ensure mojo calls happen on a right sequence. What is more, it
+- // makes it possible to use a frame callback (when it is implemented) in the
+- // browser process, which calls back to a right sequence after a
+- // CommitBuffer call.
++ std::map<gfx::AcceleratedWidget, WaylandSurfaceGpu*> widget_to_surface_map_;
++
++ // This task runner can be used to pass messages back to the GpuMainThread.
++ // For example, swap requests come from the GpuMainThread, but rerouted to the
++ // IOChildThread and then mojo calls happen. However, when the manager
++ // receives mojo calls, it has to reroute calls back to the same thread
++ // where the calls came from to ensure correct sequence.
+ scoped_refptr<base::SingleThreadTaskRunner> gpu_thread_runner_;
+
+- std::map<gfx::AcceleratedWidget, WaylandSurfaceGpu*> widget_to_surface_map_;
++ // A task runner, which is initialized in a multi-process mode. It is used to
++ // ensure all the methods of this class are run on IOChildThread. This is
++ // needed to ensure mojo calls happen on a right sequence.
++ scoped_refptr<base::SingleThreadTaskRunner> io_thread_runner_;
+
+ DISALLOW_COPY_AND_ASSIGN(WaylandBufferManagerGpu);
+ };
+--
+2.22.0
+
diff --git a/0004-ozone-wayland-Fix-broken-software-rendering-path.patch b/0004-ozone-wayland-Fix-broken-software-rendering-path.patch
new file mode 100644
index 000000000000..23bd3ded5718
--- /dev/null
+++ b/0004-ozone-wayland-Fix-broken-software-rendering-path.patch
@@ -0,0 +1,108 @@
+From 86c0a9aac3e872c98345cc761bfbbc9dbbb6fde2 Mon Sep 17 00:00:00 2001
+From: Maksim Sisov <msisov@igalia.com>
+Date: Thu, 6 Jun 2019 08:58:59 +0000
+Subject: [PATCH 4/5] [ozone/wayland] Fix broken software rendering path.
+
+The "[Ozone/Wayland] Manager: make mojo calls on IO thread." CL:
+https://crrev.com/c/1640398 broke the software rendering path,
+which results in a DCHECK now.
+
+It turned out that when software rendering is used, the buffers
+are committed on the VizCompositorThread, whereas hw accelerated
+rendering uses GpuMainThread instead.
+
+To resolve the conflict, rename the |gpu_thread_runner_| to
+the |commit_thread_runner_|, and use it when OnSubmission
+and OnPresentation calls come.
+
+Bug: 969603
+Change-Id: I3600e35fdc9d4fd0817ce9948316a2af86108bdb
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1642558
+Reviewed-by: Michael Spang <spang@chromium.org>
+Commit-Queue: Maksim Sisov <msisov@igalia.com>
+Cr-Commit-Position: refs/heads/master@{#666629}
+---
+ .../wayland/gpu/wayland_buffer_manager_gpu.cc | 19 ++++++++++---------
+ .../wayland/gpu/wayland_buffer_manager_gpu.h | 13 +++++++------
+ 2 files changed, 17 insertions(+), 15 deletions(-)
+
+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 c37289f9179e..63bfa3032fde 100644
+--- a/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.cc
++++ b/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.cc
+@@ -17,8 +17,7 @@
+ namespace ui {
+
+ WaylandBufferManagerGpu::WaylandBufferManagerGpu()
+- : associated_binding_(this),
+- gpu_thread_runner_(base::ThreadTaskRunnerHandle::Get()) {}
++ : associated_binding_(this) {}
+
+ WaylandBufferManagerGpu::~WaylandBufferManagerGpu() = default;
+
+@@ -50,9 +49,9 @@ void WaylandBufferManagerGpu::OnSubmission(gfx::AcceleratedWidget widget,
+ // a buffer, and is able to call the OnSubmission for that specific buffer.
+ if (surface) {
+ // As long as mojo calls rerouted to the IO child thread, we have to reroute
+- // them back to the gpu main thread, where the original commit buffer call
+- // came from.
+- gpu_thread_runner_->PostTask(
++ // them back to the same thread, where the original commit buffer call came
++ // from.
++ commit_thread_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&WaylandSurfaceGpu::OnSubmission, base::Unretained(surface),
+ buffer_id, swap_result));
+@@ -71,9 +70,9 @@ void WaylandBufferManagerGpu::OnPresentation(
+ // a buffer, and is able to call the OnPresentation for that specific buffer.
+ if (surface) {
+ // As long as mojo calls rerouted to the IO child thread, we have to reroute
+- // them back to the gpu main thread, where the original commit buffer call
+- // came from.
+- gpu_thread_runner_->PostTask(
++ // them back to the same thread, where the original commit buffer call came
++ // from.
++ commit_thread_runner_->PostTask(
+ FROM_HERE, base::Bind(&WaylandSurfaceGpu::OnPresentation,
+ base::Unretained(surface), buffer_id, feedback));
+ }
+@@ -138,9 +137,11 @@ void WaylandBufferManagerGpu::CreateShmBasedBuffer(
+ void WaylandBufferManagerGpu::CommitBuffer(gfx::AcceleratedWidget widget,
+ uint32_t buffer_id,
+ const gfx::Rect& damage_region) {
+- DCHECK(gpu_thread_runner_ && gpu_thread_runner_->BelongsToCurrentThread());
+ DCHECK(io_thread_runner_);
+
++ if (!commit_thread_runner_)
++ commit_thread_runner_ = base::ThreadTaskRunnerHandle::Get();
++
+ // Do the mojo call on the IO child thread.
+ io_thread_runner_->PostTask(
+ FROM_HERE,
+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 deeb8d0f097f..87439610cfc3 100644
+--- a/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.h
++++ b/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.h
+@@ -158,12 +158,13 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu {
+
+ std::map<gfx::AcceleratedWidget, WaylandSurfaceGpu*> widget_to_surface_map_;
+
+- // This task runner can be used to pass messages back to the GpuMainThread.
+- // For example, swap requests come from the GpuMainThread, but rerouted to the
+- // IOChildThread and then mojo calls happen. However, when the manager
+- // receives mojo calls, it has to reroute calls back to the same thread
+- // where the calls came from to ensure correct sequence.
+- scoped_refptr<base::SingleThreadTaskRunner> gpu_thread_runner_;
++ // This task runner can be used to pass messages back to the same thread,
++ // where the commit buffer request came from. For example, swap requests come
++ // from the GpuMainThread, but rerouted to the IOChildThread and then mojo
++ // calls happen. However, when the manager receives mojo calls, it has to
++ // reroute calls back to the same thread where the calls came from to ensure
++ // correct sequence.
++ scoped_refptr<base::SingleThreadTaskRunner> commit_thread_runner_;
+
+ // A task runner, which is initialized in a multi-process mode. It is used to
+ // ensure all the methods of this class are run on IOChildThread. This is
+--
+2.22.0
+
diff --git a/0005-ozone-wayland-Use-mutex-before-accessing-surfaces-ma.patch b/0005-ozone-wayland-Use-mutex-before-accessing-surfaces-ma.patch
new file mode 100644
index 000000000000..9a4e8e822cb3
--- /dev/null
+++ b/0005-ozone-wayland-Use-mutex-before-accessing-surfaces-ma.patch
@@ -0,0 +1,276 @@
+From fd1d8bfd55d5b1d073cbad3ebe8f058c49f3702a Mon Sep 17 00:00:00 2001
+From: Maksim Sisov <msisov@igalia.com>
+Date: Mon, 5 Aug 2019 16:14:47 +0300
+Subject: [PATCH 5/5] [ozone/wayland] Use mutex before accessing surfaces map.
+
+We must make sure that accessing surfaces map from different threads
+is safe. Otherwise, this is subject to races and unexpected crashes.
+
+Bug: 987950
+Change-Id: I2e70e9c1ad48943be518c3571b7ca1fb91f8d51b
+---
+ ui/ozone/platform/wayland/BUILD.gn | 1 +
+ .../wayland/gpu/gbm_pixmap_wayland.cc | 6 +-
+ .../wayland/gpu/gbm_surfaceless_wayland.cc | 2 +-
+ .../wayland/gpu/wayland_buffer_manager_gpu.cc | 61 ++++++++-----------
+ .../wayland/gpu/wayland_buffer_manager_gpu.h | 14 ++++-
+ .../wayland/gpu/wayland_canvas_surface.cc | 2 +-
+ .../wayland/gpu/wayland_surface_gpu.cc | 16 +++++
+ .../wayland/gpu/wayland_surface_gpu.h | 13 +++-
+ 8 files changed, 72 insertions(+), 43 deletions(-)
+ create mode 100644 ui/ozone/platform/wayland/gpu/wayland_surface_gpu.cc
+
+diff --git a/ui/ozone/platform/wayland/BUILD.gn b/ui/ozone/platform/wayland/BUILD.gn
+index 686138bb614a..a1560a20fe23 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.cc",
+ "gpu/wayland_surface_gpu.h",
+ "host/wayland_buffer_manager_connector.cc",
+ "host/wayland_buffer_manager_connector.h",
+diff --git a/ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.cc b/ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.cc
+index 5d8167bdfd89..917f849811a2 100644
+--- a/ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.cc
++++ b/ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.cc
+@@ -126,10 +126,10 @@ bool GbmPixmapWayland::ScheduleOverlayPlane(
+ const gfx::RectF& crop_rect,
+ bool enable_blend,
+ std::unique_ptr<gfx::GpuFence> gpu_fence) {
+- auto* surface = buffer_manager_->GetSurface(widget);
+- DCHECK(surface);
++ auto surface_weak = buffer_manager_->GetSurface(widget);
++ DCHECK(surface_weak);
+ GbmSurfacelessWayland* surfaceless =
+- static_cast<GbmSurfacelessWayland*>(surface);
++ static_cast<GbmSurfacelessWayland*>(surface_weak.get());
+ DCHECK(surfaceless);
+
+ surfaceless->QueueOverlayPlane(
+diff --git a/ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.cc b/ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.cc
+index 70ea08acfa11..0554e772f5cb 100644
+--- a/ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.cc
++++ b/ui/ozone/platform/wayland/gpu/gbm_surfaceless_wayland.cc
+@@ -34,7 +34,7 @@ GbmSurfacelessWayland::GbmSurfacelessWayland(
+ has_implicit_external_sync_(
+ HasEGLExtension("EGL_ARM_implicit_external_sync")),
+ weak_factory_(this) {
+- buffer_manager_->RegisterSurface(widget_, this);
++ buffer_manager_->RegisterSurface(widget_, GetWeakPtr());
+ unsubmitted_frames_.push_back(std::make_unique<PendingFrame>());
+ }
+
+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 63bfa3032fde..f113a9887bdc 100644
+--- a/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.cc
++++ b/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.cc
+@@ -43,19 +43,13 @@ void WaylandBufferManagerGpu::OnSubmission(gfx::AcceleratedWidget widget,
+ gfx::SwapResult swap_result) {
+ DCHECK(io_thread_runner_->BelongsToCurrentThread());
+ DCHECK_NE(widget, gfx::kNullAcceleratedWidget);
+- 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.
+- if (surface) {
+- // As long as mojo calls rerouted to the IO child thread, we have to reroute
+- // them back to the same thread, where the original commit buffer call came
+- // from.
+- commit_thread_runner_->PostTask(
+- FROM_HERE,
+- base::Bind(&WaylandSurfaceGpu::OnSubmission, base::Unretained(surface),
+- buffer_id, swap_result));
+- }
++ auto surface = GetSurface(widget);
++ // As long as mojo calls rerouted to the IO child thread, we have to reroute
++ // them back to the same thread, where the original commit buffer call came
++ // from.
++ commit_thread_runner_->PostTask(
++ FROM_HERE, base::Bind(&WaylandSurfaceGpu::OnSubmission, surface,
++ buffer_id, swap_result));
+ }
+
+ void WaylandBufferManagerGpu::OnPresentation(
+@@ -64,36 +58,35 @@ void WaylandBufferManagerGpu::OnPresentation(
+ const gfx::PresentationFeedback& feedback) {
+ DCHECK(io_thread_runner_->BelongsToCurrentThread());
+ DCHECK_NE(widget, gfx::kNullAcceleratedWidget);
+- 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.
+- if (surface) {
+- // As long as mojo calls rerouted to the IO child thread, we have to reroute
+- // them back to the same thread, where the original commit buffer call came
+- // from.
+- commit_thread_runner_->PostTask(
+- FROM_HERE, base::Bind(&WaylandSurfaceGpu::OnPresentation,
+- base::Unretained(surface), buffer_id, feedback));
+- }
+-}
+-
+-void WaylandBufferManagerGpu::RegisterSurface(gfx::AcceleratedWidget widget,
+- WaylandSurfaceGpu* surface) {
++ auto surface = GetSurface(widget);
++ // As long as mojo calls rerouted to the IO child thread, we have to reroute
++ // them back to the same thread, where the original commit buffer call came
++ // from.
++ commit_thread_runner_->PostTask(
++ FROM_HERE, base::Bind(&WaylandSurfaceGpu::OnPresentation, surface,
++ buffer_id, feedback));
++}
++
++void WaylandBufferManagerGpu::RegisterSurface(
++ gfx::AcceleratedWidget widget,
++ base::WeakPtr<WaylandSurfaceGpu> surface) {
++ base::AutoLock scoped_lock(lock_);
+ widget_to_surface_map_.insert(std::make_pair(widget, surface));
+ }
+
+ void WaylandBufferManagerGpu::UnregisterSurface(gfx::AcceleratedWidget widget) {
++ base::AutoLock scoped_lock(lock_);
+ widget_to_surface_map_.erase(widget);
+ }
+
+-WaylandSurfaceGpu* WaylandBufferManagerGpu::GetSurface(
+- gfx::AcceleratedWidget widget) const {
+- WaylandSurfaceGpu* surface = nullptr;
++base::WeakPtr<WaylandSurfaceGpu> WaylandBufferManagerGpu::GetSurface(
++ gfx::AcceleratedWidget widget) {
++ base::AutoLock scoped_lock(lock_);
++
+ auto it = widget_to_surface_map_.find(widget);
+ if (it != widget_to_surface_map_.end())
+- surface = it->second;
+- return surface;
++ return it->second;
++ return nullptr;
+ }
+
+ void WaylandBufferManagerGpu::CreateDmabufBasedBuffer(
+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 87439610cfc3..631d715e719e 100644
+--- a/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.h
++++ b/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.h
+@@ -8,6 +8,8 @@
+ #include <memory>
+
+ #include "base/macros.h"
++#include "base/memory/weak_ptr.h"
++#include "base/synchronization/lock.h"
+ #include "base/threading/sequenced_task_runner_handle.h"
+ #include "base/threading/thread_checker.h"
+ #include "mojo/public/cpp/bindings/associated_binding.h"
+@@ -64,9 +66,11 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu {
+ // result of the below operations, they must register themselves with the
+ // below APIs.
+ void RegisterSurface(gfx::AcceleratedWidget widget,
+- WaylandSurfaceGpu* surface);
++ base::WeakPtr<WaylandSurfaceGpu> surface);
+ void UnregisterSurface(gfx::AcceleratedWidget widget);
+- WaylandSurfaceGpu* GetSurface(gfx::AcceleratedWidget widget) const;
++ // A client of this method must always get and acquire lock before doing
++ // any manipulations with the surface. Once done, the lock must be released.
++ base::WeakPtr<WaylandSurfaceGpu> GetSurface(gfx::AcceleratedWidget widget);
+
+ // 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
+@@ -156,7 +160,8 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu {
+ mojo::AssociatedBinding<ozone::mojom::WaylandBufferManagerGpu>
+ associated_binding_;
+
+- std::map<gfx::AcceleratedWidget, WaylandSurfaceGpu*> widget_to_surface_map_;
++ std::map<gfx::AcceleratedWidget, base::WeakPtr<WaylandSurfaceGpu>>
++ widget_to_surface_map_; // Guarded by |lock_|.
+
+ // This task runner can be used to pass messages back to the same thread,
+ // where the commit buffer request came from. For example, swap requests come
+@@ -171,6 +176,9 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu {
+ // needed to ensure mojo calls happen on a right sequence.
+ scoped_refptr<base::SingleThreadTaskRunner> io_thread_runner_;
+
++ // Protects access to |widget_to_surface_map_|.
++ base::Lock lock_;
++
+ 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 6de24d7fd177..ce44ebac2915 100644
+--- a/ui/ozone/platform/wayland/gpu/wayland_canvas_surface.cc
++++ b/ui/ozone/platform/wayland/gpu/wayland_canvas_surface.cc
+@@ -29,7 +29,7 @@ WaylandCanvasSurface::WaylandCanvasSurface(
+ WaylandBufferManagerGpu* buffer_manager,
+ gfx::AcceleratedWidget widget)
+ : buffer_manager_(buffer_manager), widget_(widget) {
+- buffer_manager_->RegisterSurface(widget_, this);
++ buffer_manager_->RegisterSurface(widget_, GetWeakPtr());
+ }
+
+ WaylandCanvasSurface::~WaylandCanvasSurface() {
+diff --git a/ui/ozone/platform/wayland/gpu/wayland_surface_gpu.cc b/ui/ozone/platform/wayland/gpu/wayland_surface_gpu.cc
+new file mode 100644
+index 000000000000..85296edcca42
+--- /dev/null
++++ b/ui/ozone/platform/wayland/gpu/wayland_surface_gpu.cc
+@@ -0,0 +1,16 @@
++// 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.
++
++#include "ui/ozone/platform/wayland/gpu/wayland_surface_gpu.h"
++
++namespace ui {
++
++WaylandSurfaceGpu::WaylandSurfaceGpu() = default;
++WaylandSurfaceGpu::~WaylandSurfaceGpu() = default;
++
++base::WeakPtr<WaylandSurfaceGpu> WaylandSurfaceGpu::GetWeakPtr() {
++ return weak_factory_.GetWeakPtr();
++}
++
++} // namespace ui
+diff --git a/ui/ozone/platform/wayland/gpu/wayland_surface_gpu.h b/ui/ozone/platform/wayland/gpu/wayland_surface_gpu.h
+index ace5279e838e..38d285317ab3 100644
+--- a/ui/ozone/platform/wayland/gpu/wayland_surface_gpu.h
++++ b/ui/ozone/platform/wayland/gpu/wayland_surface_gpu.h
+@@ -8,6 +8,7 @@
+ #include <memory>
+
+ #include "base/macros.h"
++#include "base/memory/weak_ptr.h"
+
+ namespace gfx {
+ enum class SwapResult;
+@@ -22,7 +23,7 @@ namespace ui {
+ // the buffer.
+ class WaylandSurfaceGpu {
+ public:
+- virtual ~WaylandSurfaceGpu() {}
++ virtual ~WaylandSurfaceGpu();
+
+ // Tells the surface the result of the last swap of buffer with the
+ // |buffer_id|.
+@@ -33,6 +34,16 @@ class WaylandSurfaceGpu {
+ // |buffer_id|.
+ virtual void OnPresentation(uint32_t buffer_id,
+ const gfx::PresentationFeedback& feedback) = 0;
++
++ protected:
++ WaylandSurfaceGpu();
++
++ base::WeakPtr<WaylandSurfaceGpu> GetWeakPtr();
++
++ private:
++ base::WeakPtrFactory<WaylandSurfaceGpu> weak_factory_{this};
++
++ DISALLOW_COPY_AND_ASSIGN(WaylandSurfaceGpu);
+ };
+
+ } // namespace ui
+--
+2.22.0
+
diff --git a/PKGBUILD b/PKGBUILD
index e8d907ec1dfd..7eaea3ee9ba4 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -5,10 +5,10 @@
# Contributor: Daniel J Griffiths <ghost1227@archlinux.us>
pkgname=chromium-ozone
-pkgver=75.0.3770.142
+pkgver=76.0.3809.87
pkgrel=1
_launcher_ver=6
-_meta_browser_sha=3a0df19242cddda96efd91f195fe0df53fe4f955
+_meta_browser_sha=38b36f421f8d984c7004c9d9a6d514ed2fb6cf8e
pkgdesc="Chromium built with patches for wayland support via Ozone"
arch=('x86_64')
url="https://www.chromium.org/Home"
@@ -29,23 +29,25 @@ source=(https://commondatastorage.googleapis.com/chromium-browser-official/chrom
chromium-launcher-$_launcher_ver.tar.gz::https://github.com/foutrelis/chromium-launcher/archive/v$_launcher_ver.tar.gz
meta-browser-${_meta_browser_sha}.tar.gz::https://github.com/OSSystems/meta-browser/archive/${_meta_browser_sha}.tar.gz
chromium-system-icu.patch
- chromium-fix-window-flash-for-some-WMs.patch
chromium-widevine.patch
chromium-skia-harmony.patch
- chromium-sway-presentation.patch
- chromium-mutex-surfaces.patch
- https://git.nightly.network/Exherbo/desktop/raw/de0a391d9e7442dce614553835ef599119826387/packages/net-www/chromium-stable/files/chromium-remove-const.patch
+ 0001-ozone-wayland-Prepare-WaylandCanvasSurface-for-compl.patch
+ 0002-ozone-wayland-Sway-avoid-sending-presentation-early.patch
+ 0003-Ozone-Wayland-Manager-make-mojo-calls-on-IO-thread.patch
+ 0004-ozone-wayland-Fix-broken-software-rendering-path.patch
+ 0005-ozone-wayland-Use-mutex-before-accessing-surfaces-ma.patch
Added-HiDPI-support-for-Ozone-Wayland.patch)
-sha256sums=('510e6ca7ccc218b401b375c13656f6aecab196b03142026dc3602b9d1804a5ac'
+sha256sums=('215ca6acee7b4fd3c95fe796260af4dc5454dbba3b701aa43afeb98a06dc4194'
'04917e3cd4307d8e31bfb0027a5dce6d086edb10ff8a716024fbb8bb0c7dccf1'
- '6bacd62414282999a5631e06cd3fa1eca787ee5b20a41fd3499668eead55f4d1'
+ 'd87957d01be9fb59faf5fde523eb87a8256605b1533171416b7a56bfcbd6d056'
'e2d284311f49c529ea45083438a768db390bde52949995534034d2a814beab89'
- '183d8cc712f0bcf1afcb01ce90c4c104a4c8d8070a06f94974a28b007d9e2ce4'
'd081f2ef8793544685aad35dea75a7e6264a2cb987ff3541e6377f4a3650a28b'
- '5887f78b55c4ecbbcba5930f3f0bb7bc0117c2a41c2f761805fcf7f46f1ca2b3'
- '279b9558a466d96bc7dcba96a9f41efaed98ede1cd69e1562689ee4409940fe8'
- 'dcf01e0d630eb107e5efb56bb00c140269a0c9711b3ae90a3fd289ad5153ac08'
- '005f7db8acc774e2c66f99d900f2263abf495ccd5eda33c45a957fce2ed30f8d'
+ '771292942c0901092a402cc60ee883877a99fb804cb54d568c8c6c94565a48e1'
+ 'a16afeb448fc49904f4bb4f679db1a79b3305a04399d672787e708a32516ac91'
+ 'bddf821069a8037ce91c35787aa942d35ef880ca5e28dae1ddeb224c2d008548'
+ '1455cc2bb36f4247b3c16b805328b277c8538ad96f50d1e7f5fb816d5cad2d6d'
+ 'deba5fa9ebd64ca48bab71d51c3bf50a6c10e2704e60b7b50268fc2de15afb61'
+ '907be76f0906452b3327b0d469bf5bcff31eec9d9e6d6829c6a0159da73af68a'
'b6b258a6d3b42731c9375395b4e6e896edef00617d5b7028c348a5d2dbb14eb7')
# Possible replacements are listed in build/linux/unbundle/replace_gn_files.py
@@ -83,8 +85,7 @@ _google_api_key=AIzaSyDwr302FpOSkGRpLlUpPThNTDPbXcIn_FM
_google_default_client_id=413772536636.apps.googleusercontent.com
_google_default_client_secret=0ZChLK6AxeA3Isu96MkwqDR4
-_general_patches=(
- '0001-libstdc-do-not-assume-unique_ptr-has-ostream-operato.patch'
+_mb_general_patches=(
'oe-clang-fixes.patch'
# 'v8-qemu-wrapper.patch'
'wrapper-extra-flags.patch'
@@ -92,34 +93,18 @@ _general_patches=(
'add_internal_define_armv7ve.patch'
)
-_wayland_patches=(
- '0001-ozone-wayland-Factored-the-clipboard-logic-out-of-Wa.patch'
- '0002-Convert-wayland-buffer-to-the-new-shared-memory-API.patch'
- '0003-Migrate-WaylandCanvasSurface-to-the-new-shared-memor.patch'
- '0004-ozone-wayland-Ease-the-buffer-swap-and-maintenance.patch'
- '0005-ozone-wayland-Fix-presentation-feedback-flags.patch'
- '0006-wayland-Do-not-release-shared-memory-fd-when-passing.patch'
- '0007-ozone-wayland-Don-t-wait-for-frame-callback-after-su.patch'
- '0008-ozone-wayland-Do-not-add-window-if-manager-does-not-.patch '
- '0009-ozone-wayland-Fix-NativeGpuMemoryBuffers-usage.patch'
- '0010-ozone-wayland-Add-immediate-release-support.patch'
- '0011-ozone-wayland-Wrap-wl_shm-to-WaylandShm.patch'
- '0012-ozone-wayland-Shm-Proxy-make-mojo-calls-on-the-gpu-t.patch'
- '0013-ozone-wayland-Shm-add-buffer_id.patch'
- '0014-ozone-wayland-Unite-Wayland-ShmBufferManager-and-Buf.patch'
- '0015-ozone-wayland-Stop-providing-WaylandConnection-throu.patch'
- '0016-ozone-wayland-Improve-logging-when-creating-gbm-buff.patch'
- '0017-ozone-wayland-Establish-BufferManagerGpu-and-BufferM.patch'
- '0018-ozone-wayland-Use-new-shmen-API-when-loading-keymap.patch'
- '0019-ozone-wayland-Prepare-WaylandCanvasSurface-for-compl.patch'
- '0020-ozone-wayland-Reset-surface-contents-in-a-safe-way.patch'
- '0021-Ozone-Wayland-Manager-make-mojo-calls-on-IO-thread.patch'
- '0022-ozone-wayland-Manager-tests-exercise-tests-with-mojo.patch'
- '0023-ozone-wayland-Fix-broken-software-rendering-path.patch'
- '0001-v4l2_device-CanCreateEGLImageFrom-support-all-ARM-So.patch'
- '0001-Add-support-for-V4L2VDA-on-Linux.patch'
- '0002-Add-mmap-via-libv4l-to-generic_v4l2_device.patch'
+_mb_wayland_patches=(
'0001-ozone-wayland-Fix-method-prototype-match.patch'
+ 'V4L2/0001-Add-support-for-V4L2VDA-on-Linux.patch'
+ 'V4L2/0002-Add-mmap-via-libv4l-to-generic_v4l2_device.patch'
+)
+
+_bugfix_patches=(
+ '0001-ozone-wayland-Prepare-WaylandCanvasSurface-for-compl.patch'
+ '0002-ozone-wayland-Sway-avoid-sending-presentation-early.patch'
+ '0003-Ozone-Wayland-Manager-make-mojo-calls-on-IO-thread.patch'
+ '0004-ozone-wayland-Fix-broken-software-rendering-path.patch'
+ '0005-ozone-wayland-Use-mutex-before-accessing-surfaces-ma.patch'
)
prepare() {
@@ -135,9 +120,6 @@ prepare() {
third_party/blink/renderer/core/xml/parser/xml_document_parser.cc \
third_party/libxml/chromium/libxml_utils.cc
- # https://crbug.com/956061
- patch -Np1 -i ../chromium-fix-window-flash-for-some-WMs.patch
-
# Load Widevine CDM if available
patch -Np1 -i ../chromium-widevine.patch
@@ -147,27 +129,24 @@ prepare() {
# https://bugs.gentoo.org/661880#c21
patch -Np1 -i ../chromium-system-icu.patch
- # https://github.com/ungoogled-software/ungoogled-chromium-debian/issues/7
- patch -Np1 -i ../chromium-remove-const.patch
-
# chromium-ozone-wayland
- for PATCH in ${_general_patches[@]}
+ for PATCH in ${_mb_general_patches[@]}
do
echo "Applying $PATCH"
patch -Np1 -i $srcdir/meta-browser-${_meta_browser_sha}/recipes-browser/chromium/files/${PATCH}
done
- for PATCH in ${_wayland_patches[@]}
+ for PATCH in ${_mb_wayland_patches[@]}
do
echo "Applying $PATCH"
patch -Np1 -i $srcdir/meta-browser-${_meta_browser_sha}/recipes-browser/chromium/chromium-ozone-wayland/${PATCH}
done
- # https://chromium-review.googlesource.com/c/chromium/src/+/1718406
- patch -Np1 -i ../chromium-mutex-surfaces.patch
-
- # https://chromium-review.googlesource.com/c/chromium/src/+/1719013
- patch -Np1 -i ../chromium-sway-presentation.patch
+ for PATCH in ${_bugfix_patches[@]}
+ do
+ echo "Applying $PATCH"
+ patch -Np1 -i $srcdir/${PATCH}
+ done
# https://chromium-review.googlesource.com/c/chromium/src/+/1647154
patch -Np1 -i ../Added-HiDPI-support-for-Ozone-Wayland.patch
@@ -211,13 +190,6 @@ build() {
export AR=ar
export NM=nm
- if check_buildoption ccache y; then
- # Avoid falling back to preprocessor mode when sources contain time macros
- export CCACHE_SLOPPINESS=time_macros
- export CC="ccache $CC"
- export CXX="ccache $CXX"
- fi
-
local _flags=(
'custom_toolchain="//build/toolchain/linux/unbundle:default"'
'host_toolchain="//build/toolchain/linux/unbundle:default"'
@@ -250,6 +222,12 @@ build() {
"google_default_client_secret=\"${_google_default_client_secret}\""
)
+ if check_buildoption ccache y; then
+ # Avoid falling back to preprocessor mode when sources contain time macros
+ export CCACHE_SLOPPINESS=time_macros
+ _flags+=('cc_wrapper="ccache"')
+ fi
+
# Facilitate deterministic builds (taken from build/config/compiler/BUILD.gn)
CFLAGS+=' -Wno-builtin-macro-redefined'
CXXFLAGS+=' -Wno-builtin-macro-redefined'
diff --git a/chromium-fix-window-flash-for-some-WMs.patch b/chromium-fix-window-flash-for-some-WMs.patch
deleted file mode 100644
index f977cbf38cc4..000000000000
--- a/chromium-fix-window-flash-for-some-WMs.patch
+++ /dev/null
@@ -1,98 +0,0 @@
-From 90e226ba50c98b5e60f74f9dce998b17117f9051 Mon Sep 17 00:00:00 2001
-From: Peng Huang <penghuang@chromium.org>
-Date: Tue, 7 May 2019 13:16:21 +0000
-Subject: [PATCH] Fix window flash for some WMs
-
-Bug: 956061
-Change-Id: I0d8d196395e70006a8fdc770f1e4a5ba6f93dd57
-Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1597388
-Commit-Queue: Peng Huang <penghuang@chromium.org>
-Reviewed-by: Antoine Labour <piman@chromium.org>
-Cr-Commit-Position: refs/heads/master@{#657215}
----
- ui/gl/BUILD.gn | 5 ++++-
- ui/gl/gl_surface_glx.cc | 41 ++++++++++++++++++++++++++++-------------
- 2 files changed, 32 insertions(+), 14 deletions(-)
-
-diff --git a/ui/gl/BUILD.gn b/ui/gl/BUILD.gn
-index 50df0e4085..1753dd480b 100644
---- a/ui/gl/BUILD.gn
-+++ b/ui/gl/BUILD.gn
-@@ -274,7 +274,10 @@ jumbo_component("gl") {
- "//build/config/linux:xext",
- ]
-
-- deps += [ "//ui/gfx/x" ]
-+ deps += [
-+ "//ui/base/x",
-+ "//ui/gfx/x",
-+ ]
- }
- if (is_win) {
- sources += [
-diff --git a/ui/gl/gl_surface_glx.cc b/ui/gl/gl_surface_glx.cc
-index f4c13bed18..777bf767cb 100644
---- a/ui/gl/gl_surface_glx.cc
-+++ b/ui/gl/gl_surface_glx.cc
-@@ -21,6 +21,7 @@
- #include "base/time/time.h"
- #include "base/trace_event/trace_event.h"
- #include "build/build_config.h"
-+#include "ui/base/x/x11_util.h"
- #include "ui/events/platform/platform_event_source.h"
- #include "ui/gfx/x/x11.h"
- #include "ui/gfx/x/x11_connection.h"
-@@ -431,7 +432,9 @@ bool GLSurfaceGLX::InitializeOneOff() {
- }
-
- const XVisualInfo& visual_info =
-- gl::GLVisualPickerGLX::GetInstance()->rgba_visual();
-+ ui::IsCompositingManagerPresent()
-+ ? gl::GLVisualPickerGLX::GetInstance()->rgba_visual()
-+ : gl::GLVisualPickerGLX::GetInstance()->system_visual();
- g_visual = visual_info.visual;
- g_depth = visual_info.depth;
- g_colormap =
-@@ -581,18 +584,30 @@ bool NativeViewGLSurfaceGLX::Initialize(GLSurfaceFormat format) {
- }
- size_ = gfx::Size(attributes.width, attributes.height);
-
-- XSetWindowAttributes swa;
-- memset(&swa, 0, sizeof(swa));
-- swa.background_pixmap = 0;
-- swa.bit_gravity = NorthWestGravity;
-- swa.colormap = g_colormap;
-- swa.background_pixel = 0;
-- swa.border_pixel = 0;
-- window_ = XCreateWindow(
-- gfx::GetXDisplay(), parent_window_, 0 /* x */, 0 /* y */, size_.width(),
-- size_.height(), 0 /* border_width */, g_depth, InputOutput, g_visual,
-- CWBackPixmap | CWBitGravity | CWColormap | CWBackPixel | CWBorderPixel,
-- &swa);
-+ XSetWindowAttributes swa = {
-+ .background_pixmap = 0,
-+ .bit_gravity = NorthWestGravity,
-+ .colormap = g_colormap,
-+ .background_pixel = 0, // ARGB(0,0,0,0) for compositing WM
-+ .border_pixel = 0,
-+ };
-+ auto value_mask = CWBackPixmap | CWBitGravity | CWColormap | CWBorderPixel;
-+ if (ui::IsCompositingManagerPresent() &&
-+ XVisualIDFromVisual(attributes.visual) == XVisualIDFromVisual(g_visual)) {
-+ // When parent and child are using the same visual, the back buffer will be
-+ // shared between parent and child. If WM compositing is enabled, we set
-+ // child's background pixel to ARGB(0,0,0,0), so ARGB(0,0,0,0) will be
-+ // filled to the shared buffer, when the child window is mapped. It can
-+ // avoid an annoying flash when the child window is mapped below.
-+ // If WM compositing is disabled, we don't set the background pixel, so
-+ // nothing will be draw when the child window is mapped.
-+ value_mask |= CWBackPixel;
-+ }
-+
-+ window_ =
-+ XCreateWindow(gfx::GetXDisplay(), parent_window_, 0 /* x */, 0 /* y */,
-+ size_.width(), size_.height(), 0 /* border_width */,
-+ g_depth, InputOutput, g_visual, value_mask, &swa);
- if (!window_) {
- LOG(ERROR) << "XCreateWindow failed";
- return false;
diff --git a/chromium-mutex-surfaces.patch b/chromium-mutex-surfaces.patch
deleted file mode 100644
index c96fbb3124b0..000000000000
--- a/chromium-mutex-surfaces.patch
+++ /dev/null
@@ -1,123 +0,0 @@
-commit e4085b7e427a848fea61980252f17e5a3676a9ea
-Author: Maksim Sisov <msisov@igalia.com>
-Date: Thu Jul 25 16:22:09 2019 +0300
-
- [ozone/wayland] Use mutex before accessing surfaces map.
-
- We must make sure that accessing surfaces map from different threads
- is safe. Otherwise, this is subject to races and unexpected crashes.
-
- Bug: 987950
- Change-Id: I2e70e9c1ad48943be518c3571b7ca1fb91f8d51b
-
-diff --git a/ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.cc b/ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.cc
-index 72d2419b5f84..f0081ca725c5 100644
---- a/ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.cc
-+++ b/ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.cc
-@@ -135,6 +135,8 @@ bool GbmPixmapWayland::ScheduleOverlayPlane(
- const gfx::RectF& crop_rect,
- bool enable_blend,
- std::unique_ptr<gfx::GpuFence> gpu_fence) {
-+ base::AutoLock scoped_lock(*(buffer_manager_->lock()));
-+
- auto* surface = buffer_manager_->GetSurface(widget);
- DCHECK(surface);
- GbmSurfacelessWayland* surfaceless =
-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 63bfa3032fde..2f3499e93589 100644
---- a/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.cc
-+++ b/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.cc
-@@ -43,6 +43,8 @@ void WaylandBufferManagerGpu::OnSubmission(gfx::AcceleratedWidget widget,
- gfx::SwapResult swap_result) {
- DCHECK(io_thread_runner_->BelongsToCurrentThread());
- DCHECK_NE(widget, gfx::kNullAcceleratedWidget);
-+ base::AutoLock scoped_lock(*lock());
-+
- 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
-@@ -64,6 +66,8 @@ void WaylandBufferManagerGpu::OnPresentation(
- const gfx::PresentationFeedback& feedback) {
- DCHECK(io_thread_runner_->BelongsToCurrentThread());
- DCHECK_NE(widget, gfx::kNullAcceleratedWidget);
-+ base::AutoLock scoped_lock(*lock());
-+
- 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
-@@ -80,15 +84,20 @@ void WaylandBufferManagerGpu::OnPresentation(
-
- void WaylandBufferManagerGpu::RegisterSurface(gfx::AcceleratedWidget widget,
- WaylandSurfaceGpu* surface) {
-+ base::AutoLock scoped_lock(lock_);
- widget_to_surface_map_.insert(std::make_pair(widget, surface));
- }
-
- void WaylandBufferManagerGpu::UnregisterSurface(gfx::AcceleratedWidget widget) {
-+ base::AutoLock scoped_lock(lock_);
- widget_to_surface_map_.erase(widget);
- }
-
- WaylandSurfaceGpu* WaylandBufferManagerGpu::GetSurface(
-- gfx::AcceleratedWidget widget) const {
-+ gfx::AcceleratedWidget widget) {
-+ // Before accessing the map, the |lock_| must be acquired.
-+ lock_.AssertAcquired();
-+
- WaylandSurfaceGpu* surface = nullptr;
- auto it = widget_to_surface_map_.find(widget);
- if (it != widget_to_surface_map_.end())
-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 87439610cfc3..d1a34357a6a0 100644
---- a/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.h
-+++ b/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.h
-@@ -8,6 +8,7 @@
- #include <memory>
-
- #include "base/macros.h"
-+#include "base/synchronization/lock.h"
- #include "base/threading/sequenced_task_runner_handle.h"
- #include "base/threading/thread_checker.h"
- #include "mojo/public/cpp/bindings/associated_binding.h"
-@@ -43,6 +44,10 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu {
- WaylandBufferManagerGpu();
- ~WaylandBufferManagerGpu() override;
-
-+ // Whenever GetSurface is called, the caller must ensure to lock the mutex
-+ // before that call.
-+ base::Lock* lock() { return &lock_; }
-+
- // WaylandBufferManagerGpu overrides:
- void SetWaylandBufferManagerHost(
- BufferManagerHostPtr buffer_manager_host_ptr) override;
-@@ -66,7 +71,9 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu {
- void RegisterSurface(gfx::AcceleratedWidget widget,
- WaylandSurfaceGpu* surface);
- void UnregisterSurface(gfx::AcceleratedWidget widget);
-- WaylandSurfaceGpu* GetSurface(gfx::AcceleratedWidget widget) const;
-+ // A client of this method must always get and acquire lock before doing
-+ // any manipulations with the surface. Once done, the lock must be released.
-+ WaylandSurfaceGpu* GetSurface(gfx::AcceleratedWidget widget);
-
- // 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
-@@ -156,7 +163,8 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu {
- mojo::AssociatedBinding<ozone::mojom::WaylandBufferManagerGpu>
- associated_binding_;
-
-- std::map<gfx::AcceleratedWidget, WaylandSurfaceGpu*> widget_to_surface_map_;
-+ std::map<gfx::AcceleratedWidget, WaylandSurfaceGpu*>
-+ widget_to_surface_map_; // Guarded by |lock_|.
-
- // This task runner can be used to pass messages back to the same thread,
- // where the commit buffer request came from. For example, swap requests come
-@@ -171,6 +179,9 @@ class WaylandBufferManagerGpu : public ozone::mojom::WaylandBufferManagerGpu {
- // needed to ensure mojo calls happen on a right sequence.
- scoped_refptr<base::SingleThreadTaskRunner> io_thread_runner_;
-
-+ // Protects access to |widget_to_surface_map_|.
-+ base::Lock lock_;
-+
- DISALLOW_COPY_AND_ASSIGN(WaylandBufferManagerGpu);
- };
-
diff --git a/chromium-skia-harmony.patch b/chromium-skia-harmony.patch
index 949c8f020ce3..c96d07e11489 100644
--- a/chromium-skia-harmony.patch
+++ b/chromium-skia-harmony.patch
@@ -1,12 +1,13 @@
---- third_party/skia/src/ports/SkFontHost_FreeType.cpp.orig 2019-01-20 10:54:56.415239030 +0000
-+++ third_party/skia/src/ports/SkFontHost_FreeType.cpp 2019-01-20 10:55:05.695307733 +0000
-@@ -121,8 +121,8 @@ public:
+--- third_party/skia/src/ports/SkFontHost_FreeType.cpp.orig 2019-07-19 11:08:34.770972665 +0000
++++ third_party/skia/src/ports/SkFontHost_FreeType.cpp 2019-07-19 11:08:44.274442065 +0000
+@@ -128,9 +128,9 @@ public:
: fGetVarDesignCoordinates(nullptr)
, fGetVarAxisFlags(nullptr)
, fLibrary(nullptr)
- , fIsLCDSupported(false)
-- , fLCDExtra(0)
+ , fIsLCDSupported(true)
+ , fLightHintingIsYOnly(false)
+- , fLCDExtra(0)
+ , fLCDExtra(2)
{
if (FT_New_Library(&gFTMemory, &fLibrary)) {
diff --git a/chromium-sway-presentation.patch b/chromium-sway-presentation.patch
deleted file mode 100644
index 3d06fcebb1df..000000000000
--- a/chromium-sway-presentation.patch
+++ /dev/null
@@ -1,71 +0,0 @@
-commit 5682b344c0dabc6d7047363f9c877dcf4c0add72
-Author: Maksim Sisov <msisov@igalia.com>
-Date: Fri Jul 26 14:33:28 2019 +0300
-
- [ozone/wayland] Sway: avoid sending presentation early.
-
- In Sway, presentation callbacks may come much earlier than we send
- submission callbacks. That results in unexpected crashes in the
- GbmSurfacelessWayland, because of early presentation callbacks.
- Shortly speaking, a submitted frame may not receive the submission
- callback and not be moved to the list of waiting for a presentation
- frames. That means GbmSurfacelessWayland::OnPresentation simply
- accesses an invalid pointer to a frame, for which the presentation
- feedback comes.
-
- Bug: 974456
- Change-Id: Iae7ab57a00d06f0dde6057ed05df885239e099bd
-
-diff --git a/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.cc b/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.cc
-index eed48394602f..cd3245390fdf 100644
---- a/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.cc
-+++ b/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.cc
-@@ -228,6 +228,12 @@ class WaylandBufferManagerHost::Surface {
- // surface can tell the gpu about successful swap.
- bool released = true;
-
-+ // In some cases, a presentation feedback can come earlier than we fire a
-+ // submission callback. Thus, instead of sending it immediately to the GPU
-+ // process, we store it and fire as soon as the submission callback is
-+ // fired.
-+ bool needs_send_feedback = false;
-+
- gfx::PresentationFeedback feedback;
-
- DISALLOW_COPY_AND_ASSIGN(WaylandBuffer);
-@@ -355,6 +361,10 @@ class WaylandBufferManagerHost::Surface {
- void CompleteSubmission() {
- DCHECK(submitted_buffer_);
- auto id = submitted_buffer_->buffer_id;
-+
-+ auto feedback = std::move(submitted_buffer_->feedback);
-+ bool needs_send_feedback = submitted_buffer_->needs_send_feedback;
-+
- prev_submitted_buffer_ = submitted_buffer_;
- submitted_buffer_ = nullptr;
- // We can now complete the latest submission. We had to wait for this
-@@ -370,14 +380,21 @@ class WaylandBufferManagerHost::Surface {
- OnPresentation(id, gfx::PresentationFeedback(
- base::TimeTicks::Now(), base::TimeDelta(),
- GetPresentationKindFlags(0)));
-+ } else if (needs_send_feedback) {
-+ OnPresentation(id, std::move(feedback));
- }
- }
-
- void OnPresentation(uint32_t buffer_id,
- const gfx::PresentationFeedback& feedback) {
-- // The order of submission and presentation callbacks is checked on the GPU
-- // side, but it must never happen, because the Submission is called
-- // immediately after the buffer is swapped.
-+ // The order of submission and presentation callbacks cannot be controlled.
-+ // Some Wayland compositors may fire presentation callbacks earlier than we
-+ // are able to send submission callbacks is bad. Thus, handle it here.
-+ if (submitted_buffer_ && submitted_buffer_->buffer_id == buffer_id) {
-+ submitted_buffer_->feedback = feedback;
-+ return;
-+ }
-+
- buffer_manager_->OnPresentation(window_->GetWidget(), buffer_id, feedback);
- }
-