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/drm/gpu/drm_gpu_display_manager.h" | 5 #include "ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_descriptor_posix.h" | 9 #include "base/file_descriptor_posix.h" |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
12 #include "ui/display/types/gamma_ramp_rgb_entry.h" | |
13 #include "ui/display/types/native_display_observer.h" | 12 #include "ui/display/types/native_display_observer.h" |
14 #include "ui/events/ozone/device/device_event.h" | 13 #include "ui/events/ozone/device/device_event.h" |
15 #include "ui/ozone/common/display_util.h" | 14 #include "ui/ozone/common/display_util.h" |
16 #include "ui/ozone/platform/drm/gpu/drm_device.h" | 15 #include "ui/ozone/platform/drm/gpu/drm_device.h" |
17 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" | 16 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" |
18 #include "ui/ozone/platform/drm/gpu/drm_display_mode.h" | 17 #include "ui/ozone/platform/drm/gpu/drm_display_mode.h" |
19 #include "ui/ozone/platform/drm/gpu/drm_display_snapshot.h" | 18 #include "ui/ozone/platform/drm/gpu/drm_display_snapshot.h" |
20 #include "ui/ozone/platform/drm/gpu/drm_util.h" | 19 #include "ui/ozone/platform/drm/gpu/drm_util.h" |
21 #include "ui/ozone/platform/drm/gpu/screen_manager.h" | 20 #include "ui/ozone/platform/drm/gpu/screen_manager.h" |
22 #include "ui/ozone/public/ozone_switches.h" | 21 #include "ui/ozone/public/ozone_switches.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 const DrmDeviceVector& devices = drm_device_manager_->GetDrmDevices(); | 185 const DrmDeviceVector& devices = drm_device_manager_->GetDrmDevices(); |
187 for (const auto& drm : devices) { | 186 for (const auto& drm : devices) { |
188 if (!drm->DropMaster()) { | 187 if (!drm->DropMaster()) { |
189 LOG(ERROR) << "Failed to relinquish control of the display"; | 188 LOG(ERROR) << "Failed to relinquish control of the display"; |
190 return false; | 189 return false; |
191 } | 190 } |
192 } | 191 } |
193 return true; | 192 return true; |
194 } | 193 } |
195 | 194 |
196 void DrmGpuDisplayManager::SetGammaRamp( | |
197 int64_t id, | |
198 const std::vector<GammaRampRGBEntry>& lut) { | |
199 DrmDisplaySnapshot* display = FindDisplaySnapshot(id); | |
200 if (!display) { | |
201 LOG(ERROR) << "There is no display with ID " << id; | |
202 return; | |
203 } | |
204 | |
205 if (!display->drm()->SetGammaRamp(display->crtc(), lut)) { | |
206 LOG(ERROR) << "Failed to set gamma ramp for display: crtc_id = " | |
207 << display->crtc() << " size = " << lut.size(); | |
208 } | |
209 } | |
210 | |
211 DrmDisplaySnapshot* DrmGpuDisplayManager::FindDisplaySnapshot(int64_t id) { | 195 DrmDisplaySnapshot* DrmGpuDisplayManager::FindDisplaySnapshot(int64_t id) { |
212 for (size_t i = 0; i < cached_displays_.size(); ++i) | 196 for (size_t i = 0; i < cached_displays_.size(); ++i) |
213 if (cached_displays_[i]->display_id() == id) | 197 if (cached_displays_[i]->display_id() == id) |
214 return cached_displays_[i]; | 198 return cached_displays_[i]; |
215 | 199 |
216 return NULL; | 200 return NULL; |
217 } | 201 } |
218 | 202 |
219 const DrmDisplayMode* DrmGpuDisplayManager::FindDisplayMode( | 203 const DrmDisplayMode* DrmGpuDisplayManager::FindDisplayMode( |
220 const gfx::Size& size, | 204 const gfx::Size& size, |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 | 358 |
375 if (it == old_displays.end()) { | 359 if (it == old_displays.end()) { |
376 screen_manager_->AddDisplayController(new_displays[i]->drm(), | 360 screen_manager_->AddDisplayController(new_displays[i]->drm(), |
377 new_displays[i]->crtc(), | 361 new_displays[i]->crtc(), |
378 new_displays[i]->connector()); | 362 new_displays[i]->connector()); |
379 } | 363 } |
380 } | 364 } |
381 } | 365 } |
382 | 366 |
383 } // namespace ui | 367 } // namespace ui |
OLD | NEW |