Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Unified Diff: ui/ozone/platform/drm/gpu/drm_gpu_platform_support.cc

Issue 1311043016: Switch DRM platform to using a separate thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mv-drm-calls-on-thread2
Patch Set: . Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/ozone/platform/drm/gpu/drm_gpu_platform_support.cc
diff --git a/ui/ozone/platform/drm/gpu/drm_gpu_platform_support.cc b/ui/ozone/platform/drm/gpu/drm_gpu_platform_support.cc
index e87bdcd55dece76dafb9adbdd39d997cbce311d0..279724efb1b0a156c772b5d88743b1c6b2e7787b 100644
--- a/ui/ozone/platform/drm/gpu/drm_gpu_platform_support.cc
+++ b/ui/ozone/platform/drm/gpu/drm_gpu_platform_support.cc
@@ -4,320 +4,328 @@
#include "ui/ozone/platform/drm/gpu/drm_gpu_platform_support.h"
-#include "base/bind.h"
#include "base/thread_task_runner_handle.h"
-#include "ipc/ipc_message_macros.h"
-#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
+#include "ipc/ipc_message.h"
+#include "ipc/message_filter.h"
#include "ui/ozone/common/gpu/ozone_gpu_messages.h"
-#include "ui/ozone/platform/drm/gpu/drm_device.h"
-#include "ui/ozone/platform/drm/gpu/drm_device_manager.h"
-#include "ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h"
-#include "ui/ozone/platform/drm/gpu/drm_window.h"
-#include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
-#include "ui/ozone/platform/drm/gpu/screen_manager.h"
+#include "ui/ozone/platform/drm/gpu/drm_thread.h"
+#include "ui/ozone/platform/drm/gpu/proxy_helpers.h"
namespace ui {
namespace {
-void MessageProcessedOnMain(
- scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner,
- const base::Closure& io_thread_task) {
- io_thread_task_runner->PostTask(FROM_HERE, io_thread_task);
-}
-
-class DrmGpuPlatformSupportMessageFilter : public IPC::MessageFilter {
+class MessageFilter : public IPC::MessageFilter {
public:
- typedef base::Callback<void(
- const scoped_refptr<base::SingleThreadTaskRunner>&)>
- OnFilterAddedCallback;
-
- DrmGpuPlatformSupportMessageFilter(
- ScreenManager* screen_manager,
- const OnFilterAddedCallback& on_filter_added_callback,
- IPC::Listener* main_thread_listener)
- : screen_manager_(screen_manager),
- on_filter_added_callback_(on_filter_added_callback),
- main_thread_listener_(main_thread_listener),
- main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()) {}
-
- void OnFilterAdded(IPC::Sender* sender) override {
- io_thread_task_runner_ = base::ThreadTaskRunnerHandle::Get();
- main_thread_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(on_filter_added_callback_, io_thread_task_runner_));
- }
-
- // This code is meant to be very temporary and only as a special case to fix
- // cursor movement jank resulting from slowdowns on the gpu main thread.
- // It handles cursor movement on IO thread when display config is stable
- // and returns it to main thread during transitions.
- bool OnMessageReceived(const IPC::Message& message) override {
- // If this message affects the state needed to set cursor, handle it on
- // the main thread. If a cursor move message arrives but we haven't
- // processed the previous main thread message, keep processing on main
- // until nothing is pending.
- bool cursor_position_message = MessageAffectsCursorPosition(message.type());
- bool cursor_state_message = MessageAffectsCursorState(message.type());
-
- // Only handle cursor related messages here.
- if (!cursor_position_message && !cursor_state_message)
- return false;
-
- bool cursor_was_animating = cursor_animating_;
- UpdateAnimationState(message);
- if (cursor_state_message || pending_main_thread_operations_ ||
- cursor_animating_ || cursor_was_animating) {
- pending_main_thread_operations_++;
-
- base::Closure main_thread_message_handler =
- base::Bind(base::IgnoreResult(&IPC::Listener::OnMessageReceived),
- base::Unretained(main_thread_listener_), message);
- main_thread_task_runner_->PostTask(FROM_HERE,
- main_thread_message_handler);
-
- // This is an echo from the main thread to decrement pending ops.
- // When the main thread is done with the task, it posts back to IO to
- // signal completion.
- base::Closure io_thread_task = base::Bind(
- &DrmGpuPlatformSupportMessageFilter::DecrementPendingOperationsOnIO,
- this);
-
- base::Closure message_processed_callback = base::Bind(
- &MessageProcessedOnMain, io_thread_task_runner_, io_thread_task);
- main_thread_task_runner_->PostTask(FROM_HERE, message_processed_callback);
-
- return true;
- }
-
- // Otherwise, we are in a steady state and it's safe to move cursor on IO.
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(DrmGpuPlatformSupportMessageFilter, message)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_CursorMove, OnCursorMove)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_CursorSet, OnCursorSet)
- IPC_MESSAGE_UNHANDLED(handled = false);
- IPC_END_MESSAGE_MAP()
+ MessageFilter(DrmThread* drm_thread);
- return handled;
- }
+ // IPC::MessageFilter:
+ void OnFilterAdded(IPC::Sender* sender) override;
+ bool OnMessageReceived(const IPC::Message& message) override;
- protected:
- ~DrmGpuPlatformSupportMessageFilter() override {}
-
- void OnCursorMove(gfx::AcceleratedWidget widget, const gfx::Point& location) {
- screen_manager_->GetWindow(widget)->MoveCursor(location);
- }
+ private:
+ ~MessageFilter() override;
+ void OnCreateWindow(gfx::AcceleratedWidget widget);
+ void OnDestroyWindow(gfx::AcceleratedWidget widget);
+ void OnWindowBoundsChanged(gfx::AcceleratedWidget widget,
+ const gfx::Rect& bounds);
void OnCursorSet(gfx::AcceleratedWidget widget,
const std::vector<SkBitmap>& bitmaps,
const gfx::Point& location,
- int frame_delay_ms) {
- screen_manager_->GetWindow(widget)
- ->SetCursorWithoutAnimations(bitmaps, location);
- }
-
- void DecrementPendingOperationsOnIO() { pending_main_thread_operations_--; }
-
- bool MessageAffectsCursorState(uint32 message_type) {
- switch (message_type) {
- case OzoneGpuMsg_CreateWindow::ID:
- case OzoneGpuMsg_DestroyWindow::ID:
- case OzoneGpuMsg_WindowBoundsChanged::ID:
- case OzoneGpuMsg_ConfigureNativeDisplay::ID:
- case OzoneGpuMsg_DisableNativeDisplay::ID:
- return true;
- default:
- return false;
- }
- }
-
- bool MessageAffectsCursorPosition(uint32 message_type) {
- switch (message_type) {
- case OzoneGpuMsg_CursorMove::ID:
- case OzoneGpuMsg_CursorSet::ID:
- return true;
- default:
- return false;
- }
- }
-
- void UpdateAnimationState(const IPC::Message& message) {
- if (message.type() != OzoneGpuMsg_CursorSet::ID)
- return;
-
- OzoneGpuMsg_CursorSet::Param param;
- if (!OzoneGpuMsg_CursorSet::Read(&message, &param))
- return;
-
- int frame_delay_ms = base::get<3>(param);
- cursor_animating_ = frame_delay_ms != 0;
- }
-
- ScreenManager* screen_manager_;
- OnFilterAddedCallback on_filter_added_callback_;
- IPC::Listener* main_thread_listener_;
- scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
- scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_;
- int32 pending_main_thread_operations_ = 0;
- bool cursor_animating_ = false;
+ int frame_delay_ms);
+ void OnCursorMove(gfx::AcceleratedWidget widget, const gfx::Point& location);
+ void OnCheckOverlayCapabilities(
+ gfx::AcceleratedWidget widget,
+ const std::vector<OverlayCheck_Params>& overlays);
+
+ // Display related IPC handlers.
+ void OnRefreshNativeDisplays();
+ void OnConfigureNativeDisplay(int64_t id,
+ const DisplayMode_Params& mode,
+ const gfx::Point& origin);
+ void OnDisableNativeDisplay(int64_t id);
+ void OnTakeDisplayControl();
+ void OnRelinquishDisplayControl();
+ void OnAddGraphicsDevice(const base::FilePath& path,
+ const base::FileDescriptor& fd);
+ void OnRemoveGraphicsDevice(const base::FilePath& path);
+ void OnGetHDCPState(int64_t display_id);
+ void OnSetHDCPState(int64_t display_id, HDCPState state);
+ void OnSetGammaRamp(int64_t id, const std::vector<GammaRampRGBEntry>& lut);
+
+ void OnCheckOverlayCapabilitiesCallback(gfx::AcceleratedWidget widget,
+ bool success) const;
+ void OnRefreshNativeDisplaysCallback(
+ const std::vector<DisplaySnapshot_Params>& displays) const;
+ void OnConfigureNativeDisplayCallback(int64_t display_id, bool success) const;
+ void OnDisableNativeDisplayCallback(int64_t display_id, bool success) const;
+ void OnTakeDisplayControlCallback(bool success) const;
+ void OnRelinquishDisplayControlCallback(bool success) const;
+ void OnGetHDCPStateCallback(int64_t display_id,
+ bool success,
+ HDCPState state) const;
+ void OnSetHDCPStateCallback(int64_t display_id, bool success) const;
+
+ DrmThread* drm_thread_;
+
+ IPC::Sender* sender_ = nullptr;
+
+ base::WeakPtrFactory<MessageFilter> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(MessageFilter);
};
-}
-DrmGpuPlatformSupport::DrmGpuPlatformSupport(
- DrmDeviceManager* drm_device_manager,
- ScreenManager* screen_manager,
- ScanoutBufferGenerator* buffer_generator,
- scoped_ptr<DrmGpuDisplayManager> display_manager)
- : drm_device_manager_(drm_device_manager),
- screen_manager_(screen_manager),
- buffer_generator_(buffer_generator),
- display_manager_(display_manager.Pass()) {
- filter_ = new DrmGpuPlatformSupportMessageFilter(
- screen_manager, base::Bind(&DrmGpuPlatformSupport::SetIOTaskRunner,
- base::Unretained(this)),
- this);
-}
+MessageFilter::MessageFilter(DrmThread* drm_thread)
+ : drm_thread_(drm_thread), weak_ptr_factory_(this) {}
-DrmGpuPlatformSupport::~DrmGpuPlatformSupport() {
-}
+MessageFilter::~MessageFilter() {}
-void DrmGpuPlatformSupport::OnChannelEstablished(IPC::Sender* sender) {
+void MessageFilter::OnFilterAdded(IPC::Sender* sender) {
sender_ = sender;
+
+ // The DRM thread needs to be started late since we need to wait for the
+ // sandbox to start.
+ drm_thread_->Start();
}
-bool DrmGpuPlatformSupport::OnMessageReceived(const IPC::Message& message) {
+bool MessageFilter::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(DrmGpuPlatformSupport, message)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_CreateWindow, OnCreateWindow)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_DestroyWindow, OnDestroyWindow)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_WindowBoundsChanged, OnWindowBoundsChanged)
-
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_CursorSet, OnCursorSet)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_CursorMove, OnCursorMove)
-
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_RefreshNativeDisplays,
- OnRefreshNativeDisplays)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_ConfigureNativeDisplay,
- OnConfigureNativeDisplay)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_DisableNativeDisplay, OnDisableNativeDisplay)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_TakeDisplayControl, OnTakeDisplayControl)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_RelinquishDisplayControl,
- OnRelinquishDisplayControl)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_AddGraphicsDevice, OnAddGraphicsDevice)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_RemoveGraphicsDevice, OnRemoveGraphicsDevice)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_GetHDCPState, OnGetHDCPState)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_SetHDCPState, OnSetHDCPState)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_SetGammaRamp, OnSetGammaRamp);
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_CheckOverlayCapabilities,
- OnCheckOverlayCapabilities)
- IPC_MESSAGE_UNHANDLED(handled = false);
+ IPC_BEGIN_MESSAGE_MAP(MessageFilter, message)
+ IPC_MESSAGE_HANDLER(OzoneGpuMsg_CreateWindow, OnCreateWindow)
+ IPC_MESSAGE_HANDLER(OzoneGpuMsg_DestroyWindow, OnDestroyWindow)
+ IPC_MESSAGE_HANDLER(OzoneGpuMsg_WindowBoundsChanged, OnWindowBoundsChanged)
+
+ IPC_MESSAGE_HANDLER(OzoneGpuMsg_CursorSet, OnCursorSet)
+ IPC_MESSAGE_HANDLER(OzoneGpuMsg_CursorMove, OnCursorMove)
+
+ IPC_MESSAGE_HANDLER(OzoneGpuMsg_RefreshNativeDisplays,
+ OnRefreshNativeDisplays)
+ IPC_MESSAGE_HANDLER(OzoneGpuMsg_ConfigureNativeDisplay,
+ OnConfigureNativeDisplay)
+ IPC_MESSAGE_HANDLER(OzoneGpuMsg_DisableNativeDisplay,
+ OnDisableNativeDisplay)
+ IPC_MESSAGE_HANDLER(OzoneGpuMsg_TakeDisplayControl, OnTakeDisplayControl)
+ IPC_MESSAGE_HANDLER(OzoneGpuMsg_RelinquishDisplayControl,
+ OnRelinquishDisplayControl)
+ IPC_MESSAGE_HANDLER(OzoneGpuMsg_AddGraphicsDevice, OnAddGraphicsDevice)
+ IPC_MESSAGE_HANDLER(OzoneGpuMsg_RemoveGraphicsDevice,
+ OnRemoveGraphicsDevice)
+ IPC_MESSAGE_HANDLER(OzoneGpuMsg_GetHDCPState, OnGetHDCPState)
+ IPC_MESSAGE_HANDLER(OzoneGpuMsg_SetHDCPState, OnSetHDCPState)
+ IPC_MESSAGE_HANDLER(OzoneGpuMsg_SetGammaRamp, OnSetGammaRamp);
+ IPC_MESSAGE_HANDLER(OzoneGpuMsg_CheckOverlayCapabilities,
+ OnCheckOverlayCapabilities)
+ IPC_MESSAGE_UNHANDLED(handled = false);
IPC_END_MESSAGE_MAP()
return handled;
}
-void DrmGpuPlatformSupport::OnCreateWindow(gfx::AcceleratedWidget widget) {
- scoped_ptr<DrmWindow> window(
- new DrmWindow(widget, drm_device_manager_, screen_manager_));
- window->Initialize();
- screen_manager_->AddWindow(widget, window.Pass());
+void MessageFilter::OnCreateWindow(gfx::AcceleratedWidget widget) {
+ DCHECK(drm_thread_->IsRunning());
+ drm_thread_->task_runner()->PostTask(
+ FROM_HERE, base::Bind(&DrmThread::OnCreateWindow,
+ base::Unretained(drm_thread_), widget));
}
-void DrmGpuPlatformSupport::OnDestroyWindow(gfx::AcceleratedWidget widget) {
- scoped_ptr<DrmWindow> window = screen_manager_->RemoveWindow(widget);
- window->Shutdown();
+void MessageFilter::OnDestroyWindow(gfx::AcceleratedWidget widget) {
+ DCHECK(drm_thread_->IsRunning());
+ drm_thread_->task_runner()->PostTask(
+ FROM_HERE, base::Bind(&DrmThread::OnDestroyWindow,
+ base::Unretained(drm_thread_), widget));
}
-void DrmGpuPlatformSupport::OnWindowBoundsChanged(gfx::AcceleratedWidget widget,
- const gfx::Rect& bounds) {
- screen_manager_->GetWindow(widget)->OnBoundsChanged(bounds);
+void MessageFilter::OnWindowBoundsChanged(gfx::AcceleratedWidget widget,
+ const gfx::Rect& bounds) {
+ DCHECK(drm_thread_->IsRunning());
+ drm_thread_->task_runner()->PostTask(
+ FROM_HERE, base::Bind(&DrmThread::OnWindowBoundsChanged,
+ base::Unretained(drm_thread_), widget, bounds));
}
-void DrmGpuPlatformSupport::OnCursorSet(gfx::AcceleratedWidget widget,
- const std::vector<SkBitmap>& bitmaps,
- const gfx::Point& location,
- int frame_delay_ms) {
- screen_manager_->GetWindow(widget)
- ->SetCursor(bitmaps, location, frame_delay_ms);
+void MessageFilter::OnCursorSet(gfx::AcceleratedWidget widget,
+ const std::vector<SkBitmap>& bitmaps,
+ const gfx::Point& location,
+ int frame_delay_ms) {
+ DCHECK(drm_thread_->IsRunning());
+ drm_thread_->task_runner()->PostTask(
+ FROM_HERE,
+ base::Bind(&DrmThread::OnCursorSet, base::Unretained(drm_thread_), widget,
+ bitmaps, location, frame_delay_ms));
}
-void DrmGpuPlatformSupport::OnCursorMove(gfx::AcceleratedWidget widget,
- const gfx::Point& location) {
- screen_manager_->GetWindow(widget)->MoveCursor(location);
+void MessageFilter::OnCursorMove(gfx::AcceleratedWidget widget,
+ const gfx::Point& location) {
+ DCHECK(drm_thread_->IsRunning());
+ drm_thread_->task_runner()->PostTask(
+ FROM_HERE, base::Bind(&DrmThread::OnCursorMove,
+ base::Unretained(drm_thread_), widget, location));
}
-void DrmGpuPlatformSupport::OnCheckOverlayCapabilities(
+void MessageFilter::OnCheckOverlayCapabilities(
gfx::AcceleratedWidget widget,
const std::vector<OverlayCheck_Params>& overlays) {
- sender_->Send(new OzoneHostMsg_OverlayCapabilitiesReceived(
- widget, screen_manager_->GetWindow(widget)
- ->TestPageFlip(overlays, buffer_generator_)));
+ DCHECK(drm_thread_->IsRunning());
+ auto callback = base::Bind(&MessageFilter::OnCheckOverlayCapabilitiesCallback,
+ weak_ptr_factory_.GetWeakPtr());
+ drm_thread_->task_runner()->PostTask(
+ FROM_HERE, base::Bind(&DrmThread::OnCheckOverlayCapabilities,
+ base::Unretained(drm_thread_), widget, overlays,
+ CreateSafeCallback(callback)));
}
-void DrmGpuPlatformSupport::OnRefreshNativeDisplays() {
- sender_->Send(
- new OzoneHostMsg_UpdateNativeDisplays(display_manager_->GetDisplays()));
+void MessageFilter::OnRefreshNativeDisplays() {
+ DCHECK(drm_thread_->IsRunning());
+ auto callback = base::Bind(&MessageFilter::OnRefreshNativeDisplaysCallback,
+ weak_ptr_factory_.GetWeakPtr());
+ drm_thread_->task_runner()->PostTask(
+ FROM_HERE,
+ base::Bind(&DrmThread::OnRefreshNativeDisplays,
+ base::Unretained(drm_thread_), CreateSafeCallback(callback)));
}
-void DrmGpuPlatformSupport::OnConfigureNativeDisplay(
- int64_t id,
- const DisplayMode_Params& mode_param,
- const gfx::Point& origin) {
- sender_->Send(new OzoneHostMsg_DisplayConfigured(
- id, display_manager_->ConfigureDisplay(id, mode_param, origin)));
+void MessageFilter::OnConfigureNativeDisplay(int64_t id,
+ const DisplayMode_Params& mode,
+ const gfx::Point& origin) {
+ DCHECK(drm_thread_->IsRunning());
+ auto callback = base::Bind(&MessageFilter::OnConfigureNativeDisplayCallback,
+ weak_ptr_factory_.GetWeakPtr());
+ drm_thread_->task_runner()->PostTask(
+ FROM_HERE, base::Bind(&DrmThread::OnConfigureNativeDisplay,
+ base::Unretained(drm_thread_), id, mode, origin,
+ CreateSafeCallback(callback)));
}
-void DrmGpuPlatformSupport::OnDisableNativeDisplay(int64_t id) {
- sender_->Send(new OzoneHostMsg_DisplayConfigured(
- id, display_manager_->DisableDisplay(id)));
+void MessageFilter::OnDisableNativeDisplay(int64_t id) {
+ DCHECK(drm_thread_->IsRunning());
+ auto callback = base::Bind(&MessageFilter::OnDisableNativeDisplayCallback,
+ weak_ptr_factory_.GetWeakPtr());
+ drm_thread_->task_runner()->PostTask(
+ FROM_HERE, base::Bind(&DrmThread::OnDisableNativeDisplay,
+ base::Unretained(drm_thread_), id,
+ CreateSafeCallback(callback)));
}
-void DrmGpuPlatformSupport::OnTakeDisplayControl() {
- sender_->Send(new OzoneHostMsg_DisplayControlTaken(
- display_manager_->TakeDisplayControl()));
+void MessageFilter::OnTakeDisplayControl() {
+ DCHECK(drm_thread_->IsRunning());
+ auto callback = base::Bind(&MessageFilter::OnTakeDisplayControlCallback,
+ weak_ptr_factory_.GetWeakPtr());
+ drm_thread_->task_runner()->PostTask(
+ FROM_HERE,
+ base::Bind(&DrmThread::OnTakeDisplayControl,
+ base::Unretained(drm_thread_), CreateSafeCallback(callback)));
}
-void DrmGpuPlatformSupport::OnRelinquishDisplayControl() {
- display_manager_->RelinquishDisplayControl();
- sender_->Send(new OzoneHostMsg_DisplayControlRelinquished(true));
+void MessageFilter::OnRelinquishDisplayControl() {
+ DCHECK(drm_thread_->IsRunning());
+ auto callback = base::Bind(&MessageFilter::OnRelinquishDisplayControlCallback,
+ weak_ptr_factory_.GetWeakPtr());
+ drm_thread_->task_runner()->PostTask(
+ FROM_HERE,
+ base::Bind(&DrmThread::OnRelinquishDisplayControl,
+ base::Unretained(drm_thread_), CreateSafeCallback(callback)));
}
-void DrmGpuPlatformSupport::OnAddGraphicsDevice(
- const base::FilePath& path,
- const base::FileDescriptor& fd) {
- drm_device_manager_->AddDrmDevice(path, fd);
+void MessageFilter::OnAddGraphicsDevice(const base::FilePath& path,
+ const base::FileDescriptor& fd) {
+ DCHECK(drm_thread_->IsRunning());
+ drm_thread_->task_runner()->PostTask(
+ FROM_HERE, base::Bind(&DrmThread::OnAddGraphicsDevice,
+ base::Unretained(drm_thread_), path, fd));
}
-void DrmGpuPlatformSupport::OnRemoveGraphicsDevice(const base::FilePath& path) {
- drm_device_manager_->RemoveDrmDevice(path);
+void MessageFilter::OnRemoveGraphicsDevice(const base::FilePath& path) {
+ DCHECK(drm_thread_->IsRunning());
+ drm_thread_->task_runner()->PostTask(
+ FROM_HERE, base::Bind(&DrmThread::OnRemoveGraphicsDevice,
+ base::Unretained(drm_thread_), path));
}
-void DrmGpuPlatformSupport::OnSetGammaRamp(
- int64_t id,
- const std::vector<GammaRampRGBEntry>& lut) {
- display_manager_->SetGammaRamp(id, lut);
+void MessageFilter::OnGetHDCPState(int64_t display_id) {
+ DCHECK(drm_thread_->IsRunning());
+ auto callback = base::Bind(&MessageFilter::OnGetHDCPStateCallback,
+ weak_ptr_factory_.GetWeakPtr());
+ drm_thread_->task_runner()->PostTask(
+ FROM_HERE,
+ base::Bind(&DrmThread::OnGetHDCPState, base::Unretained(drm_thread_),
+ display_id, CreateSafeCallback(callback)));
}
-void DrmGpuPlatformSupport::OnGetHDCPState(int64_t display_id) {
- HDCPState state = HDCP_STATE_UNDESIRED;
- bool success = display_manager_->GetHDCPState(display_id, &state);
- sender_->Send(new OzoneHostMsg_HDCPStateReceived(display_id, success, state));
+void MessageFilter::OnSetHDCPState(int64_t display_id, HDCPState state) {
+ DCHECK(drm_thread_->IsRunning());
+ auto callback = base::Bind(&MessageFilter::OnSetHDCPStateCallback,
+ weak_ptr_factory_.GetWeakPtr());
+ drm_thread_->task_runner()->PostTask(
+ FROM_HERE,
+ base::Bind(&DrmThread::OnSetHDCPState, base::Unretained(drm_thread_),
+ display_id, state, CreateSafeCallback(callback)));
+}
+
+void MessageFilter::OnSetGammaRamp(int64_t id,
+ const std::vector<GammaRampRGBEntry>& lut) {
+ DCHECK(drm_thread_->IsRunning());
+ drm_thread_->task_runner()->PostTask(
+ FROM_HERE, base::Bind(&DrmThread::OnSetGammaRamp,
+ base::Unretained(drm_thread_), id, lut));
+}
+
+void MessageFilter::OnCheckOverlayCapabilitiesCallback(
+ gfx::AcceleratedWidget widget,
+ bool success) const {
+ sender_->Send(new OzoneHostMsg_OverlayCapabilitiesReceived(widget, success));
+}
+
+void MessageFilter::OnRefreshNativeDisplaysCallback(
+ const std::vector<DisplaySnapshot_Params>& displays) const {
+ sender_->Send(new OzoneHostMsg_UpdateNativeDisplays(displays));
+}
+
+void MessageFilter::OnConfigureNativeDisplayCallback(int64_t display_id,
+ bool success) const {
+ sender_->Send(new OzoneHostMsg_DisplayConfigured(display_id, success));
+}
+
+void MessageFilter::OnDisableNativeDisplayCallback(int64_t display_id,
+ bool success) const {
+ sender_->Send(new OzoneHostMsg_DisplayConfigured(display_id, success));
+}
+
+void MessageFilter::OnTakeDisplayControlCallback(bool success) const {
+ sender_->Send(new OzoneHostMsg_DisplayControlTaken(success));
}
-void DrmGpuPlatformSupport::OnSetHDCPState(int64_t display_id,
- HDCPState state) {
- sender_->Send(new OzoneHostMsg_HDCPStateUpdated(
- display_id, display_manager_->SetHDCPState(display_id, state)));
+void MessageFilter::OnRelinquishDisplayControlCallback(bool success) const {
+ sender_->Send(new OzoneHostMsg_DisplayControlRelinquished(success));
}
-void DrmGpuPlatformSupport::SetIOTaskRunner(
- const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) {
- drm_device_manager_->InitializeIOTaskRunner(io_task_runner);
+void MessageFilter::OnGetHDCPStateCallback(int64_t display_id,
+ bool success,
+ HDCPState state) const {
+ sender_->Send(new OzoneHostMsg_HDCPStateReceived(display_id, success, state));
+}
+
+void MessageFilter::OnSetHDCPStateCallback(int64_t display_id,
+ bool success) const {
+ sender_->Send(new OzoneHostMsg_HDCPStateUpdated(display_id, success));
}
+} // namespace
+
+DrmGpuPlatformSupport::DrmGpuPlatformSupport(DrmThread* drm_thread)
+ : filter_(new MessageFilter(drm_thread)) {}
+
+DrmGpuPlatformSupport::~DrmGpuPlatformSupport() {}
+
+void DrmGpuPlatformSupport::OnChannelEstablished(IPC::Sender* sender) {}
+
IPC::MessageFilter* DrmGpuPlatformSupport::GetMessageFilter() {
return filter_.get();
}
+bool DrmGpuPlatformSupport::OnMessageReceived(const IPC::Message& message) {
+ return false;
+}
+
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698