| Index: ui/ozone/platform/drm/ozone_platform_gbm.cc
|
| diff --git a/ui/ozone/platform/drm/ozone_platform_gbm.cc b/ui/ozone/platform/drm/ozone_platform_gbm.cc
|
| index 657aad01e307804ea092d52b2c12dec618691ee1..f4bced1d8abf5f3b3e58fd6e19ea27b66983d80c 100644
|
| --- a/ui/ozone/platform/drm/ozone_platform_gbm.cc
|
| +++ b/ui/ozone/platform/drm/ozone_platform_gbm.cc
|
| @@ -17,11 +17,14 @@
|
| #include "base/command_line.h"
|
| #include "base/macros.h"
|
| #include "base/memory/ptr_util.h"
|
| +#include "services/shell/public/cpp/connection.h"
|
| +#include "services/shell/public/cpp/interface_factory.h"
|
| #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h"
|
| #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/platform/drm/common/drm_util.h"
|
| +#include "ui/ozone/platform/drm/cursor_proxy_mojo.h"
|
| #include "ui/ozone/platform/drm/gpu/drm_device_generator.h"
|
| #include "ui/ozone/platform/drm/gpu/drm_device_manager.h"
|
| #include "ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h"
|
| @@ -77,18 +80,10 @@ class GlApiLoader {
|
| DISALLOW_COPY_AND_ASSIGN(GlApiLoader);
|
| };
|
|
|
| -// Returns true if we should operate in Mus mode.
|
| -// TODO(rjkroege): Create an explicit "single process ozone mode" that can be
|
| -// used for tests after mus+ash team finishes splitting mus.
|
| -bool RunningInsideMus() {
|
| - bool has_channel_handle = base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - "mojo-platform-channel-handle");
|
| - return has_channel_handle;
|
| -}
|
| -
|
| -class OzonePlatformGbm : public OzonePlatform {
|
| +class OzonePlatformGbm : public OzonePlatform,
|
| + public shell::InterfaceFactory<ozone::mojom::Cursor> {
|
| public:
|
| - OzonePlatformGbm() {}
|
| + OzonePlatformGbm() : using_mojo_(false), single_process_(false) {}
|
| ~OzonePlatformGbm() override {}
|
|
|
| // OzonePlatform:
|
| @@ -113,11 +108,20 @@ class OzonePlatformGbm : public OzonePlatform {
|
| std::unique_ptr<SystemInputInjector> CreateSystemInputInjector() override {
|
| return event_factory_ozone_->CreateSystemInputInjector();
|
| }
|
| + void AddInterfaces(shell::Connection* connection) override {
|
| + connection->AddInterface<ozone::mojom::Cursor>(this);
|
| + }
|
| + // shell::InterfaceFactory<mojom::ozone::Cursor> implementation.
|
| + void Create(shell::Connection* connection,
|
| + ozone::mojom::CursorRequest request) override {
|
| + DCHECK(drm_thread_);
|
| + drm_thread_->AddBinding(connection, std::move(request));
|
| + }
|
| std::unique_ptr<PlatformWindow> CreatePlatformWindow(
|
| PlatformWindowDelegate* delegate,
|
| const gfx::Rect& bounds) override {
|
| GpuThreadAdapter* adapter = gpu_platform_support_host_.get();
|
| - if (RunningInsideMus()) {
|
| + if (using_mojo_ || single_process_) {
|
| DCHECK(drm_thread_) << "drm_thread_ should exist (and be running) here.";
|
| adapter = mus_thread_proxy_.get();
|
| }
|
| @@ -134,6 +138,24 @@ class OzonePlatformGbm : public OzonePlatform {
|
| new DrmNativeDisplayDelegate(display_manager_.get()));
|
| }
|
| void InitializeUI() override {
|
| + InitParams default_params;
|
| + InitializeUI(default_params);
|
| + }
|
| + void InitializeUI(const InitParams& args) override {
|
| + // Ozone drm can operate in three modes configured at runtime:
|
| + // 1. legacy mode where browser and gpu components communicate
|
| + // via param traits IPC.
|
| + // 2. single-process mode where browser and gpu components
|
| + // communicate via PostTask.
|
| + // 3. mojo mode where browser and gpu components communicate
|
| + // via mojo IPC.
|
| + // Currently, mojo mode uses mojo in a single process but this is
|
| + // an interim implementation detail that will be eliminated in a
|
| + // future CL.
|
| + single_process_ = args.single_process;
|
| + using_mojo_ = args.connector != nullptr;
|
| + DCHECK(!(using_mojo_ && single_process_));
|
| +
|
| device_manager_ = CreateDeviceManager();
|
| window_manager_.reset(new DrmWindowHostManager());
|
| cursor_.reset(new DrmCursor(window_manager_.get()));
|
| @@ -144,16 +166,27 @@ class OzonePlatformGbm : public OzonePlatform {
|
| KeyboardLayoutEngineManager::SetKeyboardLayoutEngine(
|
| base::WrapUnique(new StubKeyboardLayoutEngine()));
|
| #endif
|
| +
|
| event_factory_ozone_.reset(new EventFactoryEvdev(
|
| cursor_.get(), device_manager_.get(),
|
| KeyboardLayoutEngineManager::GetKeyboardLayoutEngine()));
|
|
|
| GpuThreadAdapter* adapter;
|
| - if (RunningInsideMus()) {
|
| +
|
| + // TODO(rjkroege): Once mus is split, only do this for single_process.
|
| + if (single_process_ || using_mojo_)
|
| gl_api_loader_.reset(new GlApiLoader());
|
| +
|
| + if (using_mojo_) {
|
| + DCHECK(args.connector);
|
| + mus_thread_proxy_.reset(new MusThreadProxy());
|
| + adapter = mus_thread_proxy_.get();
|
| + cursor_->SetDrmCursorProxy(new CursorProxyMojo(args.connector));
|
| + } else if (single_process_) {
|
| mus_thread_proxy_.reset(new MusThreadProxy());
|
| adapter = mus_thread_proxy_.get();
|
| - cursor_->SetDrmCursorProxy(mus_thread_proxy_.get());
|
| + cursor_->SetDrmCursorProxy(
|
| + new CursorProxyThread(mus_thread_proxy_.get()));
|
| } else {
|
| gpu_platform_support_host_.reset(
|
| new DrmGpuPlatformSupportHost(cursor_.get()));
|
| @@ -167,16 +200,24 @@ class OzonePlatformGbm : public OzonePlatform {
|
| overlay_manager_.reset(
|
| new DrmOverlayManager(adapter, window_manager_.get()));
|
|
|
| - if (RunningInsideMus()) {
|
| + if (using_mojo_ || single_process_) {
|
| mus_thread_proxy_->ProvideManagers(display_manager_.get(),
|
| overlay_manager_.get());
|
| }
|
| }
|
| -
|
| void InitializeGPU() override {
|
| + InitParams default_params;
|
| + InitializeGPU(default_params);
|
| + }
|
| + void InitializeGPU(const InitParams& args) override {
|
| + // TODO(rjkroege): services/ui should initalize this with a connector.
|
| + // However, in-progress refactorings in services/ui make it difficult to
|
| + // require this at present. Set using_mojo_ like below once this is
|
| + // complete.
|
| + // using_mojo_ = args.connector != nullptr;
|
| +
|
| InterThreadMessagingProxy* itmp;
|
| - if (RunningInsideMus()) {
|
| - DCHECK(mus_thread_proxy_);
|
| + if (using_mojo_ || single_process_) {
|
| itmp = mus_thread_proxy_.get();
|
| } else {
|
| gl_api_loader_.reset(new GlApiLoader());
|
| @@ -192,13 +233,17 @@ class OzonePlatformGbm : public OzonePlatform {
|
| drm_thread_->BindThreadIntoMessagingProxy(itmp);
|
|
|
| surface_factory_.reset(new GbmSurfaceFactory(drm_thread_.get()));
|
| - if (RunningInsideMus()) {
|
| + if (using_mojo_ || single_process_) {
|
| mus_thread_proxy_->StartDrmThread();
|
| }
|
| }
|
|
|
| private:
|
| + bool using_mojo_;
|
| + bool single_process_;
|
| +
|
| // Objects in the GPU process.
|
| + // TODO(rjk): rename drm_thread_ to drm_thread_proxy_;
|
| std::unique_ptr<DrmThreadProxy> drm_thread_;
|
| std::unique_ptr<GlApiLoader> gl_api_loader_;
|
| std::unique_ptr<GbmSurfaceFactory> surface_factory_;
|
|
|