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>())); |
117 } | 118 } |
118 } | 119 } |
119 | 120 |
120 void NativeDisplayDelegateProxy::OnChannelEstablished( | 121 void NativeDisplayDelegateProxy::OnChannelEstablished( |
121 int host_id, IPC::Sender* sender) { | 122 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 |
122 // Force an initial configure such that the browser process can get the actual | 127 // Force an initial configure such that the browser process can get the actual |
123 // state. | 128 // state. Pass in the current display state since the GPU process may have |
124 proxy_->Send(new OzoneGpuMsg_RefreshNativeDisplays()); | 129 // crashed and we want to re-synchronize the state between processes. |
| 130 proxy_->Send(new OzoneGpuMsg_RefreshNativeDisplays(display_params)); |
125 } | 131 } |
126 | 132 |
127 void NativeDisplayDelegateProxy::OnChannelDestroyed(int host_id) { | 133 void NativeDisplayDelegateProxy::OnChannelDestroyed(int host_id) { |
128 } | 134 } |
129 | 135 |
130 bool NativeDisplayDelegateProxy::OnMessageReceived( | 136 bool NativeDisplayDelegateProxy::OnMessageReceived( |
131 const IPC::Message& message) { | 137 const IPC::Message& message) { |
132 bool handled = true; | 138 bool handled = true; |
133 | 139 |
134 IPC_BEGIN_MESSAGE_MAP(NativeDisplayDelegateProxy, message) | 140 IPC_BEGIN_MESSAGE_MAP(NativeDisplayDelegateProxy, message) |
135 IPC_MESSAGE_HANDLER(OzoneHostMsg_UpdateNativeDisplays, | 141 IPC_MESSAGE_HANDLER(OzoneHostMsg_UpdateNativeDisplays, |
136 OnUpdateNativeDisplays) | 142 OnUpdateNativeDisplays) |
137 IPC_MESSAGE_UNHANDLED(handled = false) | 143 IPC_MESSAGE_UNHANDLED(handled = false) |
138 IPC_END_MESSAGE_MAP() | 144 IPC_END_MESSAGE_MAP() |
139 | 145 |
140 return handled; | 146 return handled; |
141 } | 147 } |
142 | 148 |
143 void NativeDisplayDelegateProxy::OnUpdateNativeDisplays( | 149 void NativeDisplayDelegateProxy::OnUpdateNativeDisplays( |
144 const std::vector<DisplaySnapshot_Params>& displays) { | 150 const std::vector<DisplaySnapshot_Params>& displays) { |
145 displays_.clear(); | 151 displays_.clear(); |
146 for (size_t i = 0; i < displays.size(); ++i) | 152 for (size_t i = 0; i < displays.size(); ++i) |
147 displays_.push_back(new DisplaySnapshotProxy(displays[i])); | 153 displays_.push_back(new DisplaySnapshotProxy(displays[i])); |
148 | 154 |
149 FOR_EACH_OBSERVER( | 155 FOR_EACH_OBSERVER( |
150 NativeDisplayObserver, observers_, OnConfigurationChanged()); | 156 NativeDisplayObserver, observers_, OnConfigurationChanged()); |
151 } | 157 } |
152 | 158 |
153 } // namespace ui | 159 } // namespace ui |
OLD | NEW |