Commit 5f8dbf8e authored by rjkroege's avatar rjkroege Committed by Commit bot

In-mus ozone drm platform implementation.

Add an in-process bridge between the gpu, main and drm threads so that
the drm ozone implementation can operate in single-process mode.

BUG=558602

Review URL: https://codereview.chromium.org/1831693002

Cr-Commit-Position: refs/heads/master@{#383856}
parent 55de872c
......@@ -115,6 +115,8 @@ source_set("gbm") {
"host/drm_window_host_manager.h",
"host/gpu_thread_adapter.h",
"host/gpu_thread_observer.h",
"mus_thread_proxy.cc",
"mus_thread_proxy.h",
"ozone_platform_gbm.cc",
"ozone_platform_gbm.h",
]
......
......@@ -149,6 +149,8 @@
'host/drm_window_host_manager.h',
'host/gpu_thread_adapter.h',
'host/gpu_thread_observer.h',
'mus_thread_proxy.cc',
'mus_thread_proxy.h',
'ozone_platform_gbm.cc',
'ozone_platform_gbm.h',
],
......
This diff is collapsed.
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_OZONE_PLATFORM_DRM_MUS_THREAD_PROXY_H_
#define UI_OZONE_PLATFORM_DRM_MUS_THREAD_PROXY_H_
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/synchronization/lock.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/ozone/platform/drm/gpu/inter_thread_messaging_proxy.h"
#include "ui/ozone/platform/drm/host/drm_cursor.h"
#include "ui/ozone/platform/drm/host/gpu_thread_adapter.h"
namespace base {
class SingleThreadTaskRunner;
}
namespace ui {
class DrmCursor;
class DrmDisplayHostManager;
class DrmOverlayManager;
class DrmThread;
class GpuThreadObserver;
// In Mus, the window server thread (analogous to Chrome's UI thread), GPU and
// DRM threads coexist in a single Mus process. The |MusThreadProxy| connects
// these threads together via cross-thread calls.
class MusThreadProxy : public GpuThreadAdapter,
public InterThreadMessagingProxy,
public DrmCursorProxy {
public:
MusThreadProxy();
~MusThreadProxy() override;
void StartDrmThread();
void ProvideManagers(DrmDisplayHostManager* display_manager,
DrmOverlayManager* overlay_manager);
// InterThreadMessagingProxy.
void SetDrmThread(DrmThread* thread) override;
// This is the core functionality. They are invoked when we have a main
// thread, a gpu thread and we have called initialize on both.
void AddGpuThreadObserver(GpuThreadObserver* observer) override;
void RemoveGpuThreadObserver(GpuThreadObserver* observer) override;
bool IsConnected() override;
// Services needed for DrmDisplayHostMananger.
void RegisterHandlerForDrmDisplayHostManager(
DrmDisplayHostManager* handler) override;
void UnRegisterHandlerForDrmDisplayHostManager() override;
bool GpuTakeDisplayControl() override;
bool GpuRefreshNativeDisplays() override;
bool GpuRelinquishDisplayControl() override;
bool GpuAddGraphicsDevice(const base::FilePath& path,
const base::FileDescriptor& fd) override;
bool GpuRemoveGraphicsDevice(const base::FilePath& path) override;
// Services needed for DrmOverlayManager.
void RegisterHandlerForDrmOverlayManager(DrmOverlayManager* handler) override;
void UnRegisterHandlerForDrmOverlayManager() override;
bool GpuCheckOverlayCapabilities(
gfx::AcceleratedWidget widget,
const std::vector<OverlayCheck_Params>& new_params) override;
// Services needed by DrmDisplayHost
bool GpuConfigureNativeDisplay(int64_t display_id,
const ui::DisplayMode_Params& display_mode,
const gfx::Point& point) override;
bool GpuDisableNativeDisplay(int64_t display_id) override;
bool GpuGetHDCPState(int64_t display_id) override;
bool GpuSetHDCPState(int64_t display_id, ui::HDCPState state) override;
bool GpuSetGammaRamp(int64_t display_id,
const std::vector<GammaRampRGBEntry>& lut) override;
// Services needed by DrmWindowHost
bool GpuDestroyWindow(gfx::AcceleratedWidget widget) override;
bool GpuCreateWindow(gfx::AcceleratedWidget widget) override;
bool GpuWindowBoundsChanged(gfx::AcceleratedWidget widget,
const gfx::Rect& bounds) override;
// DrmCursorProxy.
void CursorSet(gfx::AcceleratedWidget window,
const std::vector<SkBitmap>& bitmaps,
const gfx::Point& point,
int frame_delay_ms) override;
void Move(gfx::AcceleratedWidget window, const gfx::Point& point) override;
private:
void RunObservers();
void DispatchObserversFromDrmThread();
void GpuCheckOverlayCapabilitiesCallback(
gfx::AcceleratedWidget widget,
const std::vector<OverlayCheck_Params>& overlays) const;
void GpuConfigureNativeDisplayCallback(int64_t display_id,
bool success) const;
void GpuRefreshNativeDisplaysCallback(
const std::vector<DisplaySnapshot_Params>& displays) const;
void GpuDisableNativeDisplayCallback(int64_t display_id, bool success) const;
void GpuTakeDisplayControlCallback(bool success) const;
void GpuRelinquishDisplayControlCallback(bool success) const;
void GpuGetHDCPStateCallback(int64_t display_id,
bool success,
HDCPState state) const;
void GpuSetHDCPStateCallback(int64_t display_id, bool success) const;
scoped_refptr<base::SingleThreadTaskRunner> ws_task_runner_;
DrmThread* drm_thread_; // Not owned.
// Guards for multi-theaded access to drm_thread_.
base::Lock lock_;
DrmDisplayHostManager* display_manager_; // Not owned.
DrmOverlayManager* overlay_manager_; // Not owned.
base::ObserverList<GpuThreadObserver> gpu_thread_observers_;
base::ThreadChecker on_window_server_thread_;
base::WeakPtrFactory<MusThreadProxy> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(MusThreadProxy);
};
} // namespace ui
#endif // UI_OZONE_PLATFORM_DRM_MUS_THREAD_PROXY_H_
\ No newline at end of file
......@@ -14,6 +14,7 @@
#include <utility>
#include "base/bind.h"
#include "base/command_line.h"
#include "base/macros.h"
#include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h"
#include "ui/events/ozone/device/device_manager.h"
......@@ -37,6 +38,7 @@
#include "ui/ozone/platform/drm/host/drm_overlay_manager.h"
#include "ui/ozone/platform/drm/host/drm_window_host.h"
#include "ui/ozone/platform/drm/host/drm_window_host_manager.h"
#include "ui/ozone/platform/drm/mus_thread_proxy.h"
#include "ui/ozone/public/cursor_factory_ozone.h"
#include "ui/ozone/public/gpu_platform_support.h"
#include "ui/ozone/public/gpu_platform_support_host.h"
......@@ -76,8 +78,9 @@ class GlApiLoader {
// Returns true if we should operate in Mus mode.
bool RunningInsideMus() {
// TODO(rjkroege): Implement.
return false;
bool has_channel_handle = base::CommandLine::ForCurrentProcess()->HasSwitch(
"mojo-platform-channel-handle");
return has_channel_handle;
}
class OzonePlatformGbm : public OzonePlatform {
......@@ -110,10 +113,15 @@ class OzonePlatformGbm : public OzonePlatform {
scoped_ptr<PlatformWindow> CreatePlatformWindow(
PlatformWindowDelegate* delegate,
const gfx::Rect& bounds) override {
GpuThreadAdapter* adapter = gpu_platform_support_host_.get();
if (RunningInsideMus()) {
DCHECK(drm_thread_) << "drm_thread_ should exist (and be running) here.";
adapter = mus_thread_proxy_.get();
}
scoped_ptr<DrmWindowHost> platform_window(new DrmWindowHost(
delegate, bounds, gpu_platform_support_host_.get(),
event_factory_ozone_.get(), cursor_.get(), window_manager_.get(),
display_manager_.get(), overlay_manager_.get()));
delegate, bounds, adapter, event_factory_ozone_.get(), cursor_.get(),
window_manager_.get(), display_manager_.get(), overlay_manager_.get()));
platform_window->Initialize();
return std::move(platform_window);
}
......@@ -138,8 +146,9 @@ class OzonePlatformGbm : public OzonePlatform {
GpuThreadAdapter* adapter;
if (RunningInsideMus()) {
NOTIMPLEMENTED();
adapter = 0;
gl_api_loader_.reset(new GlApiLoader());
mus_thread_proxy_.reset(new MusThreadProxy());
adapter = mus_thread_proxy_.get();
} else {
gpu_platform_support_host_.reset(
new DrmGpuPlatformSupportHost(cursor_.get()));
......@@ -154,15 +163,16 @@ class OzonePlatformGbm : public OzonePlatform {
new DrmOverlayManager(adapter, window_manager_.get()));
if (RunningInsideMus()) {
NOTIMPLEMENTED();
mus_thread_proxy_->ProvideManagers(display_manager_.get(),
overlay_manager_.get());
}
}
void InitializeGPU() override {
InterThreadMessagingProxy* itmp;
if (RunningInsideMus()) {
NOTIMPLEMENTED();
itmp = 0;
DCHECK(mus_thread_proxy_);
itmp = mus_thread_proxy_.get();
} else {
gl_api_loader_.reset(new GlApiLoader());
scoped_refptr<DrmThreadMessageProxy> message_proxy(
......@@ -178,7 +188,7 @@ class OzonePlatformGbm : public OzonePlatform {
surface_factory_.reset(new GbmSurfaceFactory(drm_thread_.get()));
if (RunningInsideMus()) {
NOTIMPLEMENTED();
mus_thread_proxy_->StartDrmThread();
}
}
......@@ -199,6 +209,9 @@ class OzonePlatformGbm : public OzonePlatform {
scoped_ptr<DrmDisplayHostManager> display_manager_;
scoped_ptr<DrmOverlayManager> overlay_manager_;
// Bridges the DRM, GPU and main threads in mus.
scoped_ptr<MusThreadProxy> mus_thread_proxy_;
#if defined(USE_XKBCOMMON)
XkbEvdevCodes xkb_evdev_code_converter_;
#endif
......
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