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

Side by Side Diff: ui/ozone/platform/dri/gpu_platform_support_gbm.cc

Issue 377753002: [Ozone-GBM] Add basic support for display configuration over IPC (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/ozone/platform/dri/gpu_platform_support_gbm.h" 5 #include "ui/ozone/platform/dri/gpu_platform_support_gbm.h"
6 6
7 #include "ipc/ipc_message_macros.h" 7 #include "ipc/ipc_message_macros.h"
8 #include "ui/ozone/common/gpu/ozone_gpu_messages.h"
9 #include "ui/ozone/platform/dri/dri_surface_factory.h" 8 #include "ui/ozone/platform/dri/dri_surface_factory.h"
10 9
10 #if defined(OS_CHROMEOS)
11 #include "ui/display/types/chromeos/display_mode.h"
12 #include "ui/display/types/chromeos/display_snapshot.h"
13 #include "ui/ozone/common/chromeos/display_util.h"
14 #include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
15 #include "ui/ozone/platform/dri/chromeos/native_display_delegate_dri.h"
16 #endif
17
11 namespace ui { 18 namespace ui {
12 19
13 GpuPlatformSupportGbm::GpuPlatformSupportGbm(DriSurfaceFactory* dri) 20 GpuPlatformSupportGbm::GpuPlatformSupportGbm(DriSurfaceFactory* dri)
14 : sender_(NULL), dri_(dri) { 21 : sender_(NULL), dri_(dri), ndd_() {
15 } 22 }
16 23
17 void GpuPlatformSupportGbm::OnChannelEstablished(IPC::Sender* sender) { 24 void GpuPlatformSupportGbm::OnChannelEstablished(IPC::Sender* sender) {
18 sender_ = sender; 25 sender_ = sender;
19 } 26 }
20 27
21 bool GpuPlatformSupportGbm::OnMessageReceived(const IPC::Message& message) { 28 bool GpuPlatformSupportGbm::OnMessageReceived(const IPC::Message& message) {
22 bool handled = true; 29 bool handled = true;
23 30
24 IPC_BEGIN_MESSAGE_MAP(GpuPlatformSupportGbm, message) 31 IPC_BEGIN_MESSAGE_MAP(GpuPlatformSupportGbm, message)
25 IPC_MESSAGE_HANDLER(OzoneGpuMsg_CursorSet, OnCursorSet) 32 IPC_MESSAGE_HANDLER(OzoneGpuMsg_CursorSet, OnCursorSet)
26 IPC_MESSAGE_HANDLER(OzoneGpuMsg_CursorMove, OnCursorMove) 33 IPC_MESSAGE_HANDLER(OzoneGpuMsg_CursorMove, OnCursorMove)
34 #if defined(OS_CHROMEOS)
35 IPC_MESSAGE_HANDLER(OzoneGpuMsg_ForceDPMSOn, OnForceDPMSOn)
36 IPC_MESSAGE_HANDLER(OzoneGpuMsg_RefreshNativeDisplays,
37 OnRefreshNativeDisplays)
38 IPC_MESSAGE_HANDLER(OzoneGpuMsg_ConfigureNativeDisplay,
39 OnConfigureNativeDisplay)
40 IPC_MESSAGE_HANDLER(OzoneGpuMsg_DisableNativeDisplay,
41 OnDisableNativeDisplay)
42 #endif
27 IPC_MESSAGE_UNHANDLED(handled = false); 43 IPC_MESSAGE_UNHANDLED(handled = false);
28 IPC_END_MESSAGE_MAP() 44 IPC_END_MESSAGE_MAP()
29 45
spang 2014/07/08 14:40:52 maybe instead of all these ifdefs, chain another c
dnicoara 2014/07/08 17:13:35 Done.
30 return handled; 46 return handled;
31 } 47 }
32 48
33 void GpuPlatformSupportGbm::OnCursorSet(gfx::AcceleratedWidget widget, 49 void GpuPlatformSupportGbm::OnCursorSet(gfx::AcceleratedWidget widget,
34 const SkBitmap& bitmap, 50 const SkBitmap& bitmap,
35 const gfx::Point& location) { 51 const gfx::Point& location) {
36 dri_->SetHardwareCursor(widget, bitmap, location); 52 dri_->SetHardwareCursor(widget, bitmap, location);
37 } 53 }
38 54
39 void GpuPlatformSupportGbm::OnCursorMove(gfx::AcceleratedWidget widget, 55 void GpuPlatformSupportGbm::OnCursorMove(gfx::AcceleratedWidget widget,
40 const gfx::Point& location) { 56 const gfx::Point& location) {
41 dri_->MoveHardwareCursor(widget, location); 57 dri_->MoveHardwareCursor(widget, location);
42 } 58 }
43 59
60 #if defined(OS_CHROMEOS)
61 void GpuPlatformSupportGbm::SetNativeDisplayDelegate(
62 scoped_ptr<NativeDisplayDelegateDri> ndd) {
63 ndd_.reset(ndd.release());
spang 2014/07/08 14:40:53 ndd_ = ndd.Pass();
64 }
65
66 void GpuPlatformSupportGbm::OnForceDPMSOn() {
67 ndd_->ForceDPMSOn();
68 }
69
70 void GpuPlatformSupportGbm::OnRefreshNativeDisplays() {
71 std::vector<DisplaySnapshot_Params> displays;
72 std::vector<DisplaySnapshot*> native_displays = ndd_->GetDisplays();
73 for (size_t i = 0; i < native_displays.size(); ++i)
74 displays.push_back(GetDisplaySnapshotParams(*native_displays[i]));
75
76 sender_->Send(new OzoneHostMsg_UpdateNativeDisplays(displays));
77 }
78
79 void GpuPlatformSupportGbm::OnConfigureNativeDisplay(
80 int64_t id,
81 const DisplayMode_Params& mode_param,
82 const gfx::Point& origin) {
83 DisplaySnapshot* display = ndd_->FindDisplaySnapshot(id);
84 if (!display) {
85 LOG(ERROR) << "There is no display with ID " << id;
86 return;
87 }
88
89 const DisplayMode* mode = NULL;
90 for (size_t i = 0; i < display->modes().size(); ++i) {
91 if (mode_param.size == display->modes()[i]->size() &&
92 mode_param.is_interlaced == display->modes()[i]->is_interlaced() &&
93 mode_param.refresh_rate == display->modes()[i]->refresh_rate()) {
94 mode = display->modes()[i];
95 break;
96 }
97 }
98
99 if (!mode) {
100 LOG(ERROR) << "Failed to find mode: size=" << mode_param.size.ToString()
101 << " is_interlaced=" << mode_param.is_interlaced
102 << " refresh_rate=" << mode_param.refresh_rate;
103 return;
104 }
105
106 ndd_->Configure(*display, mode, origin);
107 }
108
109 void GpuPlatformSupportGbm::OnDisableNativeDisplay(int64_t id) {
110 DisplaySnapshot* display = ndd_->FindDisplaySnapshot(id);
111 if (display)
112 ndd_->Configure(*display, NULL, gfx::Point());
113 else
114 LOG(ERROR) << "There is no display with ID " << id;
115 }
116 #endif
117
44 } // namespace ui 118 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698