| 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 "third_party/skia/include/core/SkCanvas.h" | 8 #include "third_party/skia/include/core/SkCanvas.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" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 void NativeDisplayDelegateDri::SetBackgroundColor(uint32_t color_argb) { | 143 void NativeDisplayDelegateDri::SetBackgroundColor(uint32_t color_argb) { |
| 144 if (console_buffer_) | 144 if (console_buffer_) |
| 145 console_buffer_->canvas()->clear(color_argb); | 145 console_buffer_->canvas()->clear(color_argb); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void NativeDisplayDelegateDri::ForceDPMSOn() { | 148 void NativeDisplayDelegateDri::ForceDPMSOn() { |
| 149 for (size_t i = 0; i < cached_displays_.size(); ++i) { | 149 for (size_t i = 0; i < cached_displays_.size(); ++i) { |
| 150 DisplaySnapshotDri* dri_output = cached_displays_[i]; | 150 DisplaySnapshotDri* dri_output = cached_displays_[i]; |
| 151 if (dri_output->dpms_property()) | 151 if (dri_output->dpms_property()) |
| 152 dri_->SetProperty(dri_output->connector(), | 152 dri_->SetProperty(dri_output->connector(), |
| 153 dri_output->dpms_property()->prop_id, | 153 dri_output->dpms_property()->prop_id, DRM_MODE_DPMS_ON); |
| 154 DRM_MODE_DPMS_ON); | |
| 155 } | 154 } |
| 156 } | 155 } |
| 157 | 156 |
| 158 std::vector<DisplaySnapshot*> NativeDisplayDelegateDri::GetDisplays() { | 157 std::vector<DisplaySnapshot*> NativeDisplayDelegateDri::GetDisplays() { |
| 159 ScopedVector<DisplaySnapshotDri> old_displays(cached_displays_.Pass()); | 158 ScopedVector<DisplaySnapshotDri> old_displays(cached_displays_.Pass()); |
| 160 cached_modes_.clear(); | 159 cached_modes_.clear(); |
| 161 | 160 |
| 162 ScopedVector<HardwareDisplayControllerInfo> displays = | 161 ScopedVector<HardwareDisplayControllerInfo> displays = |
| 163 GetAvailableDisplayControllerInfos(dri_->get_fd()); | 162 GetAvailableDisplayControllerInfos(dri_->get_fd()); |
| 164 for (size_t i = 0; | 163 for (size_t i = 0; |
| 165 i < displays.size() && cached_displays_.size() < kMaxDisplayCount; | 164 i < displays.size() && cached_displays_.size() < kMaxDisplayCount; ++i) { |
| 166 ++i) { | |
| 167 DisplaySnapshotDri* display = new DisplaySnapshotDri( | 165 DisplaySnapshotDri* display = new DisplaySnapshotDri( |
| 168 dri_, displays[i]->connector(), displays[i]->crtc(), i); | 166 dri_, displays[i]->connector(), displays[i]->crtc(), i); |
| 169 cached_displays_.push_back(display); | 167 cached_displays_.push_back(display); |
| 170 cached_modes_.insert( | 168 cached_modes_.insert(cached_modes_.end(), display->modes().begin(), |
| 171 cached_modes_.end(), display->modes().begin(), display->modes().end()); | 169 display->modes().end()); |
| 172 } | 170 } |
| 173 | 171 |
| 174 NotifyScreenManager(cached_displays_.get(), old_displays.get()); | 172 NotifyScreenManager(cached_displays_.get(), old_displays.get()); |
| 175 | 173 |
| 176 std::vector<DisplaySnapshot*> generic_displays(cached_displays_.begin(), | 174 std::vector<DisplaySnapshot*> generic_displays(cached_displays_.begin(), |
| 177 cached_displays_.end()); | 175 cached_displays_.end()); |
| 178 return generic_displays; | 176 return generic_displays; |
| 179 } | 177 } |
| 180 | 178 |
| 181 void NativeDisplayDelegateDri::AddMode(const DisplaySnapshot& output, | 179 void NativeDisplayDelegateDri::AddMode(const DisplaySnapshot& output, |
| 182 const DisplayMode* mode) { | 180 const DisplayMode* mode) { |
| 183 } | 181 } |
| 184 | 182 |
| 185 bool NativeDisplayDelegateDri::Configure(const DisplaySnapshot& output, | 183 bool NativeDisplayDelegateDri::Configure(const DisplaySnapshot& output, |
| 186 const DisplayMode* mode, | 184 const DisplayMode* mode, |
| 187 const gfx::Point& origin) { | 185 const gfx::Point& origin) { |
| 188 const DisplaySnapshotDri& dri_output = | 186 const DisplaySnapshotDri& dri_output = |
| 189 static_cast<const DisplaySnapshotDri&>(output); | 187 static_cast<const DisplaySnapshotDri&>(output); |
| 190 | 188 |
| 191 VLOG(1) << "DRM configuring: crtc=" << dri_output.crtc() | 189 VLOG(1) << "DRM configuring: crtc=" << dri_output.crtc() |
| 192 << " connector=" << dri_output.connector() | 190 << " connector=" << dri_output.connector() |
| 193 << " origin=" << origin.ToString() | 191 << " origin=" << origin.ToString() |
| 194 << " size=" << (mode ? mode->size().ToString() : "0x0"); | 192 << " size=" << (mode ? mode->size().ToString() : "0x0"); |
| 195 | 193 |
| 196 if (mode) { | 194 if (mode) { |
| 197 if (!screen_manager_->ConfigureDisplayController( | 195 if (!screen_manager_->ConfigureDisplayController( |
| 198 dri_output.crtc(), | 196 dri_output.crtc(), dri_output.connector(), origin, |
| 199 dri_output.connector(), | |
| 200 origin, | |
| 201 static_cast<const DisplayModeDri*>(mode)->mode_info())) { | 197 static_cast<const DisplayModeDri*>(mode)->mode_info())) { |
| 202 VLOG(1) << "Failed to configure: crtc=" << dri_output.crtc() | 198 VLOG(1) << "Failed to configure: crtc=" << dri_output.crtc() |
| 203 << " connector=" << dri_output.connector(); | 199 << " connector=" << dri_output.connector(); |
| 204 return false; | 200 return false; |
| 205 } | 201 } |
| 206 } else { | 202 } else { |
| 207 if (!screen_manager_->DisableDisplayController(dri_output.crtc())) { | 203 if (!screen_manager_->DisableDisplayController(dri_output.crtc())) { |
| 208 VLOG(1) << "Failed to disable crtc=" << dri_output.crtc(); | 204 VLOG(1) << "Failed to disable crtc=" << dri_output.crtc(); |
| 209 return false; | 205 return false; |
| 210 } | 206 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 } | 259 } |
| 264 | 260 |
| 265 ScopedDrmPropertyPtr hdcp_property( | 261 ScopedDrmPropertyPtr hdcp_property( |
| 266 dri_->GetProperty(connector.get(), kContentProtection)); | 262 dri_->GetProperty(connector.get(), kContentProtection)); |
| 267 if (!hdcp_property) { | 263 if (!hdcp_property) { |
| 268 LOG(ERROR) << "'" << kContentProtection << "' property doesn't exist."; | 264 LOG(ERROR) << "'" << kContentProtection << "' property doesn't exist."; |
| 269 return false; | 265 return false; |
| 270 } | 266 } |
| 271 | 267 |
| 272 return dri_->SetProperty( | 268 return dri_->SetProperty( |
| 273 dri_output.connector(), | 269 dri_output.connector(), hdcp_property->prop_id, |
| 274 hdcp_property->prop_id, | |
| 275 GetContentProtectionValue(hdcp_property.get(), state)); | 270 GetContentProtectionValue(hdcp_property.get(), state)); |
| 276 } | 271 } |
| 277 | 272 |
| 278 std::vector<ui::ColorCalibrationProfile> | 273 std::vector<ui::ColorCalibrationProfile> |
| 279 NativeDisplayDelegateDri::GetAvailableColorCalibrationProfiles( | 274 NativeDisplayDelegateDri::GetAvailableColorCalibrationProfiles( |
| 280 const ui::DisplaySnapshot& output) { | 275 const ui::DisplaySnapshot& output) { |
| 281 NOTIMPLEMENTED(); | 276 NOTIMPLEMENTED(); |
| 282 return std::vector<ui::ColorCalibrationProfile>(); | 277 return std::vector<ui::ColorCalibrationProfile>(); |
| 283 } | 278 } |
| 284 | 279 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 296 void NativeDisplayDelegateDri::RemoveObserver(NativeDisplayObserver* observer) { | 291 void NativeDisplayDelegateDri::RemoveObserver(NativeDisplayObserver* observer) { |
| 297 observers_.RemoveObserver(observer); | 292 observers_.RemoveObserver(observer); |
| 298 } | 293 } |
| 299 | 294 |
| 300 void NativeDisplayDelegateDri::OnDeviceEvent(const DeviceEvent& event) { | 295 void NativeDisplayDelegateDri::OnDeviceEvent(const DeviceEvent& event) { |
| 301 if (event.device_type() != DeviceEvent::DISPLAY) | 296 if (event.device_type() != DeviceEvent::DISPLAY) |
| 302 return; | 297 return; |
| 303 | 298 |
| 304 if (event.action_type() == DeviceEvent::CHANGE) { | 299 if (event.action_type() == DeviceEvent::CHANGE) { |
| 305 VLOG(1) << "Got display changed event"; | 300 VLOG(1) << "Got display changed event"; |
| 306 FOR_EACH_OBSERVER( | 301 FOR_EACH_OBSERVER(NativeDisplayObserver, observers_, |
| 307 NativeDisplayObserver, observers_, OnConfigurationChanged()); | 302 OnConfigurationChanged()); |
| 308 } | 303 } |
| 309 } | 304 } |
| 310 | 305 |
| 311 void NativeDisplayDelegateDri::NotifyScreenManager( | 306 void NativeDisplayDelegateDri::NotifyScreenManager( |
| 312 const std::vector<DisplaySnapshotDri*>& new_displays, | 307 const std::vector<DisplaySnapshotDri*>& new_displays, |
| 313 const std::vector<DisplaySnapshotDri*>& old_displays) const { | 308 const std::vector<DisplaySnapshotDri*>& old_displays) const { |
| 314 for (size_t i = 0; i < old_displays.size(); ++i) { | 309 for (size_t i = 0; i < old_displays.size(); ++i) { |
| 315 const std::vector<DisplaySnapshotDri*>::const_iterator it = | 310 const std::vector<DisplaySnapshotDri*>::const_iterator it = |
| 316 std::find_if(new_displays.begin(), | 311 std::find_if(new_displays.begin(), new_displays.end(), |
| 317 new_displays.end(), | |
| 318 DisplaySnapshotComparator(old_displays[i])); | 312 DisplaySnapshotComparator(old_displays[i])); |
| 319 | 313 |
| 320 if (it == new_displays.end()) | 314 if (it == new_displays.end()) |
| 321 screen_manager_->RemoveDisplayController(old_displays[i]->crtc()); | 315 screen_manager_->RemoveDisplayController(old_displays[i]->crtc()); |
| 322 } | 316 } |
| 323 | 317 |
| 324 for (size_t i = 0; i < new_displays.size(); ++i) { | 318 for (size_t i = 0; i < new_displays.size(); ++i) { |
| 325 const std::vector<DisplaySnapshotDri*>::const_iterator it = | 319 const std::vector<DisplaySnapshotDri*>::const_iterator it = |
| 326 std::find_if(old_displays.begin(), | 320 std::find_if(old_displays.begin(), old_displays.end(), |
| 327 old_displays.end(), | |
| 328 DisplaySnapshotComparator(new_displays[i])); | 321 DisplaySnapshotComparator(new_displays[i])); |
| 329 | 322 |
| 330 if (it == old_displays.end()) | 323 if (it == old_displays.end()) |
| 331 screen_manager_->AddDisplayController( | 324 screen_manager_->AddDisplayController(dri_, new_displays[i]->crtc(), |
| 332 dri_, new_displays[i]->crtc(), new_displays[i]->connector()); | 325 new_displays[i]->connector()); |
| 333 } | 326 } |
| 334 } | 327 } |
| 335 | 328 |
| 336 } // namespace ui | 329 } // namespace ui |
| OLD | NEW |