summaryrefslogtreecommitdiff
path: root/chromium/ui/ozone
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-05-15 10:20:33 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-05-15 10:28:57 +0000
commitd17ea114e5ef69ad5d5d7413280a13e6428098aa (patch)
tree2c01a75df69f30d27b1432467cfe7c1467a498da /chromium/ui/ozone
parent8c5c43c7b138c9b4b0bf56d946e61d3bbc111bec (diff)
downloadqtwebengine-chromium-d17ea114e5ef69ad5d5d7413280a13e6428098aa.tar.gz
BASELINE: Update Chromium to 67.0.3396.47
Change-Id: Idcb1341782e417561a2473eeecc82642dafda5b7 Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'chromium/ui/ozone')
-rw-r--r--chromium/ui/ozone/common/egl_util.cc14
-rw-r--r--chromium/ui/ozone/common/gpu/ozone_gpu_message_params.h3
-rw-r--r--chromium/ui/ozone/common/gpu/ozone_gpu_messages.h4
-rw-r--r--chromium/ui/ozone/demo/BUILD.gn6
-rw-r--r--chromium/ui/ozone/demo/demo_window.cc90
-rw-r--r--chromium/ui/ozone/demo/demo_window.h69
-rw-r--r--chromium/ui/ozone/demo/ozone_demo.cc338
-rw-r--r--chromium/ui/ozone/demo/renderer_factory.cc75
-rw-r--r--chromium/ui/ozone/demo/renderer_factory.h41
-rw-r--r--chromium/ui/ozone/demo/skia_renderer.cc6
-rw-r--r--chromium/ui/ozone/demo/surfaceless_skia_renderer.cc22
-rw-r--r--chromium/ui/ozone/demo/window_manager.cc112
-rw-r--r--chromium/ui/ozone/demo/window_manager.h66
-rw-r--r--chromium/ui/ozone/gl/gl_image_ozone_native_pixmap_unittest.cc10
-rw-r--r--chromium/ui/ozone/platform/cast/client_native_pixmap_factory_cast.cc3
-rw-r--r--chromium/ui/ozone/platform/cast/gl_ozone_egl_cast.cc1
-rw-r--r--chromium/ui/ozone/platform/cast/gl_surface_cast.cc6
-rw-r--r--chromium/ui/ozone/platform/cast/gl_surface_cast.h3
-rw-r--r--chromium/ui/ozone/platform/cast/overlay_manager_cast.cc62
-rw-r--r--chromium/ui/ozone/platform/cast/overlay_manager_cast.h15
-rw-r--r--chromium/ui/ozone/platform/cast/platform_window_cast.cc19
-rw-r--r--chromium/ui/ozone/platform/cast/platform_window_cast.h1
-rw-r--r--chromium/ui/ozone/platform/cast/surface_factory_cast.cc3
-rw-r--r--chromium/ui/ozone/platform/drm/BUILD.gn2
-rw-r--r--chromium/ui/ozone/platform/drm/client_native_pixmap_factory_gbm.cc1
-rw-r--r--chromium/ui/ozone/platform/drm/common/drm_util.cc61
-rw-r--r--chromium/ui/ozone/platform/drm/common/drm_util.h7
-rw-r--r--chromium/ui/ozone/platform/drm/common/drm_util_unittest.cc59
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/crtc_controller.cc4
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/drm_device.cc9
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/drm_display.cc1
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/drm_gpu_display_manager.cc1
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/drm_overlay_validator.cc2
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/drm_overlay_validator_unittest.cc2
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/drm_thread.cc3
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/drm_thread_message_proxy.cc35
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/drm_thread_proxy.cc9
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/drm_window.cc1
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/drm_window_proxy.cc6
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/drm_window_unittest.cc4
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/gbm_buffer.cc5
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/gbm_buffer.h3
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/gbm_surface.cc4
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/gbm_surface_factory.cc1
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/gbm_surfaceless.cc8
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/gbm_surfaceless.h3
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/hardware_display_controller.cc6
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc91
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.h14
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.cc5
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h6
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.cc2
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.h3
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.cc15
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.h3
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_unittest.cc41
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/mock_scanout_buffer.cc3
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/mock_scanout_buffer.h1
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/overlay_plane.cc3
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/overlay_plane.h2
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/proxy_helpers.cc2
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/proxy_helpers.h2
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/proxy_helpers_unittest.cc10
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/screen_manager.cc8
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/screen_manager_unittest.cc2
-rw-r--r--chromium/ui/ozone/platform/drm/host/drm_cursor.cc3
-rw-r--r--chromium/ui/ozone/platform/drm/host/drm_display_host.cc7
-rw-r--r--chromium/ui/ozone/platform/drm/host/drm_display_host_manager.cc44
-rw-r--r--chromium/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.cc62
-rw-r--r--chromium/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h8
-rw-r--r--chromium/ui/ozone/platform/drm/host/drm_overlay_manager.cc6
-rw-r--r--chromium/ui/ozone/platform/drm/host/drm_window_host.cc18
-rw-r--r--chromium/ui/ozone/platform/drm/host/drm_window_host.h1
-rw-r--r--chromium/ui/ozone/platform/drm/host/gpu_thread_observer.h7
-rw-r--r--chromium/ui/ozone/platform/drm/ozone_platform_gbm.cc1
-rw-r--r--chromium/ui/ozone/platform/headless/BUILD.gn2
-rw-r--r--chromium/ui/ozone/platform/headless/gl_surface_osmesa_png.cc2
-rw-r--r--chromium/ui/ozone/platform/headless/headless_surface_factory.cc12
-rw-r--r--chromium/ui/ozone/platform/headless/headless_window.cc13
-rw-r--r--chromium/ui/ozone/platform/headless/headless_window.h1
-rw-r--r--chromium/ui/ozone/platform/headless/ozone_platform_headless.cc3
-rw-r--r--chromium/ui/ozone/platform/wayland/fake_server.cc123
-rw-r--r--chromium/ui/ozone/platform/wayland/fake_server.h55
-rw-r--r--chromium/ui/ozone/platform/wayland/ozone_platform_wayland.cc1
-rw-r--r--chromium/ui/ozone/platform/wayland/wayland_connection.cc15
-rw-r--r--chromium/ui/ozone/platform/wayland/wayland_connection.h9
-rw-r--r--chromium/ui/ozone/platform/wayland/wayland_keyboard_unittest.cc134
-rw-r--r--chromium/ui/ozone/platform/wayland/wayland_pointer.cc54
-rw-r--r--chromium/ui/ozone/platform/wayland/wayland_pointer.h14
-rw-r--r--chromium/ui/ozone/platform/wayland/wayland_pointer_unittest.cc108
-rw-r--r--chromium/ui/ozone/platform/wayland/wayland_surface_factory_unittest.cc16
-rw-r--r--chromium/ui/ozone/platform/wayland/wayland_test.cc32
-rw-r--r--chromium/ui/ozone/platform/wayland/wayland_test.h16
-rw-r--r--chromium/ui/ozone/platform/wayland/wayland_touch.cc1
-rw-r--r--chromium/ui/ozone/platform/wayland/wayland_touch_unittest.cc16
-rw-r--r--chromium/ui/ozone/platform/wayland/wayland_window.cc26
-rw-r--r--chromium/ui/ozone/platform/wayland/wayland_window.h12
-rw-r--r--chromium/ui/ozone/platform/wayland/wayland_window_unittest.cc236
-rw-r--r--chromium/ui/ozone/platform/x11/BUILD.gn7
-rw-r--r--chromium/ui/ozone/platform/x11/ozone_platform_x11.cc10
-rw-r--r--chromium/ui/ozone/platform/x11/x11_surface_factory.cc1
-rw-r--r--chromium/ui/ozone/platform/x11/x11_window_manager_ozone.cc8
-rw-r--r--chromium/ui/ozone/platform/x11/x11_window_manager_ozone.h7
-rw-r--r--chromium/ui/ozone/platform/x11/x11_window_ozone.cc33
-rw-r--r--chromium/ui/ozone/platform/x11/x11_window_ozone.h3
-rw-r--r--chromium/ui/ozone/platform/x11/x11_window_ozone_unittest.cc150
-rw-r--r--chromium/ui/ozone/public/client_native_pixmap_factory_ozone.cc43
-rw-r--r--chromium/ui/ozone/public/client_native_pixmap_factory_ozone.h7
-rw-r--r--chromium/ui/ozone/public/interfaces/BUILD.gn2
-rw-r--r--chromium/ui/ozone/public/interfaces/drm_device.mojom10
-rw-r--r--chromium/ui/ozone/public/ozone_gpu_test_helper.cc19
-rw-r--r--chromium/ui/ozone/public/ozone_platform.cc10
-rw-r--r--chromium/ui/ozone/public/ozone_platform.h7
113 files changed, 1676 insertions, 1118 deletions
diff --git a/chromium/ui/ozone/common/egl_util.cc b/chromium/ui/ozone/common/egl_util.cc
index 9a40d1db001..86636c3f94b 100644
--- a/chromium/ui/ozone/common/egl_util.cc
+++ b/chromium/ui/ozone/common/egl_util.cc
@@ -14,12 +14,16 @@
namespace ui {
namespace {
-const char kDefaultEglSoname[] = "libEGL.so.1";
-const char kDefaultGlesSoname[] = "libGLESv2.so.2";
+const base::FilePath::CharType kDefaultEglSoname[] =
+ FILE_PATH_LITERAL("libEGL.so.1");
+const base::FilePath::CharType kDefaultGlesSoname[] =
+ FILE_PATH_LITERAL("libGLESv2.so.2");
#if BUILDFLAG(ENABLE_SWIFTSHADER)
-const char kGLESv2SwiftShaderLibraryName[] = "libGLESv2.so";
-const char kEGLSwiftShaderLibraryName[] = "libEGL.so";
+const base::FilePath::CharType kGLESv2SwiftShaderLibraryName[] =
+ FILE_PATH_LITERAL("libGLESv2.so");
+const base::FilePath::CharType kEGLSwiftShaderLibraryName[] =
+ FILE_PATH_LITERAL("libEGL.so");
#endif
bool LoadEGLGLES2Bindings(const base::FilePath& egl_library_path,
@@ -69,7 +73,7 @@ bool LoadDefaultEGLGLES2Bindings(gl::GLImplementation implementation) {
base::FilePath module_path;
if (!PathService::Get(base::DIR_MODULE, &module_path))
return false;
- module_path = module_path.Append("swiftshader/");
+ module_path = module_path.Append(FILE_PATH_LITERAL("swiftshader/"));
glesv2_path = module_path.Append(kGLESv2SwiftShaderLibraryName);
egl_path = module_path.Append(kEGLSwiftShaderLibraryName);
diff --git a/chromium/ui/ozone/common/gpu/ozone_gpu_message_params.h b/chromium/ui/ozone/common/gpu/ozone_gpu_message_params.h
index 0c5ca179b9a..06065107640 100644
--- a/chromium/ui/ozone/common/gpu/ozone_gpu_message_params.h
+++ b/chromium/ui/ozone/common/gpu/ozone_gpu_message_params.h
@@ -53,7 +53,8 @@ struct DisplaySnapshot_Params {
DisplayMode_Params current_mode;
bool has_native_mode = false;
DisplayMode_Params native_mode;
- int64_t product_id = 0;
+ int64_t product_code = 0;
+ int32_t year_of_manufacture = display::kInvalidYearOfManufacture;
gfx::Size maximum_cursor_size;
};
diff --git a/chromium/ui/ozone/common/gpu/ozone_gpu_messages.h b/chromium/ui/ozone/common/gpu/ozone_gpu_messages.h
index 6db409c8df7..d472f0830f1 100644
--- a/chromium/ui/ozone/common/gpu/ozone_gpu_messages.h
+++ b/chromium/ui/ozone/common/gpu/ozone_gpu_messages.h
@@ -4,6 +4,7 @@
// Multiply-included message file, hence no include guard here, but see below
// for a much smaller-than-usual include guard section.
+// no-include-guard-because-multiply-included
#include <stdint.h>
@@ -62,7 +63,8 @@ IPC_STRUCT_TRAITS_BEGIN(ui::DisplaySnapshot_Params)
IPC_STRUCT_TRAITS_MEMBER(current_mode)
IPC_STRUCT_TRAITS_MEMBER(has_native_mode)
IPC_STRUCT_TRAITS_MEMBER(native_mode)
- IPC_STRUCT_TRAITS_MEMBER(product_id)
+ IPC_STRUCT_TRAITS_MEMBER(product_code)
+ IPC_STRUCT_TRAITS_MEMBER(year_of_manufacture)
IPC_STRUCT_TRAITS_MEMBER(maximum_cursor_size)
IPC_STRUCT_TRAITS_END()
diff --git a/chromium/ui/ozone/demo/BUILD.gn b/chromium/ui/ozone/demo/BUILD.gn
index 8a01fb9b10e..71447419f9f 100644
--- a/chromium/ui/ozone/demo/BUILD.gn
+++ b/chromium/ui/ozone/demo/BUILD.gn
@@ -10,16 +10,22 @@ group("demo") {
executable("ozone_demo") {
sources = [
+ "demo_window.cc",
+ "demo_window.h",
"ozone_demo.cc",
"renderer.h",
"renderer_base.cc",
"renderer_base.h",
+ "renderer_factory.cc",
+ "renderer_factory.h",
"skia_renderer.cc",
"skia_renderer.h",
"software_renderer.cc",
"software_renderer.h",
"surfaceless_skia_renderer.cc",
"surfaceless_skia_renderer.h",
+ "window_manager.cc",
+ "window_manager.h",
]
deps = [
diff --git a/chromium/ui/ozone/demo/demo_window.cc b/chromium/ui/ozone/demo/demo_window.cc
new file mode 100644
index 00000000000..f641537e0f3
--- /dev/null
+++ b/chromium/ui/ozone/demo/demo_window.cc
@@ -0,0 +1,90 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/ozone/demo/demo_window.h"
+
+#include "base/threading/thread_task_runner_handle.h"
+#include "ui/events/event.h"
+#include "ui/events/keycodes/dom/dom_code.h"
+#include "ui/ozone/demo/renderer.h"
+#include "ui/ozone/demo/renderer_factory.h"
+#include "ui/ozone/demo/window_manager.h"
+#include "ui/ozone/public/ozone_platform.h"
+#include "ui/platform_window/platform_window.h"
+
+namespace ui {
+
+DemoWindow::DemoWindow(WindowManager* window_manager,
+ RendererFactory* renderer_factory,
+ const gfx::Rect& bounds)
+ : window_manager_(window_manager),
+ renderer_factory_(renderer_factory),
+ weak_ptr_factory_(this) {
+ platform_window_ =
+ OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds);
+ platform_window_->Show();
+}
+
+DemoWindow::~DemoWindow() {}
+
+gfx::AcceleratedWidget DemoWindow::GetAcceleratedWidget() {
+ // TODO(spang): We should start rendering asynchronously.
+ DCHECK_NE(widget_, gfx::kNullAcceleratedWidget)
+ << "Widget not available synchronously";
+ return widget_;
+}
+
+gfx::Size DemoWindow::GetSize() {
+ return platform_window_->GetBounds().size();
+}
+
+void DemoWindow::Start() {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
+ base::BindOnce(&DemoWindow::StartOnGpu, weak_ptr_factory_.GetWeakPtr()));
+}
+
+void DemoWindow::Quit() {
+ window_manager_->Quit();
+}
+
+void DemoWindow::OnBoundsChanged(const gfx::Rect& new_bounds) {}
+
+void DemoWindow::OnDamageRect(const gfx::Rect& damaged_region) {}
+
+void DemoWindow::DispatchEvent(Event* event) {
+ if (event->IsKeyEvent() && event->AsKeyEvent()->code() == DomCode::US_Q)
+ Quit();
+}
+
+void DemoWindow::OnCloseRequest() {
+ Quit();
+}
+
+void DemoWindow::OnClosed() {}
+
+void DemoWindow::OnWindowStateChanged(PlatformWindowState new_state) {}
+
+void DemoWindow::OnLostCapture() {}
+
+void DemoWindow::OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget,
+ float device_pixel_ratio) {
+ DCHECK_NE(widget, gfx::kNullAcceleratedWidget);
+ widget_ = widget;
+}
+
+void DemoWindow::OnAcceleratedWidgetDestroyed() {
+ NOTREACHED();
+}
+
+void DemoWindow::OnActivationChanged(bool active) {}
+
+void DemoWindow::StartOnGpu() {
+ renderer_ =
+ renderer_factory_->CreateRenderer(GetAcceleratedWidget(), GetSize());
+ if (!renderer_->Initialize())
+ LOG(ERROR) << "Failed to initialize renderer.";
+}
+
+} // namespace ui
diff --git a/chromium/ui/ozone/demo/demo_window.h b/chromium/ui/ozone/demo/demo_window.h
new file mode 100644
index 00000000000..6a41df1252b
--- /dev/null
+++ b/chromium/ui/ozone/demo/demo_window.h
@@ -0,0 +1,69 @@
+// Copyright 2018 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_DEMO_DEMO_WINDOW_H_
+#define UI_OZONE_DEMO_DEMO_WINDOW_H_
+
+#include "base/memory/weak_ptr.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/geometry/size.h"
+#include "ui/platform_window/platform_window_delegate.h"
+
+namespace ui {
+
+class Event;
+class PlatformWindow;
+class Renderer;
+class RendererFactory;
+class WindowManager;
+
+class DemoWindow : public PlatformWindowDelegate {
+ public:
+ DemoWindow(WindowManager* window_manager,
+ RendererFactory* renderer_factory,
+ const gfx::Rect& bounds);
+ ~DemoWindow() override;
+
+ gfx::AcceleratedWidget GetAcceleratedWidget();
+
+ gfx::Size GetSize();
+
+ void Start();
+ void Quit();
+
+ // PlatformWindowDelegate:
+ void OnBoundsChanged(const gfx::Rect& new_bounds) override;
+ void OnDamageRect(const gfx::Rect& damaged_region) override;
+ void DispatchEvent(Event* event) override;
+ void OnCloseRequest() override;
+ void OnClosed() override;
+ void OnWindowStateChanged(PlatformWindowState new_state) override;
+ void OnLostCapture() override;
+ void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget,
+ float device_pixel_ratio) override;
+ void OnAcceleratedWidgetDestroyed() override;
+ void OnActivationChanged(bool active) override;
+
+ private:
+ // Since we pretend to have a GPU process, we should also pretend to
+ // initialize the GPU resources via a posted task.
+ void StartOnGpu();
+
+ WindowManager* window_manager_; // Not owned.
+ RendererFactory* renderer_factory_; // Not owned.
+
+ std::unique_ptr<Renderer> renderer_;
+
+ // Window-related state.
+ std::unique_ptr<PlatformWindow> platform_window_;
+ gfx::AcceleratedWidget widget_ = gfx::kNullAcceleratedWidget;
+
+ base::WeakPtrFactory<DemoWindow> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(DemoWindow);
+};
+
+} // namespace ui
+
+#endif // UI_OZONE_DEMO_DEMO_WINDOW_H_
diff --git a/chromium/ui/ozone/demo/ozone_demo.cc b/chromium/ui/ozone/demo/ozone_demo.cc
index fc989906f2e..6806dbe84fe 100644
--- a/chromium/ui/ozone/demo/ozone_demo.cc
+++ b/chromium/ui/ozone/demo/ozone_demo.cc
@@ -2,334 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <utility>
+#include <iostream>
#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/debug/stack_trace.h"
-#include "base/macros.h"
-#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/task_scheduler/task_scheduler.h"
-#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
#include "components/tracing/common/trace_to_console.h"
#include "components/tracing/common/tracing_switches.h"
-#include "ui/display/types/display_snapshot.h"
-#include "ui/display/types/native_display_delegate.h"
-#include "ui/display/types/native_display_observer.h"
-#include "ui/events/event.h"
-#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/ozone/layout/keyboard_layout_engine.h"
#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
-#include "ui/gfx/geometry/rect.h"
-#include "ui/gfx/geometry/size.h"
-#include "ui/gl/gl_surface.h"
-#include "ui/gl/init/gl_factory.h"
-#include "ui/ozone/demo/skia_renderer.h"
-#include "ui/ozone/demo/software_renderer.h"
-#include "ui/ozone/demo/surfaceless_skia_renderer.h"
-#include "ui/ozone/public/ozone_gpu_test_helper.h"
+#include "ui/ozone/demo/window_manager.h"
#include "ui/ozone/public/ozone_platform.h"
-#include "ui/ozone/public/ozone_switches.h"
-#include "ui/platform_window/platform_window.h"
-#include "ui/platform_window/platform_window_delegate.h"
-const int kTestWindowWidth = 800;
-const int kTestWindowHeight = 600;
-
-const char kDisableGpu[] = "disable-gpu";
-const char kDisableSurfaceless[] = "disable-surfaceless";
-
-const char kWindowSize[] = "window-size";
-
-class DemoWindow;
-
-scoped_refptr<gl::GLSurface> CreateGLSurface(gfx::AcceleratedWidget widget) {
- scoped_refptr<gl::GLSurface> surface;
- if (!base::CommandLine::ForCurrentProcess()->HasSwitch(kDisableSurfaceless))
- surface = gl::init::CreateSurfacelessViewGLSurface(widget);
- if (!surface)
- surface = gl::init::CreateViewGLSurface(widget);
- return surface;
-}
-
-class RendererFactory {
- public:
- enum RendererType {
- SKIA,
- SOFTWARE,
- };
-
- RendererFactory();
- ~RendererFactory();
-
- bool Initialize();
- std::unique_ptr<ui::Renderer> CreateRenderer(gfx::AcceleratedWidget widget,
- const gfx::Size& size);
-
- private:
- RendererType type_ = SOFTWARE;
-
- // Helper for applications that do GL on main thread.
- ui::OzoneGpuTestHelper gpu_helper_;
-
- DISALLOW_COPY_AND_ASSIGN(RendererFactory);
-};
-
-class WindowManager : public display::NativeDisplayObserver {
- public:
- explicit WindowManager(const base::Closure& quit_closure);
- ~WindowManager() override;
-
- void Quit();
-
- void AddWindow(DemoWindow* window);
- void RemoveWindow(DemoWindow* window);
-
- private:
- void OnDisplaysAquired(
- const std::vector<display::DisplaySnapshot*>& displays);
- void OnDisplayConfigured(const gfx::Rect& bounds, bool success);
-
- // display::NativeDisplayDelegate:
- void OnConfigurationChanged() override;
- void OnDisplaySnapshotsInvalidated() override;
-
- std::unique_ptr<display::NativeDisplayDelegate> delegate_;
- base::Closure quit_closure_;
- RendererFactory renderer_factory_;
- std::vector<std::unique_ptr<DemoWindow>> windows_;
-
- // Flags used to keep track of the current state of display configuration.
- //
- // True if configuring the displays. In this case a new display configuration
- // isn't started.
- bool is_configuring_ = false;
-
- // If |is_configuring_| is true and another display configuration event
- // happens, the event is deferred. This is set to true and a display
- // configuration will be scheduled after the current one finishes.
- bool should_configure_ = false;
-
- DISALLOW_COPY_AND_ASSIGN(WindowManager);
-};
-
-class DemoWindow : public ui::PlatformWindowDelegate {
- public:
- DemoWindow(WindowManager* window_manager,
- RendererFactory* renderer_factory,
- const gfx::Rect& bounds)
- : window_manager_(window_manager),
- renderer_factory_(renderer_factory),
- weak_ptr_factory_(this) {
- platform_window_ =
- ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds);
- platform_window_->Show();
- }
- ~DemoWindow() override {}
-
- gfx::AcceleratedWidget GetAcceleratedWidget() {
- // TODO(spang): We should start rendering asynchronously.
- DCHECK_NE(widget_, gfx::kNullAcceleratedWidget)
- << "Widget not available synchronously";
- return widget_;
- }
-
- gfx::Size GetSize() { return platform_window_->GetBounds().size(); }
-
- void Start() {
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::Bind(&DemoWindow::StartOnGpu, weak_ptr_factory_.GetWeakPtr()));
- }
-
- void Quit() {
- window_manager_->Quit();
- }
-
- // PlatformWindowDelegate:
- void OnBoundsChanged(const gfx::Rect& new_bounds) override {}
- void OnDamageRect(const gfx::Rect& damaged_region) override {}
- void DispatchEvent(ui::Event* event) override {
- if (event->IsKeyEvent() && event->AsKeyEvent()->code() == ui::DomCode::US_Q)
- Quit();
- }
- void OnCloseRequest() override { Quit(); }
- void OnClosed() override {}
- void OnWindowStateChanged(ui::PlatformWindowState new_state) override {}
- void OnLostCapture() override {}
- void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget,
- float device_pixel_ratio) override {
- DCHECK_NE(widget, gfx::kNullAcceleratedWidget);
- widget_ = widget;
- }
- void OnAcceleratedWidgetDestroyed() override {
- NOTREACHED();
- }
- void OnActivationChanged(bool active) override {}
-
- private:
- // Since we pretend to have a GPU process, we should also pretend to
- // initialize the GPU resources via a posted task.
- void StartOnGpu() {
- renderer_ =
- renderer_factory_->CreateRenderer(GetAcceleratedWidget(), GetSize());
- if (!renderer_->Initialize())
- LOG(ERROR) << "Failed to initialize renderer.";
- }
-
- WindowManager* window_manager_; // Not owned.
- RendererFactory* renderer_factory_; // Not owned.
-
- std::unique_ptr<ui::Renderer> renderer_;
-
- // Window-related state.
- std::unique_ptr<ui::PlatformWindow> platform_window_;
- gfx::AcceleratedWidget widget_ = gfx::kNullAcceleratedWidget;
-
- base::WeakPtrFactory<DemoWindow> weak_ptr_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(DemoWindow);
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// RendererFactory implementation:
-
-RendererFactory::RendererFactory() {
-}
-
-RendererFactory::~RendererFactory() {
-}
-
-bool RendererFactory::Initialize() {
- ui::OzonePlatform::InitParams params;
- params.single_process = true;
- ui::OzonePlatform::InitializeForGPU(params);
- ui::OzonePlatform::GetInstance()->AfterSandboxEntry();
-
- base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
- if (!command_line->HasSwitch(kDisableGpu) && gl::init::InitializeGLOneOff() &&
- gpu_helper_.Initialize(base::ThreadTaskRunnerHandle::Get())) {
- type_ = SKIA;
- } else {
- type_ = SOFTWARE;
- }
-
- return true;
-}
-
-std::unique_ptr<ui::Renderer> RendererFactory::CreateRenderer(
- gfx::AcceleratedWidget widget,
- const gfx::Size& size) {
- switch (type_) {
- case SKIA: {
- scoped_refptr<gl::GLSurface> surface = CreateGLSurface(widget);
- if (!surface)
- LOG(FATAL) << "Failed to create GL surface";
- if (surface->IsSurfaceless()) {
- return std::make_unique<ui::SurfacelessSkiaRenderer>(widget, surface,
- size);
- }
- return std::make_unique<ui::SkiaRenderer>(widget, surface, size);
- }
- case SOFTWARE:
- return std::make_unique<ui::SoftwareRenderer>(widget, size);
- }
-
- return nullptr;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// WindowManager implementation:
-
-WindowManager::WindowManager(const base::Closure& quit_closure)
- : delegate_(
- ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate()),
- quit_closure_(quit_closure) {
- if (!renderer_factory_.Initialize())
- LOG(FATAL) << "Failed to initialize renderer factory";
-
- if (delegate_) {
- delegate_->AddObserver(this);
- delegate_->Initialize();
- OnConfigurationChanged();
- } else {
- LOG(WARNING) << "No display delegate; falling back to test window";
- int width = kTestWindowWidth;
- int height = kTestWindowHeight;
- sscanf(base::CommandLine::ForCurrentProcess()
- ->GetSwitchValueASCII(kWindowSize)
- .c_str(),
- "%dx%d", &width, &height);
-
- DemoWindow* window = new DemoWindow(this, &renderer_factory_,
- gfx::Rect(gfx::Size(width, height)));
- window->Start();
- }
-}
-
-WindowManager::~WindowManager() {
- if (delegate_)
- delegate_->RemoveObserver(this);
-}
-
-void WindowManager::Quit() {
- quit_closure_.Run();
-}
-
-void WindowManager::OnConfigurationChanged() {
- if (is_configuring_) {
- should_configure_ = true;
- return;
- }
-
- is_configuring_ = true;
- delegate_->GetDisplays(
- base::Bind(&WindowManager::OnDisplaysAquired, base::Unretained(this)));
-}
-
-void WindowManager::OnDisplaySnapshotsInvalidated() {}
-
-void WindowManager::OnDisplaysAquired(
- const std::vector<display::DisplaySnapshot*>& displays) {
- windows_.clear();
-
- gfx::Point origin;
- for (auto* display : displays) {
- if (!display->native_mode()) {
- LOG(ERROR) << "Display " << display->display_id()
- << " doesn't have a native mode";
- continue;
- }
-
- delegate_->Configure(
- *display, display->native_mode(), origin,
- base::Bind(&WindowManager::OnDisplayConfigured, base::Unretained(this),
- gfx::Rect(origin, display->native_mode()->size())));
- origin.Offset(display->native_mode()->size().width(), 0);
- }
- is_configuring_ = false;
-
- if (should_configure_) {
- should_configure_ = false;
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(&WindowManager::OnConfigurationChanged,
- base::Unretained(this)));
- }
-}
-
-void WindowManager::OnDisplayConfigured(const gfx::Rect& bounds, bool success) {
- if (success) {
- std::unique_ptr<DemoWindow> window(
- new DemoWindow(this, &renderer_factory_, bounds));
- window->Start();
- windows_.push_back(std::move(window));
- } else {
- LOG(ERROR) << "Failed to configure display at " << bounds.ToString();
- }
-}
+const char kHelp[] = "help";
int main(int argc, char** argv) {
base::CommandLine::Init(argc, argv);
@@ -341,6 +30,25 @@ int main(int argc, char** argv) {
logging::LoggingSettings settings;
logging::InitLogging(settings);
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(kHelp)) {
+ std::cout <<
+ "Usage:\n\n"
+ " --enable-drm-atomic Use the atomic KMS API\n"
+ " --disable-gpu Force software rendering\n"
+ " --disable-surfaceless Don't use surfaceless EGL\n"
+ " --window-size=WIDTHxHEIGHT Specify window size\n"
+ " --use-ddl Use SkDeferredDisplayList\n"
+ " --partial-primary-plane "
+ "Use smaller than fullscreen primary plane\n"
+ " --enable-overlay Use an overlay plane\n"
+ " --disable-primary-plane Don't use the primary plane\n";
+
+ // TODO(hoegsberg): We should add a little more help text about how these
+ // options interact and depend on each other.
+
+ exit(EXIT_SUCCESS);
+ }
+
// Initialize tracing.
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kTraceToConsole)) {
@@ -363,7 +71,7 @@ int main(int argc, char** argv) {
base::RunLoop run_loop;
- WindowManager window_manager(run_loop.QuitClosure());
+ ui::WindowManager window_manager(run_loop.QuitClosure());
run_loop.Run();
diff --git a/chromium/ui/ozone/demo/renderer_factory.cc b/chromium/ui/ozone/demo/renderer_factory.cc
new file mode 100644
index 00000000000..10a01103786
--- /dev/null
+++ b/chromium/ui/ozone/demo/renderer_factory.cc
@@ -0,0 +1,75 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/ozone/demo/renderer_factory.h"
+
+#include <memory>
+
+#include "base/command_line.h"
+#include "ui/gl/gl_surface.h"
+#include "ui/gl/init/gl_factory.h"
+#include "ui/ozone/demo/skia_renderer.h"
+#include "ui/ozone/demo/software_renderer.h"
+#include "ui/ozone/demo/surfaceless_skia_renderer.h"
+#include "ui/ozone/public/ozone_platform.h"
+
+namespace ui {
+namespace {
+
+const char kDisableSurfaceless[] = "disable-surfaceless";
+const char kDisableGpu[] = "disable-gpu";
+
+scoped_refptr<gl::GLSurface> CreateGLSurface(gfx::AcceleratedWidget widget) {
+ scoped_refptr<gl::GLSurface> surface;
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(kDisableSurfaceless))
+ surface = gl::init::CreateSurfacelessViewGLSurface(widget);
+ if (!surface)
+ surface = gl::init::CreateViewGLSurface(widget);
+ return surface;
+}
+
+} // namespace
+
+RendererFactory::RendererFactory() {}
+
+RendererFactory::~RendererFactory() {}
+
+bool RendererFactory::Initialize() {
+ OzonePlatform::InitParams params;
+ params.single_process = true;
+ OzonePlatform::InitializeForGPU(params);
+ OzonePlatform::GetInstance()->AfterSandboxEntry();
+
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ if (!command_line->HasSwitch(kDisableGpu) && gl::init::InitializeGLOneOff() &&
+ gpu_helper_.Initialize(base::ThreadTaskRunnerHandle::Get())) {
+ type_ = SKIA;
+ } else {
+ type_ = SOFTWARE;
+ }
+
+ return true;
+}
+
+std::unique_ptr<Renderer> RendererFactory::CreateRenderer(
+ gfx::AcceleratedWidget widget,
+ const gfx::Size& size) {
+ switch (type_) {
+ case SKIA: {
+ scoped_refptr<gl::GLSurface> surface = CreateGLSurface(widget);
+ if (!surface)
+ LOG(FATAL) << "Failed to create GL surface";
+ if (surface->IsSurfaceless()) {
+ return std::make_unique<SurfacelessSkiaRenderer>(widget, surface, size);
+ }
+ return std::make_unique<SkiaRenderer>(widget, surface, size);
+ }
+ case SOFTWARE:
+ return std::make_unique<SoftwareRenderer>(widget, size);
+ }
+
+ return nullptr;
+}
+
+} // namespace ui
diff --git a/chromium/ui/ozone/demo/renderer_factory.h b/chromium/ui/ozone/demo/renderer_factory.h
new file mode 100644
index 00000000000..f87aeaea6d3
--- /dev/null
+++ b/chromium/ui/ozone/demo/renderer_factory.h
@@ -0,0 +1,41 @@
+// Copyright 2018 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_DEMO_RENDERER_FACTORY_H_
+#define UI_OZONE_DEMO_RENDERER_FACTORY_H_
+
+#include "ui/gfx/geometry/size.h"
+#include "ui/gfx/native_widget_types.h"
+#include "ui/ozone/public/ozone_gpu_test_helper.h"
+
+namespace ui {
+
+class Renderer;
+
+class RendererFactory {
+ public:
+ enum RendererType {
+ SKIA,
+ SOFTWARE,
+ };
+
+ RendererFactory();
+ ~RendererFactory();
+
+ bool Initialize();
+ std::unique_ptr<Renderer> CreateRenderer(gfx::AcceleratedWidget widget,
+ const gfx::Size& size);
+
+ private:
+ RendererType type_ = SOFTWARE;
+
+ // Helper for applications that do GL on main thread.
+ OzoneGpuTestHelper gpu_helper_;
+
+ DISALLOW_COPY_AND_ASSIGN(RendererFactory);
+};
+
+} // namespace ui
+
+#endif // UI_OZONE_DEMO_RENDERER_FACTORY_H_
diff --git a/chromium/ui/ozone/demo/skia_renderer.cc b/chromium/ui/ozone/demo/skia_renderer.cc
index a8d7947ed8f..71154c08925 100644
--- a/chromium/ui/ozone/demo/skia_renderer.cc
+++ b/chromium/ui/ozone/demo/skia_renderer.cc
@@ -85,13 +85,13 @@ void SkiaRenderer::RenderFrame() {
if (!sk_surface_) {
GrGLFramebufferInfo framebuffer_info;
framebuffer_info.fFBOID = 0;
+ framebuffer_info.fFormat = GL_RGBA8;
GrBackendRenderTarget render_target(size_.width(), size_.height(), 0, 8,
- kRGBA_8888_GrPixelConfig,
framebuffer_info);
sk_surface_ = SkSurface::MakeFromBackendRenderTarget(
- gr_context_.get(), render_target, kBottomLeft_GrSurfaceOrigin, nullptr,
- &surface_props);
+ gr_context_.get(), render_target, kBottomLeft_GrSurfaceOrigin,
+ kRGBA_8888_SkColorType, nullptr, &surface_props);
}
if (use_ddl_) {
diff --git a/chromium/ui/ozone/demo/surfaceless_skia_renderer.cc b/chromium/ui/ozone/demo/surfaceless_skia_renderer.cc
index fef66dff8af..c3bce8be2d5 100644
--- a/chromium/ui/ozone/demo/surfaceless_skia_renderer.cc
+++ b/chromium/ui/ozone/demo/surfaceless_skia_renderer.cc
@@ -114,7 +114,7 @@ bool SurfacelessSkiaRenderer::BufferWrapper::Initialize(
->GetSurfaceFactoryOzone()
->CreateNativePixmap(widget, size, format, gfx::BufferUsage::SCANOUT);
scoped_refptr<gl::GLImageNativePixmap> image(
- new gl::GLImageNativePixmap(size, GL_RGB));
+ new gl::GLImageNativePixmap(size, GL_BGRA_EXT));
if (!image->Initialize(pixmap.get(), format)) {
LOG(ERROR) << "Failed to create GLImage";
return false;
@@ -130,12 +130,12 @@ bool SurfacelessSkiaRenderer::BufferWrapper::Initialize(
GrGLTextureInfo texture_info;
texture_info.fTarget = GL_TEXTURE_2D;
texture_info.fID = gl_tex_;
- texture_info.fFormat = GL_RGBA;
+ texture_info.fFormat = GL_BGRA8_EXT;
GrBackendTexture backend_texture(size_.width(), size_.height(),
- kRGBA_8888_GrPixelConfig, texture_info);
- sk_surface_ = SkSurface::MakeFromBackendTextureAsRenderTarget(
- gr_context, backend_texture, kTopLeft_GrSurfaceOrigin, 0, nullptr,
- nullptr);
+ GrMipMapped::kNo, texture_info);
+ sk_surface_ = SkSurface::MakeFromBackendTexture(
+ gr_context, backend_texture, kTopLeft_GrSurfaceOrigin, 0,
+ kBGRA_8888_SkColorType, nullptr, nullptr);
if (!sk_surface_) {
LOG(ERROR) << "Failed to create skia surface";
return false;
@@ -184,7 +184,7 @@ bool SurfacelessSkiaRenderer::Initialize() {
overlay_buffer_[i]->Initialize(gr_context_.get(),
gfx::kNullAcceleratedWidget, overlay_size);
SkCanvas* sk_canvas = overlay_buffer_[i]->sk_surface()->getCanvas();
- sk_canvas->clear(SkColorSetARGB(255, 255 * i, 255, 0));
+ sk_canvas->clear(SkColorSetARGB(96, 255 * i, 255, 0));
}
}
@@ -246,13 +246,13 @@ void SurfacelessSkiaRenderer::RenderFrame() {
CHECK(overlay_list.front().overlay_handled);
gl_surface_->ScheduleOverlayPlane(
0, gfx::OVERLAY_TRANSFORM_NONE, buffers_[back_buffer_]->image(),
- primary_plane_rect_, gfx::RectF(0, 0, 1, 1));
+ primary_plane_rect_, gfx::RectF(0, 0, 1, 1), /* enable_blend */ true);
}
if (overlay_buffer_[0] && overlay_list.back().overlay_handled) {
- gl_surface_->ScheduleOverlayPlane(1, gfx::OVERLAY_TRANSFORM_NONE,
- overlay_buffer_[back_buffer_]->image(),
- overlay_rect, gfx::RectF(0, 0, 1, 1));
+ gl_surface_->ScheduleOverlayPlane(
+ 1, gfx::OVERLAY_TRANSFORM_NONE, overlay_buffer_[back_buffer_]->image(),
+ overlay_rect, gfx::RectF(0, 0, 1, 1), /* enable_blend */ true);
}
back_buffer_ ^= 1;
diff --git a/chromium/ui/ozone/demo/window_manager.cc b/chromium/ui/ozone/demo/window_manager.cc
new file mode 100644
index 00000000000..9fb74d7e1c5
--- /dev/null
+++ b/chromium/ui/ozone/demo/window_manager.cc
@@ -0,0 +1,112 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/ozone/demo/window_manager.h"
+
+#include "base/command_line.h"
+#include "base/threading/thread_task_runner_handle.h"
+#include "ui/display/types/display_snapshot.h"
+#include "ui/display/types/native_display_delegate.h"
+#include "ui/ozone/demo/demo_window.h"
+#include "ui/ozone/public/ozone_platform.h"
+
+namespace ui {
+namespace {
+
+const int kTestWindowWidth = 800;
+const int kTestWindowHeight = 600;
+
+const char kWindowSize[] = "window-size";
+
+} // namespace
+
+WindowManager::WindowManager(base::OnceClosure quit_closure)
+ : delegate_(
+ ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate()),
+ quit_closure_(std::move(quit_closure)) {
+ if (!renderer_factory_.Initialize())
+ LOG(FATAL) << "Failed to initialize renderer factory";
+
+ if (delegate_) {
+ delegate_->AddObserver(this);
+ delegate_->Initialize();
+ OnConfigurationChanged();
+ } else {
+ LOG(WARNING) << "No display delegate; falling back to test window";
+ int width = kTestWindowWidth;
+ int height = kTestWindowHeight;
+ sscanf(base::CommandLine::ForCurrentProcess()
+ ->GetSwitchValueASCII(kWindowSize)
+ .c_str(),
+ "%dx%d", &width, &height);
+
+ DemoWindow* window = new DemoWindow(this, &renderer_factory_,
+ gfx::Rect(gfx::Size(width, height)));
+ window->Start();
+ }
+}
+
+WindowManager::~WindowManager() {
+ if (delegate_)
+ delegate_->RemoveObserver(this);
+}
+
+void WindowManager::Quit() {
+ std::move(quit_closure_).Run();
+}
+
+void WindowManager::OnConfigurationChanged() {
+ if (is_configuring_) {
+ should_configure_ = true;
+ return;
+ }
+
+ is_configuring_ = true;
+ delegate_->GetDisplays(base::BindRepeating(&WindowManager::OnDisplaysAquired,
+ base::Unretained(this)));
+}
+
+void WindowManager::OnDisplaySnapshotsInvalidated() {}
+
+void WindowManager::OnDisplaysAquired(
+ const std::vector<display::DisplaySnapshot*>& displays) {
+ windows_.clear();
+
+ gfx::Point origin;
+ for (auto* display : displays) {
+ if (!display->native_mode()) {
+ LOG(ERROR) << "Display " << display->display_id()
+ << " doesn't have a native mode";
+ continue;
+ }
+
+ delegate_->Configure(
+ *display, display->native_mode(), origin,
+ base::BindRepeating(&WindowManager::OnDisplayConfigured,
+ base::Unretained(this),
+ gfx::Rect(origin, display->native_mode()->size())));
+ origin.Offset(display->native_mode()->size().width(), 0);
+ }
+ is_configuring_ = false;
+
+ if (should_configure_) {
+ should_configure_ = false;
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::BindRepeating(&WindowManager::OnConfigurationChanged,
+ base::Unretained(this)));
+ }
+}
+
+void WindowManager::OnDisplayConfigured(const gfx::Rect& bounds, bool success) {
+ if (success) {
+ std::unique_ptr<DemoWindow> window(
+ new DemoWindow(this, &renderer_factory_, bounds));
+ window->Start();
+ windows_.push_back(std::move(window));
+ } else {
+ LOG(ERROR) << "Failed to configure display at " << bounds.ToString();
+ }
+}
+
+} // namespace ui
diff --git a/chromium/ui/ozone/demo/window_manager.h b/chromium/ui/ozone/demo/window_manager.h
new file mode 100644
index 00000000000..d15590843fc
--- /dev/null
+++ b/chromium/ui/ozone/demo/window_manager.h
@@ -0,0 +1,66 @@
+// Copyright 2018 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_DEMO_WINDOW_MANAGER_H_
+#define UI_OZONE_DEMO_WINDOW_MANAGER_H_
+
+#include <vector>
+
+#include "base/callback.h"
+#include "ui/display/types/native_display_observer.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/ozone/demo/renderer_factory.h"
+
+namespace display {
+
+class DisplaySnapshot;
+class NativeDisplayDelegate;
+
+} // namespace display
+
+namespace ui {
+
+class DemoWindow;
+
+class WindowManager : public display::NativeDisplayObserver {
+ public:
+ explicit WindowManager(base::OnceClosure quit_closure);
+ ~WindowManager() override;
+
+ void Quit();
+
+ void AddWindow(DemoWindow* window);
+ void RemoveWindow(DemoWindow* window);
+
+ private:
+ void OnDisplaysAquired(
+ const std::vector<display::DisplaySnapshot*>& displays);
+ void OnDisplayConfigured(const gfx::Rect& bounds, bool success);
+
+ // display::NativeDisplayDelegate:
+ void OnConfigurationChanged() override;
+ void OnDisplaySnapshotsInvalidated() override;
+
+ std::unique_ptr<display::NativeDisplayDelegate> delegate_;
+ base::OnceClosure quit_closure_;
+ RendererFactory renderer_factory_;
+ std::vector<std::unique_ptr<DemoWindow>> windows_;
+
+ // Flags used to keep track of the current state of display configuration.
+ //
+ // True if configuring the displays. In this case a new display configuration
+ // isn't started.
+ bool is_configuring_ = false;
+
+ // If |is_configuring_| is true and another display configuration event
+ // happens, the event is deferred. This is set to true and a display
+ // configuration will be scheduled after the current one finishes.
+ bool should_configure_ = false;
+
+ DISALLOW_COPY_AND_ASSIGN(WindowManager);
+};
+
+} // namespace ui
+
+#endif // UI_OZONE_DEMO_WINDOW_MANAGER_H_
diff --git a/chromium/ui/ozone/gl/gl_image_ozone_native_pixmap_unittest.cc b/chromium/ui/ozone/gl/gl_image_ozone_native_pixmap_unittest.cc
index 52a42f83617..c2948020455 100644
--- a/chromium/ui/ozone/gl/gl_image_ozone_native_pixmap_unittest.cc
+++ b/chromium/ui/ozone/gl/gl_image_ozone_native_pixmap_unittest.cc
@@ -9,7 +9,6 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/buffer_types.h"
#include "ui/gfx/client_native_pixmap.h"
-#include "ui/gfx/client_native_pixmap_factory.h"
#include "ui/gl/gl_image_native_pixmap.h"
#include "ui/gl/test/gl_image_test_template.h"
#include "ui/ozone/public/client_native_pixmap_factory_ozone.h"
@@ -26,7 +25,7 @@ template <gfx::BufferUsage usage, gfx::BufferFormat format>
class GLImageNativePixmapTestDelegate : public GLImageTestDelegateBase {
public:
GLImageNativePixmapTestDelegate() {
- ui::CreateClientNativePixmapFactoryOzone();
+ client_native_pixmap_factory_ = ui::CreateClientNativePixmapFactoryOzone();
}
~GLImageNativePixmapTestDelegate() override = default;
@@ -41,9 +40,8 @@ class GLImageNativePixmapTestDelegate : public GLImageTestDelegateBase {
DCHECK(pixmap);
if (usage == gfx::BufferUsage::GPU_READ_CPU_READ_WRITE ||
usage == gfx::BufferUsage::SCANOUT_CAMERA_READ_WRITE) {
- auto client_pixmap =
- gfx::ClientNativePixmapFactory::GetInstance()->ImportFromHandle(
- pixmap->ExportHandle(), size, usage);
+ auto client_pixmap = client_native_pixmap_factory_->ImportFromHandle(
+ pixmap->ExportHandle(), size, usage);
bool mapped = client_pixmap->Map();
EXPECT_TRUE(mapped);
@@ -77,6 +75,8 @@ class GLImageNativePixmapTestDelegate : public GLImageTestDelegateBase {
}
private:
+ std::unique_ptr<gfx::ClientNativePixmapFactory> client_native_pixmap_factory_;
+
DISALLOW_COPY_AND_ASSIGN(GLImageNativePixmapTestDelegate);
};
diff --git a/chromium/ui/ozone/platform/cast/client_native_pixmap_factory_cast.cc b/chromium/ui/ozone/platform/cast/client_native_pixmap_factory_cast.cc
index 607bf221064..4aa44c770ba 100644
--- a/chromium/ui/ozone/platform/cast/client_native_pixmap_factory_cast.cc
+++ b/chromium/ui/ozone/platform/cast/client_native_pixmap_factory_cast.cc
@@ -5,7 +5,6 @@
#include "ui/ozone/platform/cast/client_native_pixmap_factory_cast.h"
#include "base/logging.h"
-#include "base/memory/ptr_util.h"
#include "ui/gfx/buffer_types.h"
#include "ui/gfx/client_native_pixmap.h"
#include "ui/gfx/client_native_pixmap_factory.h"
@@ -39,7 +38,7 @@ class ClientNativePixmapFactoryCast : public gfx::ClientNativePixmapFactory {
// ClientNativePixmapFactoryCast implementation:
bool IsConfigurationSupported(gfx::BufferFormat format,
gfx::BufferUsage usage) const override {
- return format == gfx::BufferFormat::RGBA_8888 &&
+ return format == gfx::BufferFormat::BGRA_8888 &&
usage == gfx::BufferUsage::SCANOUT;
}
diff --git a/chromium/ui/ozone/platform/cast/gl_ozone_egl_cast.cc b/chromium/ui/ozone/platform/cast/gl_ozone_egl_cast.cc
index 4066ed416c9..33d0651f58b 100644
--- a/chromium/ui/ozone/platform/cast/gl_ozone_egl_cast.cc
+++ b/chromium/ui/ozone/platform/cast/gl_ozone_egl_cast.cc
@@ -11,7 +11,6 @@
#include "base/command_line.h"
#include "base/macros.h"
-#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "chromecast/base/chromecast_switches.h"
#include "chromecast/public/cast_egl_platform.h"
diff --git a/chromium/ui/ozone/platform/cast/gl_surface_cast.cc b/chromium/ui/ozone/platform/cast/gl_surface_cast.cc
index dd50b11cfec..7097dfbde90 100644
--- a/chromium/ui/ozone/platform/cast/gl_surface_cast.cc
+++ b/chromium/ui/ozone/platform/cast/gl_surface_cast.cc
@@ -5,7 +5,6 @@
#include "ui/ozone/platform/cast/gl_surface_cast.h"
#include "base/feature_list.h"
-#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "chromecast/base/cast_features.h"
#include "chromecast/base/chromecast_switches.h"
@@ -100,9 +99,10 @@ bool GLSurfaceCast::ScheduleOverlayPlane(int z_order,
gfx::OverlayTransform transform,
gl::GLImage* image,
const gfx::Rect& bounds_rect,
- const gfx::RectF& crop_rect) {
+ const gfx::RectF& crop_rect,
+ bool enable_blend) {
return image->ScheduleOverlayPlane(widget_, z_order, transform, bounds_rect,
- crop_rect);
+ crop_rect, enable_blend);
}
EGLConfig GLSurfaceCast::GetConfig() {
diff --git a/chromium/ui/ozone/platform/cast/gl_surface_cast.h b/chromium/ui/ozone/platform/cast/gl_surface_cast.h
index 3d3a5412021..2bd8fa16ccf 100644
--- a/chromium/ui/ozone/platform/cast/gl_surface_cast.h
+++ b/chromium/ui/ozone/platform/cast/gl_surface_cast.h
@@ -35,7 +35,8 @@ class GLSurfaceCast : public gl::NativeViewGLSurfaceEGL {
gfx::OverlayTransform transform,
gl::GLImage* image,
const gfx::Rect& bounds_rect,
- const gfx::RectF& crop_rect) override;
+ const gfx::RectF& crop_rect,
+ bool enable_blend) override;
EGLConfig GetConfig() override;
protected:
diff --git a/chromium/ui/ozone/platform/cast/overlay_manager_cast.cc b/chromium/ui/ozone/platform/cast/overlay_manager_cast.cc
index 9ce4f0a3e39..6a34f691350 100644
--- a/chromium/ui/ozone/platform/cast/overlay_manager_cast.cc
+++ b/chromium/ui/ozone/platform/cast/overlay_manager_cast.cc
@@ -4,72 +4,18 @@
#include "ui/ozone/platform/cast/overlay_manager_cast.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ptr_util.h"
-#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/ozone/public/overlay_candidates_ozone.h"
namespace ui {
namespace {
-base::LazyInstance<OverlayManagerCast::OverlayCompositedCallback>::
- DestructorAtExit g_overlay_composited_callback = LAZY_INSTANCE_INITIALIZER;
-
-// Translates a gfx::OverlayTransform into a VideoPlane::Transform.
-// Could be just a lookup table once we have unit tests for this code
-// to ensure it stays in sync with OverlayTransform.
-chromecast::media::VideoPlane::Transform ConvertTransform(
- gfx::OverlayTransform transform) {
- switch (transform) {
- case gfx::OVERLAY_TRANSFORM_NONE:
- return chromecast::media::VideoPlane::TRANSFORM_NONE;
- case gfx::OVERLAY_TRANSFORM_FLIP_HORIZONTAL:
- return chromecast::media::VideoPlane::FLIP_HORIZONTAL;
- case gfx::OVERLAY_TRANSFORM_FLIP_VERTICAL:
- return chromecast::media::VideoPlane::FLIP_VERTICAL;
- case gfx::OVERLAY_TRANSFORM_ROTATE_90:
- return chromecast::media::VideoPlane::ROTATE_90;
- case gfx::OVERLAY_TRANSFORM_ROTATE_180:
- return chromecast::media::VideoPlane::ROTATE_180;
- case gfx::OVERLAY_TRANSFORM_ROTATE_270:
- return chromecast::media::VideoPlane::ROTATE_270;
- default:
- NOTREACHED();
- return chromecast::media::VideoPlane::TRANSFORM_NONE;
- }
-}
-
class OverlayCandidatesCast : public OverlayCandidatesOzone {
public:
OverlayCandidatesCast() {}
- void CheckOverlaySupport(OverlaySurfaceCandidateList* surfaces) override;
+ void CheckOverlaySupport(OverlaySurfaceCandidateList* surfaces) override {}
};
-void OverlayCandidatesCast::CheckOverlaySupport(
- OverlaySurfaceCandidateList* surfaces) {
- for (auto& candidate : *surfaces) {
- if (candidate.plane_z_order != -1)
- continue;
-
- candidate.overlay_handled = true;
-
- // Compositor requires all overlay rectangles to have integer coords.
- candidate.display_rect =
- gfx::RectF(gfx::ToEnclosedRect(candidate.display_rect));
-
- chromecast::RectF display_rect(
- candidate.display_rect.x(), candidate.display_rect.y(),
- candidate.display_rect.width(), candidate.display_rect.height());
-
- // Update video plane geometry + transform to match compositor quad.
- if (!g_overlay_composited_callback.Get().is_null())
- g_overlay_composited_callback.Get().Run(
- display_rect, ConvertTransform(candidate.transform));
- return;
- }
-}
-
} // namespace
OverlayManagerCast::OverlayManagerCast() {
@@ -83,10 +29,4 @@ OverlayManagerCast::CreateOverlayCandidates(gfx::AcceleratedWidget w) {
return std::make_unique<OverlayCandidatesCast>();
}
-// static
-void OverlayManagerCast::SetOverlayCompositedCallback(
- const OverlayCompositedCallback& cb) {
- g_overlay_composited_callback.Get() = cb;
-}
-
} // namespace ui
diff --git a/chromium/ui/ozone/platform/cast/overlay_manager_cast.h b/chromium/ui/ozone/platform/cast/overlay_manager_cast.h
index 0ddf98d67f5..6d9963b4f4a 100644
--- a/chromium/ui/ozone/platform/cast/overlay_manager_cast.h
+++ b/chromium/ui/ozone/platform/cast/overlay_manager_cast.h
@@ -7,16 +7,12 @@
#include <memory>
-#include "base/callback.h"
#include "base/macros.h"
-#include "chromecast/public/graphics_types.h"
-#include "chromecast/public/video_plane.h"
-#include "ui/ozone/ozone_export.h"
#include "ui/ozone/public/overlay_manager_ozone.h"
namespace ui {
-class OZONE_EXPORT OverlayManagerCast : public OverlayManagerOzone {
+class OverlayManagerCast : public OverlayManagerOzone {
public:
OverlayManagerCast();
~OverlayManagerCast() override;
@@ -25,16 +21,7 @@ class OZONE_EXPORT OverlayManagerCast : public OverlayManagerOzone {
std::unique_ptr<OverlayCandidatesOzone> CreateOverlayCandidates(
gfx::AcceleratedWidget w) override;
- // Callback that's made whenever an overlay quad is processed
- // in the compositor. Used to allow hardware video plane to
- // be positioned to match compositor hole.
- using OverlayCompositedCallback =
- base::Callback<void(const chromecast::RectF&,
- chromecast::media::VideoPlane::Transform)>;
- static void SetOverlayCompositedCallback(const OverlayCompositedCallback& cb);
-
private:
-
DISALLOW_COPY_AND_ASSIGN(OverlayManagerCast);
};
diff --git a/chromium/ui/ozone/platform/cast/platform_window_cast.cc b/chromium/ui/ozone/platform/cast/platform_window_cast.cc
index d5a33378cd5..a24276ca87a 100644
--- a/chromium/ui/ozone/platform/cast/platform_window_cast.cc
+++ b/chromium/ui/ozone/platform/cast/platform_window_cast.cc
@@ -18,15 +18,13 @@ PlatformWindowCast::PlatformWindowCast(PlatformWindowDelegate* delegate,
widget_ = (bounds.width() << 16) + bounds.height();
delegate_->OnAcceleratedWidgetAvailable(widget_, 1.f);
- if (ui::PlatformEventSource::GetInstance()) {
- ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
- }
+ if (PlatformEventSource::GetInstance())
+ PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
}
PlatformWindowCast::~PlatformWindowCast() {
- if (ui::PlatformEventSource::GetInstance()) {
- ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
- }
+ if (PlatformEventSource::GetInstance())
+ PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
}
gfx::Rect PlatformWindowCast::GetBounds() {
@@ -41,16 +39,19 @@ void PlatformWindowCast::SetBounds(const gfx::Rect& bounds) {
void PlatformWindowCast::SetTitle(const base::string16& title) {
}
+bool PlatformWindowCast::HasCapture() const {
+ return false;
+}
+
PlatformImeController* PlatformWindowCast::GetPlatformImeController() {
return nullptr;
}
-bool PlatformWindowCast::CanDispatchEvent(const ui::PlatformEvent& ne) {
+bool PlatformWindowCast::CanDispatchEvent(const PlatformEvent& ne) {
return true;
}
-uint32_t PlatformWindowCast::DispatchEvent(
- const ui::PlatformEvent& native_event) {
+uint32_t PlatformWindowCast::DispatchEvent(const PlatformEvent& native_event) {
DispatchEventFromNativeUiEvent(
native_event, base::BindOnce(&PlatformWindowDelegate::DispatchEvent,
base::Unretained(delegate_)));
diff --git a/chromium/ui/ozone/platform/cast/platform_window_cast.h b/chromium/ui/ozone/platform/cast/platform_window_cast.h
index 4a494f2c830..a7930ee26fa 100644
--- a/chromium/ui/ozone/platform/cast/platform_window_cast.h
+++ b/chromium/ui/ozone/platform/cast/platform_window_cast.h
@@ -31,6 +31,7 @@ class PlatformWindowCast : public PlatformWindow,
void PrepareForShutdown() override {}
void SetCapture() override {}
void ReleaseCapture() override {}
+ bool HasCapture() const override;
void ToggleFullscreen() override {}
void Maximize() override {}
void Minimize() override {}
diff --git a/chromium/ui/ozone/platform/cast/surface_factory_cast.cc b/chromium/ui/ozone/platform/cast/surface_factory_cast.cc
index 234c3f90d71..4718585dcd0 100644
--- a/chromium/ui/ozone/platform/cast/surface_factory_cast.cc
+++ b/chromium/ui/ozone/platform/cast/surface_factory_cast.cc
@@ -69,7 +69,8 @@ class CastPixmap : public gfx::NativePixmap {
int plane_z_order,
gfx::OverlayTransform plane_transform,
const gfx::Rect& display_bounds,
- const gfx::RectF& crop_rect) override {
+ const gfx::RectF& crop_rect,
+ bool enable_blend) override {
parent_->OnOverlayScheduled(display_bounds);
return true;
}
diff --git a/chromium/ui/ozone/platform/drm/BUILD.gn b/chromium/ui/ozone/platform/drm/BUILD.gn
index 99fc0d66bf2..7ff7018bbb6 100644
--- a/chromium/ui/ozone/platform/drm/BUILD.gn
+++ b/chromium/ui/ozone/platform/drm/BUILD.gn
@@ -114,7 +114,7 @@ source_set("gbm") {
deps = [
"//base",
"//ipc",
- "//mojo/common:common_base",
+ "//mojo/public/cpp/system",
"//services/service_manager/public/cpp",
"//services/ui/public/interfaces:constants",
"//skia",
diff --git a/chromium/ui/ozone/platform/drm/client_native_pixmap_factory_gbm.cc b/chromium/ui/ozone/platform/drm/client_native_pixmap_factory_gbm.cc
index f8dd781ebf4..8e363e69280 100644
--- a/chromium/ui/ozone/platform/drm/client_native_pixmap_factory_gbm.cc
+++ b/chromium/ui/ozone/platform/drm/client_native_pixmap_factory_gbm.cc
@@ -7,7 +7,6 @@
#include <utility>
#include "base/macros.h"
-#include "base/memory/ptr_util.h"
#include "ui/gfx/linux/client_native_pixmap_factory_dmabuf.h"
#include "ui/gfx/native_pixmap_handle.h"
diff --git a/chromium/ui/ozone/platform/drm/common/drm_util.cc b/chromium/ui/ozone/platform/drm/common/drm_util.cc
index d4c3dd51037..77054a23dbf 100644
--- a/chromium/ui/ozone/platform/drm/common/drm_util.cc
+++ b/chromium/ui/ozone/platform/drm/common/drm_util.cc
@@ -14,7 +14,7 @@
#include <utility>
#include "base/containers/flat_map.h"
-#include "base/memory/ptr_util.h"
+#include "ui/display/types/display_constants.h"
#include "ui/display/types/display_mode.h"
#include "ui/display/util/edid_parser.h"
@@ -381,7 +381,7 @@ std::unique_ptr<display::DisplaySnapshot> CreateDisplaySnapshot(
const base::FilePath& sys_path,
size_t device_index,
const gfx::Point& origin) {
- int64_t display_id = ConnectorIndex(device_index, info->index());
+ const uint8_t display_index = ConnectorIndex(device_index, info->index());
const gfx::Size physical_size =
gfx::Size(info->connector()->mmWidth, info->connector()->mmHeight);
const display::DisplayConnectionType type = GetDisplayType(info->connector());
@@ -391,29 +391,31 @@ std::unique_ptr<display::DisplaySnapshot> CreateDisplaySnapshot(
HasColorCorrectionMatrix(fd, info->crtc());
const gfx::Size maximum_cursor_size = GetMaximumCursorSize(fd);
- std::vector<uint8_t> edid;
std::string display_name;
- int64_t product_id = display::DisplaySnapshot::kInvalidProductID;
+ int64_t display_id = display_index;
+ int64_t product_code = display::DisplaySnapshot::kInvalidProductCode;
+ int32_t year_of_manufacture = display::kInvalidYearOfManufacture;
bool has_overscan = false;
gfx::ColorSpace display_color_space;
-
- // This is the size of the active pixels from the first detailed timing
- // descriptor in the EDID.
+ // Active pixels size from the first detailed timing descriptor in the EDID.
gfx::Size active_pixel_size;
ScopedDrmPropertyBlobPtr edid_blob(
GetDrmPropertyBlob(fd, info->connector(), "EDID"));
+ std::vector<uint8_t> edid;
if (edid_blob) {
edid.assign(static_cast<uint8_t*>(edid_blob->data),
static_cast<uint8_t*>(edid_blob->data) + edid_blob->length);
- display::GetDisplayIdFromEDID(edid, display_id, &display_id, &product_id);
-
- display::ParseOutputDeviceData(edid, nullptr, nullptr, &display_name,
- &active_pixel_size, nullptr);
- display::ParseOutputOverscanFlag(edid, &has_overscan);
-
- display_color_space = GetColorSpaceFromEdid(edid);
+ display::EdidParser edid_parser(edid);
+ display_name = edid_parser.display_name();
+ active_pixel_size = edid_parser.active_pixel_size();
+ product_code = edid_parser.GetProductCode();
+ display_id = edid_parser.GetDisplayId(display_index);
+ year_of_manufacture = edid_parser.year_of_manufacture();
+ has_overscan =
+ edid_parser.has_overscan_flag() && edid_parser.overscan_flag();
+ display_color_space = GetColorSpaceFromEdid(edid_parser);
} else {
VLOG(1) << "Failed to get EDID blob for connector "
<< info->connector()->connector_id;
@@ -428,7 +430,7 @@ std::unique_ptr<display::DisplaySnapshot> CreateDisplaySnapshot(
display_id, origin, physical_size, type, is_aspect_preserving_scaling,
has_overscan, has_color_correction_matrix, display_color_space,
display_name, sys_path, std::move(modes), edid, current_mode, native_mode,
- product_id, maximum_cursor_size);
+ product_code, year_of_manufacture, maximum_cursor_size);
}
// TODO(rjkroege): Remove in a subsequent CL once Mojo IPC is used everywhere.
@@ -464,7 +466,8 @@ std::vector<DisplaySnapshot_Params> CreateDisplaySnapshotParams(
if (d->native_mode())
p.native_mode = GetDisplayModeParams(*d->native_mode());
- p.product_id = d->product_id();
+ p.product_code = d->product_code();
+ p.year_of_manufacture = d->year_of_manufacture();
p.maximum_cursor_size = d->maximum_cursor_size();
params.push_back(p);
@@ -490,7 +493,8 @@ std::unique_ptr<display::DisplaySnapshot> CreateDisplaySnapshot(
params.is_aspect_preserving_scaling, params.has_overscan,
params.has_color_correction_matrix, params.color_space,
params.display_name, params.sys_path, std::move(modes), params.edid,
- current_mode, native_mode, params.product_id, params.maximum_cursor_size);
+ current_mode, native_mode, params.product_code,
+ params.year_of_manufacture, params.maximum_cursor_size);
}
int GetFourCCFormatFromBufferFormat(gfx::BufferFormat format) {
@@ -631,10 +635,8 @@ std::vector<OverlayCheckReturn_Params> CreateParamsFromOverlayStatusList(
return params;
}
-gfx::ColorSpace GetColorSpaceFromEdid(const std::vector<uint8_t>& edid) {
- SkColorSpacePrimaries primaries = {0};
- if (!display::ParseChromaticityCoordinates(edid, &primaries))
- return gfx::ColorSpace();
+gfx::ColorSpace GetColorSpaceFromEdid(const display::EdidParser& edid_parser) {
+ const SkColorSpacePrimaries primaries = edid_parser.primaries();
// Sanity check: primaries should verify By <= Ry <= Gy, Bx <= Rx and Gx <=
// Rx, to guarantee that the R, G and B colors are each in the correct region.
@@ -653,12 +655,25 @@ gfx::ColorSpace GetColorSpaceFromEdid(const std::vector<uint8_t>& edid) {
if (primaries_area_twice < kBT709PrimariesArea)
return gfx::ColorSpace();
+ // Sanity check: https://crbug.com/809909, the blue primary coordinates should
+ // not be too far left/upwards of the expected location (namely [0.15, 0.06]
+ // for sRGB/ BT.709/ Adobe RGB/ DCI-P3, and [0.131, 0.046] for BT.2020).
+ constexpr float kExpectedBluePrimaryX = 0.15f;
+ constexpr float kBluePrimaryXDelta = 0.02f;
+ constexpr float kExpectedBluePrimaryY = 0.06f;
+ constexpr float kBluePrimaryYDelta = 0.031f;
+ const bool is_blue_primary_broken =
+ (std::abs(primaries.fBX - kExpectedBluePrimaryX) > kBluePrimaryXDelta) ||
+ (std::abs(primaries.fBY - kExpectedBluePrimaryY) > kBluePrimaryYDelta);
+ if (is_blue_primary_broken)
+ return gfx::ColorSpace();
+
SkMatrix44 color_space_as_matrix;
if (!primaries.toXYZD50(&color_space_as_matrix))
return gfx::ColorSpace();
- double gamma = 0.0;
- if (!display::ParseGammaValue(edid, &gamma))
+ const double gamma = edid_parser.gamma();
+ if (gamma < 1.0)
return gfx::ColorSpace();
SkColorSpaceTransferFn transfer = {gamma, 1.f, 0.f, 0.f, 0.f, 0.f, 0.f};
diff --git a/chromium/ui/ozone/platform/drm/common/drm_util.h b/chromium/ui/ozone/platform/drm/common/drm_util.h
index 9a058a78180..6677fe19cfe 100644
--- a/chromium/ui/ozone/platform/drm/common/drm_util.h
+++ b/chromium/ui/ozone/platform/drm/common/drm_util.h
@@ -21,6 +21,7 @@ typedef struct _drmModeModeInfo drmModeModeInfo;
namespace display {
class DisplayMode;
+class EdidParser;
} // namespace display
namespace gfx {
@@ -119,9 +120,9 @@ OverlayStatusList CreateOverlayStatusListFrom(
std::vector<OverlayCheckReturn_Params> CreateParamsFromOverlayStatusList(
const OverlayStatusList& returns);
-// Parses |edid| to extract a gfx::ColorSpace which will be IsValid() if both
-// gamma and the color primaries were correctly found.
-gfx::ColorSpace GetColorSpaceFromEdid(const std::vector<uint8_t>& edid);
+// Uses |edid_parser| to extract a gfx::ColorSpace which will be IsValid() if
+// both gamma and the color primaries were correctly found.
+gfx::ColorSpace GetColorSpaceFromEdid(const display::EdidParser& edid_parser);
} // namespace ui
diff --git a/chromium/ui/ozone/platform/drm/common/drm_util_unittest.cc b/chromium/ui/ozone/platform/drm/common/drm_util_unittest.cc
index 03dae19b0fc..ec4227e1e31 100644
--- a/chromium/ui/ozone/platform/drm/common/drm_util_unittest.cc
+++ b/chromium/ui/ozone/platform/drm/common/drm_util_unittest.cc
@@ -11,6 +11,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/display/types/display_snapshot.h"
+#include "ui/display/util/edid_parser.h"
#include "ui/gfx/geometry/size.h"
#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
@@ -93,6 +94,17 @@ const unsigned char kSST210Corrected[] =
"\x30\x31\x20\x54\x69\x44\x69\x67\x61\x74\x0a\x6c\x00\x00\xff\x00"
"\x48\x00\x4b\x34\x41\x54\x30\x30\x32\x38\x0a\x38\x20\x20\xf8\x00";
+// This EDID produces blue primary coordinates too far off the expected point,
+// which would paint blue colors as purple. See https://crbug.com/809909.
+const unsigned char kBrokenBluePrimaries[] =
+ "\x00\xff\xff\xff\xff\xff\xff\x00\x4c\x83\x4d\x83\x00\x00\x00\x00"
+ "\x00\x19\x01\x04\x95\x1d\x10\x78\x0a\xee\x25\xa3\x54\x4c\x99\x29"
+ "\x26\x50\x54\x00\x00\x00\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+ "\x01\x01\x01\x01\x01\x01\xd2\x37\x80\xa2\x70\x38\x40\x40\x30\x20"
+ "\x25\x00\x25\xa5\x10\x00\x00\x1a\xa6\x2c\x80\xa2\x70\x38\x40\x40"
+ "\x30\x20\x25\x00\x25\xa5\x10\x00\x00\x1a\x00\x00\x00\xfe\x00\x56"
+ "\x59\x54\x39\x36\x80\x31\x33\x33\x48\x4c\x0a\x20\x00\x00\x00\x00";
+
} // anonymous namespace
bool operator==(const ui::DisplayMode_Params& a,
@@ -114,7 +126,8 @@ bool operator==(const ui::DisplaySnapshot_Params& a,
a.has_current_mode == b.has_current_mode &&
a.current_mode == b.current_mode &&
a.has_native_mode == b.has_native_mode &&
- a.native_mode == b.native_mode && a.product_id == b.product_id &&
+ a.native_mode == b.native_mode && a.product_code == b.product_code &&
+ a.year_of_manufacture == b.year_of_manufacture &&
a.maximum_cursor_size == b.maximum_cursor_size;
}
@@ -146,7 +159,8 @@ void DetailedCompare(const ui::DisplaySnapshot_Params& a,
EXPECT_EQ(a.current_mode, b.current_mode);
EXPECT_EQ(a.has_native_mode, b.has_native_mode);
EXPECT_EQ(a.native_mode, b.native_mode);
- EXPECT_EQ(a.product_id, b.product_id);
+ EXPECT_EQ(a.product_code, b.product_code);
+ EXPECT_EQ(a.year_of_manufacture, b.year_of_manufacture);
EXPECT_EQ(a.maximum_cursor_size, b.maximum_cursor_size);
}
@@ -187,7 +201,8 @@ TEST_F(DrmUtilTest, RoundTripDisplaySnapshot) {
fp.current_mode = MakeDisplay(1.2);
fp.has_native_mode = true;
fp.native_mode = MakeDisplay(1.1);
- fp.product_id = 7;
+ fp.product_code = 7;
+ fp.year_of_manufacture = 1776;
fp.maximum_cursor_size = gfx::Size(103, 44);
sp.display_id = 1002;
@@ -206,7 +221,8 @@ TEST_F(DrmUtilTest, RoundTripDisplaySnapshot) {
sp.has_current_mode = false;
sp.has_native_mode = true;
sp.native_mode = MakeDisplay(500.2);
- sp.product_id = 8;
+ sp.product_code = 8;
+ sp.year_of_manufacture = 2018;
sp.maximum_cursor_size = gfx::Size(500, 44);
ep.display_id = 2002;
@@ -225,7 +241,8 @@ TEST_F(DrmUtilTest, RoundTripDisplaySnapshot) {
ep.has_current_mode = true;
ep.current_mode = MakeDisplay(1000.2);
ep.has_native_mode = false;
- ep.product_id = 9;
+ ep.product_code = 9;
+ ep.year_of_manufacture = 2000;
ep.maximum_cursor_size = gfx::Size(1000, 44);
orig_params.push_back(fp);
@@ -298,8 +315,8 @@ TEST_F(DrmUtilTest, GetColorSpaceFromEdid) {
hpz32x_toXYZ50_matrix.setRowMajord(hpz32x_toXYZ50_coeffs);
const gfx::ColorSpace hpz32x_color_space = gfx::ColorSpace::CreateCustom(
hpz32x_toXYZ50_matrix, SkColorSpaceTransferFn({2.2, 1, 0, 0, 0, 0, 0}));
- EXPECT_STREQ(hpz32x_color_space.ToString().c_str(),
- GetColorSpaceFromEdid(hpz32x_edid).ToString().c_str());
+ EXPECT_EQ(hpz32x_color_space.ToString(),
+ GetColorSpaceFromEdid(display::EdidParser(hpz32x_edid)).ToString());
const std::vector<uint8_t> samus_edid(kSamus, kSamus + arraysize(kSamus) - 1);
const double samus_toXYZ50_coeffs[] = {0.41211, 0.39743, 0.15468, 0.,
@@ -309,8 +326,8 @@ TEST_F(DrmUtilTest, GetColorSpaceFromEdid) {
samus_toXYZ50_matrix.setRowMajord(samus_toXYZ50_coeffs);
const gfx::ColorSpace samus_color_space = gfx::ColorSpace::CreateCustom(
samus_toXYZ50_matrix, SkColorSpaceTransferFn({2.5, 1, 0, 0, 0, 0, 0}));
- EXPECT_STREQ(samus_color_space.ToString().c_str(),
- GetColorSpaceFromEdid(samus_edid).ToString().c_str());
+ EXPECT_EQ(samus_color_space.ToString(),
+ GetColorSpaceFromEdid(display::EdidParser(samus_edid)).ToString());
const std::vector<uint8_t> eve_edid(kEve, kEve + arraysize(kEve) - 1);
const double eve_toXYZ50_coeffs[] = {0.444601, 0.377972, 0.141646, 0.,
@@ -320,37 +337,47 @@ TEST_F(DrmUtilTest, GetColorSpaceFromEdid) {
eve_toXYZ50_matrix.setRowMajord(eve_toXYZ50_coeffs);
const gfx::ColorSpace eve_color_space = gfx::ColorSpace::CreateCustom(
eve_toXYZ50_matrix, SkColorSpaceTransferFn({2.2, 1, 0, 0, 0, 0, 0}));
- EXPECT_STREQ(eve_color_space.ToString().c_str(),
- GetColorSpaceFromEdid(eve_edid).ToString().c_str());
+ EXPECT_EQ(eve_color_space.ToString(),
+ GetColorSpaceFromEdid(display::EdidParser(eve_edid)).ToString());
const std::vector<uint8_t> no_gamma_edid(
kEdidWithNoGamma, kEdidWithNoGamma + arraysize(kEdidWithNoGamma) - 1);
const gfx::ColorSpace no_gamma_color_space =
- GetColorSpaceFromEdid(no_gamma_edid);
+ GetColorSpaceFromEdid(display::EdidParser(no_gamma_edid));
EXPECT_FALSE(no_gamma_color_space.IsValid());
}
TEST_F(DrmUtilTest, GetInvalidColorSpaceFromEdid) {
const std::vector<uint8_t> empty_edid;
- EXPECT_EQ(gfx::ColorSpace(), GetColorSpaceFromEdid(empty_edid));
+ EXPECT_EQ(gfx::ColorSpace(),
+ GetColorSpaceFromEdid(display::EdidParser(empty_edid)));
const std::vector<uint8_t> invalid_edid(
kInvalidEdid, kInvalidEdid + arraysize(kInvalidEdid) - 1);
const gfx::ColorSpace invalid_color_space =
- GetColorSpaceFromEdid(invalid_edid);
+ GetColorSpaceFromEdid(display::EdidParser(invalid_edid));
EXPECT_FALSE(invalid_color_space.IsValid());
const std::vector<uint8_t> sst210_edid(kSST210,
kSST210 + arraysize(kSST210) - 1);
- const gfx::ColorSpace sst210_color_space = GetColorSpaceFromEdid(sst210_edid);
+ const gfx::ColorSpace sst210_color_space =
+ GetColorSpaceFromEdid(display::EdidParser(sst210_edid));
EXPECT_FALSE(sst210_color_space.IsValid()) << sst210_color_space.ToString();
const std::vector<uint8_t> sst210_edid_2(
kSST210Corrected, kSST210Corrected + arraysize(kSST210Corrected) - 1);
const gfx::ColorSpace sst210_color_space_2 =
- GetColorSpaceFromEdid(sst210_edid_2);
+ GetColorSpaceFromEdid(display::EdidParser(sst210_edid_2));
EXPECT_FALSE(sst210_color_space_2.IsValid())
<< sst210_color_space_2.ToString();
+
+ const std::vector<uint8_t> broken_blue_edid(
+ kBrokenBluePrimaries,
+ kBrokenBluePrimaries + arraysize(kBrokenBluePrimaries) - 1);
+ const gfx::ColorSpace broken_blue_color_space =
+ GetColorSpaceFromEdid(display::EdidParser(broken_blue_edid));
+ EXPECT_FALSE(broken_blue_color_space.IsValid())
+ << broken_blue_color_space.ToString();
}
TEST_F(DrmUtilTest, TestDisplayModesExtraction) {
diff --git a/chromium/ui/ozone/platform/drm/gpu/crtc_controller.cc b/chromium/ui/ozone/platform/drm/gpu/crtc_controller.cc
index 88456854b97..fdf87224eda 100644
--- a/chromium/ui/ozone/platform/drm/gpu/crtc_controller.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/crtc_controller.cc
@@ -44,11 +44,11 @@ CrtcController::~CrtcController() {
}
bool CrtcController::Modeset(const OverlayPlane& plane, drmModeModeInfo mode) {
- if (!drm_->SetCrtc(crtc_, plane.buffer->GetFramebufferId(),
+ if (!drm_->SetCrtc(crtc_, plane.buffer->GetOpaqueFramebufferId(),
std::vector<uint32_t>(1, connector_), &mode)) {
PLOG(ERROR) << "Failed to modeset: crtc=" << crtc_
<< " connector=" << connector_
- << " framebuffer_id=" << plane.buffer->GetFramebufferId()
+ << " framebuffer_id=" << plane.buffer->GetOpaqueFramebufferId()
<< " mode=" << mode.hdisplay << "x" << mode.vdisplay << "@"
<< mode.vrefresh;
return false;
diff --git a/chromium/ui/ozone/platform/drm/gpu/drm_device.cc b/chromium/ui/ozone/platform/drm/gpu/drm_device.cc
index 9fd0bd15bc8..b3ffc96902d 100644
--- a/chromium/ui/ozone/platform/drm/gpu/drm_device.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/drm_device.cc
@@ -15,6 +15,7 @@
#include "base/macros.h"
#include "base/memory/free_deleter.h"
#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_pump_for_io.h"
#include "base/posix/safe_strerror.h"
#include "base/task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -289,7 +290,7 @@ class DrmDevice::PageFlipManager {
DISALLOW_COPY_AND_ASSIGN(PageFlipManager);
};
-class DrmDevice::IOWatcher : public base::MessagePumpLibevent::Watcher {
+class DrmDevice::IOWatcher : public base::MessagePumpLibevent::FdWatcher {
public:
IOWatcher(int fd, DrmDevice::PageFlipManager* page_flip_manager)
: page_flip_manager_(page_flip_manager), controller_(FROM_HERE), fd_(fd) {
@@ -302,7 +303,7 @@ class DrmDevice::IOWatcher : public base::MessagePumpLibevent::Watcher {
void Register() {
DCHECK(base::MessageLoopForIO::IsCurrent());
base::MessageLoopForIO::current()->WatchFileDescriptor(
- fd_, true, base::MessageLoopForIO::WATCH_READ, &controller_, this);
+ fd_, true, base::MessagePumpForIO::WATCH_READ, &controller_, this);
}
void Unregister() {
@@ -310,7 +311,7 @@ class DrmDevice::IOWatcher : public base::MessagePumpLibevent::Watcher {
controller_.StopWatchingFileDescriptor();
}
- // base::MessagePumpLibevent::Watcher overrides:
+ // base::MessagePumpLibevent::FdWatcher overrides:
void OnFileCanReadWithoutBlocking(int fd) override {
DCHECK(base::MessageLoopForIO::IsCurrent());
TRACE_EVENT1("drm", "OnDrmEvent", "socket", fd);
@@ -324,7 +325,7 @@ class DrmDevice::IOWatcher : public base::MessagePumpLibevent::Watcher {
DrmDevice::PageFlipManager* page_flip_manager_;
- base::MessagePumpLibevent::FileDescriptorWatcher controller_;
+ base::MessagePumpLibevent::FdWatchController controller_;
int fd_;
diff --git a/chromium/ui/ozone/platform/drm/gpu/drm_display.cc b/chromium/ui/ozone/platform/drm/gpu/drm_display.cc
index 07d013b97c3..ce85361b01e 100644
--- a/chromium/ui/ozone/platform/drm/gpu/drm_display.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/drm_display.cc
@@ -7,7 +7,6 @@
#include <xf86drmMode.h>
#include "base/macros.h"
-#include "base/memory/ptr_util.h"
#include "ui/display/types/display_snapshot.h"
#include "ui/display/types/gamma_ramp_rgb_entry.h"
#include "ui/ozone/platform/drm/common/drm_util.h"
diff --git a/chromium/ui/ozone/platform/drm/gpu/drm_gpu_display_manager.cc b/chromium/ui/ozone/platform/drm/gpu/drm_gpu_display_manager.cc
index d07f5760ed1..a1cd5650a7c 100644
--- a/chromium/ui/ozone/platform/drm/gpu/drm_gpu_display_manager.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/drm_gpu_display_manager.cc
@@ -6,7 +6,6 @@
#include <stddef.h>
-#include "base/memory/ptr_util.h"
#include "ui/display/types/display_mode.h"
#include "ui/display/types/display_snapshot.h"
#include "ui/display/types/gamma_ramp_rgb_entry.h"
diff --git a/chromium/ui/ozone/platform/drm/gpu/drm_overlay_validator.cc b/chromium/ui/ozone/platform/drm/gpu/drm_overlay_validator.cc
index 15d5bae1977..d0a82568e4a 100644
--- a/chromium/ui/ozone/platform/drm/gpu/drm_overlay_validator.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/drm_overlay_validator.cc
@@ -82,7 +82,7 @@ std::vector<OverlayCheckReturn_Params> DrmOverlayValidator::TestPageFlip(
OverlayPlane plane(buffer, params[i].plane_z_order, params[i].transform,
params[i].display_rect, params[i].crop_rect,
- base::kInvalidPlatformFile);
+ /* enable_blend */ true, base::kInvalidPlatformFile);
test_list.push_back(plane);
if (buffer && controller->TestPageFlip(test_list)) {
diff --git a/chromium/ui/ozone/platform/drm/gpu/drm_overlay_validator_unittest.cc b/chromium/ui/ozone/platform/drm/gpu/drm_overlay_validator_unittest.cc
index 0328b0cc82c..3b3642b8d88 100644
--- a/chromium/ui/ozone/platform/drm/gpu/drm_overlay_validator_unittest.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/drm_overlay_validator_unittest.cc
@@ -138,7 +138,7 @@ void DrmOverlayValidatorTest::AddPlane(const ui::OverlayCheck_Params& params) {
params.buffer_size);
ui::OverlayPlane plane(std::move(scanout_buffer), params.plane_z_order,
params.transform, params.display_rect,
- params.crop_rect, base::kInvalidPlatformFile);
+ params.crop_rect, true, base::kInvalidPlatformFile);
plane_list_.push_back(plane);
}
diff --git a/chromium/ui/ozone/platform/drm/gpu/drm_thread.cc b/chromium/ui/ozone/platform/drm/gpu/drm_thread.cc
index 566de8b0b67..6e187761ea9 100644
--- a/chromium/ui/ozone/platform/drm/gpu/drm_thread.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/drm_thread.cc
@@ -9,7 +9,6 @@
#include "base/command_line.h"
#include "base/macros.h"
-#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
@@ -204,7 +203,7 @@ void DrmThread::SchedulePageFlip(gfx::AcceleratedWidget widget,
drm_device->plane_manager()->RequestPlanesReadyCallback(
planes, base::BindOnce(&DrmThread::OnPlanesReadyForPageFlip,
weak_ptr_factory_.GetWeakPtr(), widget, planes,
- base::Passed(&callback)));
+ std::move(callback)));
}
void DrmThread::OnPlanesReadyForPageFlip(
diff --git a/chromium/ui/ozone/platform/drm/gpu/drm_thread_message_proxy.cc b/chromium/ui/ozone/platform/drm/gpu/drm_thread_message_proxy.cc
index 6e1d4a749e3..842ed61ff2c 100644
--- a/chromium/ui/ozone/platform/drm/gpu/drm_thread_message_proxy.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/drm_thread_message_proxy.cc
@@ -65,23 +65,23 @@ bool DrmThreadMessageProxy::OnMessageReceived(const IPC::Message& message) {
void DrmThreadMessageProxy::OnCreateWindow(gfx::AcceleratedWidget widget) {
DCHECK(drm_thread_->IsRunning());
drm_thread_->task_runner()->PostTask(
- FROM_HERE, base::Bind(&DrmThread::CreateWindow,
- base::Unretained(drm_thread_), widget));
+ FROM_HERE, base::BindOnce(&DrmThread::CreateWindow,
+ base::Unretained(drm_thread_), widget));
}
void DrmThreadMessageProxy::OnDestroyWindow(gfx::AcceleratedWidget widget) {
DCHECK(drm_thread_->IsRunning());
drm_thread_->task_runner()->PostTask(
- FROM_HERE, base::Bind(&DrmThread::DestroyWindow,
- base::Unretained(drm_thread_), widget));
+ FROM_HERE, base::BindOnce(&DrmThread::DestroyWindow,
+ base::Unretained(drm_thread_), widget));
}
void DrmThreadMessageProxy::OnWindowBoundsChanged(gfx::AcceleratedWidget widget,
const gfx::Rect& bounds) {
DCHECK(drm_thread_->IsRunning());
drm_thread_->task_runner()->PostTask(
- FROM_HERE, base::Bind(&DrmThread::SetWindowBounds,
- base::Unretained(drm_thread_), widget, bounds));
+ FROM_HERE, base::BindOnce(&DrmThread::SetWindowBounds,
+ base::Unretained(drm_thread_), widget, bounds));
}
void DrmThreadMessageProxy::OnCursorSet(gfx::AcceleratedWidget widget,
@@ -91,16 +91,17 @@ void DrmThreadMessageProxy::OnCursorSet(gfx::AcceleratedWidget widget,
DCHECK(drm_thread_->IsRunning());
drm_thread_->task_runner()->PostTask(
FROM_HERE,
- base::Bind(&DrmThread::SetCursor, base::Unretained(drm_thread_), widget,
- bitmaps, location, frame_delay_ms));
+ base::BindOnce(&DrmThread::SetCursor, base::Unretained(drm_thread_),
+ widget, bitmaps, location, frame_delay_ms));
}
void DrmThreadMessageProxy::OnCursorMove(gfx::AcceleratedWidget widget,
const gfx::Point& location) {
DCHECK(drm_thread_->IsRunning());
drm_thread_->task_runner()->PostTask(
- FROM_HERE, base::Bind(&DrmThread::MoveCursor,
- base::Unretained(drm_thread_), widget, location));
+ FROM_HERE,
+ base::BindOnce(&DrmThread::MoveCursor, base::Unretained(drm_thread_),
+ widget, location));
}
void DrmThreadMessageProxy::OnCheckOverlayCapabilities(
@@ -191,15 +192,15 @@ void DrmThreadMessageProxy::OnAddGraphicsDevice(
base::File file(fd.fd);
drm_thread_->task_runner()->PostTask(
FROM_HERE,
- base::Bind(&DrmThread::AddGraphicsDevice, base::Unretained(drm_thread_),
- path, Passed(&file)));
+ base::BindOnce(&DrmThread::AddGraphicsDevice,
+ base::Unretained(drm_thread_), path, std::move(file)));
}
void DrmThreadMessageProxy::OnRemoveGraphicsDevice(const base::FilePath& path) {
DCHECK(drm_thread_->IsRunning());
drm_thread_->task_runner()->PostTask(
- FROM_HERE, base::Bind(&DrmThread::RemoveGraphicsDevice,
- base::Unretained(drm_thread_), path));
+ FROM_HERE, base::BindOnce(&DrmThread::RemoveGraphicsDevice,
+ base::Unretained(drm_thread_), path));
}
void DrmThreadMessageProxy::OnGetHDCPState(int64_t display_id) {
@@ -232,9 +233,9 @@ void DrmThreadMessageProxy::OnSetColorCorrection(
const std::vector<float>& correction_matrix) {
DCHECK(drm_thread_->IsRunning());
drm_thread_->task_runner()->PostTask(
- FROM_HERE,
- base::Bind(&DrmThread::SetColorCorrection, base::Unretained(drm_thread_),
- id, degamma_lut, gamma_lut, correction_matrix));
+ FROM_HERE, base::BindOnce(&DrmThread::SetColorCorrection,
+ base::Unretained(drm_thread_), id, degamma_lut,
+ gamma_lut, correction_matrix));
}
void DrmThreadMessageProxy::OnCheckOverlayCapabilitiesCallback(
diff --git a/chromium/ui/ozone/platform/drm/gpu/drm_thread_proxy.cc b/chromium/ui/ozone/platform/drm/gpu/drm_thread_proxy.cc
index 2bad52ddd44..fe6c4b3affa 100644
--- a/chromium/ui/ozone/platform/drm/gpu/drm_thread_proxy.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/drm_thread_proxy.cc
@@ -5,7 +5,6 @@
#include "ui/ozone/platform/drm/gpu/drm_thread_proxy.h"
#include "base/bind.h"
-#include "base/memory/ptr_util.h"
#include "ui/ozone/platform/drm/gpu/drm_thread_message_proxy.h"
#include "ui/ozone/platform/drm/gpu/drm_window_proxy.h"
#include "ui/ozone/platform/drm/gpu/gbm_buffer.h"
@@ -76,8 +75,8 @@ void DrmThreadProxy::AddBindingCursorDevice(
ozone::mojom::DeviceCursorRequest request) {
drm_thread_.task_runner()->PostTask(
FROM_HERE,
- base::Bind(&DrmThread::AddBindingCursorDevice,
- base::Unretained(&drm_thread_), base::Passed(&request)));
+ base::BindOnce(&DrmThread::AddBindingCursorDevice,
+ base::Unretained(&drm_thread_), std::move(request)));
}
void DrmThreadProxy::AddBindingDrmDevice(
@@ -87,8 +86,8 @@ void DrmThreadProxy::AddBindingDrmDevice(
drm_thread_.task_runner()->PostTask(
FROM_HERE,
- base::Bind(&DrmThread::AddBindingDrmDevice,
- base::Unretained(&drm_thread_), base::Passed(&request)));
+ base::BindOnce(&DrmThread::AddBindingDrmDevice,
+ base::Unretained(&drm_thread_), std::move(request)));
}
} // namespace ui
diff --git a/chromium/ui/ozone/platform/drm/gpu/drm_window.cc b/chromium/ui/ozone/platform/drm/gpu/drm_window.cc
index 51d18556c01..6deff4440b2 100644
--- a/chromium/ui/ozone/platform/drm/gpu/drm_window.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/drm_window.cc
@@ -8,7 +8,6 @@
#include <stdint.h>
#include "base/macros.h"
-#include "base/memory/ptr_util.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "third_party/skia/include/core/SkBitmap.h"
diff --git a/chromium/ui/ozone/platform/drm/gpu/drm_window_proxy.cc b/chromium/ui/ozone/platform/drm/gpu/drm_window_proxy.cc
index cd41e064885..f5f882a7958 100644
--- a/chromium/ui/ozone/platform/drm/gpu/drm_window_proxy.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/drm_window_proxy.cc
@@ -30,9 +30,9 @@ void DrmWindowProxy::SchedulePageFlip(const std::vector<OverlayPlane>& planes,
void DrmWindowProxy::GetVSyncParameters(
const gfx::VSyncProvider::UpdateVSyncCallback& callback) {
drm_thread_->task_runner()->PostTask(
- FROM_HERE,
- base::Bind(&DrmThread::GetVSyncParameters, base::Unretained(drm_thread_),
- widget_, CreateSafeCallback(callback)));
+ FROM_HERE, base::BindOnce(&DrmThread::GetVSyncParameters,
+ base::Unretained(drm_thread_), widget_,
+ CreateSafeCallback(callback)));
}
} // namespace ui
diff --git a/chromium/ui/ozone/platform/drm/gpu/drm_window_unittest.cc b/chromium/ui/ozone/platform/drm/gpu/drm_window_unittest.cc
index 4faa63288cc..40a207ec1c3 100644
--- a/chromium/ui/ozone/platform/drm/gpu/drm_window_unittest.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/drm_window_unittest.cc
@@ -183,7 +183,7 @@ TEST_F(DrmWindowTest, CheckCallbackOnFailedSwap) {
// Window was re-sized, so the expectation is to re-create the buffers first.
window->SchedulePageFlip(
std::vector<ui::OverlayPlane>(1, ui::OverlayPlane(plane)),
- base::Bind(&DrmWindowTest::OnSwapBuffers, base::Unretained(this)));
+ base::BindOnce(&DrmWindowTest::OnSwapBuffers, base::Unretained(this)));
EXPECT_EQ(1, on_swap_buffers_count_);
EXPECT_EQ(gfx::SwapResult::SWAP_NAK_RECREATE_BUFFERS,
last_swap_buffers_result_);
@@ -191,7 +191,7 @@ TEST_F(DrmWindowTest, CheckCallbackOnFailedSwap) {
window->SchedulePageFlip(
std::vector<ui::OverlayPlane>(1, ui::OverlayPlane(plane)),
- base::Bind(&DrmWindowTest::OnSwapBuffers, base::Unretained(this)));
+ base::BindOnce(&DrmWindowTest::OnSwapBuffers, base::Unretained(this)));
EXPECT_EQ(2, on_swap_buffers_count_);
EXPECT_EQ(gfx::SwapResult::SWAP_FAILED, last_swap_buffers_result_);
EXPECT_EQ(gfx::PresentationFeedback(), last_presentation_feedback_);
diff --git a/chromium/ui/ozone/platform/drm/gpu/gbm_buffer.cc b/chromium/ui/ozone/platform/drm/gpu/gbm_buffer.cc
index 17948261354..19a26ada002 100644
--- a/chromium/ui/ozone/platform/drm/gpu/gbm_buffer.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/gbm_buffer.cc
@@ -385,11 +385,12 @@ bool GbmPixmap::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
int plane_z_order,
gfx::OverlayTransform plane_transform,
const gfx::Rect& display_bounds,
- const gfx::RectF& crop_rect) {
+ const gfx::RectF& crop_rect,
+ bool enable_blend) {
DCHECK(buffer_->GetFlags() & GBM_BO_USE_SCANOUT);
surface_manager_->GetSurface(widget)->QueueOverlayPlane(
OverlayPlane(buffer_, plane_z_order, plane_transform, display_bounds,
- crop_rect, base::kInvalidPlatformFile));
+ crop_rect, enable_blend, base::kInvalidPlatformFile));
return true;
}
diff --git a/chromium/ui/ozone/platform/drm/gpu/gbm_buffer.h b/chromium/ui/ozone/platform/drm/gpu/gbm_buffer.h
index 984e7df6afd..8a5573db3e4 100644
--- a/chromium/ui/ozone/platform/drm/gpu/gbm_buffer.h
+++ b/chromium/ui/ozone/platform/drm/gpu/gbm_buffer.h
@@ -121,7 +121,8 @@ class GbmPixmap : public gfx::NativePixmap {
int plane_z_order,
gfx::OverlayTransform plane_transform,
const gfx::Rect& display_bounds,
- const gfx::RectF& crop_rect) override;
+ const gfx::RectF& crop_rect,
+ bool enable_blend) override;
gfx::NativePixmapHandle ExportHandle() override;
scoped_refptr<GbmBuffer> buffer() { return buffer_; }
diff --git a/chromium/ui/ozone/platform/drm/gpu/gbm_surface.cc b/chromium/ui/ozone/platform/drm/gpu/gbm_surface.cc
index ac50b648d41..56c05a954a5 100644
--- a/chromium/ui/ozone/platform/drm/gpu/gbm_surface.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/gbm_surface.cc
@@ -65,7 +65,7 @@ void GbmSurface::SwapBuffersAsync(
const PresentationCallback& presentation_callback) {
if (!images_[current_surface_]->ScheduleOverlayPlane(
widget(), 0, gfx::OverlayTransform::OVERLAY_TRANSFORM_NONE,
- gfx::Rect(GetSize()), gfx::RectF(1, 1))) {
+ gfx::Rect(GetSize()), gfx::RectF(1, 1), /* enable_blend */ false)) {
completion_callback.Run(gfx::SwapResult::SWAP_FAILED);
// Notify the caller, the buffer is never presented on a screen.
presentation_callback.Run(gfx::PresentationFeedback());
@@ -136,7 +136,7 @@ bool GbmSurface::CreatePixmaps() {
if (!pixmap)
return false;
scoped_refptr<gl::GLImageNativePixmap> image =
- new gl::GLImageNativePixmap(GetSize(), GL_RGB);
+ new gl::GLImageNativePixmap(GetSize(), GL_BGRA_EXT);
if (!image->Initialize(pixmap.get(),
display::DisplaySnapshot::PrimaryFormat()))
return false;
diff --git a/chromium/ui/ozone/platform/drm/gpu/gbm_surface_factory.cc b/chromium/ui/ozone/platform/drm/gpu/gbm_surface_factory.cc
index ca8a5206071..4fdef17f041 100644
--- a/chromium/ui/ozone/platform/drm/gpu/gbm_surface_factory.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/gbm_surface_factory.cc
@@ -9,7 +9,6 @@
#include <utility>
#include "base/files/file_path.h"
-#include "base/memory/ptr_util.h"
#include "build/build_config.h"
#include "third_party/khronos/EGL/egl.h"
#include "ui/gfx/buffer_format_util.h"
diff --git a/chromium/ui/ozone/platform/drm/gpu/gbm_surfaceless.cc b/chromium/ui/ozone/platform/drm/gpu/gbm_surfaceless.cc
index fab047e68ca..f067067795a 100644
--- a/chromium/ui/ozone/platform/drm/gpu/gbm_surfaceless.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/gbm_surfaceless.cc
@@ -8,7 +8,6 @@
#include "base/bind.h"
#include "base/logging.h"
-#include "base/memory/ptr_util.h"
#include "base/task_scheduler/post_task.h"
#include "base/trace_event/trace_event.h"
#include "ui/gfx/presentation_feedback.h"
@@ -68,9 +67,10 @@ bool GbmSurfaceless::ScheduleOverlayPlane(int z_order,
gfx::OverlayTransform transform,
gl::GLImage* image,
const gfx::Rect& bounds_rect,
- const gfx::RectF& crop_rect) {
- unsubmitted_frames_.back()->overlays.push_back(
- gl::GLSurfaceOverlay(z_order, transform, image, bounds_rect, crop_rect));
+ const gfx::RectF& crop_rect,
+ bool enable_blend) {
+ unsubmitted_frames_.back()->overlays.push_back(gl::GLSurfaceOverlay(
+ z_order, transform, image, bounds_rect, crop_rect, enable_blend));
return true;
}
diff --git a/chromium/ui/ozone/platform/drm/gpu/gbm_surfaceless.h b/chromium/ui/ozone/platform/drm/gpu/gbm_surfaceless.h
index 32cf0e8e863..71c3022e384 100644
--- a/chromium/ui/ozone/platform/drm/gpu/gbm_surfaceless.h
+++ b/chromium/ui/ozone/platform/drm/gpu/gbm_surfaceless.h
@@ -41,7 +41,8 @@ class GbmSurfaceless : public gl::SurfacelessEGL {
gfx::OverlayTransform transform,
gl::GLImage* image,
const gfx::Rect& bounds_rect,
- const gfx::RectF& crop_rect) override;
+ const gfx::RectF& crop_rect,
+ bool enable_blend) override;
bool IsOffscreen() override;
gfx::VSyncProvider* GetVSyncProvider() override;
bool SupportsPresentationCallback() override;
diff --git a/chromium/ui/ozone/platform/drm/gpu/hardware_display_controller.cc b/chromium/ui/ozone/platform/drm/gpu/hardware_display_controller.cc
index de661e983a7..aa68355c3a2 100644
--- a/chromium/ui/ozone/platform/drm/gpu/hardware_display_controller.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/hardware_display_controller.cc
@@ -10,7 +10,6 @@
#include <utility>
#include "base/logging.h"
-#include "base/memory/ptr_util.h"
#include "base/trace_event/trace_event.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "ui/gfx/geometry/point.h"
@@ -117,11 +116,6 @@ bool HardwareDisplayController::ActualSchedulePageFlip(
[](const OverlayPlane& l, const OverlayPlane& r) {
return l.z_order < r.z_order;
});
- if (pending_planes.front().z_order < 0) {
- std::move(callback).Run(gfx::SwapResult::SWAP_FAILED,
- gfx::PresentationFeedback());
- return false;
- }
scoped_refptr<PageFlipRequest> page_flip_request =
new PageFlipRequest(crtc_controllers_.size(), std::move(callback));
diff --git a/chromium/ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc b/chromium/ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc
index afc1acf0d57..d31581b51a8 100644
--- a/chromium/ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc
@@ -107,8 +107,8 @@ TEST_F(HardwareDisplayControllerTest, CheckStateAfterPageFlip) {
std::vector<ui::OverlayPlane> planes =
std::vector<ui::OverlayPlane>(1, plane2);
controller_->SchedulePageFlip(
- planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
- base::Unretained(this)));
+ planes, base::BindOnce(&HardwareDisplayControllerTest::PageFlipCallback,
+ base::Unretained(this)));
drm_->RunCallbacks();
EXPECT_TRUE(plane1.buffer->HasOneRef());
EXPECT_FALSE(plane2.buffer->HasOneRef());
@@ -144,8 +144,8 @@ TEST_F(HardwareDisplayControllerTest, CheckStateIfPageFlipFails) {
std::vector<ui::OverlayPlane> planes =
std::vector<ui::OverlayPlane>(1, plane2);
controller_->SchedulePageFlip(
- planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
- base::Unretained(this)));
+ planes, base::BindOnce(&HardwareDisplayControllerTest::PageFlipCallback,
+ base::Unretained(this)));
drm_->RunCallbacks();
planes.clear();
@@ -162,7 +162,7 @@ TEST_F(HardwareDisplayControllerTest, CheckOverlayPresent) {
ui::OverlayPlane plane2(
scoped_refptr<ui::ScanoutBuffer>(new ui::MockScanoutBuffer(kOverlaySize)),
1, gfx::OVERLAY_TRANSFORM_NONE, gfx::Rect(kOverlaySize),
- gfx::RectF(kDefaultModeSizeF), base::kInvalidPlatformFile);
+ gfx::RectF(kDefaultModeSizeF), true, base::kInvalidPlatformFile);
EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode));
@@ -171,8 +171,8 @@ TEST_F(HardwareDisplayControllerTest, CheckOverlayPresent) {
planes.push_back(plane2);
controller_->SchedulePageFlip(
- planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
- base::Unretained(this)));
+ planes, base::BindOnce(&HardwareDisplayControllerTest::PageFlipCallback,
+ base::Unretained(this)));
drm_->RunCallbacks();
EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_);
EXPECT_EQ(1, page_flips_);
@@ -187,7 +187,7 @@ TEST_F(HardwareDisplayControllerTest, CheckOverlayTestMode) {
ui::OverlayPlane plane2(
scoped_refptr<ui::ScanoutBuffer>(new ui::MockScanoutBuffer(kOverlaySize)),
1, gfx::OVERLAY_TRANSFORM_NONE, gfx::Rect(kOverlaySize),
- gfx::RectF(kDefaultModeSizeF), base::kInvalidPlatformFile);
+ gfx::RectF(kDefaultModeSizeF), true, base::kInvalidPlatformFile);
EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode));
@@ -196,8 +196,8 @@ TEST_F(HardwareDisplayControllerTest, CheckOverlayTestMode) {
planes.push_back(plane2);
controller_->SchedulePageFlip(
- planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
- base::Unretained(this)));
+ planes, base::BindOnce(&HardwareDisplayControllerTest::PageFlipCallback,
+ base::Unretained(this)));
// A test call shouldn't cause new flips, but should succeed.
EXPECT_TRUE(controller_->TestPageFlip(planes));
@@ -209,8 +209,8 @@ TEST_F(HardwareDisplayControllerTest, CheckOverlayTestMode) {
// Regular flips should continue on normally.
controller_->SchedulePageFlip(
- planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
- base::Unretained(this)));
+ planes, base::BindOnce(&HardwareDisplayControllerTest::PageFlipCallback,
+ base::Unretained(this)));
drm_->RunCallbacks();
EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_);
EXPECT_EQ(2, page_flips_);
@@ -218,7 +218,7 @@ TEST_F(HardwareDisplayControllerTest, CheckOverlayTestMode) {
EXPECT_EQ(2, drm_->get_overlay_flip_call_count());
}
-TEST_F(HardwareDisplayControllerTest, RejectUnderlays) {
+TEST_F(HardwareDisplayControllerTest, AcceptUnderlays) {
ui::OverlayPlane plane1(scoped_refptr<ui::ScanoutBuffer>(
new ui::MockScanoutBuffer(kDefaultModeSize)),
base::kInvalidPlatformFile);
@@ -226,7 +226,7 @@ TEST_F(HardwareDisplayControllerTest, RejectUnderlays) {
scoped_refptr<ui::ScanoutBuffer>(
new ui::MockScanoutBuffer(kDefaultModeSize)),
-1, gfx::OVERLAY_TRANSFORM_NONE, gfx::Rect(kDefaultModeSize),
- gfx::RectF(kDefaultModeSizeF), base::kInvalidPlatformFile);
+ gfx::RectF(kDefaultModeSizeF), true, base::kInvalidPlatformFile);
EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode));
@@ -235,9 +235,10 @@ TEST_F(HardwareDisplayControllerTest, RejectUnderlays) {
planes.push_back(plane2);
controller_->SchedulePageFlip(
- planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
- base::Unretained(this)));
- EXPECT_EQ(gfx::SwapResult::SWAP_FAILED, last_swap_result_);
+ planes, base::BindOnce(&HardwareDisplayControllerTest::PageFlipCallback,
+ base::Unretained(this)));
+ drm_->RunCallbacks();
+ EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_);
EXPECT_EQ(1, page_flips_);
}
@@ -257,8 +258,8 @@ TEST_F(HardwareDisplayControllerTest, PageflipMirroredControllers) {
std::vector<ui::OverlayPlane> planes =
std::vector<ui::OverlayPlane>(1, plane2);
controller_->SchedulePageFlip(
- planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
- base::Unretained(this)));
+ planes, base::BindOnce(&HardwareDisplayControllerTest::PageFlipCallback,
+ base::Unretained(this)));
drm_->RunCallbacks();
EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_);
EXPECT_EQ(1, page_flips_);
@@ -274,8 +275,8 @@ TEST_F(HardwareDisplayControllerTest, PlaneStateAfterRemoveCrtc) {
std::vector<ui::OverlayPlane> planes =
std::vector<ui::OverlayPlane>(1, plane1);
controller_->SchedulePageFlip(
- planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
- base::Unretained(this)));
+ planes, base::BindOnce(&HardwareDisplayControllerTest::PageFlipCallback,
+ base::Unretained(this)));
drm_->RunCallbacks();
EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_);
EXPECT_EQ(1, page_flips_);
@@ -297,8 +298,8 @@ TEST_F(HardwareDisplayControllerTest, PlaneStateAfterRemoveCrtc) {
// Check that controller doesn't affect the state of removed plane in
// subsequent page flip.
controller_->SchedulePageFlip(
- planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
- base::Unretained(this)));
+ planes, base::BindOnce(&HardwareDisplayControllerTest::PageFlipCallback,
+ base::Unretained(this)));
drm_->RunCallbacks();
EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_);
EXPECT_EQ(1, page_flips_);
@@ -314,8 +315,8 @@ TEST_F(HardwareDisplayControllerTest, PlaneStateAfterDestroyingCrtc) {
std::vector<ui::OverlayPlane> planes =
std::vector<ui::OverlayPlane>(1, plane1);
controller_->SchedulePageFlip(
- planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
- base::Unretained(this)));
+ planes, base::BindOnce(&HardwareDisplayControllerTest::PageFlipCallback,
+ base::Unretained(this)));
drm_->RunCallbacks();
EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_);
EXPECT_EQ(1, page_flips_);
@@ -346,8 +347,8 @@ TEST_F(HardwareDisplayControllerTest, PlaneStateAfterAddCrtc) {
std::vector<ui::OverlayPlane> planes =
std::vector<ui::OverlayPlane>(1, plane1);
controller_->SchedulePageFlip(
- planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
- base::Unretained(this)));
+ planes, base::BindOnce(&HardwareDisplayControllerTest::PageFlipCallback,
+ base::Unretained(this)));
drm_->RunCallbacks();
EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_);
EXPECT_EQ(1, page_flips_);
@@ -364,8 +365,8 @@ TEST_F(HardwareDisplayControllerTest, PlaneStateAfterAddCrtc) {
hdc_controller.reset(new ui::HardwareDisplayController(
controller_->RemoveCrtc(drm_, kPrimaryCrtc), controller_->origin()));
controller_->SchedulePageFlip(
- planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
- base::Unretained(this)));
+ planes, base::BindOnce(&HardwareDisplayControllerTest::PageFlipCallback,
+ base::Unretained(this)));
drm_->RunCallbacks();
EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_);
EXPECT_EQ(2, page_flips_);
@@ -378,8 +379,8 @@ TEST_F(HardwareDisplayControllerTest, PlaneStateAfterAddCrtc) {
primary_crtc_plane->set_in_use(false);
primary_crtc_plane->set_owning_crtc(0);
hdc_controller->SchedulePageFlip(
- planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
- base::Unretained(this)));
+ planes, base::BindOnce(&HardwareDisplayControllerTest::PageFlipCallback,
+ base::Unretained(this)));
drm_->RunCallbacks();
EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_);
EXPECT_EQ(3, page_flips_);
@@ -395,8 +396,8 @@ TEST_F(HardwareDisplayControllerTest, ModesetWhilePageFlipping) {
std::vector<ui::OverlayPlane> planes =
std::vector<ui::OverlayPlane>(1, plane1);
controller_->SchedulePageFlip(
- planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
- base::Unretained(this)));
+ planes, base::BindOnce(&HardwareDisplayControllerTest::PageFlipCallback,
+ base::Unretained(this)));
EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode));
drm_->RunCallbacks();
@@ -414,8 +415,8 @@ TEST_F(HardwareDisplayControllerTest, FailPageFlipping) {
std::vector<ui::OverlayPlane> planes =
std::vector<ui::OverlayPlane>(1, plane1);
controller_->SchedulePageFlip(
- planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
- base::Unretained(this)));
+ planes, base::BindOnce(&HardwareDisplayControllerTest::PageFlipCallback,
+ base::Unretained(this)));
drm_->RunCallbacks();
EXPECT_EQ(gfx::SwapResult::SWAP_FAILED, last_swap_result_);
@@ -427,13 +428,13 @@ TEST_F(HardwareDisplayControllerTest, CheckNoPrimaryPlane) {
new ui::MockScanoutBuffer(kDefaultModeSize)),
1, gfx::OVERLAY_TRANSFORM_NONE,
gfx::Rect(kDefaultModeSize), gfx::RectF(0, 0, 1, 1),
- base::kInvalidPlatformFile);
+ true, base::kInvalidPlatformFile);
EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode));
std::vector<ui::OverlayPlane> planes =
std::vector<ui::OverlayPlane>(1, plane1);
controller_->SchedulePageFlip(
- planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
- base::Unretained(this)));
+ planes, base::BindOnce(&HardwareDisplayControllerTest::PageFlipCallback,
+ base::Unretained(this)));
drm_->RunCallbacks();
EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_);
@@ -448,8 +449,8 @@ TEST_F(HardwareDisplayControllerTest, AddCrtcMidPageFlip) {
std::vector<ui::OverlayPlane> planes =
std::vector<ui::OverlayPlane>(1, plane1);
controller_->SchedulePageFlip(
- planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
- base::Unretained(this)));
+ planes, base::BindOnce(&HardwareDisplayControllerTest::PageFlipCallback,
+ base::Unretained(this)));
controller_->AddCrtc(std::unique_ptr<ui::CrtcController>(
new ui::CrtcController(drm_.get(), kSecondaryCrtc, kSecondaryConnector)));
@@ -467,8 +468,8 @@ TEST_F(HardwareDisplayControllerTest, RemoveCrtcMidPageFlip) {
std::vector<ui::OverlayPlane> planes =
std::vector<ui::OverlayPlane>(1, plane1);
controller_->SchedulePageFlip(
- planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
- base::Unretained(this)));
+ planes, base::BindOnce(&HardwareDisplayControllerTest::PageFlipCallback,
+ base::Unretained(this)));
controller_->RemoveCrtc(drm_, kPrimaryCrtc);
@@ -486,15 +487,15 @@ TEST_F(HardwareDisplayControllerTest, Disable) {
ui::OverlayPlane plane2(new ui::MockScanoutBuffer(kOverlaySize), 1,
gfx::OVERLAY_TRANSFORM_NONE, gfx::Rect(kOverlaySize),
- gfx::RectF(kDefaultModeSizeF),
+ gfx::RectF(kDefaultModeSizeF), true,
base::kInvalidPlatformFile);
std::vector<ui::OverlayPlane> planes;
planes.push_back(plane1);
planes.push_back(plane2);
controller_->SchedulePageFlip(
- planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
- base::Unretained(this)));
+ planes, base::BindOnce(&HardwareDisplayControllerTest::PageFlipCallback,
+ base::Unretained(this)));
drm_->RunCallbacks();
EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_);
EXPECT_EQ(1, page_flips_);
diff --git a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.h b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.h
index bf7ddde34f3..952c6f93e0d 100644
--- a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.h
+++ b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.h
@@ -25,13 +25,13 @@ class HardwareDisplayPlaneAtomic : public HardwareDisplayPlane {
HardwareDisplayPlaneAtomic(uint32_t plane_id, uint32_t possible_crtcs);
~HardwareDisplayPlaneAtomic() override;
- bool SetPlaneData(drmModeAtomicReq* property_set,
- uint32_t crtc_id,
- uint32_t framebuffer,
- const gfx::Rect& crtc_rect,
- const gfx::Rect& src_rect,
- const gfx::OverlayTransform transform,
- int in_fence_fd);
+ virtual bool SetPlaneData(drmModeAtomicReq* property_set,
+ uint32_t crtc_id,
+ uint32_t framebuffer,
+ const gfx::Rect& crtc_rect,
+ const gfx::Rect& src_rect,
+ const gfx::OverlayTransform transform,
+ int in_fence_fd);
void set_crtc(CrtcController* crtc) { crtc_ = crtc; }
CrtcController* crtc() const { return crtc_; }
diff --git a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.cc b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.cc
index b74520781ae..42446c9316d 100644
--- a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.cc
@@ -214,7 +214,10 @@ bool HardwareDisplayPlaneManager::IsCompatible(HardwareDisplayPlane* plane,
if (!plane->CanUseForCrtc(crtc_index))
return false;
- if (!plane->IsSupportedFormat(overlay.buffer->GetFramebufferPixelFormat()))
+ const uint32_t format = overlay.enable_blend ?
+ overlay.buffer->GetFramebufferPixelFormat() :
+ overlay.buffer->GetOpaqueFramebufferPixelFormat();
+ if (!plane->IsSupportedFormat(format))
return false;
// TODO(kalyank): We should check for z-order and any needed transformation
diff --git a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h
index f49d7cbd611..134c40ee9d9 100644
--- a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h
+++ b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h
@@ -137,9 +137,9 @@ class HardwareDisplayPlaneManager {
// Returns true if |plane| can support |overlay| and compatible with
// |crtc_index|.
- bool IsCompatible(HardwareDisplayPlane* plane,
- const OverlayPlane& overlay,
- uint32_t crtc_index) const;
+ virtual bool IsCompatible(HardwareDisplayPlane* plane,
+ const OverlayPlane& overlay,
+ uint32_t crtc_index) const;
void ResetCurrentPlaneList(HardwareDisplayPlaneList* plane_list) const;
diff --git a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.cc b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.cc
index febc9945b23..a2b7170f630 100644
--- a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.cc
@@ -142,7 +142,7 @@ bool HardwareDisplayPlaneManagerAtomic::SetPlaneData(
CrtcController* crtc) {
HardwareDisplayPlaneAtomic* atomic_plane =
static_cast<HardwareDisplayPlaneAtomic*>(hw_plane);
- uint32_t framebuffer_id = overlay.z_order
+ uint32_t framebuffer_id = overlay.enable_blend
? overlay.buffer->GetFramebufferId()
: overlay.buffer->GetOpaqueFramebufferId();
if (!atomic_plane->SetPlaneData(plane_list->atomic_property_set.get(),
diff --git a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.h b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.h
index 7dd8b19f94b..46619c52f9a 100644
--- a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.h
+++ b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.h
@@ -27,8 +27,6 @@ class HardwareDisplayPlaneManagerAtomic : public HardwareDisplayPlaneManager {
void RequestPlanesReadyCallback(const OverlayPlaneList& planes,
base::OnceClosure callback) override;
-
- private:
bool SetPlaneData(HardwareDisplayPlaneList* plane_list,
HardwareDisplayPlane* hw_plane,
const OverlayPlane& overlay,
@@ -36,6 +34,7 @@ class HardwareDisplayPlaneManagerAtomic : public HardwareDisplayPlaneManager {
const gfx::Rect& src_rect,
CrtcController* crtc) override;
+ private:
std::unique_ptr<HardwareDisplayPlane> CreatePlane(
uint32_t plane_id,
uint32_t possible_crtcs) override;
diff --git a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.cc b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.cc
index 8aaf4e280d2..a87020d2c4d 100644
--- a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.cc
@@ -167,10 +167,23 @@ bool HardwareDisplayPlaneManagerLegacy::SetPlaneData(
} else {
plane_list->legacy_page_flips.back().planes.push_back(
HardwareDisplayPlaneList::PageFlipInfo::Plane(
- hw_plane->plane_id(), overlay.buffer->GetFramebufferId(),
+ hw_plane->plane_id(), overlay.buffer->GetOpaqueFramebufferId(),
overlay.display_bounds, src_rect));
}
return true;
}
+bool HardwareDisplayPlaneManagerLegacy::IsCompatible(
+ HardwareDisplayPlane* plane,
+ const OverlayPlane& overlay,
+ uint32_t crtc_index) const {
+ if (!plane->CanUseForCrtc(crtc_index))
+ return false;
+
+ // When using legacy kms we always scanout only one plane (the primary),
+ // and we always use the opaque fb. Refer to SetPlaneData above.
+ const uint32_t format = overlay.buffer->GetOpaqueFramebufferPixelFormat();
+ return plane->IsSupportedFormat(format);
+}
+
} // namespace ui
diff --git a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.h b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.h
index 3f492ca1d37..db1d78a4b07 100644
--- a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.h
+++ b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.h
@@ -35,6 +35,9 @@ class HardwareDisplayPlaneManagerLegacy : public HardwareDisplayPlaneManager {
uint32_t crtc_id,
const gfx::Rect& src_rect,
CrtcController* crtc) override;
+ bool IsCompatible(HardwareDisplayPlane* plane,
+ const OverlayPlane& overlay,
+ uint32_t crtc_index) const override;
private:
DISALLOW_COPY_AND_ASSIGN(HardwareDisplayPlaneManagerLegacy);
diff --git a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_unittest.cc b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_unittest.cc
index 3c5f7146d96..46f2d563fde 100644
--- a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_unittest.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_unittest.cc
@@ -15,6 +15,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/ozone/platform/drm/gpu/crtc_controller.h"
#include "ui/ozone/platform/drm/gpu/fake_plane_info.h"
+#include "ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.h"
#include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.h"
#include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.h"
#include "ui/ozone/platform/drm/gpu/mock_drm_device.h"
@@ -362,4 +363,44 @@ TEST_F(HardwareDisplayPlaneManagerPlanesReadyTest,
EXPECT_TRUE(callback_called);
}
+class HardwareDisplayPlaneAtomicMock : public ui::HardwareDisplayPlaneAtomic {
+ public:
+ HardwareDisplayPlaneAtomicMock() : ui::HardwareDisplayPlaneAtomic(0, ~0) {}
+ ~HardwareDisplayPlaneAtomicMock() override {}
+
+ bool SetPlaneData(drmModeAtomicReq* property_set,
+ uint32_t crtc_id,
+ uint32_t framebuffer,
+ const gfx::Rect& crtc_rect,
+ const gfx::Rect& src_rect,
+ const gfx::OverlayTransform transform,
+ int in_fence_fd) override {
+ framebuffer_ = framebuffer;
+ return true;
+ }
+ uint32_t framebuffer() const { return framebuffer_; }
+
+ private:
+ uint32_t framebuffer_ = 0;
+};
+
+TEST(HardwareDisplayPlaneManagerAtomic, EnableBlend) {
+ auto plane_manager =
+ std::make_unique<ui::HardwareDisplayPlaneManagerAtomic>();
+ ui::HardwareDisplayPlaneList plane_list;
+ HardwareDisplayPlaneAtomicMock hw_plane;
+ scoped_refptr<ui::ScanoutBuffer> buffer =
+ new ui::MockScanoutBuffer(kDefaultBufferSize);
+ ui::OverlayPlane overlay(buffer, base::kInvalidPlatformFile);
+ overlay.enable_blend = true;
+ plane_manager->SetPlaneData(&plane_list, &hw_plane, overlay, 1, gfx::Rect(),
+ nullptr);
+ EXPECT_EQ(hw_plane.framebuffer(), buffer->GetFramebufferId());
+
+ overlay.enable_blend = false;
+ plane_manager->SetPlaneData(&plane_list, &hw_plane, overlay, 1, gfx::Rect(),
+ nullptr);
+ EXPECT_EQ(hw_plane.framebuffer(), buffer->GetOpaqueFramebufferId());
+}
+
} // namespace
diff --git a/chromium/ui/ozone/platform/drm/gpu/mock_scanout_buffer.cc b/chromium/ui/ozone/platform/drm/gpu/mock_scanout_buffer.cc
index fd15615ecd6..1230e86011f 100644
--- a/chromium/ui/ozone/platform/drm/gpu/mock_scanout_buffer.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/mock_scanout_buffer.cc
@@ -21,6 +21,7 @@ MockScanoutBuffer::MockScanoutBuffer(const gfx::Size& size,
format_(format),
modifier_(modifier),
id_(g_current_framebuffer_id++),
+ opaque_id_(g_current_framebuffer_id++),
drm_(drm) {}
MockScanoutBuffer::~MockScanoutBuffer() {}
@@ -30,7 +31,7 @@ uint32_t MockScanoutBuffer::GetFramebufferId() const {
}
uint32_t MockScanoutBuffer::GetOpaqueFramebufferId() const {
- return 2;
+ return opaque_id_;
}
uint32_t MockScanoutBuffer::GetHandle() const {
diff --git a/chromium/ui/ozone/platform/drm/gpu/mock_scanout_buffer.h b/chromium/ui/ozone/platform/drm/gpu/mock_scanout_buffer.h
index 33f5977d776..cbeb256d5b4 100644
--- a/chromium/ui/ozone/platform/drm/gpu/mock_scanout_buffer.h
+++ b/chromium/ui/ozone/platform/drm/gpu/mock_scanout_buffer.h
@@ -38,6 +38,7 @@ class MockScanoutBuffer : public ScanoutBuffer {
uint32_t format_;
uint64_t modifier_;
uint32_t id_;
+ uint32_t opaque_id_;
scoped_refptr<DrmDevice> drm_;
DISALLOW_COPY_AND_ASSIGN(MockScanoutBuffer);
diff --git a/chromium/ui/ozone/platform/drm/gpu/overlay_plane.cc b/chromium/ui/ozone/platform/drm/gpu/overlay_plane.cc
index 8135647550e..8cf1be09bf9 100644
--- a/chromium/ui/ozone/platform/drm/gpu/overlay_plane.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/overlay_plane.cc
@@ -16,6 +16,7 @@ OverlayPlane::OverlayPlane(const scoped_refptr<ScanoutBuffer>& buffer,
plane_transform(gfx::OVERLAY_TRANSFORM_NONE),
display_bounds(gfx::Point(), buffer->GetSize()),
crop_rect(0, 0, 1, 1),
+ enable_blend(false),
fence_fd(fence_fd) {}
OverlayPlane::OverlayPlane(const scoped_refptr<ScanoutBuffer>& buffer,
@@ -23,12 +24,14 @@ OverlayPlane::OverlayPlane(const scoped_refptr<ScanoutBuffer>& buffer,
gfx::OverlayTransform plane_transform,
const gfx::Rect& display_bounds,
const gfx::RectF& crop_rect,
+ bool enable_blend,
int fence_fd)
: buffer(buffer),
z_order(z_order),
plane_transform(plane_transform),
display_bounds(display_bounds),
crop_rect(crop_rect),
+ enable_blend(enable_blend),
fence_fd(fence_fd) {}
OverlayPlane::OverlayPlane(const OverlayPlane& other) = default;
diff --git a/chromium/ui/ozone/platform/drm/gpu/overlay_plane.h b/chromium/ui/ozone/platform/drm/gpu/overlay_plane.h
index 4bfb9b4738c..31fa65d49e6 100644
--- a/chromium/ui/ozone/platform/drm/gpu/overlay_plane.h
+++ b/chromium/ui/ozone/platform/drm/gpu/overlay_plane.h
@@ -30,6 +30,7 @@ struct OverlayPlane {
gfx::OverlayTransform plane_transform,
const gfx::Rect& display_bounds,
const gfx::RectF& crop_rect,
+ bool enable_blend,
int fence_fd);
OverlayPlane(const OverlayPlane& other);
@@ -45,6 +46,7 @@ struct OverlayPlane {
gfx::OverlayTransform plane_transform;
gfx::Rect display_bounds;
gfx::RectF crop_rect;
+ bool enable_blend;
int fence_fd;
};
diff --git a/chromium/ui/ozone/platform/drm/gpu/proxy_helpers.cc b/chromium/ui/ozone/platform/drm/gpu/proxy_helpers.cc
index 60bc23f75ea..863e96531c4 100644
--- a/chromium/ui/ozone/platform/drm/gpu/proxy_helpers.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/proxy_helpers.cc
@@ -24,7 +24,7 @@ void PostSyncTask(
base::WaitableEvent wait(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
bool success = task_runner->PostTask(
- FROM_HERE, base::Bind(OnRunPostedTaskAndSignal, callback, &wait));
+ FROM_HERE, base::BindOnce(OnRunPostedTaskAndSignal, callback, &wait));
if (success)
wait.Wait();
}
diff --git a/chromium/ui/ozone/platform/drm/gpu/proxy_helpers.h b/chromium/ui/ozone/platform/drm/gpu/proxy_helpers.h
index 086709c9a01..a1393ef3dfa 100644
--- a/chromium/ui/ozone/platform/drm/gpu/proxy_helpers.h
+++ b/chromium/ui/ozone/platform/drm/gpu/proxy_helpers.h
@@ -19,7 +19,7 @@ void PostAsyncTask(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
const base::Callback<void(Args...)>& callback,
Args... args) {
- task_runner->PostTask(FROM_HERE, base::Bind(callback, args...));
+ task_runner->PostTask(FROM_HERE, base::BindOnce(callback, args...));
}
template <typename... Args>
diff --git a/chromium/ui/ozone/platform/drm/gpu/proxy_helpers_unittest.cc b/chromium/ui/ozone/platform/drm/gpu/proxy_helpers_unittest.cc
index 46e5223c7d6..5dbc2853518 100644
--- a/chromium/ui/ozone/platform/drm/gpu/proxy_helpers_unittest.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/proxy_helpers_unittest.cc
@@ -29,8 +29,8 @@ class ProxyHelpersTest : public testing::Test {
EXPECT_TRUE(drm_checker_.CalledOnValidThread());
message_loop_.task_runner()->PostTask(
- FROM_HERE, base::Bind(&ProxyHelpersTest::QuitFunctionCallback,
- base::Unretained(this), 8));
+ FROM_HERE, base::BindOnce(&ProxyHelpersTest::QuitFunctionCallback,
+ base::Unretained(this), 8));
}
// QuitFunctionCallback runs on the main thread.
@@ -106,7 +106,7 @@ TEST_F(ProxyHelpersTest, PostTask) {
// Binds the thread checker on the drm thread.
drm_thread_->task_runner()->PostTask(
FROM_HERE,
- base::Bind(&ProxyHelpersTest::SetDrmChecker, base::Unretained(this)));
+ base::BindOnce(&ProxyHelpersTest::SetDrmChecker, base::Unretained(this)));
// Test passing a type by value.
auto value_callback = base::BindOnce(&ProxyHelpersTest::ValueTypeCallback,
@@ -147,8 +147,8 @@ TEST_F(ProxyHelpersTest, PostTask) {
// Shutdown the RunLoop.
drm_thread_->task_runner()->PostTask(
- FROM_HERE,
- base::Bind(&ProxyHelpersTest::QuitFunction, base::Unretained(this), 42));
+ FROM_HERE, base::BindOnce(&ProxyHelpersTest::QuitFunction,
+ base::Unretained(this), 42));
run_loop_.Run();
diff --git a/chromium/ui/ozone/platform/drm/gpu/screen_manager.cc b/chromium/ui/ozone/platform/drm/gpu/screen_manager.cc
index 87b2abc6f37..e8e477733e4 100644
--- a/chromium/ui/ozone/platform/drm/gpu/screen_manager.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/screen_manager.cc
@@ -9,7 +9,6 @@
#include <utility>
#include "base/files/platform_file.h"
-#include "base/memory/ptr_util.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "ui/display/types/display_snapshot.h"
#include "ui/gfx/geometry/point.h"
@@ -32,9 +31,9 @@ namespace {
void FillModesetBuffer(const scoped_refptr<DrmDevice>& drm,
HardwareDisplayController* controller,
ScanoutBuffer* buffer) {
- DrmConsoleBuffer modeset_buffer(drm, buffer->GetFramebufferId());
+ DrmConsoleBuffer modeset_buffer(drm, buffer->GetOpaqueFramebufferId());
if (!modeset_buffer.Initialize()) {
- VLOG(2) << "Failed to grab framebuffer " << buffer->GetFramebufferId();
+ VLOG(2) << "Failed to grab framebuffer " << buffer->GetOpaqueFramebufferId();
return;
}
@@ -378,7 +377,8 @@ OverlayPlane ScreenManager::GetModesetBuffer(
if (!buffer) {
LOG(ERROR) << "Failed to create scanout buffer";
return OverlayPlane(nullptr, 0, gfx::OVERLAY_TRANSFORM_INVALID, gfx::Rect(),
- gfx::RectF(), base::kInvalidPlatformFile);
+ gfx::RectF(), /* enable_blend */ true,
+ base::kInvalidPlatformFile);
}
FillModesetBuffer(drm, controller, buffer.get());
diff --git a/chromium/ui/ozone/platform/drm/gpu/screen_manager_unittest.cc b/chromium/ui/ozone/platform/drm/gpu/screen_manager_unittest.cc
index 2fe14daad7d..a50a0ac275a 100644
--- a/chromium/ui/ozone/platform/drm/gpu/screen_manager_unittest.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/screen_manager_unittest.cc
@@ -511,7 +511,7 @@ TEST_F(ScreenManagerTest, EnableControllerWhenWindowHasBuffer) {
drm_, kPrimaryCrtc, kPrimaryConnector, GetPrimaryBounds().origin(),
kDefaultMode);
- EXPECT_EQ(buffer->GetFramebufferId(), drm_->current_framebuffer());
+ EXPECT_EQ(buffer->GetOpaqueFramebufferId(), drm_->current_framebuffer());
window = screen_manager_->RemoveWindow(1);
window->Shutdown();
diff --git a/chromium/ui/ozone/platform/drm/host/drm_cursor.cc b/chromium/ui/ozone/platform/drm/host/drm_cursor.cc
index 0042294556f..8ffc06b4c05 100644
--- a/chromium/ui/ozone/platform/drm/host/drm_cursor.cc
+++ b/chromium/ui/ozone/platform/drm/host/drm_cursor.cc
@@ -226,6 +226,9 @@ void DrmCursor::SetCursorLocationLocked(const gfx::PointF& location) {
gfx::PointF(confined_bounds_.right() - 1, confined_bounds_.bottom() - 1));
location_ = clamped_location;
+#if defined(OS_CHROMEOS)
+ ui::CursorController::GetInstance()->SetCursorLocation(location_);
+#endif
}
void DrmCursor::SendCursorShowLocked() {
diff --git a/chromium/ui/ozone/platform/drm/host/drm_display_host.cc b/chromium/ui/ozone/platform/drm/host/drm_display_host.cc
index 9868a4e3719..d486445a005 100644
--- a/chromium/ui/ozone/platform/drm/host/drm_display_host.cc
+++ b/chromium/ui/ozone/platform/drm/host/drm_display_host.cc
@@ -6,7 +6,6 @@
#include "base/bind.h"
#include "base/location.h"
-#include "base/memory/ptr_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "ui/display/types/display_mode.h"
#include "ui/display/types/display_snapshot.h"
@@ -56,7 +55,7 @@ void DrmDisplayHost::Configure(const display::DisplayMode* mode,
void DrmDisplayHost::OnDisplayConfigured(bool status) {
if (!configure_callback_.is_null()) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(configure_callback_, status));
+ FROM_HERE, base::BindOnce(configure_callback_, status));
} else {
LOG(ERROR) << "Got unexpected event for display "
<< snapshot_->display_id();
@@ -76,7 +75,7 @@ void DrmDisplayHost::OnHDCPStateReceived(bool status,
display::HDCPState state) {
if (!get_hdcp_callback_.is_null()) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(get_hdcp_callback_, status, state));
+ FROM_HERE, base::BindOnce(get_hdcp_callback_, status, state));
} else {
LOG(ERROR) << "Got unexpected event for display "
<< snapshot_->display_id();
@@ -96,7 +95,7 @@ void DrmDisplayHost::SetHDCPState(
void DrmDisplayHost::OnHDCPStateUpdated(bool status) {
if (!set_hdcp_callback_.is_null()) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(set_hdcp_callback_, status));
+ FROM_HERE, base::BindOnce(set_hdcp_callback_, status));
} else {
LOG(ERROR) << "Got unexpected event for display "
<< snapshot_->display_id();
diff --git a/chromium/ui/ozone/platform/drm/host/drm_display_host_manager.cc b/chromium/ui/ozone/platform/drm/host/drm_display_host_manager.cc
index c3f28c7b473..31967c98427 100644
--- a/chromium/ui/ozone/platform/drm/host/drm_display_host_manager.cc
+++ b/chromium/ui/ozone/platform/drm/host/drm_display_host_manager.cc
@@ -12,7 +12,6 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
-#include "base/memory/ptr_util.h"
#include "base/strings/stringprintf.h"
#include "base/task_scheduler/post_task.h"
#include "base/threading/thread_restrictions.h"
@@ -60,9 +59,9 @@ void OpenDeviceAsync(const base::FilePath& device_path,
std::unique_ptr<DrmDeviceHandle> handle(new DrmDeviceHandle());
handle->Initialize(device_path, sys_path);
- reply_runner->PostTask(FROM_HERE,
- base::Bind(callback, device_path, sys_path,
- base::Passed(std::move(handle))));
+ reply_runner->PostTask(
+ FROM_HERE,
+ base::BindOnce(callback, device_path, sys_path, std::move(handle)));
}
base::FilePath GetPrimaryDisplayCardPath() {
@@ -253,18 +252,19 @@ void DrmDisplayHostManager::ProcessEvent() {
FROM_HERE,
{base::MayBlock(),
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
- base::Bind(&OpenDeviceAsync, event.path,
- base::ThreadTaskRunnerHandle::Get(),
- base::Bind(&DrmDisplayHostManager::OnAddGraphicsDevice,
- weak_ptr_factory_.GetWeakPtr())));
+ base::BindOnce(
+ &OpenDeviceAsync, event.path,
+ base::ThreadTaskRunnerHandle::Get(),
+ base::Bind(&DrmDisplayHostManager::OnAddGraphicsDevice,
+ weak_ptr_factory_.GetWeakPtr())));
task_pending_ = true;
}
break;
case DeviceEvent::CHANGE:
task_pending_ = base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
- base::Bind(&DrmDisplayHostManager::OnUpdateGraphicsDevice,
- weak_ptr_factory_.GetWeakPtr()));
+ base::BindOnce(&DrmDisplayHostManager::OnUpdateGraphicsDevice,
+ weak_ptr_factory_.GetWeakPtr()));
break;
case DeviceEvent::REMOVE:
DCHECK(event.path != primary_graphics_card_path_)
@@ -273,8 +273,8 @@ void DrmDisplayHostManager::ProcessEvent() {
if (it != drm_devices_.end()) {
task_pending_ = base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
- base::Bind(&DrmDisplayHostManager::OnRemoveGraphicsDevice,
- weak_ptr_factory_.GetWeakPtr(), it->second));
+ base::BindOnce(&DrmDisplayHostManager::OnRemoveGraphicsDevice,
+ weak_ptr_factory_.GetWeakPtr(), it->second));
drm_devices_.erase(it);
}
break;
@@ -321,7 +321,7 @@ void DrmDisplayHostManager::OnGpuProcessLaunched() {
MapDevPathToSysPath(primary_graphics_card_path_);
if (!handle) {
- handle.reset(new DrmDeviceHandle());
+ handle = std::make_unique<DrmDeviceHandle>();
if (!handle->Initialize(primary_graphics_card_path_,
drm_devices_[primary_graphics_card_path_]))
LOG(FATAL) << "Failed to open primary graphics card";
@@ -330,8 +330,10 @@ void DrmDisplayHostManager::OnGpuProcessLaunched() {
// Send the primary device first since this is used to initialize graphics
// state.
- proxy_->GpuAddGraphicsDevice(drm_devices_[primary_graphics_card_path_],
- handle->PassFD());
+ if (!proxy_->GpuAddGraphicsDevice(drm_devices_[primary_graphics_card_path_],
+ handle->PassFD())) {
+ LOG(ERROR) << "Failed to add primary graphics device.";
+ }
}
void DrmDisplayHostManager::OnGpuThreadReady() {
@@ -343,8 +345,8 @@ void DrmDisplayHostManager::OnGpuThreadReady() {
if (!get_displays_callback_.is_null()) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
- base::Bind(&DrmDisplayHostManager::RunUpdateDisplaysCallback,
- weak_ptr_factory_.GetWeakPtr(), get_displays_callback_));
+ base::BindOnce(&DrmDisplayHostManager::RunUpdateDisplaysCallback,
+ weak_ptr_factory_.GetWeakPtr(), get_displays_callback_));
get_displays_callback_.Reset();
}
@@ -384,8 +386,8 @@ void DrmDisplayHostManager::GpuHasUpdatedNativeDisplays(
if (!get_displays_callback_.is_null()) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
- base::Bind(&DrmDisplayHostManager::RunUpdateDisplaysCallback,
- weak_ptr_factory_.GetWeakPtr(), get_displays_callback_));
+ base::BindOnce(&DrmDisplayHostManager::RunUpdateDisplaysCallback,
+ weak_ptr_factory_.GetWeakPtr(), get_displays_callback_));
get_displays_callback_.Reset();
}
}
@@ -435,7 +437,7 @@ void DrmDisplayHostManager::GpuTookDisplayControl(bool status) {
}
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(take_display_control_callback_, status));
+ FROM_HERE, base::BindOnce(take_display_control_callback_, status));
take_display_control_callback_.Reset();
display_control_change_pending_ = false;
}
@@ -455,7 +457,7 @@ void DrmDisplayHostManager::GpuRelinquishedDisplayControl(bool status) {
}
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(relinquish_display_control_callback_, status));
+ FROM_HERE, base::BindOnce(relinquish_display_control_callback_, status));
relinquish_display_control_callback_.Reset();
display_control_change_pending_ = false;
}
diff --git a/chromium/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.cc b/chromium/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.cc
index 6c7f4f4b510..09632b10933 100644
--- a/chromium/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.cc
+++ b/chromium/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.cc
@@ -74,8 +74,8 @@ void CursorIPC::Move(gfx::AcceleratedWidget window, const gfx::Point& point) {
void CursorIPC::InitializeOnEvdevIfNecessary() {}
void CursorIPC::Send(IPC::Message* message) {
- if (IsConnected() &&
- send_runner_->PostTask(FROM_HERE, base::Bind(send_callback_, message)))
+ if (IsConnected() && send_runner_->PostTask(
+ FROM_HERE, base::BindOnce(send_callback_, message)))
return;
// Drop disconnected updates. DrmWindowHost will call
@@ -115,7 +115,8 @@ void DrmGpuPlatformSupportHost::RemoveGpuThreadObserver(
}
bool DrmGpuPlatformSupportHost::IsConnected() {
- return host_id_ >= 0 && channel_established_;
+ base::AutoLock auto_lock(host_id_lock_);
+ return host_id_ >= 0;
}
void DrmGpuPlatformSupportHost::OnGpuServiceLaunched(
@@ -139,27 +140,23 @@ void DrmGpuPlatformSupportHost::OnGpuProcessLaunched(
DCHECK(!ui_runner_->BelongsToCurrentThread());
TRACE_EVENT1("drm", "DrmGpuPlatformSupportHost::OnGpuProcessLaunched",
"host_id", host_id);
- host_id_ = host_id;
- send_runner_ = std::move(send_runner);
- send_callback_ = send_callback;
-
- for (GpuThreadObserver& observer : gpu_thread_observers_)
- observer.OnGpuProcessLaunched();
ui_runner_->PostTask(
FROM_HERE,
base::BindOnce(&DrmGpuPlatformSupportHost::OnChannelEstablished,
- weak_ptr_));
+ weak_ptr_, host_id, std::move(send_runner),
+ std::move(send_callback)));
}
void DrmGpuPlatformSupportHost::OnChannelDestroyed(int host_id) {
TRACE_EVENT1("drm", "DrmGpuPlatformSupportHost::OnChannelDestroyed",
"host_id", host_id);
-
if (host_id_ == host_id) {
+ {
+ base::AutoLock auto_lock(host_id_lock_);
+ host_id_ = -1;
+ }
cursor_->ResetDrmCursorProxy();
- host_id_ = -1;
- channel_established_ = false;
send_runner_ = nullptr;
send_callback_.Reset();
for (GpuThreadObserver& observer : gpu_thread_observers_)
@@ -182,8 +179,8 @@ void DrmGpuPlatformSupportHost::OnMessageReceived(const IPC::Message& message) {
}
bool DrmGpuPlatformSupportHost::Send(IPC::Message* message) {
- if (IsConnected() &&
- send_runner_->PostTask(FROM_HERE, base::Bind(send_callback_, message)))
+ if (IsConnected() && send_runner_->PostTask(
+ FROM_HERE, base::BindOnce(send_callback_, message)))
return true;
delete message;
@@ -200,9 +197,22 @@ void DrmGpuPlatformSupportHost::UnRegisterHandlerForDrmDisplayHostManager() {
display_manager_ = nullptr;
}
-void DrmGpuPlatformSupportHost::OnChannelEstablished() {
+void DrmGpuPlatformSupportHost::OnChannelEstablished(
+ int host_id,
+ scoped_refptr<base::SingleThreadTaskRunner> send_runner,
+ const base::Callback<void(IPC::Message*)>& send_callback) {
+ DCHECK(ui_runner_->BelongsToCurrentThread());
TRACE_EVENT0("drm", "DrmGpuPlatformSupportHost::OnChannelEstablished");
- channel_established_ = true;
+
+ send_runner_ = std::move(send_runner);
+ send_callback_ = send_callback;
+ {
+ base::AutoLock auto_lock(host_id_lock_);
+ host_id_ = host_id;
+ }
+
+ for (GpuThreadObserver& observer : gpu_thread_observers_)
+ observer.OnGpuProcessLaunched();
for (GpuThreadObserver& observer : gpu_thread_observers_)
observer.OnGpuThreadReady();
@@ -278,22 +288,8 @@ bool DrmGpuPlatformSupportHost::GpuRelinquishDisplayControl() {
bool DrmGpuPlatformSupportHost::GpuAddGraphicsDevice(const base::FilePath& path,
base::ScopedFD fd) {
- IPC::Message* message = new OzoneGpuMsg_AddGraphicsDevice(
- path, base::FileDescriptor(std::move(fd)));
-
- // This function may be called from two places:
- // - DrmDisplayHostManager::OnGpuProcessLaunched() invoked synchronously
- // by GpuProcessHost::Init() on IO thread, which is the same thread as
- // |send_runner_|. In this case we can synchronously send the IPC;
- // - DrmDisplayHostManager::OnAddGraphicsDevice() on UI thread. In this
- // case we need to post the send task to IO thread.
- if (send_runner_ && send_runner_->BelongsToCurrentThread()) {
- DCHECK(!send_callback_.is_null());
- send_callback_.Run(message);
- return true;
- }
-
- return Send(message);
+ return Send(new OzoneGpuMsg_AddGraphicsDevice(
+ path, base::FileDescriptor(std::move(fd))));
}
bool DrmGpuPlatformSupportHost::GpuRemoveGraphicsDevice(
diff --git a/chromium/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h b/chromium/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h
index ebcb9d5ea0d..4f0f918fdff 100644
--- a/chromium/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h
+++ b/chromium/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h
@@ -10,6 +10,7 @@
#include "base/callback.h"
#include "base/observer_list.h"
#include "base/single_thread_task_runner.h"
+#include "base/synchronization/lock.h"
#include "ui/display/types/display_constants.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
@@ -99,7 +100,10 @@ class DrmGpuPlatformSupportHost : public GpuPlatformSupportHost,
const gfx::Rect& bounds) override;
private:
- void OnChannelEstablished();
+ void OnChannelEstablished(
+ int host_id,
+ scoped_refptr<base::SingleThreadTaskRunner> send_runner,
+ const base::Callback<void(IPC::Message*)>& send_callback);
bool OnMessageReceivedForDrmDisplayHostManager(const IPC::Message& message);
void OnUpdateNativeDisplays(
const std::vector<DisplaySnapshot_Params>& displays);
@@ -117,7 +121,7 @@ class DrmGpuPlatformSupportHost : public GpuPlatformSupportHost,
const std::vector<OverlayCheckReturn_Params>& returns);
int host_id_ = -1;
- bool channel_established_ = false;
+ base::Lock host_id_lock_;
scoped_refptr<base::SingleThreadTaskRunner> ui_runner_;
scoped_refptr<base::SingleThreadTaskRunner> send_runner_;
diff --git a/chromium/ui/ozone/platform/drm/host/drm_overlay_manager.cc b/chromium/ui/ozone/platform/drm/host/drm_overlay_manager.cc
index dc0f75a1f9e..4e8aae39f35 100644
--- a/chromium/ui/ozone/platform/drm/host/drm_overlay_manager.cc
+++ b/chromium/ui/ozone/platform/drm/host/drm_overlay_manager.cc
@@ -9,7 +9,6 @@
#include <algorithm>
#include "base/command_line.h"
-#include "base/memory/ptr_util.h"
#include "base/trace_event/trace_event.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/ozone/platform/drm/common/drm_util.h"
@@ -61,11 +60,6 @@ void DrmOverlayManager::CheckOverlaySupport(
continue;
}
- // Compositor doesn't have information about the total size of primary
- // candidate. We get this information from display rect.
- if (candidate.plane_z_order == 0)
- candidate.buffer_size = gfx::ToNearestRect(candidate.display_rect).size();
-
result_candidates.push_back(OverlaySurfaceCandidate(candidate));
// Start out hoping that we can have an overlay.
result_candidates.back().overlay_handled = true;
diff --git a/chromium/ui/ozone/platform/drm/host/drm_window_host.cc b/chromium/ui/ozone/platform/drm/host/drm_window_host.cc
index 3df6467ad0c..c3470c283c2 100644
--- a/chromium/ui/ozone/platform/drm/host/drm_window_host.cc
+++ b/chromium/ui/ozone/platform/drm/host/drm_window_host.cc
@@ -97,6 +97,10 @@ void DrmWindowHost::ReleaseCapture() {
window_manager_->UngrabEvents(widget_);
}
+bool DrmWindowHost::HasCapture() const {
+ return widget_ == window_manager_->event_grabber();
+}
+
void DrmWindowHost::ToggleFullscreen() {
}
@@ -129,9 +133,8 @@ PlatformImeController* DrmWindowHost::GetPlatformImeController() {
return nullptr;
}
-bool DrmWindowHost::CanDispatchEvent(const PlatformEvent& ne) {
- DCHECK(ne);
- Event* event = static_cast<Event*>(ne);
+bool DrmWindowHost::CanDispatchEvent(const PlatformEvent& event) {
+ DCHECK(event);
// If there is a grab, capture events here.
gfx::AcceleratedWidget grabber = window_manager_->event_grabber();
@@ -170,10 +173,9 @@ bool DrmWindowHost::CanDispatchEvent(const PlatformEvent& ne) {
return true;
}
-uint32_t DrmWindowHost::DispatchEvent(const PlatformEvent& native_event) {
- DCHECK(native_event);
+uint32_t DrmWindowHost::DispatchEvent(const PlatformEvent& event) {
+ DCHECK(event);
- Event* event = static_cast<Event*>(native_event);
if (event->IsLocatedEvent()) {
// Make the event location relative to this window's origin.
LocatedEvent* located_event = event->AsLocatedEvent();
@@ -183,8 +185,8 @@ uint32_t DrmWindowHost::DispatchEvent(const PlatformEvent& native_event) {
located_event->set_root_location_f(location);
}
DispatchEventFromNativeUiEvent(
- native_event, base::BindOnce(&PlatformWindowDelegate::DispatchEvent,
- base::Unretained(delegate_)));
+ event, base::BindOnce(&PlatformWindowDelegate::DispatchEvent,
+ base::Unretained(delegate_)));
return POST_DISPATCH_STOP_PROPAGATION;
}
diff --git a/chromium/ui/ozone/platform/drm/host/drm_window_host.h b/chromium/ui/ozone/platform/drm/host/drm_window_host.h
index 01f0ccefce2..1b17b20c8c5 100644
--- a/chromium/ui/ozone/platform/drm/host/drm_window_host.h
+++ b/chromium/ui/ozone/platform/drm/host/drm_window_host.h
@@ -67,6 +67,7 @@ class DrmWindowHost : public PlatformWindow,
void SetTitle(const base::string16& title) override;
void SetCapture() override;
void ReleaseCapture() override;
+ bool HasCapture() const override;
void ToggleFullscreen() override;
void Maximize() override;
void Minimize() override;
diff --git a/chromium/ui/ozone/platform/drm/host/gpu_thread_observer.h b/chromium/ui/ozone/platform/drm/host/gpu_thread_observer.h
index ed6da90beac..24b5b19831e 100644
--- a/chromium/ui/ozone/platform/drm/host/gpu_thread_observer.h
+++ b/chromium/ui/ozone/platform/drm/host/gpu_thread_observer.h
@@ -7,20 +7,19 @@
namespace ui {
-// Observes the channel state.
+// Observes the channel state. All calls should happen on the same thread that
+// OzonePlatform::InitializeForUI() is called on. This can be the browser UI
+// thread or the WS thread for mus/mash.
class GpuThreadObserver {
public:
virtual ~GpuThreadObserver() {}
// Called when the GPU process is launched.
- // This is called from browser IO thread.
virtual void OnGpuProcessLaunched() = 0;
// Called when a GPU thread implementation has become available.
- // This is called from browser UI thread.
virtual void OnGpuThreadReady() = 0;
// Called when the GPU thread implementation has ceased to be
// available.
- // This is called from browser UI thread.
virtual void OnGpuThreadRetired() = 0;
};
diff --git a/chromium/ui/ozone/platform/drm/ozone_platform_gbm.cc b/chromium/ui/ozone/platform/drm/ozone_platform_gbm.cc
index 963f77e8804..a6e1286c2a7 100644
--- a/chromium/ui/ozone/platform/drm/ozone_platform_gbm.cc
+++ b/chromium/ui/ozone/platform/drm/ozone_platform_gbm.cc
@@ -14,7 +14,6 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/macros.h"
-#include "base/memory/ptr_util.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread_task_runner_handle.h"
diff --git a/chromium/ui/ozone/platform/headless/BUILD.gn b/chromium/ui/ozone/platform/headless/BUILD.gn
index 6de57300b13..0637f8e6f01 100644
--- a/chromium/ui/ozone/platform/headless/BUILD.gn
+++ b/chromium/ui/ozone/platform/headless/BUILD.gn
@@ -20,6 +20,8 @@ source_set("headless") {
"ozone_platform_headless.h",
]
+ defines = [ "OZONE_IMPLEMENTATION" ]
+
deps = [
"//base",
"//skia",
diff --git a/chromium/ui/ozone/platform/headless/gl_surface_osmesa_png.cc b/chromium/ui/ozone/platform/headless/gl_surface_osmesa_png.cc
index 8700136a9f7..2bbb7a86b7e 100644
--- a/chromium/ui/ozone/platform/headless/gl_surface_osmesa_png.cc
+++ b/chromium/ui/ozone/platform/headless/gl_surface_osmesa_png.cc
@@ -67,7 +67,7 @@ void GLSurfaceOSMesaPng::WriteBufferToPng() {
base::PostTaskWithTraits(
FROM_HERE,
{base::MayBlock(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
- base::Bind(&WritePngToFile, output_path_, base::Passed(&png_data)));
+ base::BindOnce(&WritePngToFile, output_path_, std::move(png_data)));
}
}
diff --git a/chromium/ui/ozone/platform/headless/headless_surface_factory.cc b/chromium/ui/ozone/platform/headless/headless_surface_factory.cc
index 6e64f51c583..7bfe64670d3 100644
--- a/chromium/ui/ozone/platform/headless/headless_surface_factory.cc
+++ b/chromium/ui/ozone/platform/headless/headless_surface_factory.cc
@@ -8,7 +8,6 @@
#include "base/files/file_util.h"
#include "base/location.h"
#include "base/macros.h"
-#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/task_scheduler/post_task.h"
#include "build/build_config.h"
@@ -28,6 +27,8 @@ namespace ui {
namespace {
+const base::FilePath::CharType kDevNull[] = FILE_PATH_LITERAL("/dev/null");
+
void WriteDataToFile(const base::FilePath& location, const SkBitmap& bitmap) {
DCHECK(!location.empty());
std::vector<unsigned char> png_data;
@@ -60,7 +61,7 @@ class FileSurface : public SurfaceOzoneCanvas {
base::PostTaskWithTraits(
FROM_HERE,
{base::MayBlock(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
- base::Bind(&WriteDataToFile, base_path_, bitmap));
+ base::BindOnce(&WriteDataToFile, base_path_, bitmap));
}
}
std::unique_ptr<gfx::VSyncProvider> CreateVSyncProvider() override {
@@ -90,7 +91,8 @@ class TestPixmap : public gfx::NativePixmap {
int plane_z_order,
gfx::OverlayTransform plane_transform,
const gfx::Rect& display_bounds,
- const gfx::RectF& crop_rect) override {
+ const gfx::RectF& crop_rect,
+ bool enable_blend) override {
return true;
}
gfx::NativePixmapHandle ExportHandle() override {
@@ -137,7 +139,7 @@ HeadlessSurfaceFactory::~HeadlessSurfaceFactory() = default;
base::FilePath HeadlessSurfaceFactory::GetPathForWidget(
gfx::AcceleratedWidget widget) {
- if (base_path_.empty() || base_path_ == base::FilePath("/dev/null"))
+ if (base_path_.empty() || base_path_ == base::FilePath(kDevNull))
return base_path_;
// Disambiguate multiple window output files with the window id.
@@ -177,7 +179,7 @@ void HeadlessSurfaceFactory::CheckBasePath() const {
return;
if (!DirectoryExists(base_path_) && !base::CreateDirectory(base_path_) &&
- base_path_ != base::FilePath("/dev/null"))
+ base_path_ != base::FilePath(kDevNull))
PLOG(FATAL) << "Unable to create output directory";
if (!base::PathIsWritable(base_path_))
diff --git a/chromium/ui/ozone/platform/headless/headless_window.cc b/chromium/ui/ozone/platform/headless/headless_window.cc
index 3608ffa4255..5bf6e7c9653 100644
--- a/chromium/ui/ozone/platform/headless/headless_window.cc
+++ b/chromium/ui/ozone/platform/headless/headless_window.cc
@@ -6,6 +6,7 @@
#include <string>
+#include "build/build_config.h"
#include "ui/events/platform/platform_event_source.h"
#include "ui/ozone/platform/headless/headless_window_manager.h"
#include "ui/platform_window/platform_window_delegate.h"
@@ -16,12 +17,20 @@ HeadlessWindow::HeadlessWindow(PlatformWindowDelegate* delegate,
HeadlessWindowManager* manager,
const gfx::Rect& bounds)
: delegate_(delegate), manager_(manager), bounds_(bounds) {
+#if defined(OS_WIN)
+ widget_ = reinterpret_cast<gfx::AcceleratedWidget>(manager_->AddWindow(this));
+#else
widget_ = manager_->AddWindow(this);
+#endif
delegate_->OnAcceleratedWidgetAvailable(widget_, 1.f);
}
HeadlessWindow::~HeadlessWindow() {
+#if defined(OS_WIN)
+ manager_->RemoveWindow(reinterpret_cast<uint64_t>(widget_), this);
+#else
manager_->RemoveWindow(widget_, this);
+#endif
}
gfx::Rect HeadlessWindow::GetBounds() {
@@ -47,6 +56,10 @@ void HeadlessWindow::SetCapture() {}
void HeadlessWindow::ReleaseCapture() {}
+bool HeadlessWindow::HasCapture() const {
+ return false;
+}
+
void HeadlessWindow::ToggleFullscreen() {}
void HeadlessWindow::Maximize() {}
diff --git a/chromium/ui/ozone/platform/headless/headless_window.h b/chromium/ui/ozone/platform/headless/headless_window.h
index 4e909cf6e4e..2051d143cb9 100644
--- a/chromium/ui/ozone/platform/headless/headless_window.h
+++ b/chromium/ui/ozone/platform/headless/headless_window.h
@@ -32,6 +32,7 @@ class HeadlessWindow : public PlatformWindow {
void PrepareForShutdown() override;
void SetCapture() override;
void ReleaseCapture() override;
+ bool HasCapture() const override;
void ToggleFullscreen() override;
void Maximize() override;
void Minimize() override;
diff --git a/chromium/ui/ozone/platform/headless/ozone_platform_headless.cc b/chromium/ui/ozone/platform/headless/ozone_platform_headless.cc
index 8c569f49131..e6935b79eaf 100644
--- a/chromium/ui/ozone/platform/headless/ozone_platform_headless.cc
+++ b/chromium/ui/ozone/platform/headless/ozone_platform_headless.cc
@@ -7,7 +7,6 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/macros.h"
-#include "base/memory/ptr_util.h"
#include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h"
#include "ui/display/manager/fake_display_delegate.h"
#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
@@ -31,7 +30,7 @@ namespace {
// A headless implementation of PlatformEventSource that we can instantiate to
// make
// sure that the PlatformEventSource has an instance while in unit tests.
-class HeadlessPlatformEventSource : public ui::PlatformEventSource {
+class HeadlessPlatformEventSource : public PlatformEventSource {
public:
HeadlessPlatformEventSource() = default;
~HeadlessPlatformEventSource() override = default;
diff --git a/chromium/ui/ozone/platform/wayland/fake_server.cc b/chromium/ui/ozone/platform/wayland/fake_server.cc
index 7adfe81029e..84c6594cb95 100644
--- a/chromium/ui/ozone/platform/wayland/fake_server.cc
+++ b/chromium/ui/ozone/platform/wayland/fake_server.cc
@@ -23,6 +23,11 @@ const uint32_t kOutputVersion = 2;
const uint32_t kSeatVersion = 4;
const uint32_t kXdgShellVersion = 1;
+template <class T>
+T* GetUserDataAs(wl_resource* resource) {
+ return static_cast<T*>(wl_resource_get_user_data(resource));
+}
+
void DestroyResource(wl_client* client, wl_resource* resource) {
wl_resource_destroy(resource);
}
@@ -30,8 +35,7 @@ void DestroyResource(wl_client* client, wl_resource* resource) {
// wl_compositor
void CreateSurface(wl_client* client, wl_resource* resource, uint32_t id) {
- auto* compositor =
- static_cast<MockCompositor*>(wl_resource_get_user_data(resource));
+ auto* compositor = GetUserDataAs<MockCompositor>(resource);
wl_resource* surface_resource = wl_resource_create(
client, &wl_surface_interface, wl_resource_get_version(resource), id);
if (!surface_resource) {
@@ -53,8 +57,7 @@ void Attach(wl_client* client,
wl_resource* buffer_resource,
int32_t x,
int32_t y) {
- static_cast<MockSurface*>(wl_resource_get_user_data(resource))
- ->Attach(buffer_resource, x, y);
+ GetUserDataAs<MockSurface>(resource)->Attach(buffer_resource, x, y);
}
void Damage(wl_client* client,
@@ -63,12 +66,11 @@ void Damage(wl_client* client,
int32_t y,
int32_t width,
int32_t height) {
- static_cast<MockSurface*>(wl_resource_get_user_data(resource))
- ->Damage(x, y, width, height);
+ GetUserDataAs<MockSurface>(resource)->Damage(x, y, width, height);
}
void Commit(wl_client* client, wl_resource* resource) {
- static_cast<MockSurface*>(wl_resource_get_user_data(resource))->Commit();
+ GetUserDataAs<MockSurface>(resource)->Commit();
}
const struct wl_surface_interface surface_impl = {
@@ -89,14 +91,13 @@ const struct wl_surface_interface surface_impl = {
void UseUnstableVersion(wl_client* client,
wl_resource* resource,
int32_t version) {
- static_cast<MockXdgShell*>(wl_resource_get_user_data(resource))
- ->UseUnstableVersion(version);
+ GetUserDataAs<MockXdgShell>(resource)->UseUnstableVersion(version);
}
// xdg_shell and zxdg_shell_v6
void Pong(wl_client* client, wl_resource* resource, uint32_t serial) {
- static_cast<MockXdgShell*>(wl_resource_get_user_data(resource))->Pong(serial);
+ GetUserDataAs<MockXdgShell>(resource)->Pong(serial);
}
// xdg_shell
@@ -131,36 +132,36 @@ const struct zxdg_shell_v6_interface zxdg_shell_v6_impl = {
// wl_seat
void GetPointer(wl_client* client, wl_resource* resource, uint32_t id) {
- auto* seat = static_cast<MockSeat*>(wl_resource_get_user_data(resource));
wl_resource* pointer_resource = wl_resource_create(
client, &wl_pointer_interface, wl_resource_get_version(resource), id);
if (!pointer_resource) {
wl_client_post_no_memory(client);
return;
}
- seat->pointer.reset(new MockPointer(pointer_resource));
+ auto* seat = GetUserDataAs<MockSeat>(resource);
+ seat->set_pointer(std::make_unique<MockPointer>(pointer_resource));
}
void GetKeyboard(wl_client* client, wl_resource* resource, uint32_t id) {
- auto* seat = static_cast<MockSeat*>(wl_resource_get_user_data(resource));
wl_resource* keyboard_resource = wl_resource_create(
client, &wl_keyboard_interface, wl_resource_get_version(resource), id);
if (!keyboard_resource) {
wl_client_post_no_memory(client);
return;
}
- seat->keyboard.reset(new MockKeyboard(keyboard_resource));
+ auto* seat = GetUserDataAs<MockSeat>(resource);
+ seat->set_keyboard(std::make_unique<MockKeyboard>(keyboard_resource));
}
void GetTouch(wl_client* client, wl_resource* resource, uint32_t id) {
- auto* seat = static_cast<MockSeat*>(wl_resource_get_user_data(resource));
wl_resource* touch_resource = wl_resource_create(
client, &wl_touch_interface, wl_resource_get_version(resource), id);
if (!touch_resource) {
wl_client_post_no_memory(client);
return;
}
- seat->touch.reset(new MockTouch(touch_resource));
+ auto* seat = GetUserDataAs<MockSeat>(resource);
+ seat->set_touch(std::make_unique<MockTouch>(touch_resource));
}
const struct wl_seat_interface seat_impl = {
@@ -192,18 +193,15 @@ const struct wl_touch_interface touch_impl = {
// xdg_surface, zxdg_surface_v6 and zxdg_toplevel shared methods.
void SetTitle(wl_client* client, wl_resource* resource, const char* title) {
- static_cast<MockXdgSurface*>(wl_resource_get_user_data(resource))
- ->SetTitle(title);
+ GetUserDataAs<MockXdgSurface>(resource)->SetTitle(title);
}
void SetAppId(wl_client* client, wl_resource* resource, const char* app_id) {
- static_cast<MockXdgSurface*>(wl_resource_get_user_data(resource))
- ->SetAppId(app_id);
+ GetUserDataAs<MockXdgSurface>(resource)->SetAppId(app_id);
}
void AckConfigure(wl_client* client, wl_resource* resource, uint32_t serial) {
- static_cast<MockXdgSurface*>(wl_resource_get_user_data(resource))
- ->AckConfigure(serial);
+ GetUserDataAs<MockXdgSurface>(resource)->AckConfigure(serial);
}
void SetWindowGeometry(wl_client* client,
@@ -212,35 +210,30 @@ void SetWindowGeometry(wl_client* client,
int32_t y,
int32_t width,
int32_t height) {
- static_cast<MockXdgSurface*>(wl_resource_get_user_data(resource))
- ->SetWindowGeometry(x, y, width, height);
+ GetUserDataAs<MockXdgSurface>(resource)->SetWindowGeometry(x, y, width,
+ height);
}
void SetMaximized(wl_client* client, wl_resource* resource) {
- static_cast<MockXdgSurface*>(wl_resource_get_user_data(resource))
- ->SetMaximized();
+ GetUserDataAs<MockXdgSurface>(resource)->SetMaximized();
}
void UnsetMaximized(wl_client* client, wl_resource* resource) {
- static_cast<MockXdgSurface*>(wl_resource_get_user_data(resource))
- ->UnsetMaximized();
+ GetUserDataAs<MockXdgSurface>(resource)->UnsetMaximized();
}
void SetFullscreen(wl_client* client,
wl_resource* resource,
wl_resource* output) {
- static_cast<MockXdgSurface*>(wl_resource_get_user_data(resource))
- ->SetFullscreen();
+ GetUserDataAs<MockXdgSurface>(resource)->SetFullscreen();
}
void UnsetFullscreen(wl_client* client, wl_resource* resource) {
- static_cast<MockXdgSurface*>(wl_resource_get_user_data(resource))
- ->UnsetFullscreen();
+ GetUserDataAs<MockXdgSurface>(resource)->UnsetFullscreen();
}
void SetMinimized(wl_client* client, wl_resource* resource) {
- static_cast<MockXdgSurface*>(wl_resource_get_user_data(resource))
- ->SetMinimized();
+ GetUserDataAs<MockXdgSurface>(resource)->SetMinimized();
}
const struct xdg_surface_interface xdg_surface_impl = {
@@ -263,9 +256,8 @@ const struct xdg_surface_interface xdg_surface_impl = {
// zxdg_surface specific interface
void GetTopLevel(wl_client* client, wl_resource* resource, uint32_t id) {
- auto* surface =
- static_cast<MockXdgSurface*>(wl_resource_get_user_data(resource));
- if (surface->xdg_toplevel) {
+ auto* surface = GetUserDataAs<MockXdgSurface>(resource);
+ if (surface->xdg_toplevel()) {
wl_resource_post_error(resource, ZXDG_SURFACE_V6_ERROR_ALREADY_CONSTRUCTED,
"surface has already been constructed");
return;
@@ -276,7 +268,8 @@ void GetTopLevel(wl_client* client, wl_resource* resource, uint32_t id) {
wl_client_post_no_memory(client);
return;
}
- surface->xdg_toplevel.reset(new MockXdgTopLevel(xdg_toplevel_resource));
+ surface->set_xdg_toplevel(
+ std::make_unique<MockXdgTopLevel>(xdg_toplevel_resource));
}
const struct zxdg_surface_v6_interface zxdg_surface_v6_impl = {
@@ -310,9 +303,8 @@ void GetXdgSurfaceImpl(wl_client* client,
wl_resource* surface_resource,
const struct wl_interface* interface,
const void* implementation) {
- auto* surface =
- static_cast<MockSurface*>(wl_resource_get_user_data(surface_resource));
- if (surface->xdg_surface) {
+ auto* surface = GetUserDataAs<MockSurface>(surface_resource);
+ if (surface->xdg_surface()) {
uint32_t xdg_error = implementation == &xdg_surface_impl
? XDG_SHELL_ERROR_ROLE
: ZXDG_SHELL_V6_ERROR_ROLE;
@@ -326,8 +318,8 @@ void GetXdgSurfaceImpl(wl_client* client,
wl_client_post_no_memory(client);
return;
}
- surface->xdg_surface.reset(
- new MockXdgSurface(xdg_surface_resource, implementation));
+ surface->set_xdg_surface(
+ std::make_unique<MockXdgSurface>(xdg_surface_resource, implementation));
}
// xdg_shell
@@ -361,60 +353,62 @@ ServerObject::~ServerObject() {
// static
void ServerObject::OnResourceDestroyed(wl_resource* resource) {
- auto* obj = static_cast<ServerObject*>(wl_resource_get_user_data(resource));
+ auto* obj = GetUserDataAs<ServerObject>(resource);
obj->resource_ = nullptr;
}
+template <class T>
+void SetImplementation(wl_resource* resource,
+ const void* implementation,
+ T* user_data) {
+ wl_resource_set_implementation(resource, implementation, user_data,
+ &ServerObject::OnResourceDestroyed);
+}
+
MockXdgSurface::MockXdgSurface(wl_resource* resource,
const void* implementation)
: ServerObject(resource) {
- wl_resource_set_implementation(resource, implementation, this,
- &ServerObject::OnResourceDestroyed);
+ SetImplementation(resource, implementation, this);
}
MockXdgSurface::~MockXdgSurface() {}
MockXdgTopLevel::MockXdgTopLevel(wl_resource* resource)
: MockXdgSurface(resource, &zxdg_surface_v6_impl) {
- wl_resource_set_implementation(resource, &zxdg_toplevel_v6_impl, this,
- &ServerObject::OnResourceDestroyed);
+ SetImplementation(resource, &zxdg_toplevel_v6_impl, this);
}
MockXdgTopLevel::~MockXdgTopLevel() {}
MockSurface::MockSurface(wl_resource* resource) : ServerObject(resource) {
- wl_resource_set_implementation(resource, &surface_impl, this,
- &ServerObject::OnResourceDestroyed);
+ SetImplementation(resource, &surface_impl, this);
}
MockSurface::~MockSurface() {
- if (xdg_surface && xdg_surface->resource())
- wl_resource_destroy(xdg_surface->resource());
+ if (xdg_surface_ && xdg_surface_->resource())
+ wl_resource_destroy(xdg_surface_->resource());
}
MockSurface* MockSurface::FromResource(wl_resource* resource) {
if (!wl_resource_instance_of(resource, &wl_surface_interface, &surface_impl))
return nullptr;
- return static_cast<MockSurface*>(wl_resource_get_user_data(resource));
+ return GetUserDataAs<MockSurface>(resource);
}
MockPointer::MockPointer(wl_resource* resource) : ServerObject(resource) {
- wl_resource_set_implementation(resource, &pointer_impl, this,
- &ServerObject::OnResourceDestroyed);
+ SetImplementation(resource, &pointer_impl, this);
}
MockPointer::~MockPointer() {}
MockKeyboard::MockKeyboard(wl_resource* resource) : ServerObject(resource) {
- wl_resource_set_implementation(resource, &keyboard_impl, this,
- &ServerObject::OnResourceDestroyed);
+ SetImplementation(resource, &keyboard_impl, this);
}
MockKeyboard::~MockKeyboard() {}
MockTouch::MockTouch(wl_resource* resource) : ServerObject(resource) {
- wl_resource_set_implementation(resource, &touch_impl, this,
- &ServerObject::OnResourceDestroyed);
+ SetImplementation(resource, &touch_impl, this);
}
MockTouch::~MockTouch() {}
@@ -451,14 +445,13 @@ void Global::Bind(wl_client* client,
}
if (!global->resource_)
global->resource_ = resource;
- wl_resource_set_implementation(resource, global->implementation_, global,
- &Global::OnResourceDestroyed);
+ SetImplementation(resource, global->implementation_, global);
global->OnBind();
}
// static
void Global::OnResourceDestroyed(wl_resource* resource) {
- auto* global = static_cast<Global*>(wl_resource_get_user_data(resource));
+ auto* global = GetUserDataAs<Global>(resource);
if (global->resource_ == resource)
global->resource_ = nullptr;
}
@@ -552,8 +545,8 @@ bool FakeServer::Start(uint32_t shell_version) {
(void)server_fd.release();
base::Thread::Options options;
- options.message_pump_factory =
- base::Bind(&FakeServer::CreateMessagePump, base::Unretained(this));
+ options.message_pump_factory = base::BindRepeating(
+ &FakeServer::CreateMessagePump, base::Unretained(this));
if (!base::Thread::StartWithOptions(options))
return false;
@@ -564,7 +557,7 @@ bool FakeServer::Start(uint32_t shell_version) {
void FakeServer::Pause() {
task_runner()->PostTask(
- FROM_HERE, base::Bind(&FakeServer::DoPause, base::Unretained(this)));
+ FROM_HERE, base::BindOnce(&FakeServer::DoPause, base::Unretained(this)));
pause_event_.Wait();
}
diff --git a/chromium/ui/ozone/platform/wayland/fake_server.h b/chromium/ui/ozone/platform/wayland/fake_server.h
index 816f5815e6f..24e3863053d 100644
--- a/chromium/ui/ozone/platform/wayland/fake_server.h
+++ b/chromium/ui/ozone/platform/wayland/fake_server.h
@@ -25,7 +25,7 @@ namespace wl {
// Base class for managing the life cycle of server objects.
class ServerObject {
public:
- ServerObject(wl_resource* resource);
+ explicit ServerObject(wl_resource* resource);
virtual ~ServerObject();
wl_resource* resource() { return resource_; }
@@ -54,24 +54,29 @@ class MockXdgSurface : public ServerObject {
MOCK_METHOD1(SetAppId, void(const char* app_id));
MOCK_METHOD1(AckConfigure, void(uint32_t serial));
MOCK_METHOD4(SetWindowGeometry,
- void(int32_t x, int32_t y, int32_t widht, int32_t height));
+ void(int32_t x, int32_t y, int32_t width, int32_t height));
MOCK_METHOD0(SetMaximized, void());
MOCK_METHOD0(UnsetMaximized, void());
MOCK_METHOD0(SetFullscreen, void());
MOCK_METHOD0(UnsetFullscreen, void());
MOCK_METHOD0(SetMinimized, void());
- // Used when xdg v6 is used.
- std::unique_ptr<MockXdgTopLevel> xdg_toplevel;
+ void set_xdg_toplevel(std::unique_ptr<MockXdgTopLevel> xdg_toplevel) {
+ xdg_toplevel_ = std::move(xdg_toplevel);
+ }
+ MockXdgTopLevel* xdg_toplevel() { return xdg_toplevel_.get(); }
private:
+ // Used when xdg v6 is used.
+ std::unique_ptr<MockXdgTopLevel> xdg_toplevel_;
+
DISALLOW_COPY_AND_ASSIGN(MockXdgSurface);
};
// Manage zxdg_toplevel for providing desktop UI.
class MockXdgTopLevel : public MockXdgSurface {
public:
- MockXdgTopLevel(wl_resource* resource);
+ explicit MockXdgTopLevel(wl_resource* resource);
~MockXdgTopLevel() override;
// TODO(msisov): mock other zxdg_toplevel specific methods once implementation
@@ -85,7 +90,7 @@ class MockXdgTopLevel : public MockXdgSurface {
// Manage client surface
class MockSurface : public ServerObject {
public:
- MockSurface(wl_resource* resource);
+ explicit MockSurface(wl_resource* resource);
~MockSurface() override;
static MockSurface* FromResource(wl_resource* resource);
@@ -95,15 +100,20 @@ class MockSurface : public ServerObject {
void(int32_t x, int32_t y, int32_t width, int32_t height));
MOCK_METHOD0(Commit, void());
- std::unique_ptr<MockXdgSurface> xdg_surface;
+ void set_xdg_surface(std::unique_ptr<MockXdgSurface> xdg_surface) {
+ xdg_surface_ = std::move(xdg_surface);
+ }
+ MockXdgSurface* xdg_surface() { return xdg_surface_.get(); }
private:
+ std::unique_ptr<MockXdgSurface> xdg_surface_;
+
DISALLOW_COPY_AND_ASSIGN(MockSurface);
};
class MockPointer : public ServerObject {
public:
- MockPointer(wl_resource* resource);
+ explicit MockPointer(wl_resource* resource);
~MockPointer() override;
private:
@@ -112,7 +122,7 @@ class MockPointer : public ServerObject {
class MockKeyboard : public ServerObject {
public:
- MockKeyboard(wl_resource* resource);
+ explicit MockKeyboard(wl_resource* resource);
~MockKeyboard() override;
private:
@@ -207,11 +217,26 @@ class MockSeat : public Global {
MockSeat();
~MockSeat() override;
- std::unique_ptr<MockPointer> pointer;
- std::unique_ptr<MockKeyboard> keyboard;
- std::unique_ptr<MockTouch> touch;
+ void set_pointer(std::unique_ptr<MockPointer> pointer) {
+ pointer_ = std::move(pointer);
+ }
+ MockPointer* pointer() { return pointer_.get(); }
+
+ void set_keyboard(std::unique_ptr<MockKeyboard> keyboard) {
+ keyboard_ = std::move(keyboard);
+ }
+ MockKeyboard* keyboard() { return keyboard_.get(); }
+
+ void set_touch(std::unique_ptr<MockTouch> touch) {
+ touch_ = std::move(touch);
+ }
+ MockTouch* touch() { return touch_.get(); }
private:
+ std::unique_ptr<MockPointer> pointer_;
+ std::unique_ptr<MockKeyboard> keyboard_;
+ std::unique_ptr<MockTouch> touch_;
+
DISALLOW_COPY_AND_ASSIGN(MockSeat);
};
@@ -244,7 +269,7 @@ struct DisplayDeleter {
void operator()(wl_display* display);
};
-class FakeServer : public base::Thread, base::MessagePumpLibevent::Watcher {
+class FakeServer : public base::Thread, base::MessagePumpLibevent::FdWatcher {
public:
FakeServer();
~FakeServer() override;
@@ -278,7 +303,7 @@ class FakeServer : public base::Thread, base::MessagePumpLibevent::Watcher {
std::unique_ptr<base::MessagePump> CreateMessagePump();
- // base::MessagePumpLibevent::Watcher
+ // base::MessagePumpLibevent::FdWatcher
void OnFileCanReadWithoutBlocking(int fd) override;
void OnFileCanWriteWithoutBlocking(int fd) override;
@@ -296,7 +321,7 @@ class FakeServer : public base::Thread, base::MessagePumpLibevent::Watcher {
MockXdgShell xdg_shell_;
MockXdgShellV6 zxdg_shell_v6_;
- base::MessagePumpLibevent::FileDescriptorWatcher controller_;
+ base::MessagePumpLibevent::FdWatchController controller_;
DISALLOW_COPY_AND_ASSIGN(FakeServer);
};
diff --git a/chromium/ui/ozone/platform/wayland/ozone_platform_wayland.cc b/chromium/ui/ozone/platform/wayland/ozone_platform_wayland.cc
index 843d7c99fdf..f0774bf1211 100644
--- a/chromium/ui/ozone/platform/wayland/ozone_platform_wayland.cc
+++ b/chromium/ui/ozone/platform/wayland/ozone_platform_wayland.cc
@@ -4,7 +4,6 @@
#include "ui/ozone/platform/wayland/ozone_platform_wayland.h"
-#include "base/memory/ptr_util.h"
#include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h"
#include "ui/base/ui_features.h"
#include "ui/display/manager/fake_display_delegate.h"
diff --git a/chromium/ui/ozone/platform/wayland/wayland_connection.cc b/chromium/ui/ozone/platform/wayland/wayland_connection.cc
index 89cf855b386..a90445be880 100644
--- a/chromium/ui/ozone/platform/wayland/wayland_connection.cc
+++ b/chromium/ui/ozone/platform/wayland/wayland_connection.cc
@@ -92,7 +92,8 @@ void WaylandConnection::ScheduleFlush() {
return;
DCHECK(base::MessageLoopForUI::IsCurrent());
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(&WaylandConnection::Flush, base::Unretained(this)));
+ FROM_HERE,
+ base::BindOnce(&WaylandConnection::Flush, base::Unretained(this)));
scheduled_flush_ = true;
}
@@ -253,8 +254,8 @@ void WaylandConnection::Capabilities(void* data,
return;
}
connection->pointer_ = std::make_unique<WaylandPointer>(
- pointer, base::Bind(&WaylandConnection::DispatchUiEvent,
- base::Unretained(connection)));
+ pointer, base::BindRepeating(&WaylandConnection::DispatchUiEvent,
+ base::Unretained(connection)));
connection->pointer_->set_connection(connection);
}
} else if (connection->pointer_) {
@@ -268,8 +269,8 @@ void WaylandConnection::Capabilities(void* data,
return;
}
connection->keyboard_ = std::make_unique<WaylandKeyboard>(
- keyboard, base::Bind(&WaylandConnection::DispatchUiEvent,
- base::Unretained(connection)));
+ keyboard, base::BindRepeating(&WaylandConnection::DispatchUiEvent,
+ base::Unretained(connection)));
connection->keyboard_->set_connection(connection);
}
} else if (connection->keyboard_) {
@@ -283,8 +284,8 @@ void WaylandConnection::Capabilities(void* data,
return;
}
connection->touch_ = std::make_unique<WaylandTouch>(
- touch, base::Bind(&WaylandConnection::DispatchUiEvent,
- base::Unretained(connection)));
+ touch, base::BindRepeating(&WaylandConnection::DispatchUiEvent,
+ base::Unretained(connection)));
connection->touch_->set_connection(connection);
}
} else if (connection->touch_) {
diff --git a/chromium/ui/ozone/platform/wayland/wayland_connection.h b/chromium/ui/ozone/platform/wayland/wayland_connection.h
index e745efd5b6b..747a11a465a 100644
--- a/chromium/ui/ozone/platform/wayland/wayland_connection.h
+++ b/chromium/ui/ozone/platform/wayland/wayland_connection.h
@@ -21,7 +21,7 @@ namespace ui {
class WaylandWindow;
class WaylandConnection : public PlatformEventSource,
- public base::MessagePumpLibevent::Watcher {
+ public base::MessagePumpLibevent::FdWatcher {
public:
WaylandConnection();
~WaylandConnection() override;
@@ -53,6 +53,9 @@ class WaylandConnection : public PlatformEventSource,
int GetKeyboardModifiers();
+ // Returns the current pointer, which may be null.
+ WaylandPointer* pointer() { return pointer_.get(); }
+
private:
void Flush();
void DispatchUiEvent(Event* event);
@@ -60,7 +63,7 @@ class WaylandConnection : public PlatformEventSource,
// PlatformEventSource
void OnDispatcherListChanged() override;
- // base::MessagePumpLibevent::Watcher
+ // base::MessagePumpLibevent::FdWatcher
void OnFileCanReadWithoutBlocking(int fd) override;
void OnFileCanWriteWithoutBlocking(int fd) override;
@@ -98,7 +101,7 @@ class WaylandConnection : public PlatformEventSource,
bool scheduled_flush_ = false;
bool watching_ = false;
- base::MessagePumpLibevent::FileDescriptorWatcher controller_;
+ base::MessagePumpLibevent::FdWatchController controller_;
uint32_t serial_ = 0;
diff --git a/chromium/ui/ozone/platform/wayland/wayland_keyboard_unittest.cc b/chromium/ui/ozone/platform/wayland/wayland_keyboard_unittest.cc
index 7ce077a7e97..492152b68b2 100644
--- a/chromium/ui/ozone/platform/wayland/wayland_keyboard_unittest.cc
+++ b/chromium/ui/ozone/platform/wayland/wayland_keyboard_unittest.cc
@@ -31,13 +31,13 @@ class WaylandKeyboardTest : public WaylandTest {
void SetUp() override {
WaylandTest::SetUp();
- wl_seat_send_capabilities(server.seat()->resource(),
+ wl_seat_send_capabilities(server_.seat()->resource(),
WL_SEAT_CAPABILITY_KEYBOARD);
Sync();
- keyboard = server.seat()->keyboard.get();
- ASSERT_TRUE(keyboard);
+ keyboard_ = server_.seat()->keyboard();
+ ASSERT_TRUE(keyboard_);
#if BUILDFLAG(USE_XKBCOMMON)
// Set up XKB bits and set the keymap to the client.
@@ -54,14 +54,14 @@ class WaylandKeyboardTest : public WaylandTest {
bool rv = shared_keymap.CreateAndMapAnonymous(keymap_size);
DCHECK(rv);
memcpy(shared_keymap.memory(), keymap_string.get(), keymap_size);
- wl_keyboard_send_keymap(keyboard->resource(),
+ wl_keyboard_send_keymap(keyboard_->resource(),
WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
shared_keymap.handle().GetHandle(), keymap_size);
#endif
}
protected:
- wl::MockKeyboard* keyboard;
+ wl::MockKeyboard* keyboard_;
private:
#if BUILDFLAG(USE_XKBCOMMON)
@@ -81,14 +81,15 @@ ACTION_P(CloneEvent, ptr) {
TEST_P(WaylandKeyboardTest, Keypress) {
struct wl_array empty;
wl_array_init(&empty);
- wl_keyboard_send_enter(keyboard->resource(), 1, surface->resource(), &empty);
+ wl_keyboard_send_enter(keyboard_->resource(), 1, surface_->resource(),
+ &empty);
wl_array_release(&empty);
- wl_keyboard_send_key(keyboard->resource(), 2, 0, 30 /* a */,
+ wl_keyboard_send_key(keyboard_->resource(), 2, 0, 30 /* a */,
WL_KEYBOARD_KEY_STATE_PRESSED);
std::unique_ptr<Event> event;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
Sync();
ASSERT_TRUE(event);
@@ -98,27 +99,28 @@ TEST_P(WaylandKeyboardTest, Keypress) {
EXPECT_EQ(ui::VKEY_A, key_event->key_code());
EXPECT_EQ(ET_KEY_PRESSED, key_event->type());
- wl_keyboard_send_leave(keyboard->resource(), 3, surface->resource());
+ wl_keyboard_send_leave(keyboard_->resource(), 3, surface_->resource());
Sync();
- wl_keyboard_send_key(keyboard->resource(), 3, 0, 30 /* a */,
+ wl_keyboard_send_key(keyboard_->resource(), 3, 0, 30 /* a */,
WL_KEYBOARD_KEY_STATE_PRESSED);
- EXPECT_CALL(delegate, DispatchEvent(_)).Times(0);
+ EXPECT_CALL(delegate_, DispatchEvent(_)).Times(0);
}
TEST_P(WaylandKeyboardTest, AltModifierKeypress) {
struct wl_array empty;
wl_array_init(&empty);
- wl_keyboard_send_enter(keyboard->resource(), 1, surface->resource(), &empty);
+ wl_keyboard_send_enter(keyboard_->resource(), 1, surface_->resource(),
+ &empty);
wl_array_release(&empty);
// Alt
- wl_keyboard_send_key(keyboard->resource(), 2, 0, 56 /* left Alt */,
+ wl_keyboard_send_key(keyboard_->resource(), 2, 0, 56 /* left Alt */,
WL_KEYBOARD_KEY_STATE_PRESSED);
std::unique_ptr<Event> event;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
Sync();
ASSERT_TRUE(event);
@@ -134,15 +136,16 @@ TEST_P(WaylandKeyboardTest, AltModifierKeypress) {
TEST_P(WaylandKeyboardTest, ControlModifierKeypress) {
struct wl_array empty;
wl_array_init(&empty);
- wl_keyboard_send_enter(keyboard->resource(), 1, surface->resource(), &empty);
+ wl_keyboard_send_enter(keyboard_->resource(), 1, surface_->resource(),
+ &empty);
wl_array_release(&empty);
// Control
- wl_keyboard_send_key(keyboard->resource(), 2, 0, 29 /* left Control */,
+ wl_keyboard_send_key(keyboard_->resource(), 2, 0, 29 /* left Control */,
WL_KEYBOARD_KEY_STATE_PRESSED);
std::unique_ptr<Event> event;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
Sync();
ASSERT_TRUE(event);
@@ -158,15 +161,16 @@ TEST_P(WaylandKeyboardTest, ControlModifierKeypress) {
TEST_P(WaylandKeyboardTest, ShiftModifierKeypress) {
struct wl_array empty;
wl_array_init(&empty);
- wl_keyboard_send_enter(keyboard->resource(), 1, surface->resource(), &empty);
+ wl_keyboard_send_enter(keyboard_->resource(), 1, surface_->resource(),
+ &empty);
wl_array_release(&empty);
// Shift
- wl_keyboard_send_key(keyboard->resource(), 2, 0, 42 /* left Shift */,
+ wl_keyboard_send_key(keyboard_->resource(), 2, 0, 42 /* left Shift */,
WL_KEYBOARD_KEY_STATE_PRESSED);
std::unique_ptr<Event> event;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
Sync();
ASSERT_TRUE(event);
@@ -183,41 +187,42 @@ TEST_P(WaylandKeyboardTest, ControlShiftModifiers) {
struct wl_array empty;
wl_array_init(&empty);
wl_array_init(&empty);
- wl_keyboard_send_enter(keyboard->resource(), 1, surface->resource(), &empty);
+ wl_keyboard_send_enter(keyboard_->resource(), 1, surface_->resource(),
+ &empty);
wl_array_release(&empty);
// Pressing control.
- wl_keyboard_send_key(keyboard->resource(), 2, 0, 29 /* Control */,
+ wl_keyboard_send_key(keyboard_->resource(), 2, 0, 29 /* Control */,
WL_KEYBOARD_KEY_STATE_PRESSED);
std::unique_ptr<Event> event;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
Sync();
- wl_keyboard_send_modifiers(keyboard->resource(), 3, 4 /* mods_depressed*/,
+ wl_keyboard_send_modifiers(keyboard_->resource(), 3, 4 /* mods_depressed*/,
0 /* mods_latched */, 0 /* mods_locked */,
0 /* group */);
Sync();
// Pressing shift (with control key still held down).
- wl_keyboard_send_key(keyboard->resource(), 4, 0, 42 /* Shift */,
+ wl_keyboard_send_key(keyboard_->resource(), 4, 0, 42 /* Shift */,
WL_KEYBOARD_KEY_STATE_PRESSED);
std::unique_ptr<Event> event2;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event2));
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event2));
Sync();
- wl_keyboard_send_modifiers(keyboard->resource(), 5, 5 /* mods_depressed*/,
+ wl_keyboard_send_modifiers(keyboard_->resource(), 5, 5 /* mods_depressed*/,
0 /* mods_latched */, 0 /* mods_locked */,
0 /* group */);
Sync();
// Sending a reguard keypress, eg 'a'.
- wl_keyboard_send_key(keyboard->resource(), 6, 0, 30 /* a */,
+ wl_keyboard_send_key(keyboard_->resource(), 6, 0, 30 /* a */,
WL_KEYBOARD_KEY_STATE_PRESSED);
std::unique_ptr<Event> event3;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event3));
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event3));
Sync();
ASSERT_TRUE(event3);
@@ -234,15 +239,16 @@ TEST_P(WaylandKeyboardTest, CapsLockKeypress) {
struct wl_array empty;
wl_array_init(&empty);
wl_array_init(&empty);
- wl_keyboard_send_enter(keyboard->resource(), 1, surface->resource(), &empty);
+ wl_keyboard_send_enter(keyboard_->resource(), 1, surface_->resource(),
+ &empty);
wl_array_release(&empty);
// Capslock
- wl_keyboard_send_key(keyboard->resource(), 2, 0, 58 /* Capslock */,
+ wl_keyboard_send_key(keyboard_->resource(), 2, 0, 58 /* Capslock */,
WL_KEYBOARD_KEY_STATE_PRESSED);
std::unique_ptr<Event> event;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
Sync();
ASSERT_TRUE(event);
@@ -256,11 +262,11 @@ TEST_P(WaylandKeyboardTest, CapsLockKeypress) {
Sync();
- wl_keyboard_send_key(keyboard->resource(), 2, 0, 58 /* Capslock */,
+ wl_keyboard_send_key(keyboard_->resource(), 2, 0, 58 /* Capslock */,
WL_KEYBOARD_KEY_STATE_RELEASED);
std::unique_ptr<Event> event2;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event2));
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event2));
Sync();
ASSERT_TRUE(event2);
@@ -278,41 +284,42 @@ TEST_P(WaylandKeyboardTest, CapsLockModifier) {
struct wl_array empty;
wl_array_init(&empty);
wl_array_init(&empty);
- wl_keyboard_send_enter(keyboard->resource(), 1, surface->resource(), &empty);
+ wl_keyboard_send_enter(keyboard_->resource(), 1, surface_->resource(),
+ &empty);
wl_array_release(&empty);
// Pressing capslock (led ON).
- wl_keyboard_send_key(keyboard->resource(), 2, 0, 58 /* Capslock */,
+ wl_keyboard_send_key(keyboard_->resource(), 2, 0, 58 /* Capslock */,
WL_KEYBOARD_KEY_STATE_PRESSED);
std::unique_ptr<Event> event;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
Sync();
- wl_keyboard_send_modifiers(keyboard->resource(), 3, 2 /* mods_depressed*/,
+ wl_keyboard_send_modifiers(keyboard_->resource(), 3, 2 /* mods_depressed*/,
0 /* mods_latched */, 2 /* mods_locked */,
0 /* group */);
Sync();
// Releasing capslock (led ON).
- wl_keyboard_send_key(keyboard->resource(), 4, 0, 58 /* Capslock */,
+ wl_keyboard_send_key(keyboard_->resource(), 4, 0, 58 /* Capslock */,
WL_KEYBOARD_KEY_STATE_RELEASED);
std::unique_ptr<Event> event2;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event2));
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event2));
Sync();
- wl_keyboard_send_modifiers(keyboard->resource(), 5, 0 /* mods_depressed*/,
+ wl_keyboard_send_modifiers(keyboard_->resource(), 5, 0 /* mods_depressed*/,
0 /* mods_latched */, 2 /* mods_locked */,
0 /* group */);
Sync();
// Sending a reguard keypress, eg 'a'.
- wl_keyboard_send_key(keyboard->resource(), 6, 0, 30 /* a */,
+ wl_keyboard_send_key(keyboard_->resource(), 6, 0, 30 /* a */,
WL_KEYBOARD_KEY_STATE_PRESSED);
std::unique_ptr<Event> event3;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event3));
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event3));
Sync();
ASSERT_TRUE(event3);
@@ -330,20 +337,21 @@ TEST_P(WaylandKeyboardTest, EventAutoRepeat) {
struct wl_array empty;
wl_array_init(&empty);
- wl_keyboard_send_enter(keyboard->resource(), 1, surface->resource(), &empty);
+ wl_keyboard_send_enter(keyboard_->resource(), 1, surface_->resource(),
+ &empty);
wl_array_release(&empty);
// Auto repeat info in ms.
uint32_t rate = 75;
uint32_t delay = 25;
- wl_keyboard_send_repeat_info(keyboard->resource(), rate, delay);
+ wl_keyboard_send_repeat_info(keyboard_->resource(), rate, delay);
- wl_keyboard_send_key(keyboard->resource(), 2, 0, 30 /* a */,
+ wl_keyboard_send_key(keyboard_->resource(), 2, 0, 30 /* a */,
WL_KEYBOARD_KEY_STATE_PRESSED);
std::unique_ptr<Event> event;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
Sync();
@@ -361,9 +369,9 @@ TEST_P(WaylandKeyboardTest, EventAutoRepeat) {
Sync();
std::unique_ptr<Event> event2;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillRepeatedly(CloneEvent(&event2));
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillRepeatedly(CloneEvent(&event2));
- wl_keyboard_send_key(keyboard->resource(), 3, 0, 30 /* a */,
+ wl_keyboard_send_key(keyboard_->resource(), 3, 0, 30 /* a */,
WL_KEYBOARD_KEY_STATE_RELEASED);
Sync();
}
@@ -372,20 +380,21 @@ TEST_P(WaylandKeyboardTest, NoEventAutoRepeatOnLeave) {
struct wl_array empty;
wl_array_init(&empty);
- wl_keyboard_send_enter(keyboard->resource(), 1, surface->resource(), &empty);
+ wl_keyboard_send_enter(keyboard_->resource(), 1, surface_->resource(),
+ &empty);
wl_array_release(&empty);
// Auto repeat info in ms.
uint32_t rate = 75;
uint32_t delay = 25;
- wl_keyboard_send_repeat_info(keyboard->resource(), rate, delay);
+ wl_keyboard_send_repeat_info(keyboard_->resource(), rate, delay);
- wl_keyboard_send_key(keyboard->resource(), 2, 0, 30 /* a */,
+ wl_keyboard_send_key(keyboard_->resource(), 2, 0, 30 /* a */,
WL_KEYBOARD_KEY_STATE_PRESSED);
std::unique_ptr<Event> event;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
Sync();
@@ -400,13 +409,13 @@ TEST_P(WaylandKeyboardTest, NoEventAutoRepeatOnLeave) {
base::TimeDelta::FromMilliseconds(rate * 2));
}
- wl_keyboard_send_leave(keyboard->resource(), 3, surface->resource());
+ wl_keyboard_send_leave(keyboard_->resource(), 3, surface_->resource());
Sync();
- EXPECT_CALL(delegate, DispatchEvent(_)).Times(0);
+ EXPECT_CALL(delegate_, DispatchEvent(_)).Times(0);
- wl_keyboard_send_key(keyboard->resource(), 4, 0, 30 /* a */,
+ wl_keyboard_send_key(keyboard_->resource(), 4, 0, 30 /* a */,
WL_KEYBOARD_KEY_STATE_RELEASED);
Sync();
}
@@ -415,20 +424,21 @@ TEST_P(WaylandKeyboardTest, NoEventAutoRepeatBeforeTimeout) {
struct wl_array empty;
wl_array_init(&empty);
- wl_keyboard_send_enter(keyboard->resource(), 1, surface->resource(), &empty);
+ wl_keyboard_send_enter(keyboard_->resource(), 1, surface_->resource(),
+ &empty);
wl_array_release(&empty);
// Auto repeat info in ms.
uint32_t rate = 500;
uint32_t delay = 50;
- wl_keyboard_send_repeat_info(keyboard->resource(), rate, delay);
+ wl_keyboard_send_repeat_info(keyboard_->resource(), rate, delay);
- wl_keyboard_send_key(keyboard->resource(), 2, 0, 30 /* a */,
+ wl_keyboard_send_key(keyboard_->resource(), 2, 0, 30 /* a */,
WL_KEYBOARD_KEY_STATE_PRESSED);
std::unique_ptr<Event> event;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
Sync();
@@ -444,11 +454,11 @@ TEST_P(WaylandKeyboardTest, NoEventAutoRepeatBeforeTimeout) {
base::TimeDelta::FromMilliseconds(rate / 5));
}
- wl_keyboard_send_key(keyboard->resource(), 4, 0, 30 /* a */,
+ wl_keyboard_send_key(keyboard_->resource(), 4, 0, 30 /* a */,
WL_KEYBOARD_KEY_STATE_RELEASED);
std::unique_ptr<Event> event2;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event2));
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event2));
Sync();
ASSERT_TRUE(event2);
diff --git a/chromium/ui/ozone/platform/wayland/wayland_pointer.cc b/chromium/ui/ozone/platform/wayland/wayland_pointer.cc
index 9d6f4ae78e3..8d74daf9b73 100644
--- a/chromium/ui/ozone/platform/wayland/wayland_pointer.cc
+++ b/chromium/ui/ozone/platform/wayland/wayland_pointer.cc
@@ -23,6 +23,12 @@ bool VerifyFlagsAfterMasking(int flags, int original_flags, int modifiers) {
return flags == original_flags;
}
+bool HasAnyButtonFlag(int flags) {
+ return (flags & (EF_LEFT_MOUSE_BUTTON | EF_MIDDLE_MOUSE_BUTTON |
+ EF_RIGHT_MOUSE_BUTTON | EF_BACK_MOUSE_BUTTON |
+ EF_FORWARD_MOUSE_BUTTON)) != 0;
+}
+
} // namespace
WaylandPointer::WaylandPointer(wl_pointer* pointer,
@@ -38,7 +44,12 @@ WaylandPointer::WaylandPointer(wl_pointer* pointer,
cursor_.reset(new WaylandCursor);
}
-WaylandPointer::~WaylandPointer() {}
+WaylandPointer::~WaylandPointer() {
+ if (window_with_pointer_focus_) {
+ window_with_pointer_focus_->set_pointer_focus(false);
+ window_with_pointer_focus_->set_has_implicit_grab(false);
+ }
+}
// static
void WaylandPointer::Enter(void* data,
@@ -50,8 +61,11 @@ void WaylandPointer::Enter(void* data,
WaylandPointer* pointer = static_cast<WaylandPointer*>(data);
pointer->location_.SetPoint(wl_fixed_to_double(surface_x),
wl_fixed_to_double(surface_y));
- if (surface)
- WaylandWindow::FromSurface(surface)->set_pointer_focus(true);
+ if (surface) {
+ WaylandWindow* window = WaylandWindow::FromSurface(surface);
+ window->set_pointer_focus(true);
+ pointer->window_with_pointer_focus_ = window;
+ }
}
// static
@@ -63,8 +77,11 @@ void WaylandPointer::Leave(void* data,
MouseEvent event(ET_MOUSE_EXITED, gfx::Point(), gfx::Point(),
EventTimeForNow(), pointer->flags_, 0);
pointer->callback_.Run(&event);
- if (surface)
- WaylandWindow::FromSurface(surface)->set_pointer_focus(false);
+ if (surface) {
+ WaylandWindow* window = WaylandWindow::FromSurface(surface);
+ window->set_pointer_focus(false);
+ pointer->window_with_pointer_focus_ = nullptr;
+ }
}
// static
@@ -92,22 +109,22 @@ void WaylandPointer::Button(void* data,
uint32_t button,
uint32_t state) {
WaylandPointer* pointer = static_cast<WaylandPointer*>(data);
- int flag;
+ int changed_button;
switch (button) {
case BTN_LEFT:
- flag = EF_LEFT_MOUSE_BUTTON;
+ changed_button = EF_LEFT_MOUSE_BUTTON;
break;
case BTN_MIDDLE:
- flag = EF_MIDDLE_MOUSE_BUTTON;
+ changed_button = EF_MIDDLE_MOUSE_BUTTON;
break;
case BTN_RIGHT:
- flag = EF_RIGHT_MOUSE_BUTTON;
+ changed_button = EF_RIGHT_MOUSE_BUTTON;
break;
case BTN_BACK:
- flag = EF_BACK_MOUSE_BUTTON;
+ changed_button = EF_BACK_MOUSE_BUTTON;
break;
case BTN_FORWARD:
- flag = EF_FORWARD_MOUSE_BUTTON;
+ changed_button = EF_FORWARD_MOUSE_BUTTON;
break;
default:
return;
@@ -116,17 +133,24 @@ void WaylandPointer::Button(void* data,
EventType type;
if (state == WL_POINTER_BUTTON_STATE_PRESSED) {
type = ET_MOUSE_PRESSED;
- pointer->flags_ |= flag;
+ pointer->flags_ |= changed_button;
pointer->connection_->set_serial(serial);
} else {
type = ET_MOUSE_RELEASED;
- pointer->flags_ &= ~flag;
+ pointer->flags_ &= ~changed_button;
+ }
+
+ if (pointer->window_with_pointer_focus_) {
+ pointer->window_with_pointer_focus_->set_has_implicit_grab(
+ HasAnyButtonFlag(pointer->flags_));
}
- int flags = pointer->GetFlagsWithKeyboardModifiers() | flag;
+ // MouseEvent's flags should contain the button that was released too.
+ const int flags = pointer->GetFlagsWithKeyboardModifiers() | changed_button;
MouseEvent event(type, gfx::Point(), gfx::Point(),
base::TimeTicks() + base::TimeDelta::FromMilliseconds(time),
- flags, flag);
+ flags, changed_button);
+
event.set_location_f(pointer->location_);
event.set_root_location_f(pointer->location_);
pointer->callback_.Run(&event);
diff --git a/chromium/ui/ozone/platform/wayland/wayland_pointer.h b/chromium/ui/ozone/platform/wayland/wayland_pointer.h
index 9550da69334..9515dfccdac 100644
--- a/chromium/ui/ozone/platform/wayland/wayland_pointer.h
+++ b/chromium/ui/ozone/platform/wayland/wayland_pointer.h
@@ -5,6 +5,7 @@
#ifndef UI_OZONE_PLATFORM_WAYLAND_WAYLAND_POINTER_H_
#define UI_OZONE_PLATFORM_WAYLAND_WAYLAND_POINTER_H_
+#include "base/macros.h"
#include "ui/events/ozone/evdev/event_dispatch_callback.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/ozone/platform/wayland/wayland_cursor.h"
@@ -12,6 +13,8 @@
namespace ui {
+class WaylandWindow;
+
class WaylandPointer {
public:
WaylandPointer(wl_pointer* pointer, const EventDispatchCallback& callback);
@@ -26,6 +29,10 @@ class WaylandPointer {
WaylandCursor* cursor() { return cursor_.get(); }
+ void reset_window_with_pointer_focus() {
+ window_with_pointer_focus_ = nullptr;
+ }
+
private:
// wl_pointer_listener
static void Enter(void* data,
@@ -60,11 +67,18 @@ class WaylandPointer {
wl::Object<wl_pointer> obj_;
EventDispatchCallback callback_;
gfx::PointF location_;
+ // Flags is a bitmask of EventFlags corresponding to the pointer/keyboard
+ // state.
int flags_ = 0;
// Keeps track of current modifiers. These are needed in order to properly
// update |flags_| with newest modifiers.
int keyboard_modifiers_ = 0;
+
+ // The window the mouse is over.
+ WaylandWindow* window_with_pointer_focus_ = nullptr;
+
+ DISALLOW_COPY_AND_ASSIGN(WaylandPointer);
};
} // namespace ui
diff --git a/chromium/ui/ozone/platform/wayland/wayland_pointer_unittest.cc b/chromium/ui/ozone/platform/wayland/wayland_pointer_unittest.cc
index ab2a8085d69..5c0e98a78d7 100644
--- a/chromium/ui/ozone/platform/wayland/wayland_pointer_unittest.cc
+++ b/chromium/ui/ozone/platform/wayland/wayland_pointer_unittest.cc
@@ -25,17 +25,17 @@ class WaylandPointerTest : public WaylandTest {
void SetUp() override {
WaylandTest::SetUp();
- wl_seat_send_capabilities(server.seat()->resource(),
+ wl_seat_send_capabilities(server_.seat()->resource(),
WL_SEAT_CAPABILITY_POINTER);
Sync();
- pointer = server.seat()->pointer.get();
- ASSERT_TRUE(pointer);
+ pointer_ = server_.seat()->pointer();
+ ASSERT_TRUE(pointer_);
}
protected:
- wl::MockPointer* pointer;
+ wl::MockPointer* pointer_;
private:
DISALLOW_COPY_AND_ASSIGN(WaylandPointerTest);
@@ -43,7 +43,7 @@ class WaylandPointerTest : public WaylandTest {
TEST_P(WaylandPointerTest, Leave) {
MockPlatformWindowDelegate other_delegate;
- WaylandWindow other_window(&other_delegate, connection.get(),
+ WaylandWindow other_window(&other_delegate, connection_.get(),
gfx::Rect(0, 0, 10, 10));
gfx::AcceleratedWidget other_widget = gfx::kNullAcceleratedWidget;
EXPECT_CALL(other_delegate, OnAcceleratedWidgetAvailable(_, _))
@@ -54,16 +54,16 @@ TEST_P(WaylandPointerTest, Leave) {
Sync();
wl::MockSurface* other_surface =
- server.GetObject<wl::MockSurface>(other_widget);
+ server_.GetObject<wl::MockSurface>(other_widget);
ASSERT_TRUE(other_surface);
- wl_pointer_send_enter(pointer->resource(), 1, surface->resource(), 0, 0);
- wl_pointer_send_leave(pointer->resource(), 2, surface->resource());
- wl_pointer_send_enter(pointer->resource(), 3, other_surface->resource(), 0,
+ wl_pointer_send_enter(pointer_->resource(), 1, surface_->resource(), 0, 0);
+ wl_pointer_send_leave(pointer_->resource(), 2, surface_->resource());
+ wl_pointer_send_enter(pointer_->resource(), 3, other_surface->resource(), 0,
0);
- wl_pointer_send_button(pointer->resource(), 4, 1004, BTN_LEFT,
+ wl_pointer_send_button(pointer_->resource(), 4, 1004, BTN_LEFT,
WL_POINTER_BUTTON_STATE_PRESSED);
- EXPECT_CALL(delegate, DispatchEvent(_)).Times(1);
+ EXPECT_CALL(delegate_, DispatchEvent(_)).Times(1);
// Do an extra Sync() here so that we process the second enter event before we
// destroy |other_window|.
@@ -75,12 +75,13 @@ ACTION_P(CloneEvent, ptr) {
}
TEST_P(WaylandPointerTest, Motion) {
- wl_pointer_send_enter(pointer->resource(), 1, surface->resource(), 0, 0);
- wl_pointer_send_motion(pointer->resource(), 1002, wl_fixed_from_double(10.75),
+ wl_pointer_send_enter(pointer_->resource(), 1, surface_->resource(), 0, 0);
+ wl_pointer_send_motion(pointer_->resource(), 1002,
+ wl_fixed_from_double(10.75),
wl_fixed_from_double(20.375));
std::unique_ptr<Event> event;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
Sync();
@@ -95,15 +96,15 @@ TEST_P(WaylandPointerTest, Motion) {
}
TEST_P(WaylandPointerTest, MotionDragged) {
- wl_pointer_send_enter(pointer->resource(), 1, surface->resource(), 0, 0);
- wl_pointer_send_button(pointer->resource(), 2, 1002, BTN_MIDDLE,
+ wl_pointer_send_enter(pointer_->resource(), 1, surface_->resource(), 0, 0);
+ wl_pointer_send_button(pointer_->resource(), 2, 1002, BTN_MIDDLE,
WL_POINTER_BUTTON_STATE_PRESSED);
Sync();
std::unique_ptr<Event> event;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
- wl_pointer_send_motion(pointer->resource(), 1003, wl_fixed_from_int(400),
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
+ wl_pointer_send_motion(pointer_->resource(), 1003, wl_fixed_from_int(400),
wl_fixed_from_int(500));
Sync();
@@ -119,44 +120,59 @@ TEST_P(WaylandPointerTest, MotionDragged) {
}
TEST_P(WaylandPointerTest, ButtonPress) {
- wl_pointer_send_enter(pointer->resource(), 1, surface->resource(),
+ wl_pointer_send_enter(pointer_->resource(), 1, surface_->resource(),
wl_fixed_from_int(200), wl_fixed_from_int(150));
- wl_pointer_send_button(pointer->resource(), 2, 1002, BTN_RIGHT,
- WL_POINTER_BUTTON_STATE_PRESSED);
-
Sync();
- std::unique_ptr<Event> event;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
- wl_pointer_send_button(pointer->resource(), 3, 1003, BTN_LEFT,
+ wl_pointer_send_button(pointer_->resource(), 2, 1002, BTN_RIGHT,
+ WL_POINTER_BUTTON_STATE_PRESSED);
+ std::unique_ptr<Event> right_press_event;
+ EXPECT_CALL(delegate_, DispatchEvent(_))
+ .WillOnce(CloneEvent(&right_press_event));
+ Sync();
+ ASSERT_TRUE(right_press_event);
+ ASSERT_TRUE(right_press_event->IsMouseEvent());
+ auto* right_press_mouse_event = right_press_event->AsMouseEvent();
+ EXPECT_EQ(ET_MOUSE_PRESSED, right_press_mouse_event->type());
+ EXPECT_EQ(EF_RIGHT_MOUSE_BUTTON, right_press_mouse_event->button_flags());
+ EXPECT_EQ(EF_RIGHT_MOUSE_BUTTON,
+ right_press_mouse_event->changed_button_flags());
+
+ std::unique_ptr<Event> left_press_event;
+ EXPECT_CALL(delegate_, DispatchEvent(_))
+ .WillOnce(CloneEvent(&left_press_event));
+ wl_pointer_send_button(pointer_->resource(), 3, 1003, BTN_LEFT,
WL_POINTER_BUTTON_STATE_PRESSED);
Sync();
- ASSERT_TRUE(event);
- ASSERT_TRUE(event->IsMouseEvent());
- auto* mouse_event = event->AsMouseEvent();
- EXPECT_EQ(ET_MOUSE_PRESSED, mouse_event->type());
+ ASSERT_TRUE(left_press_event);
+ ASSERT_TRUE(left_press_event->IsMouseEvent());
+ auto* left_press_mouse_event = left_press_event->AsMouseEvent();
+ EXPECT_EQ(ET_MOUSE_PRESSED, left_press_mouse_event->type());
EXPECT_EQ(EF_LEFT_MOUSE_BUTTON | EF_RIGHT_MOUSE_BUTTON,
- mouse_event->button_flags());
- EXPECT_EQ(EF_LEFT_MOUSE_BUTTON, mouse_event->changed_button_flags());
- EXPECT_EQ(gfx::PointF(200, 150), mouse_event->location_f());
- EXPECT_EQ(gfx::PointF(200, 150), mouse_event->root_location_f());
+ left_press_mouse_event->button_flags());
+ EXPECT_EQ(EF_LEFT_MOUSE_BUTTON,
+ left_press_mouse_event->changed_button_flags());
+ EXPECT_EQ(EF_LEFT_MOUSE_BUTTON,
+ left_press_mouse_event->changed_button_flags());
+ EXPECT_EQ(gfx::PointF(200, 150), left_press_mouse_event->location_f());
+ EXPECT_EQ(gfx::PointF(200, 150), left_press_mouse_event->root_location_f());
}
TEST_P(WaylandPointerTest, ButtonRelease) {
- wl_pointer_send_enter(pointer->resource(), 1, surface->resource(),
+ wl_pointer_send_enter(pointer_->resource(), 1, surface_->resource(),
wl_fixed_from_int(50), wl_fixed_from_int(50));
- wl_pointer_send_button(pointer->resource(), 2, 1002, BTN_BACK,
+ wl_pointer_send_button(pointer_->resource(), 2, 1002, BTN_BACK,
WL_POINTER_BUTTON_STATE_PRESSED);
- wl_pointer_send_button(pointer->resource(), 3, 1003, BTN_LEFT,
+ wl_pointer_send_button(pointer_->resource(), 3, 1003, BTN_LEFT,
WL_POINTER_BUTTON_STATE_PRESSED);
Sync();
std::unique_ptr<Event> event;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
- wl_pointer_send_button(pointer->resource(), 4, 1004, BTN_LEFT,
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
+ wl_pointer_send_button(pointer_->resource(), 4, 1004, BTN_LEFT,
WL_POINTER_BUTTON_STATE_RELEASED);
Sync();
@@ -173,17 +189,17 @@ TEST_P(WaylandPointerTest, ButtonRelease) {
}
TEST_P(WaylandPointerTest, AxisVertical) {
- wl_pointer_send_enter(pointer->resource(), 1, surface->resource(),
+ wl_pointer_send_enter(pointer_->resource(), 1, surface_->resource(),
wl_fixed_from_int(0), wl_fixed_from_int(0));
- wl_pointer_send_button(pointer->resource(), 2, 1002, BTN_RIGHT,
+ wl_pointer_send_button(pointer_->resource(), 2, 1002, BTN_RIGHT,
WL_POINTER_BUTTON_STATE_PRESSED);
Sync();
std::unique_ptr<Event> event;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
// Wayland servers typically send a value of 10 per mouse wheel click.
- wl_pointer_send_axis(pointer->resource(), 1003,
+ wl_pointer_send_axis(pointer_->resource(), 1003,
WL_POINTER_AXIS_VERTICAL_SCROLL, wl_fixed_from_int(20));
Sync();
@@ -200,17 +216,17 @@ TEST_P(WaylandPointerTest, AxisVertical) {
}
TEST_P(WaylandPointerTest, AxisHorizontal) {
- wl_pointer_send_enter(pointer->resource(), 1, surface->resource(),
+ wl_pointer_send_enter(pointer_->resource(), 1, surface_->resource(),
wl_fixed_from_int(50), wl_fixed_from_int(75));
- wl_pointer_send_button(pointer->resource(), 2, 1002, BTN_LEFT,
+ wl_pointer_send_button(pointer_->resource(), 2, 1002, BTN_LEFT,
WL_POINTER_BUTTON_STATE_PRESSED);
Sync();
std::unique_ptr<Event> event;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
// Wayland servers typically send a value of 10 per mouse wheel click.
- wl_pointer_send_axis(pointer->resource(), 1003,
+ wl_pointer_send_axis(pointer_->resource(), 1003,
WL_POINTER_AXIS_HORIZONTAL_SCROLL,
wl_fixed_from_int(10));
diff --git a/chromium/ui/ozone/platform/wayland/wayland_surface_factory_unittest.cc b/chromium/ui/ozone/platform/wayland/wayland_surface_factory_unittest.cc
index 2ee97407685..ac537496dc7 100644
--- a/chromium/ui/ozone/platform/wayland/wayland_surface_factory_unittest.cc
+++ b/chromium/ui/ozone/platform/wayland/wayland_surface_factory_unittest.cc
@@ -19,13 +19,13 @@ namespace ui {
class WaylandSurfaceFactoryTest : public WaylandTest {
public:
- WaylandSurfaceFactoryTest() : surface_factory(connection.get()) {}
+ WaylandSurfaceFactoryTest() : surface_factory(connection_.get()) {}
~WaylandSurfaceFactoryTest() override {}
void SetUp() override {
WaylandTest::SetUp();
- canvas = surface_factory.CreateCanvasForWidget(widget);
+ canvas = surface_factory.CreateCanvasForWidget(widget_);
ASSERT_TRUE(canvas);
}
@@ -41,11 +41,11 @@ TEST_P(WaylandSurfaceFactoryTest, Canvas) {
canvas->GetSurface();
canvas->PresentCanvas(gfx::Rect(5, 10, 20, 15));
- Expectation damage = EXPECT_CALL(*surface, Damage(5, 10, 20, 15));
+ Expectation damage = EXPECT_CALL(*surface_, Damage(5, 10, 20, 15));
wl_resource* buffer_resource = nullptr;
- Expectation attach = EXPECT_CALL(*surface, Attach(_, 0, 0))
+ Expectation attach = EXPECT_CALL(*surface_, Attach(_, 0, 0))
.WillOnce(SaveArg<0>(&buffer_resource));
- EXPECT_CALL(*surface, Commit()).After(damage, attach);
+ EXPECT_CALL(*surface_, Commit()).After(damage, attach);
Sync();
@@ -65,11 +65,11 @@ TEST_P(WaylandSurfaceFactoryTest, CanvasResize) {
canvas->GetSurface();
canvas->PresentCanvas(gfx::Rect(0, 0, 100, 50));
- Expectation damage = EXPECT_CALL(*surface, Damage(0, 0, 100, 50));
+ Expectation damage = EXPECT_CALL(*surface_, Damage(0, 0, 100, 50));
wl_resource* buffer_resource = nullptr;
- Expectation attach = EXPECT_CALL(*surface, Attach(_, 0, 0))
+ Expectation attach = EXPECT_CALL(*surface_, Attach(_, 0, 0))
.WillOnce(SaveArg<0>(&buffer_resource));
- EXPECT_CALL(*surface, Commit()).After(damage, attach);
+ EXPECT_CALL(*surface_, Commit()).After(damage, attach);
Sync();
diff --git a/chromium/ui/ozone/platform/wayland/wayland_test.cc b/chromium/ui/ozone/platform/wayland/wayland_test.cc
index 7bc6c91e462..a56cbcb8a4f 100644
--- a/chromium/ui/ozone/platform/wayland/wayland_test.cc
+++ b/chromium/ui/ozone/platform/wayland/wayland_test.cc
@@ -27,48 +27,48 @@ WaylandTest::WaylandTest() {
KeyboardLayoutEngineManager::SetKeyboardLayoutEngine(
std::make_unique<StubKeyboardLayoutEngine>());
#endif
- connection.reset(new WaylandConnection);
- window = std::make_unique<WaylandWindow>(&delegate, connection.get(),
- gfx::Rect(0, 0, 800, 600));
+ connection_.reset(new WaylandConnection);
+ window_ = std::make_unique<WaylandWindow>(&delegate_, connection_.get(),
+ gfx::Rect(0, 0, 800, 600));
}
WaylandTest::~WaylandTest() {}
void WaylandTest::SetUp() {
- ASSERT_TRUE(server.Start(GetParam()));
- ASSERT_TRUE(connection->Initialize());
- EXPECT_CALL(delegate, OnAcceleratedWidgetAvailable(_, _))
- .WillOnce(SaveArg<0>(&widget));
- ASSERT_TRUE(window->Initialize());
- ASSERT_NE(widget, gfx::kNullAcceleratedWidget);
+ ASSERT_TRUE(server_.Start(GetParam()));
+ ASSERT_TRUE(connection_->Initialize());
+ EXPECT_CALL(delegate_, OnAcceleratedWidgetAvailable(_, _))
+ .WillOnce(SaveArg<0>(&widget_));
+ ASSERT_TRUE(window_->Initialize());
+ ASSERT_NE(widget_, gfx::kNullAcceleratedWidget);
// Wait for the client to flush all pending requests from initialization.
base::RunLoop().RunUntilIdle();
// Pause the server after it has responded to all incoming events.
- server.Pause();
+ server_.Pause();
- surface = server.GetObject<wl::MockSurface>(widget);
- ASSERT_TRUE(surface);
+ surface_ = server_.GetObject<wl::MockSurface>(widget_);
+ ASSERT_TRUE(surface_);
- initialized = true;
+ initialized_ = true;
}
void WaylandTest::TearDown() {
- if (initialized)
+ if (initialized_)
Sync();
}
void WaylandTest::Sync() {
// Resume the server, flushing its pending events.
- server.Resume();
+ server_.Resume();
// Wait for the client to finish processing these events.
base::RunLoop().RunUntilIdle();
// Pause the server, after it has finished processing any follow-up requests
// from the client.
- server.Pause();
+ server_.Pause();
}
} // namespace ui
diff --git a/chromium/ui/ozone/platform/wayland/wayland_test.h b/chromium/ui/ozone/platform/wayland/wayland_test.h
index 80587745e1a..20f7dfa47ad 100644
--- a/chromium/ui/ozone/platform/wayland/wayland_test.h
+++ b/chromium/ui/ozone/platform/wayland/wayland_test.h
@@ -35,17 +35,17 @@ class WaylandTest : public ::testing::TestWithParam<uint32_t> {
void Sync();
private:
- bool initialized = false;
- base::MessageLoopForUI message_loop;
+ base::MessageLoopForUI message_loop_;
+ bool initialized_ = false;
protected:
- wl::FakeServer server;
- wl::MockSurface* surface;
+ wl::FakeServer server_;
+ wl::MockSurface* surface_;
- MockPlatformWindowDelegate delegate;
- std::unique_ptr<WaylandConnection> connection;
- std::unique_ptr<WaylandWindow> window;
- gfx::AcceleratedWidget widget = gfx::kNullAcceleratedWidget;
+ MockPlatformWindowDelegate delegate_;
+ std::unique_ptr<WaylandConnection> connection_;
+ std::unique_ptr<WaylandWindow> window_;
+ gfx::AcceleratedWidget widget_ = gfx::kNullAcceleratedWidget;
private:
#if BUILDFLAG(USE_XKBCOMMON)
diff --git a/chromium/ui/ozone/platform/wayland/wayland_touch.cc b/chromium/ui/ozone/platform/wayland/wayland_touch.cc
index b8dc5437f79..9052eaf09b3 100644
--- a/chromium/ui/ozone/platform/wayland/wayland_touch.cc
+++ b/chromium/ui/ozone/platform/wayland/wayland_touch.cc
@@ -8,7 +8,6 @@
#include <wayland-client.h>
#include "base/files/scoped_file.h"
-#include "base/memory/ptr_util.h"
#include "ui/base/ui_features.h"
#include "ui/events/event.h"
#include "ui/ozone/platform/wayland/wayland_connection.h"
diff --git a/chromium/ui/ozone/platform/wayland/wayland_touch_unittest.cc b/chromium/ui/ozone/platform/wayland/wayland_touch_unittest.cc
index c9afacb6a22..13a830f4baf 100644
--- a/chromium/ui/ozone/platform/wayland/wayland_touch_unittest.cc
+++ b/chromium/ui/ozone/platform/wayland/wayland_touch_unittest.cc
@@ -33,13 +33,13 @@ class WaylandTouchTest : public WaylandTest {
void SetUp() override {
WaylandTest::SetUp();
- wl_seat_send_capabilities(server.seat()->resource(),
+ wl_seat_send_capabilities(server_.seat()->resource(),
WL_SEAT_CAPABILITY_TOUCH);
Sync();
- touch = server.seat()->touch.get();
- ASSERT_TRUE(touch);
+ touch_ = server_.seat()->touch();
+ ASSERT_TRUE(touch_);
}
protected:
@@ -51,7 +51,7 @@ class WaylandTouchTest : public WaylandTest {
EXPECT_EQ(event_type, key_event->type());
}
- wl::MockTouch* touch;
+ wl::MockTouch* touch_;
private:
DISALLOW_COPY_AND_ASSIGN(WaylandTouchTest);
@@ -59,21 +59,21 @@ class WaylandTouchTest : public WaylandTest {
TEST_P(WaylandTouchTest, KeypressAndMotion) {
std::unique_ptr<Event> event;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillRepeatedly(CloneEvent(&event));
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillRepeatedly(CloneEvent(&event));
- wl_touch_send_down(touch->resource(), 1, 0, surface->resource(), 0 /* id */,
+ wl_touch_send_down(touch_->resource(), 1, 0, surface_->resource(), 0 /* id */,
wl_fixed_from_int(50), wl_fixed_from_int(100));
Sync();
CheckEventType(ui::ET_TOUCH_PRESSED, event.get());
- wl_touch_send_motion(touch->resource(), 500, 0 /* id */,
+ wl_touch_send_motion(touch_->resource(), 500, 0 /* id */,
wl_fixed_from_int(100), wl_fixed_from_int(100));
Sync();
CheckEventType(ui::ET_TOUCH_MOVED, event.get());
- wl_touch_send_up(touch->resource(), 1, 1000, 0 /* id */);
+ wl_touch_send_up(touch_->resource(), 1, 1000, 0 /* id */);
Sync();
CheckEventType(ui::ET_TOUCH_RELEASED, event.get());
diff --git a/chromium/ui/ozone/platform/wayland/wayland_window.cc b/chromium/ui/ozone/platform/wayland/wayland_window.cc
index bed831b995c..6ebe40755d8 100644
--- a/chromium/ui/ozone/platform/wayland/wayland_window.cc
+++ b/chromium/ui/ozone/platform/wayland/wayland_window.cc
@@ -7,11 +7,11 @@
#include <wayland-client.h>
#include "base/bind.h"
-#include "base/memory/ptr_util.h"
#include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h"
#include "ui/events/event.h"
#include "ui/events/ozone/events_ozone.h"
#include "ui/ozone/platform/wayland/wayland_connection.h"
+#include "ui/ozone/platform/wayland/wayland_pointer.h"
#include "ui/ozone/platform/wayland/xdg_surface_wrapper_v5.h"
#include "ui/ozone/platform/wayland/xdg_surface_wrapper_v6.h"
@@ -55,6 +55,8 @@ WaylandWindow::~WaylandWindow() {
PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
connection_->RemoveWindow(surface_.id());
}
+ if (has_pointer_focus_)
+ connection_->pointer()->reset_window_with_pointer_focus();
}
// static
@@ -134,13 +136,21 @@ void WaylandWindow::SetTitle(const base::string16& title) {
}
void WaylandWindow::SetCapture() {
+ // Wayland does implicit grabs, and doesn't allow for explicit grabs. The
+ // exception to that seems to be popups, which can do a grab during show. Need
+ // to evaluate under what circumstances we need this.
NOTIMPLEMENTED();
}
void WaylandWindow::ReleaseCapture() {
+ // See comment in SetCapture() for details on wayland and grabs.
NOTIMPLEMENTED();
}
+bool WaylandWindow::HasCapture() const {
+ return has_implicit_grab_;
+}
+
void WaylandWindow::ToggleFullscreen() {
DCHECK(xdg_surface_);
@@ -234,8 +244,7 @@ PlatformImeController* WaylandWindow::GetPlatformImeController() {
return nullptr;
}
-bool WaylandWindow::CanDispatchEvent(const PlatformEvent& native_event) {
- Event* event = static_cast<Event*>(native_event);
+bool WaylandWindow::CanDispatchEvent(const PlatformEvent& event) {
if (event->IsMouseEvent())
return has_pointer_focus_;
if (event->IsKeyEvent())
@@ -268,14 +277,21 @@ void WaylandWindow::HandleSurfaceConfigure(int32_t width,
else
state_ = PlatformWindowState::PLATFORM_WINDOW_STATE_NORMAL;
- if (old_state != state_)
- delegate_->OnWindowStateChanged(state_);
+ // Update state before notifying delegate.
+ const bool did_active_change = is_active_ != is_activated;
+ is_active_ = is_activated;
// Rather than call SetBounds here for every configure event, just save the
// most recent bounds, and have WaylandConnection call ApplyPendingBounds
// when it has finished processing events. We may get many configure events
// in a row during an interactive resize, and only the last one matters.
SetPendingBounds(width, height);
+
+ if (old_state != state_)
+ delegate_->OnWindowStateChanged(state_);
+
+ if (did_active_change)
+ delegate_->OnActivationChanged(is_active_);
}
void WaylandWindow::OnCloseRequest() {
diff --git a/chromium/ui/ozone/platform/wayland/wayland_window.h b/chromium/ui/ozone/platform/wayland/wayland_window.h
index 8d205fa48b4..b534566ea63 100644
--- a/chromium/ui/ozone/platform/wayland/wayland_window.h
+++ b/chromium/ui/ozone/platform/wayland/wayland_window.h
@@ -43,6 +43,7 @@ class WaylandWindow : public PlatformWindow, public PlatformEventDispatcher {
// Set whether this window has pointer focus and should dispatch mouse events.
void set_pointer_focus(bool focus) { has_pointer_focus_ = focus; }
+ bool has_pointer_focus() const { return has_pointer_focus_; }
// Set whether this window has keyboard focus and should dispatch key events.
void set_keyboard_focus(bool focus) { has_keyboard_focus_ = focus; }
@@ -50,6 +51,13 @@ class WaylandWindow : public PlatformWindow, public PlatformEventDispatcher {
// Set whether this window has touch focus and should dispatch touch events.
void set_touch_focus(bool focus) { has_touch_focus_ = focus; }
+ // Set whether this window has an implicit grab (often referred to as capture
+ // in Chrome code). Implicit grabs happen while a pointer is down.
+ void set_has_implicit_grab(bool value) { has_implicit_grab_ = value; }
+ bool has_implicit_grab() const { return has_implicit_grab_; }
+
+ bool is_active() const { return is_active_; }
+
// PlatformWindow
void Show() override;
void Hide() override;
@@ -60,6 +68,7 @@ class WaylandWindow : public PlatformWindow, public PlatformEventDispatcher {
void SetTitle(const base::string16& title) override;
void SetCapture() override;
void ReleaseCapture() override;
+ bool HasCapture() const override;
void ToggleFullscreen() override;
void Maximize() override;
void Minimize() override;
@@ -113,10 +122,13 @@ class WaylandWindow : public PlatformWindow, public PlatformEventDispatcher {
bool has_pointer_focus_ = false;
bool has_keyboard_focus_ = false;
bool has_touch_focus_ = false;
+ bool has_implicit_grab_ = false;
// Stores current states of the window.
ui::PlatformWindowState state_;
+ bool is_active_ = false;
+
DISALLOW_COPY_AND_ASSIGN(WaylandWindow);
};
diff --git a/chromium/ui/ozone/platform/wayland/wayland_window_unittest.cc b/chromium/ui/ozone/platform/wayland/wayland_window_unittest.cc
index 2c2e2679a2a..77c1084fac8 100644
--- a/chromium/ui/ozone/platform/wayland/wayland_window_unittest.cc
+++ b/chromium/ui/ozone/platform/wayland/wayland_window_unittest.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "ui/ozone/platform/wayland/wayland_window.h"
+
#include <wayland-server-core.h>
#include <xdg-shell-unstable-v5-server-protocol.h>
#include <xdg-shell-unstable-v6-server-protocol.h>
@@ -14,7 +16,6 @@
#include "ui/events/event.h"
#include "ui/ozone/platform/wayland/fake_server.h"
#include "ui/ozone/platform/wayland/wayland_test.h"
-#include "ui/ozone/platform/wayland/wayland_window.h"
#include "ui/ozone/test/mock_platform_window_delegate.h"
using ::testing::Eq;
@@ -28,18 +29,18 @@ namespace ui {
class WaylandWindowTest : public WaylandTest {
public:
WaylandWindowTest()
- : test_mouse_event(ET_MOUSE_PRESSED,
- gfx::Point(10, 15),
- gfx::Point(10, 15),
- ui::EventTimeStampFromSeconds(123456),
- EF_LEFT_MOUSE_BUTTON | EF_RIGHT_MOUSE_BUTTON,
- EF_LEFT_MOUSE_BUTTON) {}
+ : test_mouse_event_(ET_MOUSE_PRESSED,
+ gfx::Point(10, 15),
+ gfx::Point(10, 15),
+ ui::EventTimeStampFromSeconds(123456),
+ EF_LEFT_MOUSE_BUTTON | EF_RIGHT_MOUSE_BUTTON,
+ EF_LEFT_MOUSE_BUTTON) {}
void SetUp() override {
WaylandTest::SetUp();
- xdg_surface = surface->xdg_surface.get();
- ASSERT_TRUE(xdg_surface);
+ xdg_surface_ = surface_->xdg_surface();
+ ASSERT_TRUE(xdg_surface_);
}
protected:
@@ -47,26 +48,26 @@ class WaylandWindowTest : public WaylandTest {
int height,
uint32_t serial,
struct wl_array* states) {
- if (!xdg_surface->xdg_toplevel) {
- xdg_surface_send_configure(xdg_surface->resource(), width, height, states,
- serial);
+ if (!xdg_surface_->xdg_toplevel()) {
+ xdg_surface_send_configure(xdg_surface_->resource(), width, height,
+ states, serial);
return;
}
// In xdg_shell_v6, both surfaces send serial configure event and toplevel
// surfaces send other data like states, heights and widths.
- zxdg_surface_v6_send_configure(xdg_surface->resource(), serial);
- ASSERT_TRUE(xdg_surface->xdg_toplevel);
- zxdg_toplevel_v6_send_configure(xdg_surface->xdg_toplevel->resource(),
+ zxdg_surface_v6_send_configure(xdg_surface_->resource(), serial);
+ ASSERT_TRUE(xdg_surface_->xdg_toplevel());
+ zxdg_toplevel_v6_send_configure(xdg_surface_->xdg_toplevel()->resource(),
width, height, states);
}
- // Depending on a shell version, xdg_surface or xdg_toplevel surface should
+ // Depending on a shell version, xdg_surface_ or xdg_toplevel surface should
// get the mock calls. This method decided, which surface to use.
wl::MockXdgSurface* GetXdgSurface() {
if (GetParam() == kXdgShellV5)
- return xdg_surface;
- return xdg_surface->xdg_toplevel.get();
+ return xdg_surface_;
+ return xdg_surface_->xdg_toplevel();
}
void SetWlArrayWithState(uint32_t state, wl_array* states) {
@@ -80,9 +81,9 @@ class WaylandWindowTest : public WaylandTest {
SetWlArrayWithState(XDG_SURFACE_STATE_ACTIVATED, states);
}
- wl::MockXdgSurface* xdg_surface;
+ wl::MockXdgSurface* xdg_surface_;
- MouseEvent test_mouse_event;
+ MouseEvent test_mouse_event_;
private:
DISALLOW_COPY_AND_ASSIGN(WaylandWindowTest);
@@ -90,25 +91,26 @@ class WaylandWindowTest : public WaylandTest {
TEST_P(WaylandWindowTest, SetTitle) {
EXPECT_CALL(*GetXdgSurface(), SetTitle(StrEq("hello")));
- window->SetTitle(base::ASCIIToUTF16("hello"));
+ window_->SetTitle(base::ASCIIToUTF16("hello"));
}
TEST_P(WaylandWindowTest, MaximizeAndRestore) {
wl_array states;
InitializeWlArrayWithActivatedState(&states);
- EXPECT_CALL(delegate,
+ EXPECT_CALL(delegate_,
OnWindowStateChanged(Eq(PLATFORM_WINDOW_STATE_MAXIMIZED)));
SetWlArrayWithState(XDG_SURFACE_STATE_MAXIMIZED, &states);
EXPECT_CALL(*GetXdgSurface(), SetMaximized());
- window->Maximize();
+ window_->Maximize();
SendConfigureEvent(0, 0, 1, &states);
Sync();
- EXPECT_CALL(delegate, OnWindowStateChanged(Eq(PLATFORM_WINDOW_STATE_NORMAL)));
+ EXPECT_CALL(delegate_,
+ OnWindowStateChanged(Eq(PLATFORM_WINDOW_STATE_NORMAL)));
EXPECT_CALL(*GetXdgSurface(), UnsetMaximized());
- window->Restore();
+ window_->Restore();
// Reinitialize wl_array, which removes previous old states.
InitializeWlArrayWithActivatedState(&states);
SendConfigureEvent(0, 0, 2, &states);
@@ -120,7 +122,8 @@ TEST_P(WaylandWindowTest, Minimize) {
wl_array_init(&states);
// Initialize to normal first.
- EXPECT_CALL(delegate, OnWindowStateChanged(Eq(PLATFORM_WINDOW_STATE_NORMAL)));
+ EXPECT_CALL(delegate_,
+ OnWindowStateChanged(Eq(PLATFORM_WINDOW_STATE_NORMAL)));
SendConfigureEvent(0, 0, 1, &states);
Sync();
@@ -129,8 +132,8 @@ TEST_P(WaylandWindowTest, Minimize) {
// notified about the state, because 1) minimized state was set manually
// in WaylandWindow, and it has been confirmed in a back call from the server,
// which resulted in the same state as before.
- EXPECT_CALL(delegate, OnWindowStateChanged(_)).Times(0);
- window->Minimize();
+ EXPECT_CALL(delegate_, OnWindowStateChanged(_)).Times(0);
+ window_->Minimize();
// Reinitialize wl_array, which removes previous old states.
wl_array_init(&states);
SendConfigureEvent(0, 0, 2, &states);
@@ -144,15 +147,16 @@ TEST_P(WaylandWindowTest, SetFullscreenAndRestore) {
SetWlArrayWithState(XDG_SURFACE_STATE_FULLSCREEN, &states);
EXPECT_CALL(*GetXdgSurface(), SetFullscreen());
- EXPECT_CALL(delegate,
+ EXPECT_CALL(delegate_,
OnWindowStateChanged(Eq(PLATFORM_WINDOW_STATE_FULLSCREEN)));
- window->ToggleFullscreen();
+ window_->ToggleFullscreen();
SendConfigureEvent(0, 0, 1, &states);
Sync();
EXPECT_CALL(*GetXdgSurface(), UnsetFullscreen());
- EXPECT_CALL(delegate, OnWindowStateChanged(Eq(PLATFORM_WINDOW_STATE_NORMAL)));
- window->Restore();
+ EXPECT_CALL(delegate_,
+ OnWindowStateChanged(Eq(PLATFORM_WINDOW_STATE_NORMAL)));
+ window_->Restore();
// Reinitialize wl_array, which removes previous old states.
InitializeWlArrayWithActivatedState(&states);
SendConfigureEvent(0, 0, 2, &states);
@@ -164,25 +168,26 @@ TEST_P(WaylandWindowTest, SetMaximizedFullscreenAndRestore) {
InitializeWlArrayWithActivatedState(&states);
EXPECT_CALL(*GetXdgSurface(), SetMaximized());
- EXPECT_CALL(delegate,
+ EXPECT_CALL(delegate_,
OnWindowStateChanged(Eq(PLATFORM_WINDOW_STATE_MAXIMIZED)));
- window->Maximize();
+ window_->Maximize();
SetWlArrayWithState(XDG_SURFACE_STATE_MAXIMIZED, &states);
SendConfigureEvent(0, 0, 2, &states);
Sync();
EXPECT_CALL(*GetXdgSurface(), SetFullscreen());
- EXPECT_CALL(delegate,
+ EXPECT_CALL(delegate_,
OnWindowStateChanged(Eq(PLATFORM_WINDOW_STATE_FULLSCREEN)));
- window->ToggleFullscreen();
+ window_->ToggleFullscreen();
SetWlArrayWithState(XDG_SURFACE_STATE_FULLSCREEN, &states);
SendConfigureEvent(0, 0, 3, &states);
Sync();
EXPECT_CALL(*GetXdgSurface(), UnsetFullscreen());
EXPECT_CALL(*GetXdgSurface(), UnsetMaximized());
- EXPECT_CALL(delegate, OnWindowStateChanged(Eq(PLATFORM_WINDOW_STATE_NORMAL)));
- window->Restore();
+ EXPECT_CALL(delegate_,
+ OnWindowStateChanged(Eq(PLATFORM_WINDOW_STATE_NORMAL)));
+ window_->Restore();
// Reinitialize wl_array, which removes previous old states.
InitializeWlArrayWithActivatedState(&states);
SendConfigureEvent(0, 0, 4, &states);
@@ -190,26 +195,26 @@ TEST_P(WaylandWindowTest, SetMaximizedFullscreenAndRestore) {
}
TEST_P(WaylandWindowTest, RestoreBoundsAfterMaximize) {
- const gfx::Rect current_bounds = window->GetBounds();
+ const gfx::Rect current_bounds = window_->GetBounds();
wl_array states;
InitializeWlArrayWithActivatedState(&states);
const gfx::Rect maximized_bounds = gfx::Rect(0, 0, 1024, 768);
- EXPECT_CALL(delegate, OnBoundsChanged(Eq(maximized_bounds)));
- window->Maximize();
+ EXPECT_CALL(delegate_, OnBoundsChanged(Eq(maximized_bounds)));
+ window_->Maximize();
SetWlArrayWithState(XDG_SURFACE_STATE_MAXIMIZED, &states);
SendConfigureEvent(maximized_bounds.width(), maximized_bounds.height(), 1,
&states);
Sync();
- EXPECT_CALL(delegate, OnBoundsChanged(Eq(current_bounds)));
+ EXPECT_CALL(delegate_, OnBoundsChanged(Eq(current_bounds)));
// Both in XdgV5 and XdgV6, surfaces implement SetWindowGeometry method.
// Thus, using a toplevel object in XdgV6 case is not right thing. Use a
// surface here instead.
- EXPECT_CALL(*xdg_surface, SetWindowGeometry(0, 0, current_bounds.width(),
- current_bounds.height()));
- window->Restore();
+ EXPECT_CALL(*xdg_surface_, SetWindowGeometry(0, 0, current_bounds.width(),
+ current_bounds.height()));
+ window_->Restore();
// Reinitialize wl_array, which removes previous old states.
InitializeWlArrayWithActivatedState(&states);
SendConfigureEvent(0, 0, 2, &states);
@@ -217,26 +222,26 @@ TEST_P(WaylandWindowTest, RestoreBoundsAfterMaximize) {
}
TEST_P(WaylandWindowTest, RestoreBoundsAfterFullscreen) {
- const gfx::Rect current_bounds = window->GetBounds();
+ const gfx::Rect current_bounds = window_->GetBounds();
wl_array states;
InitializeWlArrayWithActivatedState(&states);
const gfx::Rect fullscreen_bounds = gfx::Rect(0, 0, 1280, 720);
- EXPECT_CALL(delegate, OnBoundsChanged(Eq(fullscreen_bounds)));
- window->ToggleFullscreen();
+ EXPECT_CALL(delegate_, OnBoundsChanged(Eq(fullscreen_bounds)));
+ window_->ToggleFullscreen();
SetWlArrayWithState(XDG_SURFACE_STATE_FULLSCREEN, &states);
SendConfigureEvent(fullscreen_bounds.width(), fullscreen_bounds.height(), 1,
&states);
Sync();
- EXPECT_CALL(delegate, OnBoundsChanged(Eq(current_bounds)));
+ EXPECT_CALL(delegate_, OnBoundsChanged(Eq(current_bounds)));
// Both in XdgV5 and XdgV6, surfaces implement SetWindowGeometry method.
// Thus, using a toplevel object in XdgV6 case is not right thing. Use a
// surface here instead.
- EXPECT_CALL(*xdg_surface, SetWindowGeometry(0, 0, current_bounds.width(),
- current_bounds.height()));
- window->Restore();
+ EXPECT_CALL(*xdg_surface_, SetWindowGeometry(0, 0, current_bounds.width(),
+ current_bounds.height()));
+ window_->Restore();
// Reinitialize wl_array, which removes previous old states.
InitializeWlArrayWithActivatedState(&states);
SendConfigureEvent(0, 0, 2, &states);
@@ -244,29 +249,29 @@ TEST_P(WaylandWindowTest, RestoreBoundsAfterFullscreen) {
}
TEST_P(WaylandWindowTest, RestoreBoundsAfterMaximizeAndFullscreen) {
- const gfx::Rect current_bounds = window->GetBounds();
+ const gfx::Rect current_bounds = window_->GetBounds();
wl_array states;
InitializeWlArrayWithActivatedState(&states);
const gfx::Rect maximized_bounds = gfx::Rect(0, 0, 1024, 768);
- EXPECT_CALL(delegate, OnBoundsChanged(Eq(maximized_bounds)));
- window->Maximize();
+ EXPECT_CALL(delegate_, OnBoundsChanged(Eq(maximized_bounds)));
+ window_->Maximize();
SetWlArrayWithState(XDG_SURFACE_STATE_MAXIMIZED, &states);
SendConfigureEvent(maximized_bounds.width(), maximized_bounds.height(), 1,
&states);
Sync();
const gfx::Rect fullscreen_bounds = gfx::Rect(0, 0, 1280, 720);
- EXPECT_CALL(delegate, OnBoundsChanged(Eq(fullscreen_bounds)));
- window->ToggleFullscreen();
+ EXPECT_CALL(delegate_, OnBoundsChanged(Eq(fullscreen_bounds)));
+ window_->ToggleFullscreen();
SetWlArrayWithState(XDG_SURFACE_STATE_FULLSCREEN, &states);
SendConfigureEvent(fullscreen_bounds.width(), fullscreen_bounds.height(), 2,
&states);
Sync();
- EXPECT_CALL(delegate, OnBoundsChanged(Eq(maximized_bounds)));
- window->Maximize();
+ EXPECT_CALL(delegate_, OnBoundsChanged(Eq(maximized_bounds)));
+ window_->Maximize();
// Reinitialize wl_array, which removes previous old states.
InitializeWlArrayWithActivatedState(&states);
SetWlArrayWithState(XDG_SURFACE_STATE_MAXIMIZED, &states);
@@ -274,13 +279,13 @@ TEST_P(WaylandWindowTest, RestoreBoundsAfterMaximizeAndFullscreen) {
&states);
Sync();
- EXPECT_CALL(delegate, OnBoundsChanged(Eq(current_bounds)));
+ EXPECT_CALL(delegate_, OnBoundsChanged(Eq(current_bounds)));
// Both in XdgV5 and XdgV6, surfaces implement SetWindowGeometry method.
// Thus, using a toplevel object in XdgV6 case is not right thing. Use a
// surface here instead.
- EXPECT_CALL(*xdg_surface, SetWindowGeometry(0, 0, current_bounds.width(),
- current_bounds.height()));
- window->Restore();
+ EXPECT_CALL(*xdg_surface_, SetWindowGeometry(0, 0, current_bounds.width(),
+ current_bounds.height()));
+ window_->Restore();
// Reinitialize wl_array, which removes previous old states.
InitializeWlArrayWithActivatedState(&states);
SendConfigureEvent(0, 0, 4, &states);
@@ -288,19 +293,19 @@ TEST_P(WaylandWindowTest, RestoreBoundsAfterMaximizeAndFullscreen) {
}
TEST_P(WaylandWindowTest, SendsBoundsOnRequest) {
- const gfx::Rect initial_bounds = window->GetBounds();
+ const gfx::Rect initial_bounds = window_->GetBounds();
const gfx::Rect new_bounds = gfx::Rect(0, 0, initial_bounds.width() + 10,
initial_bounds.height() + 10);
- EXPECT_CALL(delegate, OnBoundsChanged(Eq(new_bounds)));
- window->SetBounds(new_bounds);
+ EXPECT_CALL(delegate_, OnBoundsChanged(Eq(new_bounds)));
+ window_->SetBounds(new_bounds);
wl_array states;
InitializeWlArrayWithActivatedState(&states);
// First case is when Wayland sends a configure event with 0,0 height and
// widht.
- EXPECT_CALL(*xdg_surface,
+ EXPECT_CALL(*xdg_surface_,
SetWindowGeometry(0, 0, new_bounds.width(), new_bounds.height()))
.Times(2);
SendConfigureEvent(0, 0, 2, &states);
@@ -314,17 +319,22 @@ TEST_P(WaylandWindowTest, SendsBoundsOnRequest) {
}
TEST_P(WaylandWindowTest, CanDispatchMouseEventDefault) {
- EXPECT_FALSE(window->CanDispatchEvent(&test_mouse_event));
+ EXPECT_FALSE(window_->CanDispatchEvent(&test_mouse_event_));
}
TEST_P(WaylandWindowTest, CanDispatchMouseEventFocus) {
- window->set_pointer_focus(true);
- EXPECT_TRUE(window->CanDispatchEvent(&test_mouse_event));
+ // set_pointer_focus(true) requires a WaylandPointer.
+ wl_seat_send_capabilities(server_.seat()->resource(),
+ WL_SEAT_CAPABILITY_POINTER);
+ Sync();
+ ASSERT_TRUE(connection_->pointer());
+ window_->set_pointer_focus(true);
+ EXPECT_TRUE(window_->CanDispatchEvent(&test_mouse_event_));
}
TEST_P(WaylandWindowTest, CanDispatchMouseEventUnfocus) {
- window->set_pointer_focus(false);
- EXPECT_FALSE(window->CanDispatchEvent(&test_mouse_event));
+ EXPECT_FALSE(window_->has_pointer_focus());
+ EXPECT_FALSE(window_->CanDispatchEvent(&test_mouse_event_));
}
ACTION_P(CloneEvent, ptr) {
@@ -333,17 +343,47 @@ ACTION_P(CloneEvent, ptr) {
TEST_P(WaylandWindowTest, DispatchEvent) {
std::unique_ptr<Event> event;
- EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
- window->DispatchEvent(&test_mouse_event);
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
+ window_->DispatchEvent(&test_mouse_event_);
ASSERT_TRUE(event);
ASSERT_TRUE(event->IsMouseEvent());
auto* mouse_event = event->AsMouseEvent();
- EXPECT_EQ(mouse_event->location_f(), test_mouse_event.location_f());
- EXPECT_EQ(mouse_event->root_location_f(), test_mouse_event.root_location_f());
- EXPECT_EQ(mouse_event->time_stamp(), test_mouse_event.time_stamp());
- EXPECT_EQ(mouse_event->button_flags(), test_mouse_event.button_flags());
+ EXPECT_EQ(mouse_event->location_f(), test_mouse_event_.location_f());
+ EXPECT_EQ(mouse_event->root_location_f(),
+ test_mouse_event_.root_location_f());
+ EXPECT_EQ(mouse_event->time_stamp(), test_mouse_event_.time_stamp());
+ EXPECT_EQ(mouse_event->button_flags(), test_mouse_event_.button_flags());
EXPECT_EQ(mouse_event->changed_button_flags(),
- test_mouse_event.changed_button_flags());
+ test_mouse_event_.changed_button_flags());
+}
+
+TEST_P(WaylandWindowTest, HasCaptureUpdatedOnPointerEvents) {
+ wl_seat_send_capabilities(server_.seat()->resource(),
+ WL_SEAT_CAPABILITY_POINTER);
+
+ Sync();
+
+ wl::MockPointer* pointer = server_.seat()->pointer();
+ ASSERT_TRUE(pointer);
+
+ wl_pointer_send_enter(pointer->resource(), 1, surface_->resource(), 0, 0);
+ Sync();
+ EXPECT_FALSE(window_->HasCapture());
+
+ wl_pointer_send_button(pointer->resource(), 2, 1002, BTN_LEFT,
+ WL_POINTER_BUTTON_STATE_PRESSED);
+ Sync();
+ EXPECT_TRUE(window_->HasCapture());
+
+ wl_pointer_send_motion(pointer->resource(), 1003, wl_fixed_from_int(400),
+ wl_fixed_from_int(500));
+ Sync();
+ EXPECT_TRUE(window_->HasCapture());
+
+ wl_pointer_send_button(pointer->resource(), 4, 1004, BTN_LEFT,
+ WL_POINTER_BUTTON_STATE_RELEASED);
+ Sync();
+ EXPECT_FALSE(window_->HasCapture());
}
TEST_P(WaylandWindowTest, ConfigureEvent) {
@@ -354,14 +394,14 @@ TEST_P(WaylandWindowTest, ConfigureEvent) {
// Make sure that the implementation does not call OnBoundsChanged for each
// configure event if it receives multiple in a row.
- EXPECT_CALL(delegate, OnBoundsChanged(Eq(gfx::Rect(0, 0, 1500, 1000))));
+ EXPECT_CALL(delegate_, OnBoundsChanged(Eq(gfx::Rect(0, 0, 1500, 1000))));
// Responding to a configure event, the window geometry in here must respect
// the sizing negotiations specified by the configure event.
- // |xdg_surface| must receive the following calls in both xdg_shell_v5 and
+ // |xdg_surface_| must receive the following calls in both xdg_shell_v5 and
// xdg_shell_v6. Other calls like SetTitle or SetMaximized are recieved by
- // xdg_toplevel in xdg_shell_v6 and by xdg_surface in xdg_shell_v5.
- EXPECT_CALL(*xdg_surface, SetWindowGeometry(0, 0, 1500, 1000)).Times(1);
- EXPECT_CALL(*xdg_surface, AckConfigure(13));
+ // xdg_toplevel in xdg_shell_v6 and by xdg_surface_ in xdg_shell_v5.
+ EXPECT_CALL(*xdg_surface_, SetWindowGeometry(0, 0, 1500, 1000)).Times(1);
+ EXPECT_CALL(*xdg_surface_, AckConfigure(13));
}
TEST_P(WaylandWindowTest, ConfigureEventWithNulledSize) {
@@ -372,11 +412,31 @@ TEST_P(WaylandWindowTest, ConfigureEventWithNulledSize) {
// call back with desired sizes. In this case, that's the actual size of
// the window.
SendConfigureEvent(0, 0, 14, &states);
- // |xdg_surface| must receive the following calls in both xdg_shell_v5 and
+ // |xdg_surface_| must receive the following calls in both xdg_shell_v5 and
// xdg_shell_v6. Other calls like SetTitle or SetMaximized are recieved by
- // xdg_toplevel in xdg_shell_v6 and by xdg_surface in xdg_shell_v5.
- EXPECT_CALL(*xdg_surface, SetWindowGeometry(0, 0, 800, 600));
- EXPECT_CALL(*xdg_surface, AckConfigure(14));
+ // xdg_toplevel in xdg_shell_v6 and by xdg_surface_ in xdg_shell_v5.
+ EXPECT_CALL(*xdg_surface_, SetWindowGeometry(0, 0, 800, 600));
+ EXPECT_CALL(*xdg_surface_, AckConfigure(14));
+}
+
+TEST_P(WaylandWindowTest, OnActivationChanged) {
+ EXPECT_FALSE(window_->is_active());
+
+ {
+ wl_array states;
+ InitializeWlArrayWithActivatedState(&states);
+ EXPECT_CALL(delegate_, OnActivationChanged(Eq(true)));
+ SendConfigureEvent(0, 0, 1, &states);
+ Sync();
+ EXPECT_TRUE(window_->is_active());
+ }
+
+ wl_array states;
+ wl_array_init(&states);
+ EXPECT_CALL(delegate_, OnActivationChanged(Eq(false)));
+ SendConfigureEvent(0, 0, 2, &states);
+ Sync();
+ EXPECT_FALSE(window_->is_active());
}
INSTANTIATE_TEST_CASE_P(XdgVersionV5Test,
diff --git a/chromium/ui/ozone/platform/x11/BUILD.gn b/chromium/ui/ozone/platform/x11/BUILD.gn
index e73f2cf063b..24d53e267a5 100644
--- a/chromium/ui/ozone/platform/x11/BUILD.gn
+++ b/chromium/ui/ozone/platform/x11/BUILD.gn
@@ -59,12 +59,19 @@ source_set("x11_unittests") {
testonly = true
sources = [
"x11_cursor_factory_ozone_unittest.cc",
+ "x11_window_ozone_unittest.cc",
]
deps = [
":x11",
+ "//testing/gmock",
"//testing/gtest",
+ "//ui/events:test_support",
+ "//ui/events/devices/x11",
+ "//ui/events/platform/x11",
"//ui/ozone:platform",
+ "//ui/ozone:test_support",
"//ui/ozone/common",
+ "//ui/platform_window/x11:x11",
]
}
diff --git a/chromium/ui/ozone/platform/x11/ozone_platform_x11.cc b/chromium/ui/ozone/platform/x11/ozone_platform_x11.cc
index 476f69ff287..9dd37001e47 100644
--- a/chromium/ui/ozone/platform/x11/ozone_platform_x11.cc
+++ b/chromium/ui/ozone/platform/x11/ozone_platform_x11.cc
@@ -7,7 +7,6 @@
#include <memory>
#include <utility>
-#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/base/x/x11_util.h"
@@ -108,15 +107,18 @@ class OzonePlatformX11 : public OzonePlatform {
private:
// Performs initialization steps need by both UI and GPU.
void InitializeCommon(const InitParams& params) {
- // TODO(kylechar): Add DCHECK we only enter InitializeCommon() twice for
- // single process mode.
if (common_initialized_)
return;
- // Always initialze in multi-thread mode, since this is used only during
+ // Always initialize in multi-thread mode, since this is used only during
// development.
XInitThreads();
+ // If XOpenDisplay() failed there is nothing we can do. Crash here instead
+ // of crashing later. If you are crashing here, make sure there is an X
+ // server running and $DISPLAY is set.
+ CHECK(gfx::GetXDisplay()) << "Missing X server or $DISPLAY";
+
ui::SetDefaultX11ErrorHandlers();
common_initialized_ = true;
diff --git a/chromium/ui/ozone/platform/x11/x11_surface_factory.cc b/chromium/ui/ozone/platform/x11/x11_surface_factory.cc
index 95ec3306ad3..b0207c19c71 100644
--- a/chromium/ui/ozone/platform/x11/x11_surface_factory.cc
+++ b/chromium/ui/ozone/platform/x11/x11_surface_factory.cc
@@ -4,7 +4,6 @@
#include "ui/ozone/platform/x11/x11_surface_factory.h"
-#include "base/memory/ptr_util.h"
#include "ui/gfx/x/x11.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gl/gl_surface_egl.h"
diff --git a/chromium/ui/ozone/platform/x11/x11_window_manager_ozone.cc b/chromium/ui/ozone/platform/x11/x11_window_manager_ozone.cc
index 494c43cd6f2..100bc2e793e 100644
--- a/chromium/ui/ozone/platform/x11/x11_window_manager_ozone.cc
+++ b/chromium/ui/ozone/platform/x11/x11_window_manager_ozone.cc
@@ -13,14 +13,20 @@ X11WindowManagerOzone::X11WindowManagerOzone() : event_grabber_(nullptr) {}
X11WindowManagerOzone::~X11WindowManagerOzone() {}
void X11WindowManagerOzone::GrabEvents(X11WindowOzone* window) {
- if (event_grabber_ != window)
+ if (event_grabber_ == window)
return;
+
+ X11WindowOzone* old_grabber = event_grabber_;
+ if (old_grabber)
+ old_grabber->OnLostCapture();
+
event_grabber_ = window;
}
void X11WindowManagerOzone::UngrabEvents(X11WindowOzone* window) {
if (event_grabber_ != window)
return;
+ event_grabber_->OnLostCapture();
event_grabber_ = nullptr;
}
diff --git a/chromium/ui/ozone/platform/x11/x11_window_manager_ozone.h b/chromium/ui/ozone/platform/x11/x11_window_manager_ozone.h
index 884425c8571..81250ddf6ae 100644
--- a/chromium/ui/ozone/platform/x11/x11_window_manager_ozone.h
+++ b/chromium/ui/ozone/platform/x11/x11_window_manager_ozone.h
@@ -16,11 +16,12 @@ class X11WindowManagerOzone {
X11WindowManagerOzone();
~X11WindowManagerOzone();
- // Tries to set a given X11WindowOzone as the recipient for events. It will
- // fail if there is already another X11WindowOzone as recipient.
+ // Sets a given X11WindowOzone as the recipient for events and calls
+ // OnLostCapture for another |event_grabber_| if it has been set previously.
void GrabEvents(X11WindowOzone* window);
- // Unsets a given X11WindowOzone as the recipient for events.
+ // Unsets a given X11WindowOzone as the recipient for events and calls
+ // OnLostCapture.
void UngrabEvents(X11WindowOzone* window);
// Gets the current X11WindowOzone recipient of mouse events.
diff --git a/chromium/ui/ozone/platform/x11/x11_window_ozone.cc b/chromium/ui/ozone/platform/x11/x11_window_ozone.cc
index 1ce459877dc..c3f17315009 100644
--- a/chromium/ui/ozone/platform/x11/x11_window_ozone.cc
+++ b/chromium/ui/ozone/platform/x11/x11_window_ozone.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "ui/events/event.h"
+#include "ui/events/event_utils.h"
#include "ui/events/ozone/events_ozone.h"
#include "ui/events/platform/x11/x11_event_source.h"
#include "ui/gfx/geometry/point.h"
@@ -68,17 +69,33 @@ bool X11WindowOzone::DispatchXEvent(XEvent* xev) {
return true;
}
-bool X11WindowOzone::CanDispatchEvent(const PlatformEvent& platform_event) {
+bool X11WindowOzone::CanDispatchEvent(const PlatformEvent& event) {
return handle_next_event_;
}
-uint32_t X11WindowOzone::DispatchEvent(const PlatformEvent& platform_event) {
- // This is unfortunately needed otherwise events that depend on global state
- // (eg. double click) are broken.
- DispatchEventFromNativeUiEvent(
- platform_event, base::BindOnce(&PlatformWindowDelegate::DispatchEvent,
- base::Unretained(delegate())));
- return POST_DISPATCH_STOP_PROPAGATION;
+uint32_t X11WindowOzone::DispatchEvent(const PlatformEvent& event) {
+ if (!window_manager_->event_grabber() ||
+ window_manager_->event_grabber() == this) {
+ // This is unfortunately needed otherwise events that depend on global state
+ // (eg. double click) are broken.
+ DispatchEventFromNativeUiEvent(
+ event, base::BindOnce(&PlatformWindowDelegate::DispatchEvent,
+ base::Unretained(delegate())));
+ return POST_DISPATCH_STOP_PROPAGATION;
+ }
+
+ if (event->IsLocatedEvent()) {
+ // Another X11WindowOzone has installed itself as capture. Translate the
+ // event's location and dispatch to the other.
+ ConvertEventLocationToTargetWindowLocation(
+ window_manager_->event_grabber()->GetBounds().origin(),
+ GetBounds().origin(), event->AsLocatedEvent());
+ }
+ return window_manager_->event_grabber()->DispatchEvent(event);
+}
+
+void X11WindowOzone::OnLostCapture() {
+ delegate()->OnLostCapture();
}
} // namespace ui
diff --git a/chromium/ui/ozone/platform/x11/x11_window_ozone.h b/chromium/ui/ozone/platform/x11/x11_window_ozone.h
index 48568ca420c..e1586341f19 100644
--- a/chromium/ui/ozone/platform/x11/x11_window_ozone.h
+++ b/chromium/ui/ozone/platform/x11/x11_window_ozone.h
@@ -24,6 +24,9 @@ class X11WindowOzone : public X11WindowBase,
const gfx::Rect& bounds);
~X11WindowOzone() override;
+ // Called by |window_manager_| once capture is set to another X11WindowOzone.
+ void OnLostCapture();
+
// PlatformWindow:
void PrepareForShutdown() override;
void SetCapture() override;
diff --git a/chromium/ui/ozone/platform/x11/x11_window_ozone_unittest.cc b/chromium/ui/ozone/platform/x11/x11_window_ozone_unittest.cc
new file mode 100644
index 00000000000..f770a61a243
--- /dev/null
+++ b/chromium/ui/ozone/platform/x11/x11_window_ozone_unittest.cc
@@ -0,0 +1,150 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/ozone/platform/x11/x11_window_ozone.h"
+
+#include "base/run_loop.h"
+#include "base/test/scoped_task_environment.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/events/devices/x11/touch_factory_x11.h"
+#include "ui/events/event.h"
+#include "ui/events/platform/x11/x11_event_source_libevent.h"
+#include "ui/events/test/events_test_utils_x11.h"
+#include "ui/ozone/platform/x11/x11_window_manager_ozone.h"
+#include "ui/ozone/test/mock_platform_window_delegate.h"
+#include "ui/platform_window/platform_window_delegate.h"
+
+namespace ui {
+
+namespace {
+
+using ::testing::Eq;
+using ::testing::_;
+
+constexpr int kPointerDeviceId = 1;
+
+ACTION_P(StoreWidget, widget_ptr) {
+ *widget_ptr = arg0;
+}
+
+ACTION_P(CloneEvent, event_ptr) {
+ *event_ptr = Event::Clone(*arg0);
+}
+
+} // namespace
+
+class X11WindowOzoneTest : public testing::Test {
+ public:
+ X11WindowOzoneTest()
+ : task_env_(std::make_unique<base::test::ScopedTaskEnvironment>(
+ base::test::ScopedTaskEnvironment::MainThreadType::UI)) {}
+
+ ~X11WindowOzoneTest() override = default;
+
+ void SetUp() override {
+ XDisplay* display = gfx::GetXDisplay();
+ event_source_ = std::make_unique<X11EventSourceLibevent>(display);
+ window_manager_ = std::make_unique<X11WindowManagerOzone>();
+
+ TouchFactory::GetInstance()->SetPointerDeviceForTest({kPointerDeviceId});
+ }
+
+ protected:
+ std::unique_ptr<PlatformWindow> CreatePlatformWindow(
+ MockPlatformWindowDelegate* delegate,
+ const gfx::Rect& bounds,
+ gfx::AcceleratedWidget* widget) {
+ EXPECT_CALL(*delegate, OnAcceleratedWidgetAvailable(_, _))
+ .WillOnce(StoreWidget(widget));
+ auto window = std::make_unique<X11WindowOzone>(window_manager_.get(),
+ delegate, bounds);
+ return std::move(window);
+ }
+
+ void DispatchXEvent(XEvent* event, gfx::AcceleratedWidget widget) {
+ DCHECK_EQ(GenericEvent, event->type);
+ XIDeviceEvent* device_event =
+ static_cast<XIDeviceEvent*>(event->xcookie.data);
+ device_event->event = widget;
+ event_source_->ProcessXEvent(event);
+ }
+
+ private:
+ std::unique_ptr<base::test::ScopedTaskEnvironment> task_env_;
+ std::unique_ptr<X11WindowManagerOzone> window_manager_;
+ std::unique_ptr<X11EventSourceLibevent> event_source_;
+
+ DISALLOW_COPY_AND_ASSIGN(X11WindowOzoneTest);
+};
+
+// This test ensures that events are handled by a right target(widget).
+TEST_F(X11WindowOzoneTest, SendPlatformEventToRightTarget) {
+ MockPlatformWindowDelegate delegate;
+ gfx::AcceleratedWidget widget;
+ constexpr gfx::Rect bounds(30, 80, 800, 600);
+ auto window = CreatePlatformWindow(&delegate, bounds, &widget);
+
+ ScopedXI2Event xi_event;
+ xi_event.InitGenericButtonEvent(kPointerDeviceId, ET_MOUSE_PRESSED,
+ gfx::Point(218, 290), EF_NONE);
+
+ // First check events can be received by a target window.
+ std::unique_ptr<Event> event;
+ EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
+
+ DispatchXEvent(xi_event, widget);
+ EXPECT_EQ(ET_MOUSE_PRESSED, event->type());
+ testing::Mock::VerifyAndClearExpectations(&delegate);
+
+ MockPlatformWindowDelegate delegate_2;
+ gfx::AcceleratedWidget widget_2;
+ gfx::Rect bounds_2(525, 155, 296, 407);
+
+ auto window_2 = CreatePlatformWindow(&delegate_2, bounds_2, &widget_2);
+
+ // Check event goes to right target without capture being set.
+ event.reset();
+ EXPECT_CALL(delegate, DispatchEvent(_)).Times(0);
+ EXPECT_CALL(delegate_2, DispatchEvent(_)).WillOnce(CloneEvent(&event));
+
+ DispatchXEvent(xi_event, widget_2);
+ EXPECT_EQ(ET_MOUSE_PRESSED, event->type());
+
+ EXPECT_CALL(delegate, OnClosed()).Times(1);
+ EXPECT_CALL(delegate_2, OnClosed()).Times(1);
+}
+
+// This test case ensures that events are consumed by a window with explicit
+// capture, even though the event is sent to other window.
+TEST_F(X11WindowOzoneTest, SendPlatformEventToCapturedWindow) {
+ MockPlatformWindowDelegate delegate;
+ gfx::AcceleratedWidget widget;
+ constexpr gfx::Rect bounds(30, 80, 800, 600);
+ EXPECT_CALL(delegate, OnClosed()).Times(1);
+ auto window = CreatePlatformWindow(&delegate, bounds, &widget);
+
+ MockPlatformWindowDelegate delegate_2;
+ gfx::AcceleratedWidget widget_2;
+ gfx::Rect bounds_2(525, 155, 296, 407);
+ EXPECT_CALL(delegate_2, OnClosed()).Times(1);
+ auto window_2 = CreatePlatformWindow(&delegate_2, bounds_2, &widget_2);
+
+ ScopedXI2Event xi_event;
+ xi_event.InitGenericButtonEvent(kPointerDeviceId, ET_MOUSE_PRESSED,
+ gfx::Point(218, 290), EF_NONE);
+
+ // Set capture to the second window, but send an event to another window
+ // target. The event must have its location converted and received by the
+ // captured window instead.
+ window_2->SetCapture();
+ std::unique_ptr<Event> event;
+ EXPECT_CALL(delegate, DispatchEvent(_)).Times(0);
+ EXPECT_CALL(delegate_2, DispatchEvent(_)).WillOnce(CloneEvent(&event));
+
+ DispatchXEvent(xi_event, widget);
+ EXPECT_EQ(ET_MOUSE_PRESSED, event->type());
+ EXPECT_EQ(gfx::Point(-277, 215), event->AsLocatedEvent()->location());
+}
+
+} // namespace ui
diff --git a/chromium/ui/ozone/public/client_native_pixmap_factory_ozone.cc b/chromium/ui/ozone/public/client_native_pixmap_factory_ozone.cc
index 110f816c557..7d6428b48d8 100644
--- a/chromium/ui/ozone/public/client_native_pixmap_factory_ozone.cc
+++ b/chromium/ui/ozone/public/client_native_pixmap_factory_ozone.cc
@@ -4,50 +4,17 @@
#include "ui/ozone/public/client_native_pixmap_factory_ozone.h"
-#include <memory>
-
-#include "base/memory/singleton.h"
#include "base/trace_event/trace_event.h"
-#include "ui/gfx/client_native_pixmap_factory.h"
#include "ui/ozone/platform_object.h"
#include "ui/ozone/platform_selection.h"
namespace ui {
-namespace {
-
-// Thread-safe owner of the gfx::ClientNativePixmapFactory. Not a LazyInstance
-// because it uses PlatformObject<>::Create() for factory construction.
-// TODO(jamescook|spang): This exists to solve a startup race for chrome with
-// mash http://crbug.com/807781. Removing the factory entirely would be better,
-// with something like http://crrev.com/c/899949.
-class PixmapFactorySingleton {
- public:
- static PixmapFactorySingleton* GetInstance() {
- return base::Singleton<PixmapFactorySingleton>::get();
- }
-
- private:
- friend struct base::DefaultSingletonTraits<PixmapFactorySingleton>;
-
- PixmapFactorySingleton() {
- TRACE_EVENT1("ozone", "CreateClientNativePixmapFactoryOzone", "platform",
- GetOzonePlatformName());
- pixmap_factory_ = PlatformObject<gfx::ClientNativePixmapFactory>::Create();
- gfx::ClientNativePixmapFactory::SetInstance(pixmap_factory_.get());
- }
-
- std::unique_ptr<gfx::ClientNativePixmapFactory> pixmap_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(PixmapFactorySingleton);
-};
-
-} // namespace
-void CreateClientNativePixmapFactoryOzone() {
- // Multiple threads may race to create the factory (e.g. when the UI service
- // and ash service are running in the same process). Create the object as a
- // side effect of a thread-safe singleton.
- PixmapFactorySingleton::GetInstance();
+std::unique_ptr<gfx::ClientNativePixmapFactory>
+CreateClientNativePixmapFactoryOzone() {
+ TRACE_EVENT1("ozone", "CreateClientNativePixmapFactoryOzone", "platform",
+ GetOzonePlatformName());
+ return PlatformObject<gfx::ClientNativePixmapFactory>::Create();
}
} // namespace ui
diff --git a/chromium/ui/ozone/public/client_native_pixmap_factory_ozone.h b/chromium/ui/ozone/public/client_native_pixmap_factory_ozone.h
index 29d6b5019e4..744e868ad85 100644
--- a/chromium/ui/ozone/public/client_native_pixmap_factory_ozone.h
+++ b/chromium/ui/ozone/public/client_native_pixmap_factory_ozone.h
@@ -5,14 +5,13 @@
#ifndef UI_OZONE_PUBLIC_CLIENT_NATIVE_PIXMAP_FACTORY_OZONE_H_
#define UI_OZONE_PUBLIC_CLIENT_NATIVE_PIXMAP_FACTORY_OZONE_H_
+#include "ui/gfx/client_native_pixmap_factory.h"
#include "ui/ozone/ozone_export.h"
namespace ui {
-// Creates a factory for pixmaps that can use be transported from the client to
-// the GPU process using a low-level ozone-provided platform specific mechanism.
-// The factory is installed as the gfx::ClientNativePixmapFactory instance.
-OZONE_EXPORT void CreateClientNativePixmapFactoryOzone();
+OZONE_EXPORT std::unique_ptr<gfx::ClientNativePixmapFactory>
+CreateClientNativePixmapFactoryOzone();
} // namespace ui
diff --git a/chromium/ui/ozone/public/interfaces/BUILD.gn b/chromium/ui/ozone/public/interfaces/BUILD.gn
index b9e7663b08c..ec7f11f2836 100644
--- a/chromium/ui/ozone/public/interfaces/BUILD.gn
+++ b/chromium/ui/ozone/public/interfaces/BUILD.gn
@@ -12,7 +12,7 @@ mojom("interfaces") {
]
public_deps = [
- "//mojo/common:common_custom_types",
+ "//mojo/public/mojom/base",
"//skia/public/interfaces:interfaces",
"//ui/display/mojo:interfaces",
"//ui/gfx/geometry/mojo",
diff --git a/chromium/ui/ozone/public/interfaces/drm_device.mojom b/chromium/ui/ozone/public/interfaces/drm_device.mojom
index eede42437b0..48ea6df2d89 100644
--- a/chromium/ui/ozone/public/interfaces/drm_device.mojom
+++ b/chromium/ui/ozone/public/interfaces/drm_device.mojom
@@ -4,8 +4,8 @@
module ui.ozone.mojom;
-import "mojo/common/file.mojom";
-import "mojo/common/file_path.mojom";
+import "mojo/public/mojom/base/file.mojom";
+import "mojo/public/mojom/base/file_path.mojom";
import "ui/display/mojo/display_constants.mojom";
import "ui/display/mojo/display_mode.mojom";
import "ui/display/mojo/display_snapshot.mojom";
@@ -46,11 +46,11 @@ interface DrmDevice {
(array<display.mojom.DisplaySnapshot> display_snapshots);
// Transfers ownership of a DRM device to the GPU process.
- AddGraphicsDevice(mojo.common.mojom.FilePath path,
- mojo.common.mojom.File file);
+ AddGraphicsDevice(mojo_base.mojom.FilePath path,
+ mojo_base.mojom.File file);
// Instructs the GPU to abandon a DRM device.
- RemoveGraphicsDevice(mojo.common.mojom.FilePath path);
+ RemoveGraphicsDevice(mojo_base.mojom.FilePath path);
// Instructs the GPU to disable a DRM device.
DisableNativeDisplay(int64 display_id) => (int64 display_id, bool success);
diff --git a/chromium/ui/ozone/public/ozone_gpu_test_helper.cc b/chromium/ui/ozone/public/ozone_gpu_test_helper.cc
index cc89a0e3cac..3ade4fe580f 100644
--- a/chromium/ui/ozone/public/ozone_gpu_test_helper.cc
+++ b/chromium/ui/ozone/public/ozone_gpu_test_helper.cc
@@ -5,6 +5,7 @@
#include "ui/ozone/public/ozone_gpu_test_helper.h"
#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
#include "base/threading/thread.h"
#include "base/threading/thread_task_runner_handle.h"
#include "ipc/ipc_listener.h"
@@ -55,7 +56,7 @@ class FakeGpuProcess : public IPC::Channel {
// IPC::Channel implementation:
bool Send(IPC::Message* msg) override {
ui_task_runner_->PostTask(
- FROM_HERE, base::Bind(&DispatchToGpuPlatformSupportHostTask, msg));
+ FROM_HERE, base::BindOnce(&DispatchToGpuPlatformSupportHostTask, msg));
return true;
}
@@ -109,16 +110,24 @@ bool OzoneGpuTestHelper::Initialize(
fake_gpu_process_.reset(new FakeGpuProcess(ui_task_runner));
io_helper_thread_->task_runner()->PostTask(
- FROM_HERE, base::Bind(&FakeGpuProcess::InitOnIO,
- base::Unretained(fake_gpu_process_.get())));
+ FROM_HERE, base::BindOnce(&FakeGpuProcess::InitOnIO,
+ base::Unretained(fake_gpu_process_.get())));
fake_gpu_process_host_.reset(new FakeGpuProcessHost(
ui_task_runner, io_helper_thread_->task_runner()));
io_helper_thread_->task_runner()->PostTask(
- FROM_HERE, base::Bind(&FakeGpuProcessHost::InitOnIO,
- base::Unretained(fake_gpu_process_host_.get())));
+ FROM_HERE,
+ base::BindOnce(&FakeGpuProcessHost::InitOnIO,
+ base::Unretained(fake_gpu_process_host_.get())));
io_helper_thread_->FlushForTesting();
+ // Give the UI thread a chance to run any tasks posted from the IO thread
+ // after the GPU process is launched. This is needed for Ozone DRM, see
+ // https://crbug.com/830233.
+ base::RunLoop run_loop;
+ ui_task_runner->PostTask(FROM_HERE, run_loop.QuitClosure());
+ run_loop.Run();
+
return true;
}
diff --git a/chromium/ui/ozone/public/ozone_platform.cc b/chromium/ui/ozone/public/ozone_platform.cc
index 58c114ba430..2457d0b89e2 100644
--- a/chromium/ui/ozone/public/ozone_platform.cc
+++ b/chromium/ui/ozone/public/ozone_platform.cc
@@ -42,8 +42,11 @@ void OzonePlatform::InitializeForUI(const InitParams& args) {
EnsureInstance();
if (g_platform_initialized_ui)
return;
- g_platform_initialized_ui = true;
instance_->InitializeUI(args);
+ {
+ base::AutoLock lock(GetOzoneInstanceLock());
+ g_platform_initialized_ui = true;
+ }
// This is deliberately created after initializing so that the platform can
// create its own version of DDM.
DeviceDataManager::CreateInstance();
@@ -56,8 +59,11 @@ void OzonePlatform::InitializeForGPU(const InitParams& args) {
EnsureInstance();
if (g_platform_initialized_gpu)
return;
- g_platform_initialized_gpu = true;
instance_->InitializeGPU(args);
+ {
+ base::AutoLock lock(GetOzoneInstanceLock());
+ g_platform_initialized_gpu = true;
+ }
if (!args.single_process && !instance_callback.Get().is_null())
std::move(instance_callback.Get()).Run(instance_);
}
diff --git a/chromium/ui/ozone/public/ozone_platform.h b/chromium/ui/ozone/public/ozone_platform.h
index f715a6af03a..008e2c20d29 100644
--- a/chromium/ui/ozone/public/ozone_platform.h
+++ b/chromium/ui/ozone/public/ozone_platform.h
@@ -13,7 +13,6 @@
#include "services/service_manager/public/cpp/binder_registry.h"
#include "ui/events/system_input_injector.h"
#include "ui/ozone/ozone_export.h"
-//#include "ui/ozone/public/interfaces/drm_device.mojom.h"
namespace display {
class NativeDisplayDelegate;
@@ -78,9 +77,9 @@ class OZONE_EXPORT OzonePlatform {
// split between a host and viz specific portion.
bool single_process = false;
- // Setting this to true indicates that the platform implementation should
- // use mojo. Setting this to true requires calling |AddInterfaces|
- // afterwards in the Viz process and providing a connector as part
+ // Setting this to true indicates that the platform implementation should
+ // use mojo. Setting this to true requires calling |AddInterfaces|
+ // afterwards in the Viz process and providing a connector as part.
bool using_mojo = false;
};