Chromium Code Reviews| Index: ui/ozone/platform/dri/gpu_platform_support_gbm.cc |
| diff --git a/ui/ozone/platform/dri/gpu_platform_support_gbm.cc b/ui/ozone/platform/dri/gpu_platform_support_gbm.cc |
| index 70c99f4d2ff782c8badb7975109605460e77c2b0..30f40191ab2cdc833cdf8c2d903a676accd27cb3 100644 |
| --- a/ui/ozone/platform/dri/gpu_platform_support_gbm.cc |
| +++ b/ui/ozone/platform/dri/gpu_platform_support_gbm.cc |
| @@ -5,13 +5,20 @@ |
| #include "ui/ozone/platform/dri/gpu_platform_support_gbm.h" |
| #include "ipc/ipc_message_macros.h" |
| -#include "ui/ozone/common/gpu/ozone_gpu_messages.h" |
| #include "ui/ozone/platform/dri/dri_surface_factory.h" |
| +#if defined(OS_CHROMEOS) |
| +#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/platform/dri/chromeos/native_display_delegate_dri.h" |
| +#endif |
| + |
| namespace ui { |
| GpuPlatformSupportGbm::GpuPlatformSupportGbm(DriSurfaceFactory* dri) |
| - : sender_(NULL), dri_(dri) { |
| + : sender_(NULL), dri_(dri), ndd_() { |
| } |
| void GpuPlatformSupportGbm::OnChannelEstablished(IPC::Sender* sender) { |
| @@ -24,6 +31,15 @@ bool GpuPlatformSupportGbm::OnMessageReceived(const IPC::Message& message) { |
| IPC_BEGIN_MESSAGE_MAP(GpuPlatformSupportGbm, message) |
| IPC_MESSAGE_HANDLER(OzoneGpuMsg_CursorSet, OnCursorSet) |
| IPC_MESSAGE_HANDLER(OzoneGpuMsg_CursorMove, OnCursorMove) |
| +#if defined(OS_CHROMEOS) |
| + IPC_MESSAGE_HANDLER(OzoneGpuMsg_ForceDPMSOn, OnForceDPMSOn) |
| + IPC_MESSAGE_HANDLER(OzoneGpuMsg_RefreshNativeDisplays, |
| + OnRefreshNativeDisplays) |
| + IPC_MESSAGE_HANDLER(OzoneGpuMsg_ConfigureNativeDisplay, |
| + OnConfigureNativeDisplay) |
| + IPC_MESSAGE_HANDLER(OzoneGpuMsg_DisableNativeDisplay, |
| + OnDisableNativeDisplay) |
| +#endif |
| IPC_MESSAGE_UNHANDLED(handled = false); |
| IPC_END_MESSAGE_MAP() |
|
spang
2014/07/08 14:40:52
maybe instead of all these ifdefs, chain another c
dnicoara
2014/07/08 17:13:35
Done.
|
| @@ -41,4 +57,62 @@ void GpuPlatformSupportGbm::OnCursorMove(gfx::AcceleratedWidget widget, |
| dri_->MoveHardwareCursor(widget, location); |
| } |
| +#if defined(OS_CHROMEOS) |
| +void GpuPlatformSupportGbm::SetNativeDisplayDelegate( |
| + scoped_ptr<NativeDisplayDelegateDri> ndd) { |
| + ndd_.reset(ndd.release()); |
|
spang
2014/07/08 14:40:53
ndd_ = ndd.Pass();
|
| +} |
| + |
| +void GpuPlatformSupportGbm::OnForceDPMSOn() { |
| + ndd_->ForceDPMSOn(); |
| +} |
| + |
| +void GpuPlatformSupportGbm::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 GpuPlatformSupportGbm::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 GpuPlatformSupportGbm::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; |
| +} |
| +#endif |
| + |
| } // namespace ui |