| 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_dri.h" | 5 #include "ui/ozone/platform/dri/native_display_delegate_dri.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "ui/display/types/native_display_observer.h" | 8 #include "ui/display/types/native_display_observer.h" |
| 9 #include "ui/events/ozone/device/device_event.h" | 9 #include "ui/events/ozone/device/device_event.h" |
| 10 #include "ui/ozone/platform/dri/display_mode_dri.h" | 10 #include "ui/ozone/platform/dri/display_mode_dri.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 for (int i = 0; i < property->count_enums; ++i) | 42 for (int i = 0; i < property->count_enums; ++i) |
| 43 if (name == property->enums[i].name) | 43 if (name == property->enums[i].name) |
| 44 return i; | 44 return i; |
| 45 | 45 |
| 46 NOTREACHED(); | 46 NOTREACHED(); |
| 47 return 0; | 47 return 0; |
| 48 } | 48 } |
| 49 | 49 |
| 50 class DisplaySnapshotComparator { | 50 class DisplaySnapshotComparator { |
| 51 public: | 51 public: |
| 52 DisplaySnapshotComparator(const DisplaySnapshotDri* snapshot) | 52 explicit DisplaySnapshotComparator(const DisplaySnapshotDri* snapshot) |
| 53 : snapshot_(snapshot) {} | 53 : crtc_(snapshot->crtc()), connector_(snapshot->connector()) {} |
| 54 |
| 55 DisplaySnapshotComparator(uint32_t crtc, uint32_t connector) |
| 56 : crtc_(crtc), connector_(connector) {} |
| 54 | 57 |
| 55 bool operator()(const DisplaySnapshotDri* other) const { | 58 bool operator()(const DisplaySnapshotDri* other) const { |
| 56 if (snapshot_->connector() == other->connector() && | 59 return connector_ == other->connector() && crtc_ == other->crtc(); |
| 57 snapshot_->crtc() == other->crtc()) | |
| 58 return true; | |
| 59 | |
| 60 return false; | |
| 61 } | 60 } |
| 62 | 61 |
| 63 private: | 62 private: |
| 64 const DisplaySnapshotDri* snapshot_; | 63 uint32_t crtc_; |
| 64 uint32_t connector_; |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 } // namespace | 67 } // namespace |
| 68 | 68 |
| 69 NativeDisplayDelegateDri::NativeDisplayDelegateDri( | 69 NativeDisplayDelegateDri::NativeDisplayDelegateDri( |
| 70 DriWrapper* dri, | 70 DriWrapper* dri, |
| 71 ScreenManager* screen_manager) | 71 ScreenManager* screen_manager) |
| 72 : dri_(dri), screen_manager_(screen_manager) { | 72 : dri_(dri), screen_manager_(screen_manager) { |
| 73 // TODO(dnicoara): Remove when async display configuration is supported. | 73 // TODO(dnicoara): Remove when async display configuration is supported. |
| 74 screen_manager_->ForceInitializationOfPrimaryDisplay(); | 74 screen_manager_->ForceInitializationOfPrimaryDisplay(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 for (size_t i = 0; i < cached_displays_.size(); ++i) { | 133 for (size_t i = 0; i < cached_displays_.size(); ++i) { |
| 134 DisplaySnapshotDri* dri_output = cached_displays_[i]; | 134 DisplaySnapshotDri* dri_output = cached_displays_[i]; |
| 135 if (dri_output->dpms_property()) | 135 if (dri_output->dpms_property()) |
| 136 dri_->SetProperty(dri_output->connector(), | 136 dri_->SetProperty(dri_output->connector(), |
| 137 dri_output->dpms_property()->prop_id, DRM_MODE_DPMS_ON); | 137 dri_output->dpms_property()->prop_id, DRM_MODE_DPMS_ON); |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 | 140 |
| 141 std::vector<DisplaySnapshot*> NativeDisplayDelegateDri::GetDisplays() { | 141 std::vector<DisplaySnapshot*> NativeDisplayDelegateDri::GetDisplays() { |
| 142 ScopedVector<DisplaySnapshotDri> old_displays(cached_displays_.Pass()); | 142 ScopedVector<DisplaySnapshotDri> old_displays(cached_displays_.Pass()); |
| 143 cached_modes_.clear(); | 143 ScopedVector<const DisplayMode> old_modes(cached_modes_.Pass()); |
| 144 | 144 |
| 145 ScopedVector<HardwareDisplayControllerInfo> displays = | 145 ScopedVector<HardwareDisplayControllerInfo> displays = |
| 146 GetAvailableDisplayControllerInfos(dri_->get_fd()); | 146 GetAvailableDisplayControllerInfos(dri_->get_fd()); |
| 147 for (size_t i = 0; i < displays.size(); ++i) { | 147 for (size_t i = 0; i < displays.size(); ++i) { |
| 148 DisplaySnapshotDri* display = new DisplaySnapshotDri( | 148 DisplaySnapshotDri* display = new DisplaySnapshotDri( |
| 149 dri_, displays[i]->connector(), displays[i]->crtc(), i); | 149 dri_, displays[i]->connector(), displays[i]->crtc(), i); |
| 150 |
| 151 // If the display exists make sure to sync up the new snapshot with the old |
| 152 // one to keep the user configured details. |
| 153 auto it = std::find_if( |
| 154 old_displays.begin(), old_displays.end(), |
| 155 DisplaySnapshotComparator(displays[i]->crtc()->crtc_id, |
| 156 displays[i]->connector()->connector_id)); |
| 157 // Origin is only used within the platform code to keep track of the display |
| 158 // location. |
| 159 if (it != old_displays.end()) |
| 160 display->set_origin((*it)->origin()); |
| 161 |
| 150 cached_displays_.push_back(display); | 162 cached_displays_.push_back(display); |
| 151 cached_modes_.insert(cached_modes_.end(), display->modes().begin(), | 163 cached_modes_.insert(cached_modes_.end(), display->modes().begin(), |
| 152 display->modes().end()); | 164 display->modes().end()); |
| 153 } | 165 } |
| 154 | 166 |
| 155 NotifyScreenManager(cached_displays_.get(), old_displays.get()); | 167 NotifyScreenManager(cached_displays_.get(), old_displays.get()); |
| 156 | 168 |
| 157 std::vector<DisplaySnapshot*> generic_displays(cached_displays_.begin(), | 169 std::vector<DisplaySnapshot*> generic_displays(cached_displays_.begin(), |
| 158 cached_displays_.end()); | 170 cached_displays_.end()); |
| 159 return generic_displays; | 171 return generic_displays; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 std::find_if(old_displays.begin(), old_displays.end(), | 316 std::find_if(old_displays.begin(), old_displays.end(), |
| 305 DisplaySnapshotComparator(new_displays[i])); | 317 DisplaySnapshotComparator(new_displays[i])); |
| 306 | 318 |
| 307 if (it == old_displays.end()) | 319 if (it == old_displays.end()) |
| 308 screen_manager_->AddDisplayController(dri_, new_displays[i]->crtc(), | 320 screen_manager_->AddDisplayController(dri_, new_displays[i]->crtc(), |
| 309 new_displays[i]->connector()); | 321 new_displays[i]->connector()); |
| 310 } | 322 } |
| 311 } | 323 } |
| 312 | 324 |
| 313 } // namespace ui | 325 } // namespace ui |
| OLD | NEW |