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/native_display_delegate_proxy.h" | 5 #include "ui/ozone/platform/dri/native_display_delegate_proxy.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/display/types/display_snapshot.h" | 8 #include "ui/display/types/display_snapshot.h" |
9 #include "ui/display/types/native_display_observer.h" | 9 #include "ui/display/types/native_display_observer.h" |
10 #include "ui/events/ozone/device/device_event.h" | 10 #include "ui/events/ozone/device/device_event.h" |
11 #include "ui/events/ozone/device/device_manager.h" | 11 #include "ui/events/ozone/device/device_manager.h" |
12 #include "ui/ozone/common/display_snapshot_proxy.h" | 12 #include "ui/ozone/common/display_snapshot_proxy.h" |
13 #include "ui/ozone/common/display_util.h" | 13 #include "ui/ozone/common/display_util.h" |
14 #include "ui/ozone/common/gpu/ozone_gpu_messages.h" | 14 #include "ui/ozone/common/gpu/ozone_gpu_messages.h" |
| 15 #include "ui/ozone/platform/dri/display_manager.h" |
15 #include "ui/ozone/platform/dri/dri_gpu_platform_support_host.h" | 16 #include "ui/ozone/platform/dri/dri_gpu_platform_support_host.h" |
16 | 17 |
17 namespace ui { | 18 namespace ui { |
18 | 19 |
| 20 namespace { |
| 21 |
| 22 class DriDisplaySnapshotProxy : public DisplaySnapshotProxy { |
| 23 public: |
| 24 DriDisplaySnapshotProxy(const DisplaySnapshot_Params& params, |
| 25 DisplayManager* display_manager) |
| 26 : DisplaySnapshotProxy(params), display_manager_(display_manager) { |
| 27 display_manager_->RegisterDisplay(this); |
| 28 } |
| 29 |
| 30 virtual ~DriDisplaySnapshotProxy() { |
| 31 display_manager_->UnregisterDisplay(this); |
| 32 } |
| 33 |
| 34 private: |
| 35 DisplayManager* display_manager_; // Not owned. |
| 36 |
| 37 DISALLOW_COPY_AND_ASSIGN(DriDisplaySnapshotProxy); |
| 38 }; |
| 39 |
| 40 } // namespace |
| 41 |
19 NativeDisplayDelegateProxy::NativeDisplayDelegateProxy( | 42 NativeDisplayDelegateProxy::NativeDisplayDelegateProxy( |
20 DriGpuPlatformSupportHost* proxy, | 43 DriGpuPlatformSupportHost* proxy, |
21 DeviceManager* device_manager) | 44 DeviceManager* device_manager, |
22 : proxy_(proxy), device_manager_(device_manager) { | 45 DisplayManager* display_manager) |
| 46 : proxy_(proxy), |
| 47 device_manager_(device_manager), |
| 48 display_manager_(display_manager) { |
23 proxy_->RegisterHandler(this); | 49 proxy_->RegisterHandler(this); |
24 } | 50 } |
25 | 51 |
26 NativeDisplayDelegateProxy::~NativeDisplayDelegateProxy() { | 52 NativeDisplayDelegateProxy::~NativeDisplayDelegateProxy() { |
27 if (device_manager_) | 53 if (device_manager_) |
28 device_manager_->RemoveObserver(this); | 54 device_manager_->RemoveObserver(this); |
29 | 55 |
30 proxy_->UnregisterHandler(this); | 56 proxy_->UnregisterHandler(this); |
31 } | 57 } |
32 | 58 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 IPC_MESSAGE_UNHANDLED(handled = false) | 172 IPC_MESSAGE_UNHANDLED(handled = false) |
147 IPC_END_MESSAGE_MAP() | 173 IPC_END_MESSAGE_MAP() |
148 | 174 |
149 return handled; | 175 return handled; |
150 } | 176 } |
151 | 177 |
152 void NativeDisplayDelegateProxy::OnUpdateNativeDisplays( | 178 void NativeDisplayDelegateProxy::OnUpdateNativeDisplays( |
153 const std::vector<DisplaySnapshot_Params>& displays) { | 179 const std::vector<DisplaySnapshot_Params>& displays) { |
154 displays_.clear(); | 180 displays_.clear(); |
155 for (size_t i = 0; i < displays.size(); ++i) | 181 for (size_t i = 0; i < displays.size(); ++i) |
156 displays_.push_back(new DisplaySnapshotProxy(displays[i])); | 182 displays_.push_back( |
| 183 new DriDisplaySnapshotProxy(displays[i], display_manager_)); |
157 | 184 |
158 FOR_EACH_OBSERVER( | 185 FOR_EACH_OBSERVER( |
159 NativeDisplayObserver, observers_, OnConfigurationChanged()); | 186 NativeDisplayObserver, observers_, OnConfigurationChanged()); |
160 } | 187 } |
161 | 188 |
162 } // namespace ui | 189 } // namespace ui |
OLD | NEW |