summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Playfair Cal2019-09-11 09:36:32 +1000
committerDaniel Playfair Cal2019-09-11 09:36:32 +1000
commit3b8ed451c5c515ab91e8c0ddbbd85b71d3d77ef5 (patch)
tree136e51e2872504a2a6a7e1daff7cee07bd7b8948
parent249a3e483f2c540bd0604def89e61382e3a98bb6 (diff)
downloadaur-3b8ed451c5c515ab91e8c0ddbbd85b71d3d77ef5.tar.gz
77.0.3865.75 draft
-rw-r--r--.SRCINFO41
-rw-r--r--0001-ozone-wayland-Prepare-WaylandCanvasSurface-for-compl.patch655
-rw-r--r--0001-ozone-wayland-Sway-avoid-sending-presentation-early.patch (renamed from 0002-ozone-wayland-Sway-avoid-sending-presentation-early.patch)24
-rw-r--r--0002-ozone-wayland-Use-mutex-before-accessing-surfaces-ma.patch (renamed from 0005-ozone-wayland-Use-mutex-before-accessing-surfaces-ma.patch)17
-rw-r--r--0003-Ozone-Wayland-Manager-make-mojo-calls-on-IO-thread.patch271
-rw-r--r--0003-ozone-wayland-Stop-using-wl_display_roundtrip.patch (renamed from 0007-ozone-wayland-Stop-using-wl_display_roundtrip.patch)8
-rw-r--r--0004-ozone-wayland-Extract-window-management-methods-to-o.patch (renamed from 0010-ozone-wayland-Extract-window-management-methods-to-o.patch)22
-rw-r--r--0004-ozone-wayland-Fix-broken-software-rendering-path.patch108
-rw-r--r--0005-ozone-wayland-Do-not-use-possibly-blocking-dispatch-.patch (renamed from 0011-ozone-wayland-Do-not-use-possibly-blocking-dispatch-.patch)17
-rw-r--r--0006-IWYU-include-memory-in-one_euro_filter.h-as-it-uses-.patch35
-rw-r--r--0006-ozone-wayland-Reset-surface-contents-in-a-safe-way.patch171
-rw-r--r--0008-ozone-wayland-Added-HiDPI-support-for-Ozone-Wayland.patch991
-rw-r--r--0009-Fixed-positioning-and-sizes-of-menus-when-the-scale-.patch315
-rw-r--r--PKGBUILD70
14 files changed, 117 insertions, 2628 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 6ee12633e633..e1197a068459 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,6 +1,6 @@
pkgbase = chromium-ozone
pkgdesc = Chromium built with patches for wayland support via Ozone
- pkgver = 76.0.3809.132
+ pkgver = 77.0.3865.75
pkgrel = 1
url = https://www.chromium.org/Home
install = chromium.install
@@ -45,7 +45,6 @@ pkgbase = chromium-ozone
depends = ffmpeg
depends = flac
depends = libwebp
- depends = minizip
depends = libxslt
depends = freetype2
depends = opus
@@ -57,40 +56,30 @@ pkgbase = chromium-ozone
conflicts = chromium
options = debug
options = !strip
- source = https://commondatastorage.googleapis.com/chromium-browser-official/chromium-76.0.3809.132.tar.xz
+ source = https://commondatastorage.googleapis.com/chromium-browser-official/chromium-77.0.3865.75.tar.xz
source = chromium-launcher-6.tar.gz::https://github.com/foutrelis/chromium-launcher/archive/v6.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-widevine.patch
source = chromium-skia-harmony.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 = 0006-ozone-wayland-Reset-surface-contents-in-a-safe-way.patch
- source = 0007-ozone-wayland-Stop-using-wl_display_roundtrip.patch
- source = 0008-ozone-wayland-Added-HiDPI-support-for-Ozone-Wayland.patch
- source = 0009-Fixed-positioning-and-sizes-of-menus-when-the-scale-.patch
- source = 0010-ozone-wayland-Extract-window-management-methods-to-o.patch
- source = 0011-ozone-wayland-Do-not-use-possibly-blocking-dispatch-.patch
- sha256sums = d54e4640b5e399d170dffbc5bcff65157eb1b29314b94b5d808f727d9ce45241
+ source = 0001-ozone-wayland-Sway-avoid-sending-presentation-early.patch
+ source = 0002-ozone-wayland-Use-mutex-before-accessing-surfaces-ma.patch
+ source = 0003-ozone-wayland-Stop-using-wl_display_roundtrip.patch
+ source = 0004-ozone-wayland-Extract-window-management-methods-to-o.patch
+ source = 0005-ozone-wayland-Do-not-use-possibly-blocking-dispatch-.patch
+ source = 0006-IWYU-include-memory-in-one_euro_filter.h-as-it-uses-.patch
+ sha256sums = eb952ff241e719cbdcc2aae1832ecc1dd2263736ab38ee1dbf88ac9120119789
sha256sums = 04917e3cd4307d8e31bfb0027a5dce6d086edb10ff8a716024fbb8bb0c7dccf1
sha256sums = d87957d01be9fb59faf5fde523eb87a8256605b1533171416b7a56bfcbd6d056
sha256sums = e2d284311f49c529ea45083438a768db390bde52949995534034d2a814beab89
sha256sums = d081f2ef8793544685aad35dea75a7e6264a2cb987ff3541e6377f4a3650a28b
sha256sums = 771292942c0901092a402cc60ee883877a99fb804cb54d568c8c6c94565a48e1
- sha256sums = 1fe3bb02ffd0445da8ea3b9eb09e8dff6b7bdd1ca26f4b439310a3e94aa16ebf
- sha256sums = d9c5932f1af91a8c2e8b7687d9ad013d5895e3e03811d9f03e674afb77031ce5
- sha256sums = 424c5c0e5b6ded87d0c00dd4755eb6e63bfdf42233ee60c354729f5cbba82334
- sha256sums = fecdfa694a84b4dc688ec20970ea18b11d9e332b8423a935ba35cd3fae7485a5
- sha256sums = 2359fdd84a3c10eeb576b15cfea86a34867097cb3e3d30ade6c823cf0d538d99
- sha256sums = 13be86e54b14f5a9f21e371a0f2762c5ff9a4204877ded60600f5950f6a14885
- sha256sums = ede2a4c0283f01f7653c0caabd8439d96c27da16dd557ebb0730c0b3e7134097
- sha256sums = 9996ddaa8a83c58dcbe45e21746ffe41a9f8b56edc71a16090ebdb6adbc74541
- sha256sums = 6f4fc0a82443f9bfaeecfd1a463b4bc10dfa29b9357f17592dfac8332d27cb3c
- sha256sums = 470cf88aa6878bfaaf74f00791d33f4f922f31a13e0503b8bb11edb4bb89d29c
- sha256sums = aaefa3a868024aa1eb118236bd528986db972646f762418764b5f0ab326468b0
+ sha256sums = 333a4ecac50f1f2a2545132dc97bd22ccb1a0623bd5a5d86487327e8ee6fde3d
+ sha256sums = 5d1e93f1930a53d2cee7d7cff94b4aba3a91dc15e13f667ce56956b2d08222cc
+ sha256sums = 19dc0c5b521ad252b75a42cad254ced431f790bb71d1c048eb748a65e29aeb69
+ sha256sums = d0ed9879427db1412b679c2ab0ff4da83698f6dfe389080d272ec85716478b43
+ sha256sums = 465dbcefbe8b01d242491bb527da8ecb466654262162b9bdc96bbf13ee8b864f
+ sha256sums = c5ea9e17c745de25ce9d1935883b538e660a406b07fc3ac72354e5a24a5354f8
pkgname = chromium-ozone
diff --git a/0001-ozone-wayland-Prepare-WaylandCanvasSurface-for-compl.patch b/0001-ozone-wayland-Prepare-WaylandCanvasSurface-for-compl.patch
deleted file mode 100644
index 33f838075076..000000000000
--- a/0001-ozone-wayland-Prepare-WaylandCanvasSurface-for-compl.patch
+++ /dev/null
@@ -1,655 +0,0 @@
-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 01/11] [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/0001-ozone-wayland-Sway-avoid-sending-presentation-early.patch
index c1f5e7ac317a..9b4c074dab49 100644
--- a/0002-ozone-wayland-Sway-avoid-sending-presentation-early.patch
+++ b/0001-ozone-wayland-Sway-avoid-sending-presentation-early.patch
@@ -1,7 +1,7 @@
-From c644b4aba05233a8a78d7708a98d9a583ff78a27 Mon Sep 17 00:00:00 2001
+From a8202f907f739a2e68e401d3e36136270bd6fc7a Mon Sep 17 00:00:00 2001
From: Maksim Sisov <msisov@igalia.com>
Date: Tue, 30 Jul 2019 05:53:48 +0000
-Subject: [PATCH 02/11] [ozone/wayland] Sway: avoid sending presentation early.
+Subject: [PATCH 1/6] [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
@@ -32,7 +32,7 @@ Cr-Commit-Position: refs/heads/master@{#682157}
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
+index 91f497052fae..95f20b1fb288 100644
--- a/ui/ozone/platform/wayland/BUILD.gn
+++ b/ui/ozone/platform/wayland/BUILD.gn
@@ -173,6 +173,8 @@ source_set("test_support") {
@@ -66,10 +66,10 @@ index f3593766eed8..ace5279e838e 100644
// |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
+index 3f163a012c31..1bcf85261b41 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 {
+@@ -228,6 +228,12 @@ class WaylandBufferManagerHost::Surface {
// surface can tell the gpu about successful swap.
bool released = true;
@@ -82,7 +82,7 @@ index bbcfa84016f9..5f7efebac400 100644
gfx::PresentationFeedback feedback;
DISALLOW_COPY_AND_ASSIGN(WaylandBuffer);
-@@ -334,6 +340,11 @@ class WaylandBufferManagerHost::Surface {
+@@ -355,6 +361,11 @@ class WaylandBufferManagerHost::Surface {
void CompleteSubmission() {
DCHECK(submitted_buffer_);
auto id = submitted_buffer_->buffer_id;
@@ -94,7 +94,7 @@ index bbcfa84016f9..5f7efebac400 100644
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 {
+@@ -370,14 +381,22 @@ class WaylandBufferManagerHost::Surface {
OnPresentation(id, gfx::PresentationFeedback(
base::TimeTicks::Now(), base::TimeDelta(),
GetPresentationKindFlags(0)));
@@ -121,7 +121,7 @@ index bbcfa84016f9..5f7efebac400 100644
}
diff --git a/ui/ozone/platform/wayland/test/mock_surface.cc b/ui/ozone/platform/wayland/test/mock_surface.cc
-index 9d2333683a41..6ee1c0a9c543 100644
+index b086bdc85416..fa53a037669b 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,
@@ -149,7 +149,7 @@ index 9d2333683a41..6ee1c0a9c543 100644
}
void Commit(wl_client* client, wl_resource* resource) {
-@@ -85,4 +92,37 @@ MockSurface* MockSurface::FromResource(wl_resource* resource) {
+@@ -89,4 +96,37 @@ MockSurface* MockSurface::FromResource(wl_resource* resource) {
return GetUserDataAs<MockSurface>(resource);
}
@@ -188,10 +188,10 @@ index 9d2333683a41..6ee1c0a9c543 100644
+
} // 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
+index d283e44b2fe9..1d781d03d3dc 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 {
+@@ -51,10 +51,24 @@ class MockSurface : public ServerObject {
}
MockXdgPopup* xdg_popup() const { return xdg_popup_.get(); }
@@ -376,5 +376,5 @@ index fddd426db690..110e3ffbc1c2 100644
std::vector<std::unique_ptr<GlobalObject>> globals_;
--
-2.22.0
+2.23.0
diff --git a/0005-ozone-wayland-Use-mutex-before-accessing-surfaces-ma.patch b/0002-ozone-wayland-Use-mutex-before-accessing-surfaces-ma.patch
index b04ec01fde86..7bb3d35002fb 100644
--- a/0005-ozone-wayland-Use-mutex-before-accessing-surfaces-ma.patch
+++ b/0002-ozone-wayland-Use-mutex-before-accessing-surfaces-ma.patch
@@ -1,8 +1,7 @@
-From fd1d8bfd55d5b1d073cbad3ebe8f058c49f3702a Mon Sep 17 00:00:00 2001
+From 296c7b4e9935aaed1d05d32416043a03f67e268d Mon Sep 17 00:00:00 2001
From: Maksim Sisov <msisov@igalia.com>
Date: Mon, 5 Aug 2019 16:14:47 +0300
-Subject: [PATCH 05/11] [ozone/wayland] Use mutex before accessing surfaces
- map.
+Subject: [PATCH 2/6] [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.
@@ -22,7 +21,7 @@ Change-Id: I2e70e9c1ad48943be518c3571b7ca1fb91f8d51b
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
+index 95f20b1fb288..3dbb00bc6239 100644
--- a/ui/ozone/platform/wayland/BUILD.gn
+++ b/ui/ozone/platform/wayland/BUILD.gn
@@ -30,6 +30,7 @@ source_set("wayland") {
@@ -34,10 +33,10 @@ index 686138bb614a..a1560a20fe23 100644
"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
+index 72d2419b5f84..48f2a7f655bd 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(
+@@ -135,10 +135,10 @@ bool GbmPixmapWayland::ScheduleOverlayPlane(
const gfx::RectF& crop_rect,
bool enable_blend,
std::unique_ptr<gfx::GpuFence> gpu_fence) {
@@ -200,10 +199,10 @@ index 87439610cfc3..631d715e719e 100644
};
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
+index 231d590296d9..d1e244e910c6 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(
+@@ -147,7 +147,7 @@ WaylandCanvasSurface::WaylandCanvasSurface(
WaylandBufferManagerGpu* buffer_manager,
gfx::AcceleratedWidget widget)
: buffer_manager_(buffer_manager), widget_(widget) {
@@ -273,5 +272,5 @@ index ace5279e838e..38d285317ab3 100644
} // namespace ui
--
-2.22.0
+2.23.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
deleted file mode 100644
index bf1f45114d7d..000000000000
--- a/0003-Ozone-Wayland-Manager-make-mojo-calls-on-IO-thread.patch
+++ /dev/null
@@ -1,271 +0,0 @@
-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 03/11] [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/0007-ozone-wayland-Stop-using-wl_display_roundtrip.patch b/0003-ozone-wayland-Stop-using-wl_display_roundtrip.patch
index 40da4077c1e1..5ccac7e792a7 100644
--- a/0007-ozone-wayland-Stop-using-wl_display_roundtrip.patch
+++ b/0003-ozone-wayland-Stop-using-wl_display_roundtrip.patch
@@ -1,7 +1,7 @@
-From baa6e8592ccb0f4975676e9d1cac4ffc8c1b6e2f Mon Sep 17 00:00:00 2001
+From e58ed0f56e9ffbee6222b9b8b3f62be4acde72ac Mon Sep 17 00:00:00 2001
From: Maksim Sisov <msisov@igalia.com>
Date: Thu, 8 Aug 2019 11:32:57 +0000
-Subject: [PATCH 07/11] [ozone/wayland] Stop using wl_display_roundtrip
+Subject: [PATCH 3/6] [ozone/wayland] Stop using wl_display_roundtrip
According to the Wayland documentation, wl_display_roundtrip is a
blocking call that can block if the event queue is empty. That is,
@@ -53,7 +53,7 @@ Cr-Commit-Position: refs/heads/master@{#685143}
5 files changed, 175 insertions(+), 61 deletions(-)
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 a6759bb798f4..f58a9f1ed8fb 100644
+index 1bcf85261b41..9355d47f2ec7 100644
--- a/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.cc
+++ b/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.cc
@@ -63,10 +63,22 @@ class WaylandBufferManagerHost::Surface {
@@ -468,5 +468,5 @@ index f63b92d34a50..9d2e1077d79f 100644
};
--
-2.22.0
+2.23.0
diff --git a/0010-ozone-wayland-Extract-window-management-methods-to-o.patch b/0004-ozone-wayland-Extract-window-management-methods-to-o.patch
index c784acd8e0f1..122ec9a81797 100644
--- a/0010-ozone-wayland-Extract-window-management-methods-to-o.patch
+++ b/0004-ozone-wayland-Extract-window-management-methods-to-o.patch
@@ -1,8 +1,8 @@
-From 1cac377724089974aef3dd66b215301bfd6c3dbd Mon Sep 17 00:00:00 2001
+From 1a25d1eb6a0a38f27d62f3d872079156e3542d62 Mon Sep 17 00:00:00 2001
From: Maksim Sisov <msisov@igalia.com>
Date: Fri, 26 Jul 2019 04:56:22 +0000
-Subject: [PATCH 10/11] [ozone/wayland]: Extract window management methods to
- own class
+Subject: [PATCH 4/6] [ozone/wayland]: Extract window management methods to own
+ class
WaylandConnection still has been overloaded with different tasks.
@@ -35,7 +35,7 @@ Cr-Commit-Position: refs/heads/master@{#681191}
create mode 100644 ui/ozone/platform/wayland/host/wayland_window_manager_unittests.cc
diff --git a/ui/ozone/platform/wayland/BUILD.gn b/ui/ozone/platform/wayland/BUILD.gn
-index a1560a20fe23..157d1beea880 100644
+index 3dbb00bc6239..8c6f4a0dece6 100644
--- a/ui/ozone/platform/wayland/BUILD.gn
+++ b/ui/ozone/platform/wayland/BUILD.gn
@@ -74,6 +74,8 @@ source_set("wayland") {
@@ -47,7 +47,7 @@ index a1560a20fe23..157d1beea880 100644
"host/wayland_zwp_linux_dmabuf.cc",
"host/wayland_zwp_linux_dmabuf.h",
"host/xdg_popup_wrapper.h",
-@@ -250,6 +252,7 @@ source_set("wayland_unittests") {
+@@ -249,6 +251,7 @@ source_set("wayland_unittests") {
"host/wayland_pointer_unittest.cc",
"host/wayland_screen_unittest.cc",
"host/wayland_touch_unittest.cc",
@@ -345,7 +345,7 @@ index ef372ad794d3..126b252624ab 100644
return window->GetWidget();
return gfx::kNullAcceleratedWidget;
diff --git a/ui/ozone/platform/wayland/host/wayland_window.cc b/ui/ozone/platform/wayland/host/wayland_window.cc
-index 9afed0cc87fb..12b3661985a6 100644
+index cf4e41391056..64364a3064f3 100644
--- a/ui/ozone/platform/wayland/host/wayland_window.cc
+++ b/ui/ozone/platform/wayland/host/wayland_window.cc
@@ -105,7 +105,7 @@ WaylandWindow::~WaylandWindow() {
@@ -376,7 +376,7 @@ index 9afed0cc87fb..12b3661985a6 100644
// Tooltip creation is an async operation. By the time Aura actually creates
// the tooltip, it is possible that the user has already moved the
-@@ -563,7 +564,8 @@ uint32_t WaylandWindow::DispatchEvent(const PlatformEvent& native_event) {
+@@ -566,7 +567,8 @@ uint32_t WaylandWindow::DispatchEvent(const PlatformEvent& native_event) {
// Parent window of the main menu window is not a popup, but rather an
// xdg surface.
DCHECK(!parent_window_->xdg_popup() && parent_window_->xdg_surface());
@@ -386,7 +386,7 @@ index 9afed0cc87fb..12b3661985a6 100644
if (window) {
ConvertEventLocationToTargetWindowLocation(GetBounds().origin(),
window->GetBounds().origin(),
-@@ -802,7 +804,8 @@ void WaylandWindow::MaybeTriggerPendingStateChange() {
+@@ -803,7 +805,8 @@ void WaylandWindow::MaybeTriggerPendingStateChange() {
WaylandWindow* WaylandWindow::GetParentWindow(
gfx::AcceleratedWidget parent_widget) {
@@ -396,7 +396,7 @@ index 9afed0cc87fb..12b3661985a6 100644
// If propagated parent has already had a child, it means that |this| is a
// submenu of a 3-dot menu. In aura, the parent of a 3-dot menu and its
-@@ -816,7 +819,7 @@ WaylandWindow* WaylandWindow::GetParentWindow(
+@@ -817,7 +820,7 @@ WaylandWindow* WaylandWindow::GetParentWindow(
if (parent_window && parent_window->child_window_)
return parent_window->child_window_;
if (!parent_window)
@@ -405,7 +405,7 @@ index 9afed0cc87fb..12b3661985a6 100644
return parent_window;
}
-@@ -873,7 +876,8 @@ void WaylandWindow::RemoveEnteredOutputId(struct wl_output* output) {
+@@ -874,7 +877,8 @@ void WaylandWindow::RemoveEnteredOutputId(struct wl_output* output) {
void WaylandWindow::UpdateCursorPositionFromEvent(
std::unique_ptr<Event> event) {
DCHECK(event->IsLocatedEvent());
@@ -806,5 +806,5 @@ index 000000000000..a38267564a0d
+
+} // namespace ui
--
-2.22.0
+2.23.0
diff --git a/0004-ozone-wayland-Fix-broken-software-rendering-path.patch b/0004-ozone-wayland-Fix-broken-software-rendering-path.patch
deleted file mode 100644
index 528d86643f84..000000000000
--- a/0004-ozone-wayland-Fix-broken-software-rendering-path.patch
+++ /dev/null
@@ -1,108 +0,0 @@
-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 04/11] [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/0011-ozone-wayland-Do-not-use-possibly-blocking-dispatch-.patch b/0005-ozone-wayland-Do-not-use-possibly-blocking-dispatch-.patch
index def2841ee476..01c0d8d2a510 100644
--- a/0011-ozone-wayland-Do-not-use-possibly-blocking-dispatch-.patch
+++ b/0005-ozone-wayland-Do-not-use-possibly-blocking-dispatch-.patch
@@ -1,8 +1,7 @@
-From 4f4c199c6654ef75319eabf3977e916b2a744d3f Mon Sep 17 00:00:00 2001
+From 3ab4f4ab9266f273b5846a518f9a50c3c455ae78 Mon Sep 17 00:00:00 2001
From: Maksim Sisov <msisov@igalia.com>
Date: Thu, 8 Aug 2019 11:47:41 +0000
-Subject: [PATCH 11/11] [ozone/wayland] Do not use possibly blocking dispatch
- API
+Subject: [PATCH 5/6] [ozone/wayland] Do not use possibly blocking dispatch API
Using wl_display_dispatch is a wrong thing to do as it is a blocking
method (see [1]). It can cause freezes and deadlocks.
@@ -215,10 +214,10 @@ index dcd6b75aa299..1f41fd6786b9 100644
void WaylandDataSource::UpdateDataMap(
diff --git a/ui/ozone/platform/wayland/host/wayland_keyboard.cc b/ui/ozone/platform/wayland/host/wayland_keyboard.cc
-index 181e6e56b4b6..69cd9686bdf8 100644
+index c082b30133e5..fbadb0e3b1e2 100644
--- a/ui/ozone/platform/wayland/host/wayland_keyboard.cc
+++ b/ui/ozone/platform/wayland/host/wayland_keyboard.cc
-@@ -165,7 +165,7 @@ void WaylandKeyboard::FlushInput(base::OnceClosure closure) {
+@@ -167,7 +167,7 @@ void WaylandKeyboard::FlushInput(base::OnceClosure closure) {
// get spurious repeats.
sync_callback_.reset(wl_display_sync(connection_->display()));
wl_callback_add_listener(sync_callback_.get(), &callback_listener_, this);
@@ -228,7 +227,7 @@ index 181e6e56b4b6..69cd9686bdf8 100644
void WaylandKeyboard::DispatchKey(uint32_t key,
diff --git a/ui/ozone/platform/wayland/host/wayland_window.cc b/ui/ozone/platform/wayland/host/wayland_window.cc
-index 12b3661985a6..cf0f3c336414 100644
+index 64364a3064f3..a03dde334c19 100644
--- a/ui/ozone/platform/wayland/host/wayland_window.cc
+++ b/ui/ozone/platform/wayland/host/wayland_window.cc
@@ -285,7 +285,6 @@ void WaylandWindow::ApplyPendingBounds() {
@@ -239,7 +238,7 @@ index 12b3661985a6..cf0f3c336414 100644
pending_bounds_dip_ = gfx::Rect();
connection_->ScheduleFlush();
-@@ -659,6 +658,8 @@ void WaylandWindow::HandleSurfaceConfigure(int32_t width,
+@@ -662,6 +661,8 @@ void WaylandWindow::HandleSurfaceConfigure(int32_t width,
delegate_->OnWindowStateChanged(state_);
}
@@ -249,7 +248,7 @@ index 12b3661985a6..cf0f3c336414 100644
delegate_->OnActivationChanged(is_active_);
diff --git a/ui/ozone/platform/wayland/host/wayland_window_unittest.cc b/ui/ozone/platform/wayland/host/wayland_window_unittest.cc
-index 8083f7a84dcd..5fdf4a6184ba 100644
+index 699d3cebe703..747b7dd60baf 100644
--- a/ui/ozone/platform/wayland/host/wayland_window_unittest.cc
+++ b/ui/ozone/platform/wayland/host/wayland_window_unittest.cc
@@ -677,19 +677,26 @@ TEST_P(WaylandWindowTest, HasCaptureUpdatedOnPointerEvents) {
@@ -311,5 +310,5 @@ index 9cac792bf630..c7c9fc079590 100644
// static
--
-2.22.0
+2.23.0
diff --git a/0006-IWYU-include-memory-in-one_euro_filter.h-as-it-uses-.patch b/0006-IWYU-include-memory-in-one_euro_filter.h-as-it-uses-.patch
new file mode 100644
index 000000000000..d412e6bfb949
--- /dev/null
+++ b/0006-IWYU-include-memory-in-one_euro_filter.h-as-it-uses-.patch
@@ -0,0 +1,35 @@
+From b5d3ed44285154ed3a96ba21c01862119559ce12 Mon Sep 17 00:00:00 2001
+From: Jose Dapena Paz <jose.dapena@lge.com>
+Date: Fri, 26 Jul 2019 16:18:17 +0000
+Subject: [PATCH 6/6] IWYU: include <memory> in one_euro_filter.h as it uses
+ std::unique_ptr
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Bug: 819294
+Change-Id: Ie1530f7046b0c8eb76e26adca530fa57c67ed876
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1720637
+Reviewed-by: Ella Ge <eirage@chromium.org>
+Commit-Queue: José Dapena Paz <jose.dapena@lge.com>
+Cr-Commit-Position: refs/heads/master@{#681321}
+---
+ third_party/one_euro_filter/src/one_euro_filter.h | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/third_party/one_euro_filter/src/one_euro_filter.h b/third_party/one_euro_filter/src/one_euro_filter.h
+index 7f8d15b62afa..a8cd0ab9a256 100644
+--- a/third_party/one_euro_filter/src/one_euro_filter.h
++++ b/third_party/one_euro_filter/src/one_euro_filter.h
+@@ -1,6 +1,8 @@
+ #ifndef ONE_EURO_ONE_EURO_FILTER_H_
+ #define ONE_EURO_ONE_EURO_FILTER_H_
+
++#include <memory>
++
+ #include "low_pass_filter.h"
+
+ namespace one_euro_filter {
+--
+2.23.0
+
diff --git a/0006-ozone-wayland-Reset-surface-contents-in-a-safe-way.patch b/0006-ozone-wayland-Reset-surface-contents-in-a-safe-way.patch
deleted file mode 100644
index 6cf070677427..000000000000
--- a/0006-ozone-wayland-Reset-surface-contents-in-a-safe-way.patch
+++ /dev/null
@@ -1,171 +0,0 @@
-From 739876012248a57964326a4dcc9f00039ad1ad73 Mon Sep 17 00:00:00 2001
-From: Maksim Sisov <msisov@igalia.com>
-Date: Tue, 4 Jun 2019 06:58:40 +0000
-Subject: [PATCH 06/11] [ozone/wayland] Reset surface contents in a safe way
-
-Currently, WaylandWindow may attach a null buffer to a surface,
-which makes the Wayland compositor skip the buffer release call even
-though there was a buffer attached.
-
-The skipped buffer release call results in a missed submission
-callback, and the Chromium display compositor starts to lag
-behind one frame.
-
-What is more, we no longer trigger a buffer swap completion
-callback before presention feedback is provided, which also
-results in DCHECK when checking the order of the callbacks.
-
-Bug: 968497
-Change-Id: I12494e78fa376d6c421b7366d0bddb52ae59a5af
-Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1636354
-Commit-Queue: Maksim Sisov <msisov@igalia.com>
-Reviewed-by: Robert Kroeger <rjkroege@chromium.org>
-Cr-Commit-Position: refs/heads/master@{#665833}
----
- .../host/wayland_buffer_manager_host.cc | 38 ++++++++++++++++++-
- .../host/wayland_buffer_manager_host.h | 6 +++
- .../platform/wayland/host/wayland_window.cc | 26 ++++++-------
- 3 files changed, 55 insertions(+), 15 deletions(-)
-
-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 5f7efebac400..a6759bb798f4 100644
---- a/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.cc
-+++ b/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.cc
-@@ -103,6 +103,14 @@ class WaylandBufferManagerHost::Surface {
-
- connection_->ScheduleFlush();
-
-+ // If the contents were reset, there is no buffer attached. It means we have
-+ // to behave the same way as if it was the very first frame. Check the
-+ // comment below where the |contents_reset_| is declared.
-+ if (contents_reset_) {
-+ prev_submitted_buffer_ = nullptr;
-+ contents_reset_ = false;
-+ }
-+
- // If it was the very first frame, the surface has not had a back buffer
- // before, and Wayland won't release the front buffer until next buffer is
- // attached. Thus, notify about successful submission immediately.
-@@ -166,13 +174,26 @@ class WaylandBufferManagerHost::Surface {
- wl_frame_callback_.reset();
- presentation_feedbacks_ = PresentationFeedbackQueue();
-
-- wl_surface_attach(window_->surface(), nullptr, 0, 0);
-+ ResetSurfaceContents();
-+
- prev_submitted_buffer_ = nullptr;
- submitted_buffer_ = nullptr;
-
- connection_->ScheduleFlush();
- }
-
-+ void ResetSurfaceContents() {
-+ wl_surface_attach(window_->surface(), nullptr, 0, 0);
-+ wl_surface_commit(window_->surface());
-+
-+ // We cannot reset |prev_submitted_buffer_| here as long as the surface
-+ // might have attached a new buffer and is about to receive a release
-+ // callback. Check more comments below where the variable is declared.
-+ contents_reset_ = true;
-+
-+ connection_->ScheduleFlush();
-+ }
-+
- private:
- using PresentationFeedbackQueue = base::queue<
- std::pair<uint32_t, wl::Object<struct wp_presentation_feedback>>>;
-@@ -449,6 +470,14 @@ class WaylandBufferManagerHost::Surface {
- // Previous submitted buffer.
- WaylandBuffer* prev_submitted_buffer_ = nullptr;
-
-+ // If WaylandWindow becomes hidden, it may need to attach a null buffer to the
-+ // surface it backed to avoid its contents shown on screen. However, it
-+ // means that the Wayland compositor no longer sends new buffer release events
-+ // as long as there has not been buffer attached and no submission callback is
-+ // sent. To avoid this, |contents_reset_| can be used as an identification of a
-+ // need to call submission callback manually.
-+ bool contents_reset_ = false;
-+
- DISALLOW_COPY_AND_ASSIGN(Surface);
- };
-
-@@ -620,6 +649,13 @@ void WaylandBufferManagerHost::DestroyBuffer(gfx::AcceleratedWidget widget,
- connection_->ScheduleFlush();
- }
-
-+void WaylandBufferManagerHost::ResetSurfaceContents(
-+ gfx::AcceleratedWidget widget) {
-+ auto* surface = GetSurface(widget);
-+ DCHECK(surface);
-+ surface->ResetSurfaceContents();
-+}
-+
- bool WaylandBufferManagerHost::CreateBuffer(gfx::AcceleratedWidget& widget,
- const gfx::Size& size,
- uint32_t buffer_id) {
-diff --git a/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.h b/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.h
-index a2dd899e2de0..63fa02b4089d 100644
---- a/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.h
-+++ b/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.h
-@@ -94,6 +94,12 @@ class WaylandBufferManagerHost : ozone::mojom::WaylandBufferManagerHost {
- uint32_t buffer_id,
- const gfx::Rect& damage_region) override;
-
-+ // When a surface is hidden, the client may want to detach the buffer attached
-+ // to the surface backed by |widget| to ensure Wayland does not present those
-+ // contents and do not composite in a wrong way. Otherwise, users may see the
-+ // contents of a hidden surface on their screens.
-+ void ResetSurfaceContents(gfx::AcceleratedWidget widget);
-+
- private:
- // This is an internal representation of a real surface, which holds a pointer
- // to WaylandWindow. Also, this object holds buffers, frame callbacks and
-diff --git a/ui/ozone/platform/wayland/host/wayland_window.cc b/ui/ozone/platform/wayland/host/wayland_window.cc
-index 4b0a9908a13e..3d4229f466ff 100644
---- a/ui/ozone/platform/wayland/host/wayland_window.cc
-+++ b/ui/ozone/platform/wayland/host/wayland_window.cc
-@@ -16,6 +16,7 @@
- #include "ui/events/event_utils.h"
- #include "ui/events/ozone/events_ozone.h"
- #include "ui/gfx/geometry/point_f.h"
-+#include "ui/ozone/platform/wayland/host/wayland_buffer_manager_host.h"
- #include "ui/ozone/platform/wayland/host/wayland_connection.h"
- #include "ui/ozone/platform/wayland/host/wayland_cursor_position.h"
- #include "ui/ozone/platform/wayland/host/wayland_output_manager.h"
-@@ -300,22 +301,19 @@ void WaylandWindow::Show() {
- void WaylandWindow::Hide() {
- if (is_tooltip_) {
- parent_window_ = nullptr;
-- wl_surface_attach(surface_.get(), NULL, 0, 0);
-- wl_surface_commit(surface_.get());
-- return;
-+ } else {
-+ if (child_window_)
-+ child_window_->Hide();
-+ if (xdg_popup_) {
-+ parent_window_->set_child_window(nullptr);
-+ xdg_popup_.reset();
-+ }
- }
-
-- if (child_window_)
-- child_window_->Hide();
--
-- if (xdg_popup_) {
-- parent_window_->set_child_window(nullptr);
-- xdg_popup_.reset();
-- // Detach buffer from surface in order to completely shutdown popups and
-- // release resources.
-- wl_surface_attach(surface_.get(), NULL, 0, 0);
-- wl_surface_commit(surface_.get());
-- }
-+ // Detach buffer from surface in order to completely shutdown popups and
-+ // tooltips, and release resources.
-+ if (!xdg_surface())
-+ connection_->buffer_manager_host()->ResetSurfaceContents(GetWidget());
- }
-
- void WaylandWindow::Close() {
---
-2.22.0
-
diff --git a/0008-ozone-wayland-Added-HiDPI-support-for-Ozone-Wayland.patch b/0008-ozone-wayland-Added-HiDPI-support-for-Ozone-Wayland.patch
deleted file mode 100644
index d9eb2d8925e4..000000000000
--- a/0008-ozone-wayland-Added-HiDPI-support-for-Ozone-Wayland.patch
+++ /dev/null
@@ -1,991 +0,0 @@
-From d0ddcd522423f533cec29e43c4cbaca7b8d8e45c Mon Sep 17 00:00:00 2001
-From: Alexander Dunaev <adunaev@igalia.com>
-Date: Mon, 10 Jun 2019 08:28:04 +0000
-Subject: [PATCH 08/11] [ozone/wayland] Added HiDPI support for Ozone/Wayland.
-
-Wayland operates in DIP but the platform level works with physical pixels
-so it's the application's responsibility to render properly and translate
-locations and sizes to physical pixels and back.
-
-This CL introduces the behaviour required to support HiDPI screens:
-* The backing buffer now takes the scale factor taken from the output device.
-* Windows update their buffer scale when moved between displays that have
- different scale factor, or when properties of the display are changed.
-* Windows translate DIP to physical pixels and back, where necessary.
-
-R=msisov@igalia.com, rjkroege@chromium.org
-
-Bug: 910797
-Change-Id: I1acb96ebc306194c13865149e026bcfdfb8046bf
-Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1647154
-Reviewed-by: Maksim Sisov <msisov@igalia.com>
-Reviewed-by: Robert Kroeger <rjkroege@chromium.org>
-Commit-Queue: Alexander Dunaev <adunaev@igalia.com>
-Cr-Commit-Position: refs/heads/master@{#667537}
----
- .../wayland/host/wayland_connection.cc | 10 +
- .../wayland/host/wayland_connection.h | 5 +-
- .../platform/wayland/host/wayland_output.cc | 10 +-
- .../platform/wayland/host/wayland_output.h | 5 +-
- .../wayland/host/wayland_output_manager.cc | 24 ++-
- .../wayland/host/wayland_output_manager.h | 9 +-
- .../platform/wayland/host/wayland_screen.cc | 33 ++--
- .../platform/wayland/host/wayland_screen.h | 2 +-
- .../wayland/host/wayland_screen_unittest.cc | 22 ++-
- .../platform/wayland/host/wayland_window.cc | 183 ++++++++++++++----
- .../platform/wayland/host/wayland_window.h | 48 ++++-
- .../wayland/host/xdg_popup_wrapper_v6.cc | 9 +-
- .../platform/wayland/test/mock_surface.cc | 6 +-
- ui/ozone/platform/wayland/test/mock_surface.h | 1 +
- ui/ozone/platform/wayland/test/test_output.cc | 5 +
- ui/ozone/platform/wayland/test/test_output.h | 2 +
- .../platform/wayland/test/wayland_test.cc | 4 +
- ui/ozone/platform/wayland/test/wayland_test.h | 3 +
- 18 files changed, 298 insertions(+), 83 deletions(-)
-
-diff --git a/ui/ozone/platform/wayland/host/wayland_connection.cc b/ui/ozone/platform/wayland/host/wayland_connection.cc
-index 477ee110a0de..72617b5f37a3 100644
---- a/ui/ozone/platform/wayland/host/wayland_connection.cc
-+++ b/ui/ozone/platform/wayland/host/wayland_connection.cc
-@@ -160,6 +160,16 @@ WaylandWindow* WaylandConnection::GetCurrentKeyboardFocusedWindow() const {
- return nullptr;
- }
-
-+std::vector<WaylandWindow*> WaylandConnection::GetWindowsOnOutput(
-+ uint32_t output_id) {
-+ std::vector<WaylandWindow*> result;
-+ for (auto entry : window_map_) {
-+ if (entry.second->GetEnteredOutputsIds().count(output_id) > 0)
-+ result.push_back(entry.second);
-+ }
-+ return result;
-+}
-+
- void WaylandConnection::AddWindow(gfx::AcceleratedWidget widget,
- WaylandWindow* window) {
- DCHECK(buffer_manager_host_);
-diff --git a/ui/ozone/platform/wayland/host/wayland_connection.h b/ui/ozone/platform/wayland/host/wayland_connection.h
-index 65c13332c7a2..9ae6527337c6 100644
---- a/ui/ozone/platform/wayland/host/wayland_connection.h
-+++ b/ui/ozone/platform/wayland/host/wayland_connection.h
-@@ -62,6 +62,9 @@ class WaylandConnection : public PlatformEventSource,
- WaylandWindow* GetWindowWithLargestBounds() const;
- WaylandWindow* GetCurrentFocusedWindow() const;
- WaylandWindow* GetCurrentKeyboardFocusedWindow() const;
-+ // TODO(crbug.com/971525): remove this in favor of targeted subscription of
-+ // windows to their outputs.
-+ std::vector<WaylandWindow*> GetWindowsOnOutput(uint32_t output_id);
- void AddWindow(gfx::AcceleratedWidget widget, WaylandWindow* window);
- void RemoveWindow(gfx::AcceleratedWidget widget);
-
-@@ -163,7 +166,7 @@ class WaylandConnection : public PlatformEventSource,
- // xdg_shell_listener
- static void Ping(void* data, xdg_shell* shell, uint32_t serial);
-
-- std::map<gfx::AcceleratedWidget, WaylandWindow*> window_map_;
-+ base::flat_map<gfx::AcceleratedWidget, WaylandWindow*> window_map_;
-
- wl::Object<wl_display> display_;
- wl::Object<wl_registry> registry_;
-diff --git a/ui/ozone/platform/wayland/host/wayland_output.cc b/ui/ozone/platform/wayland/host/wayland_output.cc
-index 0b36d955ed45..701f1678b19c 100644
---- a/ui/ozone/platform/wayland/host/wayland_output.cc
-+++ b/ui/ozone/platform/wayland/host/wayland_output.cc
-@@ -11,14 +11,10 @@
-
- namespace ui {
-
--namespace {
--constexpr float kDefaultScaleFactor = 1.0f;
--}
--
- WaylandOutput::WaylandOutput(const uint32_t output_id, wl_output* output)
- : output_id_(output_id),
- output_(output),
-- device_scale_factor_(kDefaultScaleFactor),
-+ scale_factor_(kDefaultScaleFactor),
- rect_in_physical_pixels_(gfx::Rect()) {}
-
- WaylandOutput::~WaylandOutput() = default;
-@@ -38,7 +34,7 @@ void WaylandOutput::Initialize(Delegate* delegate) {
- void WaylandOutput::TriggerDelegateNotification() const {
- DCHECK(!rect_in_physical_pixels_.IsEmpty());
- delegate_->OnOutputHandleMetrics(output_id_, rect_in_physical_pixels_,
-- device_scale_factor_);
-+ scale_factor_);
- }
-
- // static
-@@ -82,7 +78,7 @@ void WaylandOutput::OutputHandleScale(void* data,
- int32_t factor) {
- WaylandOutput* wayland_output = static_cast<WaylandOutput*>(data);
- if (wayland_output)
-- wayland_output->device_scale_factor_ = factor;
-+ wayland_output->scale_factor_ = factor;
- }
-
- } // namespace ui
-diff --git a/ui/ozone/platform/wayland/host/wayland_output.h b/ui/ozone/platform/wayland/host/wayland_output.h
-index 464689eadf7d..36f8c89fc1e0 100644
---- a/ui/ozone/platform/wayland/host/wayland_output.h
-+++ b/ui/ozone/platform/wayland/host/wayland_output.h
-@@ -36,12 +36,15 @@ class WaylandOutput {
-
- uint32_t output_id() const { return output_id_; }
- bool has_output(wl_output* output) const { return output_.get() == output; }
-+ int32_t scale_factor() const { return scale_factor_; }
-
- // Tells if the output has already received physical screen dimensions in the
- // global compositor space.
- bool is_ready() const { return !rect_in_physical_pixels_.IsEmpty(); }
-
- private:
-+ static constexpr int32_t kDefaultScaleFactor = 1;
-+
- // Callback functions used for setting geometric properties of the output
- // and available modes.
- static void OutputHandleGeometry(void* data,
-@@ -68,7 +71,7 @@ class WaylandOutput {
-
- const uint32_t output_id_ = 0;
- wl::Object<wl_output> output_;
-- float device_scale_factor_;
-+ int32_t scale_factor_ = kDefaultScaleFactor;
- gfx::Rect rect_in_physical_pixels_;
-
- Delegate* delegate_ = nullptr;
-diff --git a/ui/ozone/platform/wayland/host/wayland_output_manager.cc b/ui/ozone/platform/wayland/host/wayland_output_manager.cc
-index 38dad071ff53..1f403f4928a7 100644
---- a/ui/ozone/platform/wayland/host/wayland_output_manager.cc
-+++ b/ui/ozone/platform/wayland/host/wayland_output_manager.cc
-@@ -26,10 +26,7 @@ void WaylandOutputManager::AddWaylandOutput(const uint32_t output_id,
- // Make sure an output with |output_id| has not been added yet. It's very
- // unlikely to happen, unless a compositor has a bug in the numeric names
- // representation of global objects.
-- auto output_it = std::find_if(output_list_.begin(), output_list_.end(),
-- [output_id](const auto& output) {
-- return output->output_id() == output_id;
-- });
-+ auto output_it = GetOutputItById(output_id);
- DCHECK(output_it == output_list_.end());
- auto wayland_output = std::make_unique<WaylandOutput>(output_id, output);
- WaylandOutput* wayland_output_ptr = wayland_output.get();
-@@ -44,10 +41,7 @@ void WaylandOutputManager::AddWaylandOutput(const uint32_t output_id,
- }
-
- void WaylandOutputManager::RemoveWaylandOutput(const uint32_t output_id) {
-- auto output_it = std::find_if(output_list_.begin(), output_list_.end(),
-- [output_id](const auto& output) {
-- return output->output_id() == output_id;
-- });
-+ auto output_it = GetOutputItById(output_id);
-
- // Check the comment in the WaylandConnetion::GlobalRemove.
- if (output_it == output_list_.end())
-@@ -89,6 +83,13 @@ uint32_t WaylandOutputManager::GetIdForOutput(wl_output* output) const {
- return output_it->get()->output_id();
- }
-
-+WaylandOutput* WaylandOutputManager::GetOutput(uint32_t id) const {
-+ auto output_it = GetOutputItById(id);
-+ // This is unlikely to happen, but better to be explicit here.
-+ DCHECK(output_it != output_list_.end());
-+ return output_it->get();
-+}
-+
- void WaylandOutputManager::OnWaylandOutputAdded(uint32_t output_id) {
- if (wayland_screen_)
- wayland_screen_->OnOutputAdded(output_id);
-@@ -107,4 +108,11 @@ void WaylandOutputManager::OnOutputHandleMetrics(uint32_t output_id,
- scale_factor);
- }
-
-+WaylandOutputManager::OutputList::const_iterator
-+WaylandOutputManager::GetOutputItById(uint32_t id) const {
-+ return std::find_if(
-+ output_list_.begin(), output_list_.end(),
-+ [id](const auto& item) { return item->output_id() == id; });
-+}
-+
- } // namespace ui
-diff --git a/ui/ozone/platform/wayland/host/wayland_output_manager.h b/ui/ozone/platform/wayland/host/wayland_output_manager.h
-index 812323281eaf..f05828a6d90b 100644
---- a/ui/ozone/platform/wayland/host/wayland_output_manager.h
-+++ b/ui/ozone/platform/wayland/host/wayland_output_manager.h
-@@ -39,6 +39,9 @@ class WaylandOutputManager : public WaylandOutput::Delegate {
- WaylandConnection* connection);
-
- uint32_t GetIdForOutput(wl_output* output) const;
-+ WaylandOutput* GetOutput(uint32_t id) const;
-+
-+ WaylandScreen* wayland_screen() const { return wayland_screen_.get(); }
-
- private:
- void OnWaylandOutputAdded(uint32_t output_id);
-@@ -49,7 +52,11 @@ class WaylandOutputManager : public WaylandOutput::Delegate {
- const gfx::Rect& new_bounds,
- int32_t scale_factor) override;
-
-- std::vector<std::unique_ptr<WaylandOutput>> output_list_;
-+ using OutputList = std::vector<std::unique_ptr<WaylandOutput>>;
-+
-+ OutputList::const_iterator GetOutputItById(uint32_t id) const;
-+
-+ OutputList output_list_;
-
- // Non-owned wayland screen instance.
- base::WeakPtr<WaylandScreen> wayland_screen_;
-diff --git a/ui/ozone/platform/wayland/host/wayland_screen.cc b/ui/ozone/platform/wayland/host/wayland_screen.cc
-index e53a95932ef1..694c13f4e4d2 100644
---- a/ui/ozone/platform/wayland/host/wayland_screen.cc
-+++ b/ui/ozone/platform/wayland/host/wayland_screen.cc
-@@ -23,14 +23,12 @@ WaylandScreen::WaylandScreen(WaylandConnection* connection)
- WaylandScreen::~WaylandScreen() = default;
-
- void WaylandScreen::OnOutputAdded(uint32_t output_id) {
-- display::Display new_display(output_id);
-- display_list_.AddDisplay(std::move(new_display),
-+ display_list_.AddDisplay(display::Display(output_id),
- display::DisplayList::Type::NOT_PRIMARY);
- }
-
- void WaylandScreen::OnOutputRemoved(uint32_t output_id) {
-- display::Display primary_display = GetPrimaryDisplay();
-- if (primary_display.id() == output_id) {
-+ if (output_id == GetPrimaryDisplay().id()) {
- // First, set a new primary display as required by the |display_list_|. It's
- // safe to set any of the displays to be a primary one. Once the output is
- // completely removed, Wayland updates geometry of other displays. And a
-@@ -49,9 +47,10 @@ void WaylandScreen::OnOutputRemoved(uint32_t output_id) {
-
- void WaylandScreen::OnOutputMetricsChanged(uint32_t output_id,
- const gfx::Rect& new_bounds,
-- float device_pixel_ratio) {
-+ int32_t device_pixel_ratio) {
- display::Display changed_display(output_id);
-- changed_display.set_device_scale_factor(device_pixel_ratio);
-+ if (!display::Display::HasForceDeviceScaleFactor())
-+ changed_display.set_device_scale_factor(device_pixel_ratio);
- changed_display.set_bounds(new_bounds);
- changed_display.set_work_area(new_bounds);
-
-@@ -81,6 +80,9 @@ void WaylandScreen::OnOutputMetricsChanged(uint32_t output_id,
- display_list_.UpdateDisplay(
- changed_display, is_primary ? display::DisplayList::Type::PRIMARY
- : display::DisplayList::Type::NOT_PRIMARY);
-+
-+ for (auto* window : connection_->GetWindowsOnOutput(output_id))
-+ window->UpdateBufferScale(true);
- }
-
- base::WeakPtr<WaylandScreen> WaylandScreen::GetWeakPtr() {
-@@ -99,13 +101,13 @@ display::Display WaylandScreen::GetPrimaryDisplay() const {
-
- display::Display WaylandScreen::GetDisplayForAcceleratedWidget(
- gfx::AcceleratedWidget widget) const {
-- auto* wayland_window = connection_->GetWindow(widget);
-+ auto* window = connection_->GetWindow(widget);
- // A window might be destroyed by this time on shutting down the browser.
-- if (!wayland_window)
-+ if (!window)
- return GetPrimaryDisplay();
-
-- const std::set<uint32_t> entered_outputs_ids =
-- wayland_window->GetEnteredOutputsIds();
-+ const auto* parent_window = window->parent_window();
-+ const std::set<uint32_t> entered_outputs_ids = window->GetEnteredOutputsIds();
- // Although spec says a surface receives enter/leave surface events on
- // create/move/resize actions, this might be called right after a window is
- // created, but it has not been configured by a Wayland compositor and it has
-@@ -114,14 +116,19 @@ display::Display WaylandScreen::GetDisplayForAcceleratedWidget(
- // events immediately, which can result in empty container of entered ids
- // (check comments in WaylandWindow::RemoveEnteredOutputId). In this case,
- // it's also safe to return the primary display.
-- if (entered_outputs_ids.empty())
-+ // A child window will most probably enter the same display than its parent
-+ // so we return the parent's display if there is a parent.
-+ if (entered_outputs_ids.empty()) {
-+ if (parent_window)
-+ return GetDisplayForAcceleratedWidget(parent_window->GetWidget());
- return GetPrimaryDisplay();
-+ }
-
- DCHECK(!display_list_.displays().empty());
-
- // A widget can be located on two or more displays. It would be better if the
-- // most in pixels occupied display was returned, but it's impossible to do in
-- // Wayland. Thus, return the one, which was the very first used.
-+ // most in DIP occupied display was returned, but it's impossible to do so in
-+ // Wayland. Thus, return the one that was used the earliest.
- for (const auto& display : display_list_.displays()) {
- if (display.id() == *entered_outputs_ids.begin())
- return display;
-diff --git a/ui/ozone/platform/wayland/host/wayland_screen.h b/ui/ozone/platform/wayland/host/wayland_screen.h
-index f395b9b496fd..c81b47a3ecd1 100644
---- a/ui/ozone/platform/wayland/host/wayland_screen.h
-+++ b/ui/ozone/platform/wayland/host/wayland_screen.h
-@@ -29,7 +29,7 @@ class WaylandScreen : public PlatformScreen {
- void OnOutputRemoved(uint32_t output_id);
- void OnOutputMetricsChanged(uint32_t output_id,
- const gfx::Rect& bounds,
-- float device_pixel_ratio);
-+ int32_t output_scale);
-
- base::WeakPtr<WaylandScreen> GetWeakPtr();
-
-diff --git a/ui/ozone/platform/wayland/host/wayland_screen_unittest.cc b/ui/ozone/platform/wayland/host/wayland_screen_unittest.cc
-index 54e72fb5c916..f93ac20d51e0 100644
---- a/ui/ozone/platform/wayland/host/wayland_screen_unittest.cc
-+++ b/ui/ozone/platform/wayland/host/wayland_screen_unittest.cc
-@@ -223,9 +223,8 @@ TEST_P(WaylandScreenTest, OutputPropertyChanges) {
- EXPECT_EQ(observer.GetAndClearChangedMetrics(), changed_values);
- EXPECT_EQ(observer.GetDisplay().bounds(), new_rect);
-
-- const float new_scale_value = 2.0f;
-- wl_output_send_scale(output_->resource(), new_scale_value);
-- wl_output_send_done(output_->resource());
-+ const int32_t new_scale_value = 2;
-+ output_->SetScale(new_scale_value);
-
- Sync();
-
-@@ -580,6 +579,23 @@ TEST_P(WaylandScreenTest, GetCursorScreenPoint) {
- EXPECT_EQ(gfx::Point(1912, 1071), platform_screen_->GetCursorScreenPoint());
- }
-
-+// Checks that the surface that backs the window receives new scale of the
-+// output that it is in.
-+TEST_P(WaylandScreenTest, SetBufferScale) {
-+ // Place the window onto the output.
-+ wl_surface_send_enter(surface_->resource(), output_->resource());
-+
-+ // Change the scale of the output. Windows looking into that output must get
-+ // the new scale and update scale of their buffers.
-+ const int32_t kNewScale = 3;
-+ EXPECT_CALL(*surface_, SetBufferScale(kNewScale));
-+ output_->SetScale(kNewScale);
-+
-+ Sync();
-+
-+ EXPECT_EQ(window_->buffer_scale(), kNewScale);
-+}
-+
- INSTANTIATE_TEST_SUITE_P(XdgVersionV5Test,
- WaylandScreenTest,
- ::testing::Values(kXdgShellV5));
-diff --git a/ui/ozone/platform/wayland/host/wayland_window.cc b/ui/ozone/platform/wayland/host/wayland_window.cc
-index 3d4229f466ff..eb79b91892f9 100644
---- a/ui/ozone/platform/wayland/host/wayland_window.cc
-+++ b/ui/ozone/platform/wayland/host/wayland_window.cc
-@@ -123,7 +123,11 @@ WaylandWindow* WaylandWindow::FromSurface(wl_surface* surface) {
- bool WaylandWindow::Initialize(PlatformWindowInitProperties properties) {
- DCHECK(xdg_shell_objects_factory_);
-
-- bounds_ = properties.bounds;
-+ // Properties contain DIP bounds but the buffer scale is initially 1 so it's
-+ // OK to assign. The bounds will be recalculated when the buffer scale
-+ // changes.
-+ DCHECK_EQ(buffer_scale_, 1);
-+ bounds_px_ = properties.bounds;
- opacity_ = properties.opacity;
-
- surface_.reset(wl_compositor_create_surface(connection_->compositor()));
-@@ -140,6 +144,10 @@ bool WaylandWindow::Initialize(PlatformWindowInitProperties properties) {
- case ui::PlatformWindowType::kPopup:
- parent_window_ = GetParentWindow(properties.parent_widget);
-
-+ // Popups need to know their scale earlier to position themselves.
-+ DCHECK(parent_window_);
-+ SetBufferScale(parent_window_->buffer_scale_, false);
-+
- // TODO(msisov, jkim): Handle notification windows, which are marked
- // as popup windows as well. Those are the windows that do not have
- // parents and pop up when the browser receives a notification.
-@@ -160,10 +168,35 @@ bool WaylandWindow::Initialize(PlatformWindowInitProperties properties) {
- PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
- delegate_->OnAcceleratedWidgetAvailable(GetWidget());
-
-+ // Will do nothing for popups because they have got their scale above.
-+ UpdateBufferScale(false);
-+
- MaybeUpdateOpaqueRegion();
- return true;
- }
-
-+void WaylandWindow::UpdateBufferScale(bool update_bounds) {
-+ DCHECK(connection_->wayland_output_manager());
-+ const auto* screen = connection_->wayland_output_manager()->wayland_screen();
-+ DCHECK(screen);
-+ const auto widget = GetWidget();
-+
-+ int32_t new_scale = 0;
-+ if (parent_window_) {
-+ new_scale = parent_window_->buffer_scale_;
-+ } else if (widget == gfx::kNullAcceleratedWidget) {
-+ new_scale = screen->GetPrimaryDisplay().device_scale_factor();
-+ } else {
-+ // This is the main window that is fully set up so we can ask which display
-+ // we are at currently.
-+ new_scale =
-+ connection_->wayland_output_manager()
-+ ->GetOutput(screen->GetDisplayForAcceleratedWidget(widget).id())
-+ ->scale_factor();
-+ }
-+ SetBufferScale(new_scale, update_bounds);
-+}
-+
- gfx::AcceleratedWidget WaylandWindow::GetWidget() const {
- if (!surface_)
- return gfx::kNullAcceleratedWidget;
-@@ -175,7 +208,7 @@ std::set<uint32_t> WaylandWindow::GetEnteredOutputsIds() const {
- }
-
- void WaylandWindow::CreateXdgPopup() {
-- if (bounds_.IsEmpty())
-+ if (bounds_px_.IsEmpty())
- return;
-
- // TODO(jkim): Consider how to support DropArrow window on tabstrip.
-@@ -193,11 +226,11 @@ void WaylandWindow::CreateXdgPopup() {
-
- DCHECK(parent_window_ && !xdg_popup_);
-
-- auto bounds = AdjustPopupWindowPosition();
-+ auto bounds_px = AdjustPopupWindowPosition();
-
- xdg_popup_ = xdg_shell_objects_factory_->CreateXDGPopup(connection_, this);
-- if (!xdg_popup_ ||
-- !xdg_popup_->Initialize(connection_, surface(), parent_window_, bounds)) {
-+ if (!xdg_popup_ || !xdg_popup_->Initialize(connection_, surface(),
-+ parent_window_, bounds_px)) {
- CHECK(false) << "Failed to create xdg_popup";
- }
-
-@@ -234,22 +267,24 @@ void WaylandWindow::CreateAndShowTooltipSubSurface() {
- }
-
- DCHECK(tooltip_subsurface_);
-- wl_subsurface_set_position(tooltip_subsurface_.get(), bounds_.x(),
-- bounds_.y());
-+ // Convert position to DIP.
-+ wl_subsurface_set_position(tooltip_subsurface_.get(),
-+ bounds_px_.x() / buffer_scale_,
-+ bounds_px_.y() / buffer_scale_);
- wl_subsurface_set_desync(tooltip_subsurface_.get());
- wl_surface_commit(parent_window_->surface());
- connection_->ScheduleFlush();
- }
-
- void WaylandWindow::ApplyPendingBounds() {
-- if (pending_bounds_.IsEmpty())
-+ if (pending_bounds_dip_.IsEmpty())
- return;
- DCHECK(xdg_surface_);
-
-- SetBounds(pending_bounds_);
-- xdg_surface_->SetWindowGeometry(bounds_);
-+ SetBoundsDip(pending_bounds_dip_);
-+ xdg_surface_->SetWindowGeometry(pending_bounds_dip_);
- xdg_surface_->AckConfigure();
-- pending_bounds_ = gfx::Rect();
-+ pending_bounds_dip_ = gfx::Rect();
- connection_->ScheduleFlush();
-
- // Opaque region is based on the size of the window. Thus, update the region
-@@ -293,9 +328,17 @@ void WaylandWindow::Show() {
- }
-
- if (!xdg_popup_) {
-+ // When showing a sub-menu after it has been previously shown and hidden,
-+ // Wayland sends SetBounds prior to Show, and |bounds_px| takes the pixel
-+ // bounds. This makes a difference against the normal flow when the
-+ // window is created (see |Initialize|). To equalize things, rescale
-+ // |bounds_px_| to DIP. It will be adjusted while creating the popup.
-+ bounds_px_ = gfx::ScaleToRoundedRect(bounds_px_, 1.0 / buffer_scale_);
- CreateXdgPopup();
- connection_->ScheduleFlush();
- }
-+
-+ UpdateBufferScale(false);
- }
-
- void WaylandWindow::Hide() {
-@@ -322,15 +365,25 @@ void WaylandWindow::Close() {
-
- void WaylandWindow::PrepareForShutdown() {}
-
--void WaylandWindow::SetBounds(const gfx::Rect& bounds) {
-- if (bounds == bounds_)
-+void WaylandWindow::SetBounds(const gfx::Rect& bounds_px) {
-+ // TODO(crbug.com/958314): figure out if this return is legitimate.
-+ //
-+ // The X11 implementation says that even if the pixel bounds didn't change, we
-+ // still need to forward this call to the delegate, and that the device scale
-+ // factor may have changed which effectively changes the bounds. Perhaps we
-+ // need to do the same here.
-+ //
-+ // After this is resolved, update test expectations for calls to
-+ // delegate's OnBoundsChanged.
-+ if (bounds_px_ == bounds_px)
- return;
-- bounds_ = bounds;
-- delegate_->OnBoundsChanged(bounds);
-+ bounds_px_ = bounds_px;
-+
-+ delegate_->OnBoundsChanged(bounds_px_);
- }
-
- gfx::Rect WaylandWindow::GetBounds() {
-- return bounds_;
-+ return bounds_px_;
- }
-
- void WaylandWindow::SetTitle(const base::string16& title) {
-@@ -457,12 +510,12 @@ PlatformImeController* WaylandWindow::GetPlatformImeController() {
- return nullptr;
- }
-
--void WaylandWindow::SetRestoredBoundsInPixels(const gfx::Rect& bounds) {
-- restored_bounds_ = bounds;
-+void WaylandWindow::SetRestoredBoundsInPixels(const gfx::Rect& bounds_px) {
-+ restored_bounds_px_ = bounds_px;
- }
-
- gfx::Rect WaylandWindow::GetRestoredBoundsInPixels() const {
-- return restored_bounds_;
-+ return restored_bounds_px_;
- }
-
- bool WaylandWindow::CanDispatchEvent(const PlatformEvent& event) {
-@@ -493,6 +546,10 @@ uint32_t WaylandWindow::DispatchEvent(const PlatformEvent& native_event) {
- Event* event = static_cast<Event*>(native_event);
-
- if (event->IsLocatedEvent()) {
-+ // Wayland sends locations in DIP so they need to be translated to
-+ // physical pixels.
-+ event->AsLocatedEvent()->set_location_f(gfx::ScalePoint(
-+ event->AsLocatedEvent()->location_f(), buffer_scale_, buffer_scale_));
- auto copied_event = Event::Clone(*event);
- UpdateCursorPositionFromEvent(std::move(copied_event));
- }
-@@ -574,11 +631,13 @@ void WaylandWindow::HandleSurfaceConfigure(int32_t width,
- // explicitly set the bounds to the current desired ones or the previous
- // bounds.
- if (width > 1 && height > 1) {
-- pending_bounds_ = gfx::Rect(0, 0, width, height);
-+ pending_bounds_dip_ = gfx::Rect(0, 0, width, height);
- } else if (is_normal) {
-- pending_bounds_.set_size(restored_bounds_.IsEmpty()
-- ? GetBounds().size()
-- : restored_bounds_.size());
-+ pending_bounds_dip_.set_size(gfx::ScaleToRoundedSize(
-+ restored_bounds_px_.IsEmpty() ? GetBounds().size()
-+ : restored_bounds_px_.size(),
-+
-+ 1.0 / buffer_scale_));
- }
-
- if (state_changed) {
-@@ -590,8 +649,8 @@ void WaylandWindow::HandleSurfaceConfigure(int32_t width,
- if (is_normal) {
- SetRestoredBoundsInPixels({});
- } else if (old_state == PlatformWindowState::PLATFORM_WINDOW_STATE_NORMAL ||
-- restored_bounds_.IsEmpty()) {
-- SetRestoredBoundsInPixels(bounds_);
-+ restored_bounds_px_.IsEmpty()) {
-+ SetRestoredBoundsInPixels(bounds_px_);
- }
-
- delegate_->OnWindowStateChanged(state_);
-@@ -603,9 +662,13 @@ void WaylandWindow::HandleSurfaceConfigure(int32_t width,
- MaybeTriggerPendingStateChange();
- }
-
--void WaylandWindow::HandlePopupConfigure(const gfx::Rect& bounds) {
-+void WaylandWindow::HandlePopupConfigure(const gfx::Rect& bounds_dip) {
- DCHECK(xdg_popup());
-- gfx::Rect new_bounds = bounds;
-+ DCHECK(parent_window_);
-+
-+ SetBufferScale(parent_window_->buffer_scale_, true);
-+
-+ gfx::Rect new_bounds_dip = bounds_dip;
-
- // It's not enough to just set new bounds. If it is a menu window, whose
- // parent is a top level window aka browser window, it can be flipped
-@@ -623,10 +686,10 @@ void WaylandWindow::HandlePopupConfigure(const gfx::Rect& bounds) {
- gfx::Rect parent_bounds = parent_window_->GetBounds();
- // The menu window is flipped along y-axis and have x,-y origin. Shift the
- // parent top level window instead.
-- if (new_bounds.y() < 0) {
-+ if (new_bounds_dip.y() < 0) {
- // Move parent bounds along y-axis.
-- parent_bounds.set_y(-(new_bounds.y()));
-- new_bounds.set_y(0);
-+ parent_bounds.set_y(-(new_bounds_dip.y() * buffer_scale_));
-+ new_bounds_dip.set_y(0);
- } else {
- // If the menu window is located at correct origin from the browser point
- // of view, return the top level window back to 0,0.
-@@ -638,11 +701,15 @@ void WaylandWindow::HandlePopupConfigure(const gfx::Rect& bounds) {
- // Thus, the location must be translated to be relative to the top level
- // window, which automatically becomes the same as relative to an origin of
- // a display.
-- new_bounds = TranslateBoundsToTopLevelCoordinates(
-- new_bounds, parent_window_->GetBounds());
-- DCHECK(new_bounds.y() >= 0);
-+ new_bounds_dip = gfx::ScaleToRoundedRect(
-+ TranslateBoundsToTopLevelCoordinates(
-+ gfx::ScaleToRoundedRect(new_bounds_dip, buffer_scale_),
-+ parent_window_->GetBounds()),
-+ 1.0 / buffer_scale_);
-+ DCHECK(new_bounds_dip.y() >= 0);
- }
-- SetBounds(new_bounds);
-+
-+ SetBoundsDip(new_bounds_dip);
- }
-
- void WaylandWindow::OnCloseRequest() {
-@@ -690,6 +757,26 @@ void WaylandWindow::OnDragSessionClose(uint32_t dnd_action) {
- connection_->ResetPointerFlags();
- }
-
-+void WaylandWindow::SetBoundsDip(const gfx::Rect& bounds_dip) {
-+ SetBounds(gfx::ScaleToRoundedRect(bounds_dip, buffer_scale_));
-+}
-+
-+void WaylandWindow::SetBufferScale(int32_t new_scale, bool update_bounds) {
-+ DCHECK_GT(new_scale, 0);
-+
-+ if (new_scale == buffer_scale_)
-+ return;
-+
-+ auto old_scale = buffer_scale_;
-+ buffer_scale_ = new_scale;
-+ if (update_bounds)
-+ SetBoundsDip(gfx::ScaleToRoundedRect(bounds_px_, 1.0 / old_scale));
-+
-+ DCHECK(surface());
-+ wl_surface_set_buffer_scale(surface(), buffer_scale_);
-+ connection_->ScheduleFlush();
-+}
-+
- bool WaylandWindow::IsMinimized() const {
- return state_ == PlatformWindowState::PLATFORM_WINDOW_STATE_MINIMIZED;
- }
-@@ -745,14 +832,28 @@ void WaylandWindow::AddSurfaceListener() {
- }
-
- void WaylandWindow::AddEnteredOutputId(struct wl_output* output) {
-+ // Wayland does weird things for popups so instead of tracking outputs that
-+ // we entered or left, we take that from the parent window and ignore this
-+ // event.
-+ if (xdg_popup())
-+ return;
-+
- const uint32_t entered_output_id =
- connection_->wayland_output_manager()->GetIdForOutput(output);
- DCHECK_NE(entered_output_id, 0u);
- auto result = entered_outputs_ids_.insert(entered_output_id);
- DCHECK(result.first != entered_outputs_ids_.end());
-+
-+ UpdateBufferScale(true);
- }
-
- void WaylandWindow::RemoveEnteredOutputId(struct wl_output* output) {
-+ // Wayland does weird things for popups so instead of tracking outputs that
-+ // we entered or left, we take that from the parent window and ignore this
-+ // event.
-+ if (xdg_popup())
-+ return;
-+
- const uint32_t left_output_id =
- connection_->wayland_output_manager()->GetIdForOutput(output);
- auto entered_output_id_it = entered_outputs_ids_.find(left_output_id);
-@@ -764,6 +865,8 @@ void WaylandWindow::RemoveEnteredOutputId(struct wl_output* output) {
- // output only if it was stored before.
- if (entered_output_id_it != entered_outputs_ids_.end())
- entered_outputs_ids_.erase(entered_output_id_it);
-+
-+ UpdateBufferScale(true);
- }
-
- void WaylandWindow::UpdateCursorPositionFromEvent(
-@@ -812,11 +915,14 @@ gfx::Rect WaylandWindow::AdjustPopupWindowPosition() const {
- ? parent_window_->parent_window_
- : parent_window_;
- DCHECK(parent_window);
-+ DCHECK(buffer_scale_ == parent_window->buffer_scale_);
-+
- // Chromium positions windows in screen coordinates, but Wayland requires them
- // to be in local surface coordinates aka relative to parent window.
-- const gfx::Rect parent_bounds = parent_window_->GetBounds();
-+ const gfx::Rect parent_bounds_px =
-+ gfx::ScaleToRoundedRect(parent_window_->GetBounds(), 1.0 / buffer_scale_);
- gfx::Rect new_bounds =
-- TranslateBoundsToParentCoordinates(bounds_, parent_bounds);
-+ TranslateBoundsToParentCoordinates(bounds_px_, parent_bounds_px);
-
- // Chromium may decide to position nested menu windows on the left side
- // instead of the right side of parent menu windows when the size of the
-@@ -840,7 +946,8 @@ gfx::Rect WaylandWindow::AdjustPopupWindowPosition() const {
- // Position the child menu window on the right side of the parent window
- // and let the Wayland compositor decide how to do constraint
- // adjustements.
-- int new_x = parent_bounds.width() - (new_bounds.width() + new_bounds.x());
-+ int new_x =
-+ parent_bounds_px.width() - (new_bounds.width() + new_bounds.x());
- new_bounds.set_x(new_x);
- }
- }
-@@ -857,7 +964,7 @@ void WaylandWindow::MaybeUpdateOpaqueRegion() {
-
- wl::Object<wl_region> region(
- wl_compositor_create_region(connection_->compositor()));
-- wl_region_add(region.get(), 0, 0, bounds_.width(), bounds_.height());
-+ wl_region_add(region.get(), 0, 0, bounds_px_.width(), bounds_px_.height());
- wl_surface_set_opaque_region(surface(), region.get());
-
- connection_->ScheduleFlush();
-diff --git a/ui/ozone/platform/wayland/host/wayland_window.h b/ui/ozone/platform/wayland/host/wayland_window.h
-index 3d46ba1f4e7e..8fcf28fde934 100644
---- a/ui/ozone/platform/wayland/host/wayland_window.h
-+++ b/ui/ozone/platform/wayland/host/wayland_window.h
-@@ -51,10 +51,19 @@ class WaylandWindow : public PlatformWindow,
-
- bool Initialize(PlatformWindowInitProperties properties);
-
-+ // Updates the surface buffer scale of the window. Top level windows take
-+ // scale according to the scale of their current display or the primary one if
-+ // their widget is not yet created, children inherit scale from their parent.
-+ // The method recalculates window bounds appropriately if asked to do so
-+ // (this is not needed upon window initialization).
-+ void UpdateBufferScale(bool update_bounds);
-+
- wl_surface* surface() const { return surface_.get(); }
- XDGSurfaceWrapper* xdg_surface() const { return xdg_surface_.get(); }
- XDGPopupWrapper* xdg_popup() const { return xdg_popup_.get(); }
-
-+ WaylandWindow* parent_window() const { return parent_window_; }
-+
- gfx::AcceleratedWidget GetWidget() const;
-
- // Returns the list of wl_outputs aka displays, which this window occupies.
-@@ -89,6 +98,8 @@ class WaylandWindow : public PlatformWindow,
- void set_has_implicit_grab(bool value) { has_implicit_grab_ = value; }
- bool has_implicit_grab() const { return has_implicit_grab_; }
-
-+ int32_t buffer_scale() const { return buffer_scale_; }
-+
- bool is_active() const { return is_active_; }
-
- // WmMoveResizeHandler
-@@ -129,6 +140,10 @@ class WaylandWindow : public PlatformWindow,
- bool CanDispatchEvent(const PlatformEvent& event) override;
- uint32_t DispatchEvent(const PlatformEvent& event) override;
-
-+ // Handles the configuration events coming from the surface (see
-+ // |XDGSurfaceWrapperV5::Configure| and
-+ // |XDGSurfaceWrapperV6::ConfigureTopLevel|. The width and height come in
-+ // DIP of the output that the surface is currently bound to.
- void HandleSurfaceConfigure(int32_t widht,
- int32_t height,
- bool is_maximized,
-@@ -147,6 +162,9 @@ class WaylandWindow : public PlatformWindow,
- void OnDragSessionClose(uint32_t dnd_action);
-
- private:
-+ void SetBoundsDip(const gfx::Rect& bounds_dip);
-+ void SetBufferScale(int32_t scale, bool update_bounds);
-+
- bool IsMinimized() const;
- bool IsMaximized() const;
- bool IsFullscreen() const;
-@@ -214,14 +232,27 @@ class WaylandWindow : public PlatformWindow,
-
- base::OnceCallback<void(int)> drag_closed_callback_;
-
-- gfx::Rect bounds_;
-- gfx::Rect pending_bounds_;
-- // The bounds of the window before it went maximized or fullscreen.
-- gfx::Rect restored_bounds_;
-+ // These bounds attributes below have suffices that indicate units used.
-+ // Wayland operates in DIP but the platform operates in physical pixels so
-+ // our WaylandWindow is the link that has to translate the units. See also
-+ // comments in the implementation.
-+ //
-+ // Bounds that will be applied when the window state is finalized. The window
-+ // may get several configuration events that update the pending bounds, and
-+ // only upon finalizing the state is the latest value stored as the current
-+ // bounds via |ApplyPendingBounds|. Measured in DIP because updated in the
-+ // handler that receives DIP from Wayland.
-+ gfx::Rect pending_bounds_dip_;
-+ // Current bounds of the platform window.
-+ gfx::Rect bounds_px_;
-+ // The bounds of the platform window before it went maximized or fullscreen.
-+ gfx::Rect restored_bounds_px_;
-+
- bool has_pointer_focus_ = false;
- bool has_keyboard_focus_ = false;
- bool has_touch_focus_ = false;
- bool has_implicit_grab_ = false;
-+ int32_t buffer_scale_ = 1;
-
- // Stores current states of the window.
- ui::PlatformWindowState state_;
-@@ -237,7 +268,14 @@ class WaylandWindow : public PlatformWindow,
-
- bool is_tooltip_ = false;
-
-- // Stores the list of entered outputs that the window is currently in.
-+ // For top level window, stores the list of entered outputs that the window
-+ // is currently in.
-+ //
-+ // Not used by popups. When sub-menus are hidden and shown again, Wayland
-+ // 'repositions' sub-menus to wrong outputs by sending them leave and enter
-+ // events so their list of entered outputs becomes meaningless after they have
-+ // been hidden at least once. To determine which output the popup belongs to,
-+ // we ask its parent.
- std::set<uint32_t> entered_outputs_ids_;
-
- DISALLOW_COPY_AND_ASSIGN(WaylandWindow);
-diff --git a/ui/ozone/platform/wayland/host/xdg_popup_wrapper_v6.cc b/ui/ozone/platform/wayland/host/xdg_popup_wrapper_v6.cc
-index a17719ea848f..742f8d46a71c 100644
---- a/ui/ozone/platform/wayland/host/xdg_popup_wrapper_v6.cc
-+++ b/ui/ozone/platform/wayland/host/xdg_popup_wrapper_v6.cc
-@@ -257,8 +257,10 @@ zxdg_positioner_v6* XDGPopupWrapperV6::CreatePositioner(
- menu_type = MenuType::TYPE_3DOT_PARENT_MENU;
-
- // Place anchor to the end of the possible position.
-- gfx::Rect anchor_rect =
-- GetAnchorRect(menu_type, bounds, parent_window->GetBounds());
-+ gfx::Rect anchor_rect = GetAnchorRect(
-+ menu_type, bounds,
-+ gfx::ScaleToRoundedRect(parent_window->GetBounds(),
-+ 1.0 / parent_window->buffer_scale()));
-
- zxdg_positioner_v6_set_anchor_rect(positioner, anchor_rect.x(),
- anchor_rect.y(), anchor_rect.width(),
-@@ -284,11 +286,10 @@ void XDGPopupWrapperV6::Configure(void* data,
- // Wayland requires doing so in respect to parent window's origin. To properly
- // place windows, the bounds are translated and adjusted according to the
- // Wayland compositor needs during WaylandWindow::CreateXdgPopup call.
-- gfx::Rect new_bounds(x, y, width, height);
- WaylandWindow* window =
- static_cast<XDGPopupWrapperV6*>(data)->wayland_window_;
- DCHECK(window);
-- window->HandlePopupConfigure(new_bounds);
-+ window->HandlePopupConfigure({x, y, width, height});
- }
-
- // static
-diff --git a/ui/ozone/platform/wayland/test/mock_surface.cc b/ui/ozone/platform/wayland/test/mock_surface.cc
-index 6ee1c0a9c543..fa53a037669b 100644
---- a/ui/ozone/platform/wayland/test/mock_surface.cc
-+++ b/ui/ozone/platform/wayland/test/mock_surface.cc
-@@ -54,6 +54,10 @@ void Commit(wl_client* client, wl_resource* resource) {
- GetUserDataAs<MockSurface>(resource)->Commit();
- }
-
-+void SetBufferScale(wl_client* client, wl_resource* resource, int32_t scale) {
-+ GetUserDataAs<MockSurface>(resource)->SetBufferScale(scale);
-+}
-+
- void DamageBuffer(struct wl_client* client,
- struct wl_resource* resource,
- int32_t x,
-@@ -74,7 +78,7 @@ const struct wl_surface_interface kMockSurfaceImpl = {
- SetInputRegion, // set_input_region
- Commit, // commit
- nullptr, // set_buffer_transform
-- nullptr, // set_buffer_scale
-+ SetBufferScale, // set_buffer_scale
- DamageBuffer, // damage_buffer
- };
-
-diff --git a/ui/ozone/platform/wayland/test/mock_surface.h b/ui/ozone/platform/wayland/test/mock_surface.h
-index 0b44ba090187..1d781d03d3dc 100644
---- a/ui/ozone/platform/wayland/test/mock_surface.h
-+++ b/ui/ozone/platform/wayland/test/mock_surface.h
-@@ -37,6 +37,7 @@ class MockSurface : public ServerObject {
- MOCK_METHOD4(Damage,
- void(int32_t x, int32_t y, int32_t width, int32_t height));
- MOCK_METHOD0(Commit, void());
-+ MOCK_METHOD1(SetBufferScale, void(int32_t scale));
- MOCK_METHOD4(DamageBuffer,
- void(int32_t x, int32_t y, int32_t width, int32_t height));
-
-diff --git a/ui/ozone/platform/wayland/test/test_output.cc b/ui/ozone/platform/wayland/test/test_output.cc
-index 4abdc319e2e2..bbc6475cc078 100644
---- a/ui/ozone/platform/wayland/test/test_output.cc
-+++ b/ui/ozone/platform/wayland/test/test_output.cc
-@@ -31,4 +31,9 @@ void TestOutput::OnBind() {
- wl_output_send_done(resource());
- }
-
-+void TestOutput::SetScale(int32_t factor) {
-+ wl_output_send_scale(resource(), factor);
-+ wl_output_send_done(resource());
-+}
-+
- } // namespace wl
-diff --git a/ui/ozone/platform/wayland/test/test_output.h b/ui/ozone/platform/wayland/test/test_output.h
-index bbd6848c9b75..8dffd41cae22 100644
---- a/ui/ozone/platform/wayland/test/test_output.h
-+++ b/ui/ozone/platform/wayland/test/test_output.h
-@@ -20,6 +20,8 @@ class TestOutput : public GlobalObject {
- const gfx::Rect GetRect() { return rect_; }
- void OnBind() override;
-
-+ void SetScale(int32_t factor);
-+
- private:
- gfx::Rect rect_;
-
-diff --git a/ui/ozone/platform/wayland/test/wayland_test.cc b/ui/ozone/platform/wayland/test/wayland_test.cc
-index f8946442ecaa..1da8b15b54bb 100644
---- a/ui/ozone/platform/wayland/test/wayland_test.cc
-+++ b/ui/ozone/platform/wayland/test/wayland_test.cc
-@@ -6,6 +6,8 @@
-
- #include "base/run_loop.h"
- #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
-+#include "ui/ozone/platform/wayland/host/wayland_output_manager.h"
-+#include "ui/ozone/platform/wayland/host/wayland_screen.h"
- #include "ui/ozone/platform/wayland/test/mock_surface.h"
- #include "ui/platform_window/platform_window_init_properties.h"
-
-@@ -42,6 +44,8 @@ WaylandTest::~WaylandTest() {}
- void WaylandTest::SetUp() {
- ASSERT_TRUE(server_.Start(GetParam()));
- ASSERT_TRUE(connection_->Initialize());
-+ screen_ = connection_->wayland_output_manager()->CreateWaylandScreen(
-+ connection_.get());
- EXPECT_CALL(delegate_, OnAcceleratedWidgetAvailable(_))
- .WillOnce(SaveArg<0>(&widget_));
- PlatformWindowInitProperties properties;
-diff --git a/ui/ozone/platform/wayland/test/wayland_test.h b/ui/ozone/platform/wayland/test/wayland_test.h
-index 0acdf07c39b3..85a095dfd309 100644
---- a/ui/ozone/platform/wayland/test/wayland_test.h
-+++ b/ui/ozone/platform/wayland/test/wayland_test.h
-@@ -28,6 +28,8 @@ class MockSurface;
-
- namespace ui {
-
-+class WaylandScreen;
-+
- const uint32_t kXdgShellV5 = 5;
- const uint32_t kXdgShellV6 = 6;
-
-@@ -53,6 +55,7 @@ class WaylandTest : public ::testing::TestWithParam<uint32_t> {
- std::unique_ptr<WaylandSurfaceFactory> surface_factory_;
- std::unique_ptr<WaylandBufferManagerGpu> buffer_manager_gpu_;
- std::unique_ptr<WaylandConnection> connection_;
-+ std::unique_ptr<WaylandScreen> screen_;
- std::unique_ptr<WaylandWindow> window_;
- gfx::AcceleratedWidget widget_ = gfx::kNullAcceleratedWidget;
-
---
-2.22.0
-
diff --git a/0009-Fixed-positioning-and-sizes-of-menus-when-the-scale-.patch b/0009-Fixed-positioning-and-sizes-of-menus-when-the-scale-.patch
deleted file mode 100644
index 2e153cf2ff0c..000000000000
--- a/0009-Fixed-positioning-and-sizes-of-menus-when-the-scale-.patch
+++ /dev/null
@@ -1,315 +0,0 @@
-From 6077336fd2b3a5402ef07e980ebcd46106d8074e Mon Sep 17 00:00:00 2001
-From: Alexander Dunaev <adunaev@igalia.com>
-Date: Wed, 17 Jul 2019 05:26:49 +0000
-Subject: [PATCH 09/11] Fixed positioning and sizes of menus when the scale
- factor is forced.
-
-When --force-device-scale-factor command line flag is present, the UI scale
-is replaced with the value passed with the flag, which should be taken into
-account when positioning and sizing the menus.
-
-R=msisov@igalia.com, rjkroege@chromium.org
-
-Bug: 910797
-Change-Id: I7880472c29fdaa33e20e2a896e48f922c20680ac
-Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1692578
-Auto-Submit: Alexander Dunaev <adunaev@igalia.com>
-Reviewed-by: Maksim Sisov <msisov@igalia.com>
-Reviewed-by: Robert Kroeger <rjkroege@chromium.org>
-Commit-Queue: Maksim Sisov <msisov@igalia.com>
-Cr-Commit-Position: refs/heads/master@{#678151}
----
- .../wayland/host/wayland_connection.cc | 2 +-
- .../platform/wayland/host/wayland_screen.cc | 2 +-
- .../wayland/host/wayland_screen_unittest.cc | 38 +++++++++++++--
- .../platform/wayland/host/wayland_window.cc | 46 ++++++++++---------
- .../platform/wayland/host/wayland_window.h | 37 +++++++++------
- 5 files changed, 81 insertions(+), 44 deletions(-)
-
-diff --git a/ui/ozone/platform/wayland/host/wayland_connection.cc b/ui/ozone/platform/wayland/host/wayland_connection.cc
-index 72617b5f37a3..a949baf5a934 100644
---- a/ui/ozone/platform/wayland/host/wayland_connection.cc
-+++ b/ui/ozone/platform/wayland/host/wayland_connection.cc
-@@ -164,7 +164,7 @@ std::vector<WaylandWindow*> WaylandConnection::GetWindowsOnOutput(
- uint32_t output_id) {
- std::vector<WaylandWindow*> result;
- for (auto entry : window_map_) {
-- if (entry.second->GetEnteredOutputsIds().count(output_id) > 0)
-+ if (entry.second->entered_outputs_ids().count(output_id) > 0)
- result.push_back(entry.second);
- }
- return result;
-diff --git a/ui/ozone/platform/wayland/host/wayland_screen.cc b/ui/ozone/platform/wayland/host/wayland_screen.cc
-index 694c13f4e4d2..ef372ad794d3 100644
---- a/ui/ozone/platform/wayland/host/wayland_screen.cc
-+++ b/ui/ozone/platform/wayland/host/wayland_screen.cc
-@@ -107,7 +107,7 @@ display::Display WaylandScreen::GetDisplayForAcceleratedWidget(
- return GetPrimaryDisplay();
-
- const auto* parent_window = window->parent_window();
-- const std::set<uint32_t> entered_outputs_ids = window->GetEnteredOutputsIds();
-+ const auto entered_outputs_ids = window->entered_outputs_ids();
- // Although spec says a surface receives enter/leave surface events on
- // create/move/resize actions, this might be called right after a window is
- // created, but it has not been configured by a Wayland compositor and it has
-diff --git a/ui/ozone/platform/wayland/host/wayland_screen_unittest.cc b/ui/ozone/platform/wayland/host/wayland_screen_unittest.cc
-index f93ac20d51e0..0a18b8366cae 100644
---- a/ui/ozone/platform/wayland/host/wayland_screen_unittest.cc
-+++ b/ui/ozone/platform/wayland/host/wayland_screen_unittest.cc
-@@ -5,8 +5,11 @@
- #include <wayland-server.h>
- #include <memory>
-
-+#include "base/strings/stringprintf.h"
-+#include "base/test/scoped_command_line.h"
- #include "testing/gtest/include/gtest/gtest.h"
- #include "ui/display/display_observer.h"
-+#include "ui/display/display_switches.h"
- #include "ui/ozone/platform/wayland/host/wayland_connection.h"
- #include "ui/ozone/platform/wayland/host/wayland_output_manager.h"
- #include "ui/ozone/platform/wayland/host/wayland_screen.h"
-@@ -586,14 +589,39 @@ TEST_P(WaylandScreenTest, SetBufferScale) {
- wl_surface_send_enter(surface_->resource(), output_->resource());
-
- // Change the scale of the output. Windows looking into that output must get
-- // the new scale and update scale of their buffers.
-- const int32_t kNewScale = 3;
-- EXPECT_CALL(*surface_, SetBufferScale(kNewScale));
-- output_->SetScale(kNewScale);
-+ // the new scale and update scale of their buffers. The default UI scale
-+ // equals the output scale.
-+ const int32_t kTripleScale = 3;
-+ EXPECT_CALL(*surface_, SetBufferScale(kTripleScale));
-+ output_->SetScale(kTripleScale);
-
- Sync();
-
-- EXPECT_EQ(window_->buffer_scale(), kNewScale);
-+ EXPECT_EQ(window_->buffer_scale(), kTripleScale);
-+ EXPECT_EQ(window_->ui_scale_, kTripleScale);
-+
-+ // Now simulate the --force-device-scale-factor=1.5
-+ const float kForcedUIScale = 1.5;
-+ base::test::ScopedCommandLine command_line;
-+ command_line.GetProcessCommandLine()->AppendSwitchASCII(
-+ switches::kForceDeviceScaleFactor,
-+ base::StringPrintf("%.1f", kForcedUIScale));
-+ display::Display::ResetForceDeviceScaleFactorForTesting();
-+
-+ // Change the scale of the output again. Windows must update scale of
-+ // their buffers but the UI scale must get the forced value.
-+ const int32_t kDoubleScale = 2;
-+ // Question ourselves before questioning others!
-+ EXPECT_NE(kForcedUIScale, kDoubleScale);
-+ EXPECT_CALL(*surface_, SetBufferScale(kDoubleScale));
-+ output_->SetScale(kDoubleScale);
-+
-+ Sync();
-+
-+ EXPECT_EQ(window_->buffer_scale(), kDoubleScale);
-+ EXPECT_EQ(window_->ui_scale_, kForcedUIScale);
-+
-+ display::Display::ResetForceDeviceScaleFactorForTesting();
- }
-
- INSTANTIATE_TEST_SUITE_P(XdgVersionV5Test,
-diff --git a/ui/ozone/platform/wayland/host/wayland_window.cc b/ui/ozone/platform/wayland/host/wayland_window.cc
-index eb79b91892f9..9afed0cc87fb 100644
---- a/ui/ozone/platform/wayland/host/wayland_window.cc
-+++ b/ui/ozone/platform/wayland/host/wayland_window.cc
-@@ -147,6 +147,7 @@ bool WaylandWindow::Initialize(PlatformWindowInitProperties properties) {
- // Popups need to know their scale earlier to position themselves.
- DCHECK(parent_window_);
- SetBufferScale(parent_window_->buffer_scale_, false);
-+ ui_scale_ = parent_window_->ui_scale_;
-
- // TODO(msisov, jkim): Handle notification windows, which are marked
- // as popup windows as well. Those are the windows that do not have
-@@ -184,15 +185,19 @@ void WaylandWindow::UpdateBufferScale(bool update_bounds) {
- int32_t new_scale = 0;
- if (parent_window_) {
- new_scale = parent_window_->buffer_scale_;
-- } else if (widget == gfx::kNullAcceleratedWidget) {
-- new_scale = screen->GetPrimaryDisplay().device_scale_factor();
-+ ui_scale_ = parent_window_->ui_scale_;
- } else {
-- // This is the main window that is fully set up so we can ask which display
-- // we are at currently.
-- new_scale =
-- connection_->wayland_output_manager()
-- ->GetOutput(screen->GetDisplayForAcceleratedWidget(widget).id())
-- ->scale_factor();
-+ const auto display = (widget == gfx::kNullAcceleratedWidget)
-+ ? screen->GetPrimaryDisplay()
-+ : screen->GetDisplayForAcceleratedWidget(widget);
-+ new_scale = connection_->wayland_output_manager()
-+ ->GetOutput(display.id())
-+ ->scale_factor();
-+
-+ if (display::Display::HasForceDeviceScaleFactor())
-+ ui_scale_ = display::Display::GetForcedDeviceScaleFactor();
-+ else
-+ ui_scale_ = display.device_scale_factor();
- }
- SetBufferScale(new_scale, update_bounds);
- }
-@@ -203,10 +208,6 @@ gfx::AcceleratedWidget WaylandWindow::GetWidget() const {
- return surface_.id();
- }
-
--std::set<uint32_t> WaylandWindow::GetEnteredOutputsIds() const {
-- return entered_outputs_ids_;
--}
--
- void WaylandWindow::CreateXdgPopup() {
- if (bounds_px_.IsEmpty())
- return;
-@@ -333,7 +334,7 @@ void WaylandWindow::Show() {
- // bounds. This makes a difference against the normal flow when the
- // window is created (see |Initialize|). To equalize things, rescale
- // |bounds_px_| to DIP. It will be adjusted while creating the popup.
-- bounds_px_ = gfx::ScaleToRoundedRect(bounds_px_, 1.0 / buffer_scale_);
-+ bounds_px_ = gfx::ScaleToRoundedRect(bounds_px_, 1.0 / ui_scale_);
- CreateXdgPopup();
- connection_->ScheduleFlush();
- }
-@@ -916,13 +917,14 @@ gfx::Rect WaylandWindow::AdjustPopupWindowPosition() const {
- : parent_window_;
- DCHECK(parent_window);
- DCHECK(buffer_scale_ == parent_window->buffer_scale_);
-+ DCHECK(ui_scale_ == parent_window->ui_scale_);
-
- // Chromium positions windows in screen coordinates, but Wayland requires them
- // to be in local surface coordinates aka relative to parent window.
-- const gfx::Rect parent_bounds_px =
-- gfx::ScaleToRoundedRect(parent_window_->GetBounds(), 1.0 / buffer_scale_);
-- gfx::Rect new_bounds =
-- TranslateBoundsToParentCoordinates(bounds_px_, parent_bounds_px);
-+ const gfx::Rect parent_bounds_dip =
-+ gfx::ScaleToRoundedRect(parent_window_->GetBounds(), 1.0 / ui_scale_);
-+ gfx::Rect new_bounds_dip =
-+ TranslateBoundsToParentCoordinates(bounds_px_, parent_bounds_dip);
-
- // Chromium may decide to position nested menu windows on the left side
- // instead of the right side of parent menu windows when the size of the
-@@ -942,16 +944,16 @@ gfx::Rect WaylandWindow::AdjustPopupWindowPosition() const {
- !parent_window_->parent_window_->IsMaximized()) {
- auto* top_level_window = parent_window_->parent_window_;
- DCHECK(top_level_window && !top_level_window->xdg_popup());
-- if (new_bounds.x() <= 0 && !top_level_window->IsMaximized()) {
-+ if (new_bounds_dip.x() <= 0 && !top_level_window->IsMaximized()) {
- // Position the child menu window on the right side of the parent window
- // and let the Wayland compositor decide how to do constraint
- // adjustements.
-- int new_x =
-- parent_bounds_px.width() - (new_bounds.width() + new_bounds.x());
-- new_bounds.set_x(new_x);
-+ int new_x = parent_bounds_dip.width() -
-+ (new_bounds_dip.width() + new_bounds_dip.x());
-+ new_bounds_dip.set_x(new_x);
- }
- }
-- return new_bounds;
-+ return gfx::ScaleToRoundedRect(new_bounds_dip, ui_scale_ / buffer_scale_);
- }
-
- WaylandWindow* WaylandWindow::GetTopLevelWindow() {
-diff --git a/ui/ozone/platform/wayland/host/wayland_window.h b/ui/ozone/platform/wayland/host/wayland_window.h
-index 8fcf28fde934..d21e5f48e8ff 100644
---- a/ui/ozone/platform/wayland/host/wayland_window.h
-+++ b/ui/ozone/platform/wayland/host/wayland_window.h
-@@ -10,6 +10,8 @@
- #include <vector>
-
- #include "base/callback.h"
-+#include "base/containers/flat_set.h"
-+#include "base/gtest_prod_util.h"
- #include "base/memory/ref_counted.h"
- #include "ui/events/platform/platform_event_dispatcher.h"
- #include "ui/gfx/geometry/rect.h"
-@@ -52,10 +54,10 @@ class WaylandWindow : public PlatformWindow,
- bool Initialize(PlatformWindowInitProperties properties);
-
- // Updates the surface buffer scale of the window. Top level windows take
-- // scale according to the scale of their current display or the primary one if
-- // their widget is not yet created, children inherit scale from their parent.
-- // The method recalculates window bounds appropriately if asked to do so
-- // (this is not needed upon window initialization).
-+ // scale from the output attached to either their current display or the
-+ // primary one if their widget is not yet created, children inherit scale from
-+ // their parent. The method recalculates window bounds appropriately if asked
-+ // to do so (this is not needed upon window initialization).
- void UpdateBufferScale(bool update_bounds);
-
- wl_surface* surface() const { return surface_.get(); }
-@@ -66,13 +68,6 @@ class WaylandWindow : public PlatformWindow,
-
- gfx::AcceleratedWidget GetWidget() const;
-
-- // Returns the list of wl_outputs aka displays, which this window occupies.
-- // The window can be shown on one or more displays at the same time. An empty
-- // vector can also be returned if the window is not configured on the
-- // compositor side or it has been moved due to unplug action (check the
-- // comment in RemoveEnteredOutputId).
-- std::set<uint32_t> GetEnteredOutputsIds() const;
--
- // Apply the bounds specified in the most recent configure event. This should
- // be called after processing all pending events in the wayland connection.
- void ApplyPendingBounds();
-@@ -102,6 +97,10 @@ class WaylandWindow : public PlatformWindow,
-
- bool is_active() const { return is_active_; }
-
-+ const base::flat_set<uint32_t>& entered_outputs_ids() const {
-+ return entered_outputs_ids_;
-+ }
-+
- // WmMoveResizeHandler
- void DispatchHostWindowDragMovement(
- int hittest,
-@@ -162,6 +161,8 @@ class WaylandWindow : public PlatformWindow,
- void OnDragSessionClose(uint32_t dnd_action);
-
- private:
-+ FRIEND_TEST_ALL_PREFIXES(WaylandScreenTest, SetBufferScale);
-+
- void SetBoundsDip(const gfx::Rect& bounds_dip);
- void SetBufferScale(int32_t scale, bool update_bounds);
-
-@@ -252,7 +253,13 @@ class WaylandWindow : public PlatformWindow,
- bool has_keyboard_focus_ = false;
- bool has_touch_focus_ = false;
- bool has_implicit_grab_ = false;
-+ // Wayland's scale factor for the output that this window currently belongs
-+ // to.
- int32_t buffer_scale_ = 1;
-+ // The UI scale may be forced through the command line, which means that it
-+ // replaces the default value that is equal to the natural device scale.
-+ // We need it to place and size the menus properly.
-+ float ui_scale_ = 1.0;
-
- // Stores current states of the window.
- ui::PlatformWindowState state_;
-@@ -268,15 +275,15 @@ class WaylandWindow : public PlatformWindow,
-
- bool is_tooltip_ = false;
-
-- // For top level window, stores the list of entered outputs that the window
-- // is currently in.
-+ // For top level window, stores IDs of outputs that the window is currently
-+ // rendered at.
- //
- // Not used by popups. When sub-menus are hidden and shown again, Wayland
-- // 'repositions' sub-menus to wrong outputs by sending them leave and enter
-+ // 'repositions' them to wrong outputs by sending them leave and enter
- // events so their list of entered outputs becomes meaningless after they have
- // been hidden at least once. To determine which output the popup belongs to,
- // we ask its parent.
-- std::set<uint32_t> entered_outputs_ids_;
-+ base::flat_set<uint32_t> entered_outputs_ids_;
-
- DISALLOW_COPY_AND_ASSIGN(WaylandWindow);
- };
---
-2.22.0
-
diff --git a/PKGBUILD b/PKGBUILD
index 160a5e9b3ddb..59517a09c4c8 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -5,7 +5,7 @@
# Contributor: Daniel J Griffiths <ghost1227@archlinux.us>
pkgname=chromium-ozone
-pkgver=76.0.3809.132
+pkgver=77.0.3865.75
pkgrel=1
_launcher_ver=6
_meta_browser_sha=38b36f421f8d984c7004c9d9a6d514ed2fb6cf8e
@@ -32,34 +32,24 @@ source=(https://commondatastorage.googleapis.com/chromium-browser-official/chrom
chromium-system-icu.patch
chromium-widevine.patch
chromium-skia-harmony.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
- 0006-ozone-wayland-Reset-surface-contents-in-a-safe-way.patch
- 0007-ozone-wayland-Stop-using-wl_display_roundtrip.patch
- 0008-ozone-wayland-Added-HiDPI-support-for-Ozone-Wayland.patch
- 0009-Fixed-positioning-and-sizes-of-menus-when-the-scale-.patch
- 0010-ozone-wayland-Extract-window-management-methods-to-o.patch
- 0011-ozone-wayland-Do-not-use-possibly-blocking-dispatch-.patch)
-sha256sums=('d54e4640b5e399d170dffbc5bcff65157eb1b29314b94b5d808f727d9ce45241'
+ 0001-ozone-wayland-Sway-avoid-sending-presentation-early.patch
+ 0002-ozone-wayland-Use-mutex-before-accessing-surfaces-ma.patch
+ 0003-ozone-wayland-Stop-using-wl_display_roundtrip.patch
+ 0004-ozone-wayland-Extract-window-management-methods-to-o.patch
+ 0005-ozone-wayland-Do-not-use-possibly-blocking-dispatch-.patch
+ 0006-IWYU-include-memory-in-one_euro_filter.h-as-it-uses-.patch)
+sha256sums=('eb952ff241e719cbdcc2aae1832ecc1dd2263736ab38ee1dbf88ac9120119789'
'04917e3cd4307d8e31bfb0027a5dce6d086edb10ff8a716024fbb8bb0c7dccf1'
'd87957d01be9fb59faf5fde523eb87a8256605b1533171416b7a56bfcbd6d056'
'e2d284311f49c529ea45083438a768db390bde52949995534034d2a814beab89'
'd081f2ef8793544685aad35dea75a7e6264a2cb987ff3541e6377f4a3650a28b'
'771292942c0901092a402cc60ee883877a99fb804cb54d568c8c6c94565a48e1'
- '1fe3bb02ffd0445da8ea3b9eb09e8dff6b7bdd1ca26f4b439310a3e94aa16ebf'
- 'd9c5932f1af91a8c2e8b7687d9ad013d5895e3e03811d9f03e674afb77031ce5'
- '424c5c0e5b6ded87d0c00dd4755eb6e63bfdf42233ee60c354729f5cbba82334'
- 'fecdfa694a84b4dc688ec20970ea18b11d9e332b8423a935ba35cd3fae7485a5'
- '2359fdd84a3c10eeb576b15cfea86a34867097cb3e3d30ade6c823cf0d538d99'
- '13be86e54b14f5a9f21e371a0f2762c5ff9a4204877ded60600f5950f6a14885'
- 'ede2a4c0283f01f7653c0caabd8439d96c27da16dd557ebb0730c0b3e7134097'
- '9996ddaa8a83c58dcbe45e21746ffe41a9f8b56edc71a16090ebdb6adbc74541'
- '6f4fc0a82443f9bfaeecfd1a463b4bc10dfa29b9357f17592dfac8332d27cb3c'
- '470cf88aa6878bfaaf74f00791d33f4f922f31a13e0503b8bb11edb4bb89d29c'
- 'aaefa3a868024aa1eb118236bd528986db972646f762418764b5f0ab326468b0')
+ '333a4ecac50f1f2a2545132dc97bd22ccb1a0623bd5a5d86487327e8ee6fde3d'
+ '5d1e93f1930a53d2cee7d7cff94b4aba3a91dc15e13f667ce56956b2d08222cc'
+ '19dc0c5b521ad252b75a42cad254ced431f790bb71d1c048eb748a65e29aeb69'
+ 'd0ed9879427db1412b679c2ab0ff4da83698f6dfe389080d272ec85716478b43'
+ '465dbcefbe8b01d242491bb527da8ecb466654262162b9bdc96bbf13ee8b864f'
+ 'c5ea9e17c745de25ce9d1935883b538e660a406b07fc3ac72354e5a24a5354f8')
# Possible replacements are listed in build/linux/unbundle/replace_gn_files.py
# Keys are the names in the above script; values are the dependencies in Arch
@@ -81,7 +71,7 @@ declare -gA _system_libs=(
[re2]=re2
[snappy]=snappy
[yasm]=
- [zlib]=minizip
+ # [zlib]=minizip
)
_unwanted_bundled_libs=(
${!_system_libs[@]}
@@ -96,32 +86,20 @@ _google_api_key=AIzaSyDwr302FpOSkGRpLlUpPThNTDPbXcIn_FM
_google_default_client_id=413772536636.apps.googleusercontent.com
_google_default_client_secret=0ZChLK6AxeA3Isu96MkwqDR4
-_mb_general_patches=(
- 'oe-clang-fixes.patch'
- # 'v8-qemu-wrapper.patch'
- 'wrapper-extra-flags.patch'
- 'do-not-specify-march-on-arm.patch'
- 'add_internal_define_armv7ve.patch'
-)
+_mb_general_patches=()
_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'
+ # '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'
- '0006-ozone-wayland-Reset-surface-contents-in-a-safe-way.patch'
- '0007-ozone-wayland-Stop-using-wl_display_roundtrip.patch'
- '0008-ozone-wayland-Added-HiDPI-support-for-Ozone-Wayland.patch'
- '0009-Fixed-positioning-and-sizes-of-menus-when-the-scale-.patch'
- '0010-ozone-wayland-Extract-window-management-methods-to-o.patch'
- '0011-ozone-wayland-Do-not-use-possibly-blocking-dispatch-.patch'
+ '0001-ozone-wayland-Sway-avoid-sending-presentation-early.patch'
+ '0002-ozone-wayland-Use-mutex-before-accessing-surfaces-ma.patch'
+ '0003-ozone-wayland-Stop-using-wl_display_roundtrip.patch'
+ '0004-ozone-wayland-Extract-window-management-methods-to-o.patch'
+ '0005-ozone-wayland-Do-not-use-possibly-blocking-dispatch-.patch'
+ '0006-IWYU-include-memory-in-one_euro_filter.h-as-it-uses-.patch'
)
prepare() {