[go: nahoru, domu]

[ozone/wayland/drm] Place OverlayPlane and ScanoutBuffer into shared place.

This CL is a part of Wayland gpu/ui split effort, which fixes the
Ozone/Wayland and mades it functional when the gpu service is running
out of the browser process.

The patch does not bring any functionality changes, but rather
prepares Ozone/Wayland for a dmabuf based approach, which uses ozone/drm code,
to be landed in the upstream.

In particular, overlay_plane.cc/h and scanout_buffer.h are
moved into a common folder in the ui/ozone/common/linux.
These are only compiled for wayland (downstream now) and drm backends,
and does not bring any additional load on other backends.

Bug: 820047
Change-Id: I1268eeb38e710e9a1c335def08fa94edf103095f
Reviewed-on: https://chromium-review.googlesource.com/1071928
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Reviewed-by: Robert Kroeger <rjkroege@chromium.org>
Cr-Commit-Position: refs/heads/master@{#562465}
diff --git a/ui/ozone/common/BUILD.gn b/ui/ozone/common/BUILD.gn
index daefe0e2..dd515d1 100644
--- a/ui/ozone/common/BUILD.gn
+++ b/ui/ozone/common/BUILD.gn
@@ -48,6 +48,9 @@
     sources = [
       "linux/drm_util_linux.cc",
       "linux/drm_util_linux.h",
+      "linux/overlay_plane.cc",
+      "linux/overlay_plane.h",
+      "linux/scanout_buffer.h",
     ]
 
     deps = [
@@ -55,6 +58,8 @@
       "//third_party/libdrm",
       "//third_party/minigbm",
       "//ui/gfx:buffer_types",
+      "//ui/gfx:memory_buffer",
+      "//ui/gfx/geometry:geometry",
     ]
 
     visibility = [ "//ui/ozone/platform/drm/*" ]
diff --git a/ui/ozone/common/linux/OWNERS b/ui/ozone/common/linux/OWNERS
new file mode 100644
index 0000000..363a93a
--- /dev/null
+++ b/ui/ozone/common/linux/OWNERS
@@ -0,0 +1,2 @@
+dcastagna@chromium.org
+dnicoara@chromium.org
diff --git a/ui/ozone/platform/drm/gpu/overlay_plane.cc b/ui/ozone/common/linux/overlay_plane.cc
similarity index 92%
rename from ui/ozone/platform/drm/gpu/overlay_plane.cc
rename to ui/ozone/common/linux/overlay_plane.cc
index be15821..5bbeadf 100644
--- a/ui/ozone/platform/drm/gpu/overlay_plane.cc
+++ b/ui/ozone/common/linux/overlay_plane.cc
@@ -2,11 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "ui/ozone/platform/drm/gpu/overlay_plane.h"
+#include "ui/ozone/common/linux/overlay_plane.h"
 
 #include <stddef.h>
 
-#include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
+#include "ui/ozone/common/linux/scanout_buffer.h"
 
 namespace ui {
 
@@ -36,8 +36,7 @@
 
 OverlayPlane::OverlayPlane(const OverlayPlane& other) = default;
 
-OverlayPlane::~OverlayPlane() {
-}
+OverlayPlane::~OverlayPlane() {}
 
 bool OverlayPlane::operator<(const OverlayPlane& plane) const {
   return std::tie(z_order, display_bounds, crop_rect, plane_transform) <
diff --git a/ui/ozone/platform/drm/gpu/overlay_plane.h b/ui/ozone/common/linux/overlay_plane.h
similarity index 90%
rename from ui/ozone/platform/drm/gpu/overlay_plane.h
rename to ui/ozone/common/linux/overlay_plane.h
index 34e4e1b..11cf463 100644
--- a/ui/ozone/platform/drm/gpu/overlay_plane.h
+++ b/ui/ozone/common/linux/overlay_plane.h
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef UI_OZONE_PLATFORM_DRM_GPU_OVERLAY_PLANE_H_
-#define UI_OZONE_PLATFORM_DRM_GPU_OVERLAY_PLANE_H_
+#ifndef UI_OZONE_COMMON_LINUX_OVERLAY_PLANE_H_
+#define UI_OZONE_COMMON_LINUX_OVERLAY_PLANE_H_
 
 #include <vector>
 
@@ -56,4 +56,4 @@
 
 }  // namespace ui
 
-#endif  // UI_OZONE_PLATFORM_DRM_GPU_OVERLAY_PLANE_H_
+#endif  // UI_OZONE_COMMON_LINUX_OVERLAY_PLANE_H_
diff --git a/ui/ozone/platform/drm/gpu/scanout_buffer.h b/ui/ozone/common/linux/scanout_buffer.h
similarity index 92%
rename from ui/ozone/platform/drm/gpu/scanout_buffer.h
rename to ui/ozone/common/linux/scanout_buffer.h
index 3d4f2c3..8aa8fe8 100644
--- a/ui/ozone/platform/drm/gpu/scanout_buffer.h
+++ b/ui/ozone/common/linux/scanout_buffer.h
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef UI_OZONE_PLATFORM_DRM_GPU_SCANOUT_BUFFER_H_
-#define UI_OZONE_PLATFORM_DRM_GPU_SCANOUT_BUFFER_H_
+#ifndef UI_OZONE_COMMON_LINUX_SCANOUT_BUFFER_H_
+#define UI_OZONE_COMMON_LINUX_SCANOUT_BUFFER_H_
 
 #include <stdint.h>
 
@@ -67,4 +67,4 @@
 
 }  // namespace ui
 
-#endif  // UI_OZONE_PLATFORM_DRM_GPU_SCANOUT_BUFFER_H_
+#endif  // UI_OZONE_COMMON_LINUX_SCANOUT_BUFFER_H_
diff --git a/ui/ozone/platform/drm/BUILD.gn b/ui/ozone/platform/drm/BUILD.gn
index 46d5be8..00c1368 100644
--- a/ui/ozone/platform/drm/BUILD.gn
+++ b/ui/ozone/platform/drm/BUILD.gn
@@ -74,13 +74,10 @@
     "gpu/hardware_display_plane_manager_legacy.h",
     "gpu/inter_thread_messaging_proxy.cc",
     "gpu/inter_thread_messaging_proxy.h",
-    "gpu/overlay_plane.cc",
-    "gpu/overlay_plane.h",
     "gpu/page_flip_request.cc",
     "gpu/page_flip_request.h",
     "gpu/proxy_helpers.cc",
     "gpu/proxy_helpers.h",
-    "gpu/scanout_buffer.h",
     "gpu/screen_manager.cc",
     "gpu/screen_manager.h",
     "host/drm_cursor.cc",
diff --git a/ui/ozone/platform/drm/gpu/crtc_controller.cc b/ui/ozone/platform/drm/gpu/crtc_controller.cc
index 329e6d0..b49b897 100644
--- a/ui/ozone/platform/drm/gpu/crtc_controller.cc
+++ b/ui/ozone/platform/drm/gpu/crtc_controller.cc
@@ -7,10 +7,10 @@
 #include "base/logging.h"
 #include "base/time/time.h"
 #include "ui/gfx/presentation_feedback.h"
+#include "ui/ozone/common/linux/scanout_buffer.h"
 #include "ui/ozone/platform/drm/gpu/drm_device.h"
 #include "ui/ozone/platform/drm/gpu/hardware_display_plane.h"
 #include "ui/ozone/platform/drm/gpu/page_flip_request.h"
-#include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
 
 namespace ui {
 
diff --git a/ui/ozone/platform/drm/gpu/crtc_controller.h b/ui/ozone/platform/drm/gpu/crtc_controller.h
index 98b27671..f9a089a 100644
--- a/ui/ozone/platform/drm/gpu/crtc_controller.h
+++ b/ui/ozone/platform/drm/gpu/crtc_controller.h
@@ -14,9 +14,9 @@
 #include "base/observer_list.h"
 #include "base/time/time.h"
 #include "ui/gfx/swap_result.h"
+#include "ui/ozone/common/linux/overlay_plane.h"
 #include "ui/ozone/platform/drm/common/scoped_drm_types.h"
 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h"
-#include "ui/ozone/platform/drm/gpu/overlay_plane.h"
 
 namespace gfx {
 struct PresentationFeedback;
diff --git a/ui/ozone/platform/drm/gpu/drm_buffer.h b/ui/ozone/platform/drm/gpu/drm_buffer.h
index dc6ed49..845f65be 100644
--- a/ui/ozone/platform/drm/gpu/drm_buffer.h
+++ b/ui/ozone/platform/drm/gpu/drm_buffer.h
@@ -10,7 +10,7 @@
 
 #include "base/macros.h"
 #include "third_party/skia/include/core/SkRefCnt.h"
-#include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
+#include "ui/ozone/common/linux/scanout_buffer.h"
 
 class SkCanvas;
 struct SkImageInfo;
diff --git a/ui/ozone/platform/drm/gpu/drm_overlay_validator.cc b/ui/ozone/platform/drm/gpu/drm_overlay_validator.cc
index 3f82bdd..7f95ff1 100644
--- a/ui/ozone/platform/drm/gpu/drm_overlay_validator.cc
+++ b/ui/ozone/platform/drm/gpu/drm_overlay_validator.cc
@@ -9,11 +9,11 @@
 #include "base/files/platform_file.h"
 #include "ui/gfx/geometry/size_conversions.h"
 #include "ui/ozone/common/linux/drm_util_linux.h"
+#include "ui/ozone/common/linux/scanout_buffer.h"
 #include "ui/ozone/platform/drm/common/drm_util.h"
 #include "ui/ozone/platform/drm/gpu/drm_device.h"
 #include "ui/ozone/platform/drm/gpu/drm_window.h"
 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h"
-#include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
 
 namespace ui {
 
diff --git a/ui/ozone/platform/drm/gpu/drm_overlay_validator.h b/ui/ozone/platform/drm/gpu/drm_overlay_validator.h
index 64dc7b9..ec10780 100644
--- a/ui/ozone/platform/drm/gpu/drm_overlay_validator.h
+++ b/ui/ozone/platform/drm/gpu/drm_overlay_validator.h
@@ -6,7 +6,7 @@
 #define UI_OZONE_PLATFORM_DRM_GPU_DRM_OVERLAY_VALIDATOR_H_
 
 #include "base/containers/mru_cache.h"
-#include "ui/ozone/platform/drm/gpu/overlay_plane.h"
+#include "ui/ozone/common/linux/overlay_plane.h"
 
 namespace ui {
 
diff --git a/ui/ozone/platform/drm/gpu/drm_window.h b/ui/ozone/platform/drm/gpu/drm_window.h
index fa84f66..ec5fab2 100644
--- a/ui/ozone/platform/drm/gpu/drm_window.h
+++ b/ui/ozone/platform/drm/gpu/drm_window.h
@@ -14,7 +14,7 @@
 #include "ui/gfx/native_widget_types.h"
 #include "ui/gfx/swap_result.h"
 #include "ui/gfx/vsync_provider.h"
-#include "ui/ozone/platform/drm/gpu/overlay_plane.h"
+#include "ui/ozone/common/linux/overlay_plane.h"
 #include "ui/ozone/platform/drm/gpu/page_flip_request.h"
 #include "ui/ozone/public/swap_completion_callback.h"
 
diff --git a/ui/ozone/platform/drm/gpu/drm_window_proxy.cc b/ui/ozone/platform/drm/gpu/drm_window_proxy.cc
index f5f882a..1ec1141 100644
--- a/ui/ozone/platform/drm/gpu/drm_window_proxy.cc
+++ b/ui/ozone/platform/drm/gpu/drm_window_proxy.cc
@@ -5,10 +5,10 @@
 #include "ui/ozone/platform/drm/gpu/drm_window_proxy.h"
 
 #include "ui/gfx/presentation_feedback.h"
+#include "ui/ozone/common/linux/overlay_plane.h"
+#include "ui/ozone/common/linux/scanout_buffer.h"
 #include "ui/ozone/platform/drm/gpu/drm_thread.h"
-#include "ui/ozone/platform/drm/gpu/overlay_plane.h"
 #include "ui/ozone/platform/drm/gpu/proxy_helpers.h"
-#include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
 
 namespace ui {
 
diff --git a/ui/ozone/platform/drm/gpu/gbm_buffer.h b/ui/ozone/platform/drm/gpu/gbm_buffer.h
index e647e1c..bfbb733a 100644
--- a/ui/ozone/platform/drm/gpu/gbm_buffer.h
+++ b/ui/ozone/platform/drm/gpu/gbm_buffer.h
@@ -12,7 +12,7 @@
 #include "ui/gfx/buffer_types.h"
 #include "ui/gfx/geometry/size.h"
 #include "ui/gfx/native_pixmap.h"
-#include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
+#include "ui/ozone/common/linux/scanout_buffer.h"
 
 struct gbm_bo;
 
diff --git a/ui/ozone/platform/drm/gpu/gbm_surfaceless.cc b/ui/ozone/platform/drm/gpu/gbm_surfaceless.cc
index 4375553..ff82cc0 100644
--- a/ui/ozone/platform/drm/gpu/gbm_surfaceless.cc
+++ b/ui/ozone/platform/drm/gpu/gbm_surfaceless.cc
@@ -13,10 +13,10 @@
 #include "ui/gfx/gpu_fence.h"
 #include "ui/gfx/presentation_feedback.h"
 #include "ui/ozone/common/egl_util.h"
+#include "ui/ozone/common/linux/scanout_buffer.h"
 #include "ui/ozone/platform/drm/gpu/drm_vsync_provider.h"
 #include "ui/ozone/platform/drm/gpu/drm_window_proxy.h"
 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h"
-#include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
 
 namespace ui {
 
diff --git a/ui/ozone/platform/drm/gpu/gbm_surfaceless.h b/ui/ozone/platform/drm/gpu/gbm_surfaceless.h
index cc42f71..e9e7a412 100644
--- a/ui/ozone/platform/drm/gpu/gbm_surfaceless.h
+++ b/ui/ozone/platform/drm/gpu/gbm_surfaceless.h
@@ -15,7 +15,7 @@
 #include "ui/gl/gl_surface_egl.h"
 #include "ui/gl/gl_surface_overlay.h"
 #include "ui/gl/scoped_binders.h"
-#include "ui/ozone/platform/drm/gpu/overlay_plane.h"
+#include "ui/ozone/common/linux/overlay_plane.h"
 
 namespace ui {
 
diff --git a/ui/ozone/platform/drm/gpu/hardware_display_controller.h b/ui/ozone/platform/drm/gpu/hardware_display_controller.h
index 1fa3665..1ecc4443 100644
--- a/ui/ozone/platform/drm/gpu/hardware_display_controller.h
+++ b/ui/ozone/platform/drm/gpu/hardware_display_controller.h
@@ -18,8 +18,8 @@
 #include "base/macros.h"
 #include "base/time/time.h"
 #include "ui/gfx/swap_result.h"
+#include "ui/ozone/common/linux/overlay_plane.h"
 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h"
-#include "ui/ozone/platform/drm/gpu/overlay_plane.h"
 #include "ui/ozone/public/swap_completion_callback.h"
 
 namespace gfx {
diff --git a/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.cc b/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.cc
index f6aa5f3..c221350 100644
--- a/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.cc
+++ b/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.cc
@@ -14,11 +14,11 @@
 #include "base/posix/safe_strerror.h"
 #include "base/trace_event/trace_event.h"
 #include "ui/gfx/geometry/rect.h"
+#include "ui/ozone/common/linux/scanout_buffer.h"
 #include "ui/ozone/platform/drm/gpu/drm_device.h"
 #include "ui/ozone/platform/drm/gpu/drm_gpu_util.h"
 #include "ui/ozone/platform/drm/gpu/hardware_display_plane.h"
 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_dummy.h"
-#include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
 
 namespace ui {
 namespace {
diff --git a/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h b/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h
index e053e5f..0cfd42d 100644
--- a/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h
+++ b/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h
@@ -12,9 +12,9 @@
 
 #include "base/macros.h"
 #include "ui/display/types/gamma_ramp_rgb_entry.h"
+#include "ui/ozone/common/linux/overlay_plane.h"
 #include "ui/ozone/platform/drm/common/scoped_drm_types.h"
 #include "ui/ozone/platform/drm/gpu/drm_device.h"
-#include "ui/ozone/platform/drm/gpu/overlay_plane.h"
 
 namespace gfx {
 class Rect;
diff --git a/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.cc b/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.cc
index 687dfa4..56e68e6 100644
--- a/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.cc
+++ b/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.cc
@@ -13,11 +13,11 @@
 #include "base/threading/sequenced_task_runner_handle.h"
 #include "ui/gfx/gpu_fence.h"
 #include "ui/gfx/gpu_fence_handle.h"
+#include "ui/ozone/common/linux/scanout_buffer.h"
 #include "ui/ozone/platform/drm/common/drm_util.h"
 #include "ui/ozone/platform/drm/gpu/crtc_controller.h"
 #include "ui/ozone/platform/drm/gpu/drm_device.h"
 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.h"
-#include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
 
 namespace ui {
 
diff --git a/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.cc b/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.cc
index 9db78c3..319097b 100644
--- a/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.cc
+++ b/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.cc
@@ -12,10 +12,10 @@
 #include "base/task_scheduler/post_task.h"
 #include "ui/gfx/gpu_fence.h"
 #include "ui/gfx/presentation_feedback.h"
+#include "ui/ozone/common/linux/scanout_buffer.h"
 #include "ui/ozone/platform/drm/gpu/crtc_controller.h"
 #include "ui/ozone/platform/drm/gpu/drm_device.h"
 #include "ui/ozone/platform/drm/gpu/hardware_display_plane.h"
-#include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
 
 namespace ui {
 
diff --git a/ui/ozone/platform/drm/gpu/mock_dumb_buffer_generator.h b/ui/ozone/platform/drm/gpu/mock_dumb_buffer_generator.h
index f29f7e2..2f68299 100644
--- a/ui/ozone/platform/drm/gpu/mock_dumb_buffer_generator.h
+++ b/ui/ozone/platform/drm/gpu/mock_dumb_buffer_generator.h
@@ -7,7 +7,7 @@
 
 #include "base/macros.h"
 
-#include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
+#include "ui/ozone/common/linux/scanout_buffer.h"
 
 namespace ui {
 
diff --git a/ui/ozone/platform/drm/gpu/mock_scanout_buffer.h b/ui/ozone/platform/drm/gpu/mock_scanout_buffer.h
index cbeb256..93a40e6 100644
--- a/ui/ozone/platform/drm/gpu/mock_scanout_buffer.h
+++ b/ui/ozone/platform/drm/gpu/mock_scanout_buffer.h
@@ -9,7 +9,7 @@
 #include <stdint.h>
 
 #include "base/macros.h"
-#include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
+#include "ui/ozone/common/linux/scanout_buffer.h"
 
 namespace ui {
 
diff --git a/ui/ozone/platform/drm/gpu/mock_scanout_buffer_generator.h b/ui/ozone/platform/drm/gpu/mock_scanout_buffer_generator.h
index c904501b..ad886c2 100644
--- a/ui/ozone/platform/drm/gpu/mock_scanout_buffer_generator.h
+++ b/ui/ozone/platform/drm/gpu/mock_scanout_buffer_generator.h
@@ -7,7 +7,7 @@
 
 #include "base/macros.h"
 
-#include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
+#include "ui/ozone/common/linux/scanout_buffer.h"
 
 namespace ui {
 
diff --git a/ui/ozone/platform/drm/gpu/screen_manager.cc b/ui/ozone/platform/drm/gpu/screen_manager.cc
index 3fdc922..165dcbb1 100644
--- a/ui/ozone/platform/drm/gpu/screen_manager.cc
+++ b/ui/ozone/platform/drm/gpu/screen_manager.cc
@@ -14,13 +14,13 @@
 #include "ui/gfx/geometry/point.h"
 #include "ui/gfx/geometry/rect.h"
 #include "ui/gfx/geometry/size.h"
+#include "ui/ozone/common/linux/scanout_buffer.h"
 #include "ui/ozone/platform/drm/common/drm_util.h"
 #include "ui/ozone/platform/drm/gpu/crtc_controller.h"
 #include "ui/ozone/platform/drm/gpu/drm_console_buffer.h"
 #include "ui/ozone/platform/drm/gpu/drm_device.h"
 #include "ui/ozone/platform/drm/gpu/drm_window.h"
 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h"
-#include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
 
 namespace ui {
 
diff --git a/ui/ozone/platform/drm/ozone_platform_gbm.cc b/ui/ozone/platform/drm/ozone_platform_gbm.cc
index a6e1286..a3f2586 100644
--- a/ui/ozone/platform/drm/ozone_platform_gbm.cc
+++ b/ui/ozone/platform/drm/ozone_platform_gbm.cc
@@ -23,6 +23,7 @@
 #include "ui/events/ozone/device/device_manager.h"
 #include "ui/events/ozone/evdev/event_factory_evdev.h"
 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
+#include "ui/ozone/common/linux/scanout_buffer.h"
 #include "ui/ozone/platform/drm/common/drm_util.h"
 #include "ui/ozone/platform/drm/gpu/drm_device_generator.h"
 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h"
@@ -31,7 +32,6 @@
 #include "ui/ozone/platform/drm/gpu/drm_thread_proxy.h"
 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h"
 #include "ui/ozone/platform/drm/gpu/proxy_helpers.h"
-#include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
 #include "ui/ozone/platform/drm/gpu/screen_manager.h"
 #include "ui/ozone/platform/drm/host/drm_cursor.h"
 #include "ui/ozone/platform/drm/host/drm_device_connector.h"