Commit ad1be9f1 authored by dnicoara@chromium.org's avatar dnicoara@chromium.org

[Ozone-GBM] Add basic support for display configuration over IPC

BUG=377497
NOTRY=true

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282036 0039d316-1c4b-4281-b951-d872f2087c98
parent b27feb3a
// Copyright 2014 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.
#include "ui/ozone/common/chromeos/display_mode_proxy.h"
#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
namespace ui {
DisplayModeProxy::DisplayModeProxy(const DisplayMode_Params& params)
: DisplayMode(params.size, params.is_interlaced, params.refresh_rate) {}
DisplayModeProxy::~DisplayModeProxy() {}
} // namespace ui
// Copyright 2014 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_COMMON_CHROMEOS_DISPLAY_MODE_PROXY_H_
#define UI_OZONE_COMMON_CHROMEOS_DISPLAY_MODE_PROXY_H_
#include "ui/display/types/chromeos/display_mode.h"
namespace ui {
struct DisplayMode_Params;
class DisplayModeProxy : public DisplayMode {
public:
DisplayModeProxy(const DisplayMode_Params& params);
virtual ~DisplayModeProxy();
private:
DISALLOW_COPY_AND_ASSIGN(DisplayModeProxy);
};
} // namespace ui
#endif // UI_OZONE_COMMON_CHROMEOS_DISPLAY_MODE_PROXY_H_
// Copyright 2014 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.
#include "ui/ozone/common/chromeos/display_snapshot_proxy.h"
#include "ui/ozone/common/chromeos/display_mode_proxy.h"
#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
namespace ui {
namespace {
bool SameModes(const DisplayMode_Params& lhs, const DisplayMode_Params& rhs) {
return lhs.size == rhs.size && lhs.is_interlaced == rhs.is_interlaced &&
lhs.refresh_rate == rhs.refresh_rate;
}
} // namespace
DisplaySnapshotProxy::DisplaySnapshotProxy(const DisplaySnapshot_Params& params)
: DisplaySnapshot(params.display_id,
params.has_proper_display_id,
params.origin,
params.physical_size,
params.type,
params.is_aspect_preserving_scaling,
params.has_overscan,
params.display_name,
std::vector<const DisplayMode*>(),
NULL,
NULL),
string_representation_(params.string_representation) {
for (size_t i = 0; i < params.modes.size(); ++i) {
modes_.push_back(new DisplayModeProxy(params.modes[i]));
if (params.has_current_mode &&
SameModes(params.modes[i], params.current_mode))
current_mode_ = modes_.back();
if (params.has_native_mode &&
SameModes(params.modes[i], params.native_mode))
native_mode_ = modes_.back();
}
}
DisplaySnapshotProxy::~DisplaySnapshotProxy() {}
std::string DisplaySnapshotProxy::ToString() const {
return string_representation_;
}
} // namespace ui
// Copyright 2014 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_COMMON_CHROMEOS_DISPLAY_SNAPSHOT_PROXY_H_
#define UI_OZONE_COMMON_CHROMEOS_DISPLAY_SNAPSHOT_PROXY_H_
#include "ui/display/types/chromeos/display_snapshot.h"
namespace ui {
struct DisplaySnapshot_Params;
class DisplaySnapshotProxy : public DisplaySnapshot {
public:
DisplaySnapshotProxy(const DisplaySnapshot_Params& params);
virtual ~DisplaySnapshotProxy();
// DisplaySnapshot override:
virtual std::string ToString() const OVERRIDE;
private:
std::string string_representation_;
DISALLOW_COPY_AND_ASSIGN(DisplaySnapshotProxy);
};
} // namespace ui
#endif // UI_OZONE_COMMON_CHROMEOS_DISPLAY_SNAPSHOT_PROXY_H_
// Copyright 2014 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.
#include "ui/ozone/common/chromeos/display_util.h"
#include "ui/display/types/chromeos/display_mode.h"
#include "ui/display/types/chromeos/display_snapshot.h"
namespace ui {
DisplayMode_Params GetDisplayModeParams(const DisplayMode& mode) {
DisplayMode_Params params;
params.size = mode.size();
params.is_interlaced = mode.is_interlaced();
params.refresh_rate = mode.refresh_rate();
return params;
}
DisplaySnapshot_Params GetDisplaySnapshotParams(
const DisplaySnapshot& display) {
DisplaySnapshot_Params params;
params.display_id = display.display_id();
params.has_proper_display_id = display.has_proper_display_id();
params.origin = display.origin();
params.physical_size = display.physical_size();
params.type = display.type();
params.is_aspect_preserving_scaling = display.is_aspect_preserving_scaling();
params.has_overscan = display.has_overscan();
params.display_name = display.display_name();
for (size_t i = 0; i < display.modes().size(); ++i)
params.modes.push_back(GetDisplayModeParams(*display.modes()[i]));
params.has_current_mode = display.current_mode() != NULL;
if (params.has_current_mode)
params.current_mode = GetDisplayModeParams(*display.current_mode());
params.has_native_mode = display.native_mode() != NULL;
if (params.has_native_mode)
params.native_mode = GetDisplayModeParams(*display.native_mode());
params.string_representation = display.ToString();
return params;
}
} // namespace ui
// Copyright 2014 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_COMMON_CHROMEOS_DISPLAY_UTIL_H_
#define UI_OZONE_COMMON_CHROMEOS_DISPLAY_UTIL_H_
#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
namespace ui {
class DisplayMode;
class DisplaySnapshot;
DisplayMode_Params GetDisplayModeParams(const DisplayMode& mode);
DisplaySnapshot_Params GetDisplaySnapshotParams(
const DisplaySnapshot& display);
} // namespace ui
#endif // UI_OZONE_COMMON_CHROMEOS_DISPLAY_UTIL_H_
...@@ -85,6 +85,12 @@ ...@@ -85,6 +85,12 @@
# common/chromeos files are excluded automatically when building with # common/chromeos files are excluded automatically when building with
# chromeos=0, by exclusion rules in filename_rules.gypi due to the # chromeos=0, by exclusion rules in filename_rules.gypi due to the
# 'chromeos' folder name. # 'chromeos' folder name.
'common/chromeos/display_mode_proxy.cc',
'common/chromeos/display_mode_proxy.h',
'common/chromeos/display_snapshot_proxy.cc',
'common/chromeos/display_snapshot_proxy.h',
'common/chromeos/display_util.cc',
'common/chromeos/display_util.h',
'common/chromeos/native_display_delegate_ozone.cc', 'common/chromeos/native_display_delegate_ozone.cc',
'common/chromeos/native_display_delegate_ozone.h', 'common/chromeos/native_display_delegate_ozone.h',
'common/chromeos/touchscreen_device_manager_ozone.cc', 'common/chromeos/touchscreen_device_manager_ozone.cc',
......
// Copyright 2014 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.
#include "ui/ozone/platform/dri/chromeos/display_message_handler.h"
#include "ui/display/types/chromeos/display_mode.h"
#include "ui/display/types/chromeos/display_snapshot.h"
#include "ui/ozone/common/chromeos/display_util.h"
#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
#include "ui/ozone/common/gpu/ozone_gpu_messages.h"
#include "ui/ozone/platform/dri/chromeos/native_display_delegate_dri.h"
namespace ui {
DisplayMessageHandler::DisplayMessageHandler(
scoped_ptr<NativeDisplayDelegateDri> ndd)
: sender_(NULL),
ndd_(ndd.Pass()) {}
DisplayMessageHandler::~DisplayMessageHandler() {}
void DisplayMessageHandler::OnChannelEstablished(IPC::Sender* sender) {
sender_ = sender;
}
bool DisplayMessageHandler::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(DisplayMessageHandler, message)
IPC_MESSAGE_HANDLER(OzoneGpuMsg_ForceDPMSOn, OnForceDPMSOn)
IPC_MESSAGE_HANDLER(OzoneGpuMsg_RefreshNativeDisplays,
OnRefreshNativeDisplays)
IPC_MESSAGE_HANDLER(OzoneGpuMsg_ConfigureNativeDisplay,
OnConfigureNativeDisplay)
IPC_MESSAGE_HANDLER(OzoneGpuMsg_DisableNativeDisplay,
OnDisableNativeDisplay)
IPC_MESSAGE_UNHANDLED(handled = false);
IPC_END_MESSAGE_MAP()
return handled;
}
void DisplayMessageHandler::OnForceDPMSOn() {
ndd_->ForceDPMSOn();
}
void DisplayMessageHandler::OnRefreshNativeDisplays() {
std::vector<DisplaySnapshot_Params> displays;
std::vector<DisplaySnapshot*> native_displays = ndd_->GetDisplays();
for (size_t i = 0; i < native_displays.size(); ++i)
displays.push_back(GetDisplaySnapshotParams(*native_displays[i]));
sender_->Send(new OzoneHostMsg_UpdateNativeDisplays(displays));
}
void DisplayMessageHandler::OnConfigureNativeDisplay(
int64_t id,
const DisplayMode_Params& mode_param,
const gfx::Point& origin) {
DisplaySnapshot* display = ndd_->FindDisplaySnapshot(id);
if (!display) {
LOG(ERROR) << "There is no display with ID " << id;
return;
}
const DisplayMode* mode = NULL;
for (size_t i = 0; i < display->modes().size(); ++i) {
if (mode_param.size == display->modes()[i]->size() &&
mode_param.is_interlaced == display->modes()[i]->is_interlaced() &&
mode_param.refresh_rate == display->modes()[i]->refresh_rate()) {
mode = display->modes()[i];
break;
}
}
if (!mode) {
LOG(ERROR) << "Failed to find mode: size=" << mode_param.size.ToString()
<< " is_interlaced=" << mode_param.is_interlaced
<< " refresh_rate=" << mode_param.refresh_rate;
return;
}
ndd_->Configure(*display, mode, origin);
}
void DisplayMessageHandler::OnDisableNativeDisplay(int64_t id) {
DisplaySnapshot* display = ndd_->FindDisplaySnapshot(id);
if (display)
ndd_->Configure(*display, NULL, gfx::Point());
else
LOG(ERROR) << "There is no display with ID " << id;
}
} // namespace ui
// Copyright 2014 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_DRI_CHROMEOS_DISPLAY_MESSAGE_HANDLER_H_
#define UI_OZONE_PLATFORM_DRI_CHROMEOS_DISPLAY_MESSAGE_HANDLER_H_
#include "base/memory/scoped_ptr.h"
#include "ui/ozone/public/gpu_platform_support.h"
namespace gfx {
class Point;
}
namespace ui {
class NativeDisplayDelegateDri;
struct DisplayMode_Params;
struct DisplaySnapshot_Params;
class DisplayMessageHandler : public GpuPlatformSupport {
public:
DisplayMessageHandler(scoped_ptr<NativeDisplayDelegateDri> ndd);
virtual ~DisplayMessageHandler();
// GpuPlatformSupport:
virtual void OnChannelEstablished(IPC::Sender* sender) OVERRIDE;
// IPC::Listener:
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
private:
void OnForceDPMSOn();
void OnRefreshNativeDisplays();
void OnConfigureNativeDisplay(int64_t id,
const DisplayMode_Params& mode,
const gfx::Point& origin);
void OnDisableNativeDisplay(int64_t id);
IPC::Sender* sender_;
scoped_ptr<NativeDisplayDelegateDri> ndd_;
DISALLOW_COPY_AND_ASSIGN(DisplayMessageHandler);
};
} // namespace ui
#endif // UI_OZONE_PLATFORM_DRI_CHROMEOS_DISPLAY_MESSAGE_HANDLER_H_
...@@ -32,11 +32,21 @@ NativeDisplayDelegateDri::NativeDisplayDelegateDri( ...@@ -32,11 +32,21 @@ NativeDisplayDelegateDri::NativeDisplayDelegateDri(
} }
NativeDisplayDelegateDri::~NativeDisplayDelegateDri() { NativeDisplayDelegateDri::~NativeDisplayDelegateDri() {
device_manager_->RemoveObserver(this); if (device_manager_)
device_manager_->RemoveObserver(this);
}
DisplaySnapshot* NativeDisplayDelegateDri::FindDisplaySnapshot(int64_t id) {
for (size_t i = 0; i < cached_displays_.size(); ++i)
if (cached_displays_[i]->display_id() == id)
return cached_displays_[i];
return NULL;
} }
void NativeDisplayDelegateDri::Initialize() { void NativeDisplayDelegateDri::Initialize() {
device_manager_->AddObserver(this); if (device_manager_)
device_manager_->AddObserver(this);
ScopedVector<HardwareDisplayControllerInfo> displays = ScopedVector<HardwareDisplayControllerInfo> displays =
GetAvailableDisplayControllerInfos(dri_->get_fd()); GetAvailableDisplayControllerInfos(dri_->get_fd());
......
...@@ -27,6 +27,8 @@ class NativeDisplayDelegateDri ...@@ -27,6 +27,8 @@ class NativeDisplayDelegateDri
DeviceManager* device_manager); DeviceManager* device_manager);
virtual ~NativeDisplayDelegateDri(); virtual ~NativeDisplayDelegateDri();
DisplaySnapshot* FindDisplaySnapshot(int64_t id);
// NativeDisplayDelegate overrides: // NativeDisplayDelegate overrides:
virtual void Initialize() OVERRIDE; virtual void Initialize() OVERRIDE;
virtual void GrabServer() OVERRIDE; virtual void GrabServer() OVERRIDE;
......
// Copyright 2014 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.
#include "ui/ozone/platform/dri/chromeos/native_display_delegate_proxy.h"
#include "base/logging.h"
#include "ui/display/types/chromeos/display_snapshot.h"
#include "ui/display/types/chromeos/native_display_observer.h"
#include "ui/events/ozone/device/device_event.h"
#include "ui/events/ozone/device/device_manager.h"
#include "ui/ozone/common/chromeos/display_snapshot_proxy.h"
#include "ui/ozone/common/chromeos/display_util.h"
#include "ui/ozone/common/gpu/ozone_gpu_messages.h"
#include "ui/ozone/platform/dri/gpu_platform_support_host_gbm.h"
namespace ui {
NativeDisplayDelegateProxy::NativeDisplayDelegateProxy(
GpuPlatformSupportHostGbm* proxy,
DeviceManager* device_manager)
: proxy_(proxy),
device_manager_(device_manager) {
proxy_->RegisterHandler(this);
}
NativeDisplayDelegateProxy::~NativeDisplayDelegateProxy() {
if (device_manager_)
device_manager_->RemoveObserver(this);
proxy_->UnregisterHandler(this);
}
void NativeDisplayDelegateProxy::Initialize() {
if (device_manager_)
device_manager_->AddObserver(this);
}
void NativeDisplayDelegateProxy::GrabServer() {}
void NativeDisplayDelegateProxy::UngrabServer() {}
void NativeDisplayDelegateProxy::SyncWithServer() {}
void NativeDisplayDelegateProxy::SetBackgroundColor(uint32_t color_argb) {
NOTIMPLEMENTED();
}
void NativeDisplayDelegateProxy::ForceDPMSOn() {
proxy_->Send(new OzoneGpuMsg_ForceDPMSOn());
}
std::vector<DisplaySnapshot*> NativeDisplayDelegateProxy::GetDisplays() {
return displays_.get();
}
void NativeDisplayDelegateProxy::AddMode(const DisplaySnapshot& output,
const DisplayMode* mode) {}
bool NativeDisplayDelegateProxy::Configure(const DisplaySnapshot& output,
const DisplayMode* mode,
const gfx::Point& origin) {
// TODO(dnicoara) Should handle an asynchronous response.
if (mode)
proxy_->Send(new OzoneGpuMsg_ConfigureNativeDisplay(
output.display_id(), GetDisplayModeParams(*mode), origin));
else
proxy_->Send(new OzoneGpuMsg_DisableNativeDisplay(output.display_id()));
return true;
}
void NativeDisplayDelegateProxy::CreateFrameBuffer(const gfx::Size& size) {}
bool NativeDisplayDelegateProxy::GetHDCPState(const DisplaySnapshot& output,
HDCPState* state) {
NOTIMPLEMENTED();
return false;
}
bool NativeDisplayDelegateProxy::SetHDCPState(const DisplaySnapshot& output,
HDCPState state) {
NOTIMPLEMENTED();
return false;
}
std::vector<ColorCalibrationProfile>
NativeDisplayDelegateProxy::GetAvailableColorCalibrationProfiles(
const DisplaySnapshot& output) {
NOTIMPLEMENTED();
return std::vector<ColorCalibrationProfile>();
}
bool NativeDisplayDelegateProxy::SetColorCalibrationProfile(
const DisplaySnapshot& output,
ColorCalibrationProfile new_profile) {
NOTIMPLEMENTED();
return false;
}
void NativeDisplayDelegateProxy::AddObserver(NativeDisplayObserver* observer) {
observers_.AddObserver(observer);
}
void NativeDisplayDelegateProxy::RemoveObserver(
NativeDisplayObserver* observer) {
observers_.RemoveObserver(observer);
}
void NativeDisplayDelegateProxy::OnDeviceEvent(const DeviceEvent& event) {
if (event.device_type() != DeviceEvent::DISPLAY)
return;
if (event.action_type() == DeviceEvent::CHANGE) {
VLOG(1) << "Got display changed event";
proxy_->Send(new OzoneGpuMsg_RefreshNativeDisplays());
}
}
void NativeDisplayDelegateProxy::OnChannelEstablished(
int host_id, IPC::Sender* sender) {
// Force an initial configure such that the browser process can get the actual
// state.
proxy_->Send(new OzoneGpuMsg_RefreshNativeDisplays());
}
void NativeDisplayDelegateProxy::OnChannelDestroyed(int host_id) {
}
bool NativeDisplayDelegateProxy::OnMessageReceived(
const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(NativeDisplayDelegateProxy, message)
IPC_MESSAGE_HANDLER(OzoneHostMsg_UpdateNativeDisplays,
OnUpdateNativeDisplays)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void NativeDisplayDelegateProxy::OnUpdateNativeDisplays(
const std::vector<DisplaySnapshot_Params>& displays) {
displays_.clear();
for (size_t i = 0; i < displays.size(); ++i)
displays_.push_back(new DisplaySnapshotProxy(displays[i]));
FOR_EACH_OBSERVER(
NativeDisplayObserver, observers_, OnConfigurationChanged());
}
} // namespace ui
// Copyright 2014 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_DRI_CHROMEOS_NATIVE_DISPLAY_DELEGATE_PROXY_H_
#define UI_OZONE_PLATFORM_DRI_CHROMEOS_NATIVE_DISPLAY_DELEGATE_PROXY_H_
#include "base/macros.h"
#include "base/memory/scoped_vector.h"
#include "base/observer_list.h"
#include "ui/display/types/chromeos/native_display_delegate.h"
#include "ui/events/ozone/device/device_event_observer.h"
#include "ui/ozone/public/gpu_platform_support_host.h"
namespace ui {
class DeviceManager;
class GpuPlatformSupportHostGbm;
struct DisplaySnapshot_Params;
class NativeDisplayDelegateProxy : public NativeDisplayDelegate,
public DeviceEventObserver,
public GpuPlatformSupportHost {
public:
NativeDisplayDelegateProxy(GpuPlatformSupportHostGbm* proxy,
DeviceManager* device_manager);
virtual ~NativeDisplayDelegateProxy();
// NativeDisplayDelegate overrides:
virtual void Initialize() OVERRIDE;
virtual void GrabServer() OVERRIDE;
virtual void UngrabServer() OVERRIDE;
virtual void SyncWithServer() OVERRIDE;
virtual void SetBackgroundColor(uint32_t color_argb) OVERRIDE;
virtual void ForceDPMSOn() OVERRIDE;
virtual std::vector<DisplaySnapshot*> GetDisplays() OVERRIDE;
virtual void AddMode(const DisplaySnapshot& output,
const DisplayMode* mode) OVERRIDE;
virtual bool Configure(const DisplaySnapshot& output,
const DisplayMode* mode,
const gfx::Point& origin) OVERRIDE;
virtual void CreateFrameBuffer(const gfx::Size& size) OVERRIDE;
virtual bool GetHDCPState(const DisplaySnapshot& output,
HDCPState* state) OVERRIDE;
virtual bool SetHDCPState(const DisplaySnapshot& output,
HDCPState state) OVERRIDE;
virtual std::vector<ColorCalibrationProfile>
GetAvailableColorCalibrationProfiles(
const DisplaySnapshot& output) OVERRIDE;
virtual bool SetColorCalibrationProfile(
const DisplaySnapshot& output,
ColorCalibrationProfile new_profile) OVERRIDE;
virtual void AddObserver(NativeDisplayObserver* observer) OVERRIDE;
virtual void RemoveObserver(NativeDisplayObserver* observer) OVERRIDE;
// DeviceEventObserver overrides:
virtual void OnDeviceEvent(const DeviceEvent& event) OVERRIDE;
// GpuPlatformSupportHost:
virtual void OnChannelEstablished(int host_id, IPC::Sender* sender) OVERRIDE;
virtual void OnChannelDestroyed(int host_id) OVERRIDE;
// IPC::Listener overrides:
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
private:
void OnUpdateNativeDisplays(
const std::vector<DisplaySnapshot_Params>& displays);
GpuPlatformSupportHostGbm* proxy_; // Not owned.
DeviceManager* device_manager_; // Not owned.
ScopedVector<DisplaySnapshot> displays_;
ObserverList<NativeDisplayObserver> observers_;
DISALLOW_COPY_AND_ASSIGN(NativeDisplayDelegateProxy);
};
} // namespace ui
#endif // UI_OZONE_PLATFORM_DRI_CHROMEOS_NATIVE_DISPLAY_DELEGATE_PROXY_H_
...@@ -31,6 +31,10 @@ ...@@ -31,6 +31,10 @@
'sources': [ 'sources': [
'buffer_data.cc', 'buffer_data.cc',
'buffer_data.h', 'buffer_data.h',
'chromeos/display_message_handler.cc',
'chromeos/display_message_handler.h',
'chromeos/native_display_delegate_proxy.cc',
'chromeos/native_display_delegate_proxy.h',
'gbm_buffer.cc', 'gbm_buffer.cc',
'gbm_buffer.h', 'gbm_buffer.h',
'gbm_surface.cc', 'gbm_surface.cc',
......
...@@ -14,8 +14,17 @@ GpuPlatformSupportGbm::GpuPlatformSupportGbm(DriSurfaceFactory* dri) ...@@ -14,8 +14,17 @@ GpuPlatformSupportGbm::GpuPlatformSupportGbm(DriSurfaceFactory* dri)
: sender_(NULL), dri_(dri) { : sender_(NULL), dri_(dri) {
} }
GpuPlatformSupportGbm::~GpuPlatformSupportGbm() {}
void GpuPlatformSupportGbm::AddHandler(scoped_ptr<GpuPlatformSupport> handler) {
handlers_.push_back(handler.release());
}
void GpuPlatformSupportGbm::OnChannelEstablished(IPC::Sender* sender) { void GpuPlatformSupportGbm::OnChannelEstablished(IPC::Sender* sender) {
sender_ = sender; sender_ = sender;
for (size_t i = 0; i < handlers_.size(); ++i)
handlers_[i]->OnChannelEstablished(sender);
} }
bool GpuPlatformSupportGbm::OnMessageReceived(const IPC::Message& message) { bool GpuPlatformSupportGbm::OnMessageReceived(const IPC::Message& message) {
...@@ -27,7 +36,12 @@ bool GpuPlatformSupportGbm::OnMessageReceived(const IPC::Message& message) { ...@@ -27,7 +36,12 @@ bool GpuPlatformSupportGbm::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_UNHANDLED(handled = false); IPC_MESSAGE_UNHANDLED(handled = false);
IPC_END_MESSAGE_MAP() IPC_END_MESSAGE_MAP()
return handled; if (!handled)
for (size_t i = 0; i < handlers_.size(); ++i)
if (handlers_[i]->OnMessageReceived(message))
return true;
return false;
} }
void GpuPlatformSupportGbm::OnCursorSet(gfx::AcceleratedWidget widget, void GpuPlatformSupportGbm::OnCursorSet(gfx::AcceleratedWidget widget,
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef UI_OZONE_PLATFORM_DRI_GPU_PLATFORM_SUPPORT_GBM_H_ #ifndef UI_OZONE_PLATFORM_DRI_GPU_PLATFORM_SUPPORT_GBM_H_
#define UI_OZONE_PLATFORM_DRI_GPU_PLATFORM_SUPPORT_GBM_H_ #define UI_OZONE_PLATFORM_DRI_GPU_PLATFORM_SUPPORT_GBM_H_
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
#include "ui/ozone/public/gpu_platform_support.h" #include "ui/ozone/public/gpu_platform_support.h"
...@@ -21,6 +23,9 @@ class DriSurfaceFactory; ...@@ -21,6 +23,9 @@ class DriSurfaceFactory;
class GpuPlatformSupportGbm : public GpuPlatformSupport { class GpuPlatformSupportGbm : public GpuPlatformSupport {
public: public:
GpuPlatformSupportGbm(DriSurfaceFactory* dri); GpuPlatformSupportGbm(DriSurfaceFactory* dri);
virtual ~GpuPlatformSupportGbm();
void AddHandler(scoped_ptr<GpuPlatformSupport> handler);
// GpuPlatformSupport: // GpuPlatformSupport:
virtual void OnChannelEstablished(IPC::Sender* sender) OVERRIDE; virtual void OnChannelEstablished(IPC::Sender* sender) OVERRIDE;
...@@ -37,6 +42,7 @@ class GpuPlatformSupportGbm : public GpuPlatformSupport { ...@@ -37,6 +42,7 @@ class GpuPlatformSupportGbm : public GpuPlatformSupport {
void OnCursorMove(gfx::AcceleratedWidget widget, const gfx::Point& location); void OnCursorMove(gfx::AcceleratedWidget widget, const gfx::Point& location);
DriSurfaceFactory* dri_; DriSurfaceFactory* dri_;
ScopedVector<GpuPlatformSupport> handlers_;
}; };
} // namespace ui } // namespace ui
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "ui/ozone/platform/dri/gpu_platform_support_host_gbm.h" #include "ui/ozone/platform/dri/gpu_platform_support_host_gbm.h"
#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
#include "ui/ozone/common/gpu/ozone_gpu_messages.h" #include "ui/ozone/common/gpu/ozone_gpu_messages.h"
namespace ui { namespace ui {
...@@ -12,10 +13,28 @@ GpuPlatformSupportHostGbm::GpuPlatformSupportHostGbm() ...@@ -12,10 +13,28 @@ GpuPlatformSupportHostGbm::GpuPlatformSupportHostGbm()
: host_id_(-1), sender_(NULL) { : host_id_(-1), sender_(NULL) {
} }
GpuPlatformSupportHostGbm::~GpuPlatformSupportHostGbm() {}
void GpuPlatformSupportHostGbm::RegisterHandler(
GpuPlatformSupportHost* handler) {
handlers_.push_back(handler);
}
void GpuPlatformSupportHostGbm::UnregisterHandler(
GpuPlatformSupportHost* handler) {
std::vector<GpuPlatformSupportHost*>::iterator it =
std::find(handlers_.begin(), handlers_.end(), handler);
if (it != handlers_.end())
handlers_.erase(it);
}
void GpuPlatformSupportHostGbm::OnChannelEstablished(int host_id, void GpuPlatformSupportHostGbm::OnChannelEstablished(int host_id,
IPC::Sender* sender) { IPC::Sender* sender) {
host_id_ = host_id; host_id_ = host_id;
sender_ = sender; sender_ = sender;
for (size_t i = 0; i < handlers_.size(); ++i)
handlers_[i]->OnChannelEstablished(host_id, sender);
} }
void GpuPlatformSupportHostGbm::OnChannelDestroyed(int host_id) { void GpuPlatformSupportHostGbm::OnChannelDestroyed(int host_id) {
...@@ -23,9 +42,23 @@ void GpuPlatformSupportHostGbm::OnChannelDestroyed(int host_id) { ...@@ -23,9 +42,23 @@ void GpuPlatformSupportHostGbm::OnChannelDestroyed(int host_id) {
host_id_ = -1; host_id_ = -1;
sender_ = NULL; sender_ = NULL;
} }
for (size_t i = 0; i < handlers_.size(); ++i)
handlers_[i]->OnChannelDestroyed(host_id);
} }
bool GpuPlatformSupportHostGbm::OnMessageReceived(const IPC::Message& message) { bool GpuPlatformSupportHostGbm::OnMessageReceived(const IPC::Message& message) {
for (size_t i = 0; i < handlers_.size(); ++i)
if (handlers_[i]->OnMessageReceived(message))
return true;
return false;
}
bool GpuPlatformSupportHostGbm::Send(IPC::Message* message) {
if (sender_)
return sender_->Send(message);
return false; return false;
} }
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef UI_OZONE_PLATFORM_DRI_GPU_PLATFORM_SUPPORT_HOST_GBM_H_ #ifndef UI_OZONE_PLATFORM_DRI_GPU_PLATFORM_SUPPORT_HOST_GBM_H_
#define UI_OZONE_PLATFORM_DRI_GPU_PLATFORM_SUPPORT_HOST_GBM_H_ #define UI_OZONE_PLATFORM_DRI_GPU_PLATFORM_SUPPORT_HOST_GBM_H_
#include <vector>
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
#include "ui/ozone/platform/dri/hardware_cursor_delegate.h" #include "ui/ozone/platform/dri/hardware_cursor_delegate.h"
#include "ui/ozone/public/gpu_platform_support_host.h" #include "ui/ozone/public/gpu_platform_support_host.h"
...@@ -18,9 +20,14 @@ class Point; ...@@ -18,9 +20,14 @@ class Point;
namespace ui { namespace ui {
class GpuPlatformSupportHostGbm : public GpuPlatformSupportHost, class GpuPlatformSupportHostGbm : public GpuPlatformSupportHost,
public HardwareCursorDelegate { public HardwareCursorDelegate,
public IPC::Sender {
public: public:
GpuPlatformSupportHostGbm(); GpuPlatformSupportHostGbm();
virtual ~GpuPlatformSupportHostGbm();
void RegisterHandler(GpuPlatformSupportHost* handler);
void UnregisterHandler(GpuPlatformSupportHost* handler);
// GpuPlatformSupportHost: // GpuPlatformSupportHost:
virtual void OnChannelEstablished(int host_id, IPC::Sender* sender) OVERRIDE; virtual void OnChannelEstablished(int host_id, IPC::Sender* sender) OVERRIDE;
...@@ -29,6 +36,9 @@ class GpuPlatformSupportHostGbm : public GpuPlatformSupportHost, ...@@ -29,6 +36,9 @@ class GpuPlatformSupportHostGbm : public GpuPlatformSupportHost,
// IPC::Listener: // IPC::Listener:
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
// IPC::Sender:
virtual bool Send(IPC::Message* message) OVERRIDE;
// HardwareCursorDelegate: // HardwareCursorDelegate:
virtual void SetHardwareCursor(gfx::AcceleratedWidget widget, virtual void SetHardwareCursor(gfx::AcceleratedWidget widget,
const SkBitmap& bitmap, const SkBitmap& bitmap,
...@@ -39,6 +49,7 @@ class GpuPlatformSupportHostGbm : public GpuPlatformSupportHost, ...@@ -39,6 +49,7 @@ class GpuPlatformSupportHostGbm : public GpuPlatformSupportHost,
private: private:
int host_id_; int host_id_;
IPC::Sender* sender_; IPC::Sender* sender_;
std::vector<GpuPlatformSupportHost*> handlers_;
}; };
} // namespace ui } // namespace ui
......
...@@ -26,8 +26,10 @@ ...@@ -26,8 +26,10 @@
#include "ui/ozone/public/gpu_platform_support_host.h" #include "ui/ozone/public/gpu_platform_support_host.h"
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "ui/ozone/common/chromeos/native_display_delegate_ozone.h"
#include "ui/ozone/common/chromeos/touchscreen_device_manager_ozone.h" #include "ui/ozone/common/chromeos/touchscreen_device_manager_ozone.h"
#include "ui/ozone/platform/dri/chromeos/display_message_handler.h"
#include "ui/ozone/platform/dri/chromeos/native_display_delegate_dri.h"
#include "ui/ozone/platform/dri/chromeos/native_display_delegate_proxy.h"
#endif #endif
namespace ui { namespace ui {
...@@ -92,7 +94,8 @@ class OzonePlatformGbm : public OzonePlatform { ...@@ -92,7 +94,8 @@ class OzonePlatformGbm : public OzonePlatform {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate()
OVERRIDE { OVERRIDE {
return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateOzone()); return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateProxy(
gpu_platform_support_host_.get(), device_manager_.get()));
} }
virtual scoped_ptr<TouchscreenDeviceManager> virtual scoped_ptr<TouchscreenDeviceManager>
CreateTouchscreenDeviceManager() OVERRIDE { CreateTouchscreenDeviceManager() OVERRIDE {
...@@ -128,6 +131,14 @@ class OzonePlatformGbm : public OzonePlatform { ...@@ -128,6 +131,14 @@ class OzonePlatformGbm : public OzonePlatform {
gpu_platform_support_.reset( gpu_platform_support_.reset(
new GpuPlatformSupportGbm(surface_factory_ozone_.get())); new GpuPlatformSupportGbm(surface_factory_ozone_.get()));
#if defined(OS_CHROMEOS)
gpu_platform_support_->AddHandler(scoped_ptr<GpuPlatformSupport>(
new DisplayMessageHandler(
scoped_ptr<NativeDisplayDelegateDri>(new NativeDisplayDelegateDri(
dri_.get(),
screen_manager_.get(),
NULL)))));
#endif
} }
private: private:
......
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