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_dri.h" | 5 #include "ui/ozone/platform/dri/chromeos/native_display_delegate_dri.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "third_party/skia/include/core/SkCanvas.h" | 8 #include "third_party/skia/include/core/SkCanvas.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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 } | 45 } |
46 | 46 |
47 for (int i = 0; i < property->count_enums; ++i) | 47 for (int i = 0; i < property->count_enums; ++i) |
48 if (name == property->enums[i].name) | 48 if (name == property->enums[i].name) |
49 return i; | 49 return i; |
50 | 50 |
51 NOTREACHED(); | 51 NOTREACHED(); |
52 return 0; | 52 return 0; |
53 } | 53 } |
54 | 54 |
| 55 class DisplaySnapshotComparator { |
| 56 public: |
| 57 DisplaySnapshotComparator(const DisplaySnapshotDri* snapshot) |
| 58 : snapshot_(snapshot) {} |
| 59 |
| 60 bool operator()(const DisplaySnapshotDri* other) const { |
| 61 if (snapshot_->connector() == other->connector() && |
| 62 snapshot_->crtc() == other->crtc()) |
| 63 return true; |
| 64 |
| 65 return false; |
| 66 } |
| 67 |
| 68 private: |
| 69 const DisplaySnapshotDri* snapshot_; |
| 70 }; |
| 71 |
55 } // namespace | 72 } // namespace |
56 | 73 |
57 NativeDisplayDelegateDri::NativeDisplayDelegateDri( | 74 NativeDisplayDelegateDri::NativeDisplayDelegateDri( |
58 DriWrapper* dri, | 75 DriWrapper* dri, |
59 ScreenManager* screen_manager, | 76 ScreenManager* screen_manager, |
60 DeviceManager* device_manager) | 77 DeviceManager* device_manager) |
61 : dri_(dri), | 78 : dri_(dri), |
62 screen_manager_(screen_manager), | 79 screen_manager_(screen_manager), |
63 device_manager_(device_manager) { | 80 device_manager_(device_manager) { |
64 } | 81 } |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 VLOG(1) << "Got display changed event"; | 298 VLOG(1) << "Got display changed event"; |
282 FOR_EACH_OBSERVER( | 299 FOR_EACH_OBSERVER( |
283 NativeDisplayObserver, observers_, OnConfigurationChanged()); | 300 NativeDisplayObserver, observers_, OnConfigurationChanged()); |
284 } | 301 } |
285 } | 302 } |
286 | 303 |
287 void NativeDisplayDelegateDri::NotifyScreenManager( | 304 void NativeDisplayDelegateDri::NotifyScreenManager( |
288 const std::vector<DisplaySnapshotDri*>& new_displays, | 305 const std::vector<DisplaySnapshotDri*>& new_displays, |
289 const std::vector<DisplaySnapshotDri*>& old_displays) const { | 306 const std::vector<DisplaySnapshotDri*>& old_displays) const { |
290 for (size_t i = 0; i < old_displays.size(); ++i) { | 307 for (size_t i = 0; i < old_displays.size(); ++i) { |
291 bool found = false; | 308 const std::vector<DisplaySnapshotDri*>::const_iterator it = |
292 for (size_t j = 0; j < new_displays.size(); ++j) { | 309 std::find_if(new_displays.begin(), |
293 if (old_displays[i]->connector() == new_displays[j]->connector() && | 310 new_displays.end(), |
294 old_displays[i]->crtc() == new_displays[j]->crtc()) { | 311 DisplaySnapshotComparator(old_displays[i])); |
295 found = true; | |
296 break; | |
297 } | |
298 } | |
299 | 312 |
300 if (!found) | 313 if (it == new_displays.end()) |
301 screen_manager_->RemoveDisplayController(old_displays[i]->crtc()); | 314 screen_manager_->RemoveDisplayController(old_displays[i]->crtc()); |
302 } | 315 } |
| 316 |
| 317 for (size_t i = 0; i < new_displays.size(); ++i) { |
| 318 const std::vector<DisplaySnapshotDri*>::const_iterator it = |
| 319 std::find_if(old_displays.begin(), |
| 320 old_displays.end(), |
| 321 DisplaySnapshotComparator(new_displays[i])); |
| 322 |
| 323 if (it == old_displays.end()) |
| 324 screen_manager_->AddDisplayController(new_displays[i]->crtc(), |
| 325 new_displays[i]->connector()); |
| 326 } |
303 } | 327 } |
304 | 328 |
305 } // namespace ui | 329 } // namespace ui |
OLD | NEW |