OLD | NEW |
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/chromeos/native_display_delegate_proxy.h" | 5 #include "ui/ozone/platform/dri/chromeos/native_display_delegate_proxy.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/display/types/chromeos/display_snapshot.h" | 8 #include "ui/display/types/chromeos/display_snapshot.h" |
9 #include "ui/display/types/chromeos/native_display_observer.h" | 9 #include "ui/display/types/chromeos/native_display_observer.h" |
10 #include "ui/events/ozone/device/device_event.h" | 10 #include "ui/events/ozone/device/device_event.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 NativeDisplayObserver* observer) { | 106 NativeDisplayObserver* observer) { |
107 observers_.RemoveObserver(observer); | 107 observers_.RemoveObserver(observer); |
108 } | 108 } |
109 | 109 |
110 void NativeDisplayDelegateProxy::OnDeviceEvent(const DeviceEvent& event) { | 110 void NativeDisplayDelegateProxy::OnDeviceEvent(const DeviceEvent& event) { |
111 if (event.device_type() != DeviceEvent::DISPLAY) | 111 if (event.device_type() != DeviceEvent::DISPLAY) |
112 return; | 112 return; |
113 | 113 |
114 if (event.action_type() == DeviceEvent::CHANGE) { | 114 if (event.action_type() == DeviceEvent::CHANGE) { |
115 VLOG(1) << "Got display changed event"; | 115 VLOG(1) << "Got display changed event"; |
116 proxy_->Send(new OzoneGpuMsg_RefreshNativeDisplays( | 116 proxy_->Send(new OzoneGpuMsg_RefreshNativeDisplays()); |
117 std::vector<DisplaySnapshot_Params>())); | |
118 } | 117 } |
119 } | 118 } |
120 | 119 |
121 void NativeDisplayDelegateProxy::OnChannelEstablished( | 120 void NativeDisplayDelegateProxy::OnChannelEstablished( |
122 int host_id, IPC::Sender* sender) { | 121 int host_id, IPC::Sender* sender) { |
123 std::vector<DisplaySnapshot_Params> display_params; | |
124 for (size_t i = 0; i < displays_.size(); ++i) | |
125 display_params.push_back(GetDisplaySnapshotParams(*displays_[i])); | |
126 | |
127 // Force an initial configure such that the browser process can get the actual | 122 // Force an initial configure such that the browser process can get the actual |
128 // state. Pass in the current display state since the GPU process may have | 123 // state. |
129 // crashed and we want to re-synchronize the state between processes. | 124 proxy_->Send(new OzoneGpuMsg_RefreshNativeDisplays()); |
130 proxy_->Send(new OzoneGpuMsg_RefreshNativeDisplays(display_params)); | |
131 } | 125 } |
132 | 126 |
133 void NativeDisplayDelegateProxy::OnChannelDestroyed(int host_id) { | 127 void NativeDisplayDelegateProxy::OnChannelDestroyed(int host_id) { |
134 } | 128 } |
135 | 129 |
136 bool NativeDisplayDelegateProxy::OnMessageReceived( | 130 bool NativeDisplayDelegateProxy::OnMessageReceived( |
137 const IPC::Message& message) { | 131 const IPC::Message& message) { |
138 bool handled = true; | 132 bool handled = true; |
139 | 133 |
140 IPC_BEGIN_MESSAGE_MAP(NativeDisplayDelegateProxy, message) | 134 IPC_BEGIN_MESSAGE_MAP(NativeDisplayDelegateProxy, message) |
141 IPC_MESSAGE_HANDLER(OzoneHostMsg_UpdateNativeDisplays, | 135 IPC_MESSAGE_HANDLER(OzoneHostMsg_UpdateNativeDisplays, |
142 OnUpdateNativeDisplays) | 136 OnUpdateNativeDisplays) |
143 IPC_MESSAGE_UNHANDLED(handled = false) | 137 IPC_MESSAGE_UNHANDLED(handled = false) |
144 IPC_END_MESSAGE_MAP() | 138 IPC_END_MESSAGE_MAP() |
145 | 139 |
146 return handled; | 140 return handled; |
147 } | 141 } |
148 | 142 |
149 void NativeDisplayDelegateProxy::OnUpdateNativeDisplays( | 143 void NativeDisplayDelegateProxy::OnUpdateNativeDisplays( |
150 const std::vector<DisplaySnapshot_Params>& displays) { | 144 const std::vector<DisplaySnapshot_Params>& displays) { |
151 displays_.clear(); | 145 displays_.clear(); |
152 for (size_t i = 0; i < displays.size(); ++i) | 146 for (size_t i = 0; i < displays.size(); ++i) |
153 displays_.push_back(new DisplaySnapshotProxy(displays[i])); | 147 displays_.push_back(new DisplaySnapshotProxy(displays[i])); |
154 | 148 |
155 FOR_EACH_OBSERVER( | 149 FOR_EACH_OBSERVER( |
156 NativeDisplayObserver, observers_, OnConfigurationChanged()); | 150 NativeDisplayObserver, observers_, OnConfigurationChanged()); |
157 } | 151 } |
158 | 152 |
159 } // namespace ui | 153 } // namespace ui |
OLD | NEW |