Commit 217b468d authored by Shawn Gallea's avatar Shawn Gallea Committed by Commit Bot

EXO: Refactor out CrOS-specific functionality (exo/display)

Prevented ChromeOS-specific funcionality from compiling
for other platforms. To be used for EXO on cast shell.
This CL does not offer any additional functionality.

Bug: 896710
Test: Run exo_unittests on ChromeOS
Change-Id: I72678ae35efce395f932b7d0ade816d61dd6e992
Reviewed-on: https://chromium-review.googlesource.com/c/1327402
Commit-Queue: Daniel Nicoara <dnicoara@chromium.org>
Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612224}
parent 15e8b301
...@@ -7,23 +7,18 @@ ...@@ -7,23 +7,18 @@
#include <iterator> #include <iterator>
#include <utility> #include <utility>
#include "ash/public/cpp/shell_window_ids.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "base/trace_event/traced_value.h" #include "base/trace_event/traced_value.h"
#include "components/exo/client_controlled_shell_surface.h"
#include "components/exo/data_device.h" #include "components/exo/data_device.h"
#include "components/exo/file_helper.h" #include "components/exo/file_helper.h"
#include "components/exo/input_method_surface.h"
#include "components/exo/input_method_surface_manager.h" #include "components/exo/input_method_surface_manager.h"
#include "components/exo/notification_surface.h" #include "components/exo/notification_surface.h"
#include "components/exo/notification_surface_manager.h" #include "components/exo/notification_surface_manager.h"
#include "components/exo/shared_memory.h" #include "components/exo/shared_memory.h"
#include "components/exo/shell_surface.h"
#include "components/exo/sub_surface.h" #include "components/exo/sub_surface.h"
#include "components/exo/surface.h" #include "components/exo/surface.h"
#include "components/exo/xdg_shell_surface.h"
#include "ui/gfx/linux/client_native_pixmap_factory_dmabuf.h" #include "ui/gfx/linux/client_native_pixmap_factory_dmabuf.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
#include "ui/wm/core/coordinate_conversion.h" #include "ui/wm/core/coordinate_conversion.h"
...@@ -37,26 +32,36 @@ ...@@ -37,26 +32,36 @@
#include "ui/ozone/public/ozone_switches.h" #include "ui/ozone/public/ozone_switches.h"
#endif #endif
#if defined(OS_CHROMEOS)
#include "ash/public/cpp/shell_window_ids.h"
#include "components/exo/client_controlled_shell_surface.h"
#include "components/exo/input_method_surface.h"
#include "components/exo/shell_surface.h"
#include "components/exo/xdg_shell_surface.h"
#endif
namespace exo { namespace exo {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Display, public: // Display, public:
Display::Display() : Display(nullptr, nullptr, std::unique_ptr<FileHelper>()) {} Display::Display() : file_helper_(std::unique_ptr<FileHelper>()) {}
#if defined(OS_CHROMEOS)
Display::Display(NotificationSurfaceManager* notification_surface_manager, Display::Display(NotificationSurfaceManager* notification_surface_manager,
InputMethodSurfaceManager* input_method_surface_manager, InputMethodSurfaceManager* input_method_surface_manager,
std::unique_ptr<FileHelper> file_helper) std::unique_ptr<FileHelper> file_helper)
: notification_surface_manager_(notification_surface_manager), : file_helper_(std::move(file_helper))
input_method_surface_manager_(input_method_surface_manager),
file_helper_(std::move(file_helper))
#if defined(USE_OZONE) #if defined(USE_OZONE)
, ,
client_native_pixmap_factory_( client_native_pixmap_factory_(
gfx::CreateClientNativePixmapFactoryDmabuf()) gfx::CreateClientNativePixmapFactoryDmabuf())
#endif #endif // defined(USE_OZONE)
{ {
notification_surface_manager_ = notification_surface_manager;
input_method_surface_manager_ = input_method_surface_manager;
} }
#endif // defined(OS_CHROMEOS)
Display::~Display() {} Display::~Display() {}
...@@ -118,8 +123,9 @@ std::unique_ptr<Buffer> Display::CreateLinuxDMABufBuffer( ...@@ -118,8 +123,9 @@ std::unique_ptr<Buffer> Display::CreateLinuxDMABufBuffer(
GL_COMMANDS_COMPLETED_CHROMIUM, use_zero_copy, is_overlay_candidate, GL_COMMANDS_COMPLETED_CHROMIUM, use_zero_copy, is_overlay_candidate,
y_invert); y_invert);
} }
#endif #endif // defined(USE_OZONE)
#if defined(OS_CHROMEOS)
std::unique_ptr<ShellSurface> Display::CreateShellSurface(Surface* surface) { std::unique_ptr<ShellSurface> Display::CreateShellSurface(Surface* surface) {
TRACE_EVENT1("exo", "Display::CreateShellSurface", "surface", TRACE_EVENT1("exo", "Display::CreateShellSurface", "surface",
surface->AsTracedValue()); surface->AsTracedValue());
...@@ -171,24 +177,6 @@ Display::CreateClientControlledShellSurface( ...@@ -171,24 +177,6 @@ Display::CreateClientControlledShellSurface(
return shell_surface; return shell_surface;
} }
std::unique_ptr<SubSurface> Display::CreateSubSurface(Surface* surface,
Surface* parent) {
TRACE_EVENT2("exo", "Display::CreateSubSurface", "surface",
surface->AsTracedValue(), "parent", parent->AsTracedValue());
if (surface->window()->Contains(parent->window())) {
DLOG(ERROR) << "Parent is contained within surface's hierarchy";
return nullptr;
}
if (surface->HasSurfaceDelegate()) {
DLOG(ERROR) << "Surface has already been assigned a role";
return nullptr;
}
return std::make_unique<SubSurface>(surface, parent);
}
std::unique_ptr<NotificationSurface> Display::CreateNotificationSurface( std::unique_ptr<NotificationSurface> Display::CreateNotificationSurface(
Surface* surface, Surface* surface,
const std::string& notification_key) { const std::string& notification_key) {
...@@ -205,11 +193,6 @@ std::unique_ptr<NotificationSurface> Display::CreateNotificationSurface( ...@@ -205,11 +193,6 @@ std::unique_ptr<NotificationSurface> Display::CreateNotificationSurface(
surface, notification_key); surface, notification_key);
} }
std::unique_ptr<DataDevice> Display::CreateDataDevice(
DataDeviceDelegate* delegate) {
return std::make_unique<DataDevice>(delegate, &seat_, file_helper_.get());
}
std::unique_ptr<InputMethodSurface> Display::CreateInputMethodSurface( std::unique_ptr<InputMethodSurface> Display::CreateInputMethodSurface(
Surface* surface, Surface* surface,
double default_device_scale_factor) { double default_device_scale_factor) {
...@@ -229,5 +212,29 @@ std::unique_ptr<InputMethodSurface> Display::CreateInputMethodSurface( ...@@ -229,5 +212,29 @@ std::unique_ptr<InputMethodSurface> Display::CreateInputMethodSurface(
return std::make_unique<InputMethodSurface>( return std::make_unique<InputMethodSurface>(
input_method_surface_manager_, surface, default_device_scale_factor); input_method_surface_manager_, surface, default_device_scale_factor);
} }
#endif // defined(OS_CHROMEOS)
std::unique_ptr<SubSurface> Display::CreateSubSurface(Surface* surface,
Surface* parent) {
TRACE_EVENT2("exo", "Display::CreateSubSurface", "surface",
surface->AsTracedValue(), "parent", parent->AsTracedValue());
if (surface->window()->Contains(parent->window())) {
DLOG(ERROR) << "Parent is contained within surface's hierarchy";
return nullptr;
}
if (surface->HasSurfaceDelegate()) {
DLOG(ERROR) << "Surface has already been assigned a role";
return nullptr;
}
return std::make_unique<SubSurface>(surface, parent);
}
std::unique_ptr<DataDevice> Display::CreateDataDevice(
DataDeviceDelegate* delegate) {
return std::make_unique<DataDevice>(delegate, &seat_, file_helper_.get());
}
} // namespace exo } // namespace exo
...@@ -30,15 +30,18 @@ class ClientControlledShellSurface; ...@@ -30,15 +30,18 @@ class ClientControlledShellSurface;
class DataDevice; class DataDevice;
class DataDeviceDelegate; class DataDeviceDelegate;
class FileHelper; class FileHelper;
class InputMethodSurface;
class InputMethodSurfaceManager; class InputMethodSurfaceManager;
class NotificationSurface; class NotificationSurface;
class NotificationSurfaceManager; class NotificationSurfaceManager;
class SharedMemory; class SharedMemory;
class ShellSurface;
class SubSurface; class SubSurface;
class Surface; class Surface;
#if defined(OS_CHROMEOS)
class InputMethodSurface;
class ShellSurface;
class XdgShellSurface; class XdgShellSurface;
#endif
#if defined(USE_OZONE) #if defined(USE_OZONE)
class Buffer; class Buffer;
...@@ -50,9 +53,13 @@ class Buffer; ...@@ -50,9 +53,13 @@ class Buffer;
class Display { class Display {
public: public:
Display(); Display();
#if defined(OS_CHROMEOS)
Display(NotificationSurfaceManager* notification_surface_manager, Display(NotificationSurfaceManager* notification_surface_manager,
InputMethodSurfaceManager* input_method_surface_manager, InputMethodSurfaceManager* input_method_surface_manager,
std::unique_ptr<FileHelper> file_helper); std::unique_ptr<FileHelper> file_helper);
#endif // defined(OS_CHROMEOS)
~Display(); ~Display();
// Creates a new surface. // Creates a new surface.
...@@ -71,8 +78,9 @@ class Display { ...@@ -71,8 +78,9 @@ class Display {
const std::vector<gfx::NativePixmapPlane>& planes, const std::vector<gfx::NativePixmapPlane>& planes,
bool y_invert, bool y_invert,
std::vector<base::ScopedFD>&& fds); std::vector<base::ScopedFD>&& fds);
#endif #endif // defined(USE_OZONE)
#if defined(OS_CHROMEOS)
// Creates a shell surface for an existing surface. // Creates a shell surface for an existing surface.
std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface); std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface);
...@@ -86,36 +94,40 @@ class Display { ...@@ -86,36 +94,40 @@ class Display {
int container, int container,
double default_device_scale_factor); double default_device_scale_factor);
// Creates a sub-surface for an existing surface. The sub-surface will be
// a child of |parent|.
std::unique_ptr<SubSurface> CreateSubSurface(Surface* surface,
Surface* parent);
// Creates a notification surface for a surface and notification id. // Creates a notification surface for a surface and notification id.
std::unique_ptr<NotificationSurface> CreateNotificationSurface( std::unique_ptr<NotificationSurface> CreateNotificationSurface(
Surface* surface, Surface* surface,
const std::string& notification_key); const std::string& notification_key);
// Creates a data device for a |delegate|.
std::unique_ptr<DataDevice> CreateDataDevice(DataDeviceDelegate* delegate);
// Creates a input method surface for a surface. // Creates a input method surface for a surface.
std::unique_ptr<InputMethodSurface> CreateInputMethodSurface( std::unique_ptr<InputMethodSurface> CreateInputMethodSurface(
Surface* surface, Surface* surface,
double default_device_scale_factor); double default_device_scale_factor);
#endif // defined(OS_CHROMEOS)
// Creates a sub-surface for an existing surface. The sub-surface will be
// a child of |parent|.
std::unique_ptr<SubSurface> CreateSubSurface(Surface* surface,
Surface* parent);
// Creates a data device for a |delegate|.
std::unique_ptr<DataDevice> CreateDataDevice(DataDeviceDelegate* delegate);
// Obtains seat instance. // Obtains seat instance.
Seat* seat() { return &seat_; } Seat* seat() { return &seat_; }
private: private:
NotificationSurfaceManager* const notification_surface_manager_; #if defined(OS_CHROMEOS)
InputMethodSurfaceManager* const input_method_surface_manager_; NotificationSurfaceManager* notification_surface_manager_ = nullptr;
InputMethodSurfaceManager* input_method_surface_manager_ = nullptr;
#endif // defined(OS_CHROMEOS)
std::unique_ptr<FileHelper> file_helper_; std::unique_ptr<FileHelper> file_helper_;
Seat seat_; Seat seat_;
#if defined(USE_OZONE) #if defined(USE_OZONE)
std::unique_ptr<gfx::ClientNativePixmapFactory> client_native_pixmap_factory_; std::unique_ptr<gfx::ClientNativePixmapFactory> client_native_pixmap_factory_;
#endif #endif // defined(USE_OZONE)
DISALLOW_COPY_AND_ASSIGN(Display); DISALLOW_COPY_AND_ASSIGN(Display);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment