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" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 std::find_if(devices_.begin(), devices_.end(), FindByDevicePath(path)); | 229 std::find_if(devices_.begin(), devices_.end(), FindByDevicePath(path)); |
230 if (it == devices_.end()) { | 230 if (it == devices_.end()) { |
231 VLOG(2) << "Got request to remove non-existent device '" << path.value() | 231 VLOG(2) << "Got request to remove non-existent device '" << path.value() |
232 << "'"; | 232 << "'"; |
233 return; | 233 return; |
234 } | 234 } |
235 | 235 |
236 devices_.erase(it); | 236 devices_.erase(it); |
237 } | 237 } |
238 | 238 |
| 239 void DrmGpuDisplayManager::SetGammaRamp(int64_t id, |
| 240 const std::vector<uint16_t>& r, |
| 241 const std::vector<uint16_t>& g, |
| 242 const std::vector<uint16_t>& b) { |
| 243 DrmDisplaySnapshot* display = FindDisplaySnapshot(id); |
| 244 if (!display) { |
| 245 LOG(ERROR) << "There is no display with ID " << id; |
| 246 return; |
| 247 } |
| 248 |
| 249 if (r.size() != g.size() || g.size() != b.size()) { |
| 250 LOG(ERROR) << "Gamma ramp channels must all the same length."; |
| 251 } |
| 252 |
| 253 if (!display->drm()->SetGammaRamp(display->crtc(), r, g, b)) { |
| 254 LOG(ERROR) << "Failed to set gamma ramp for display: crtc_id = " |
| 255 << display->crtc() << " size = " << r.size(); |
| 256 } |
| 257 } |
| 258 |
239 DrmDisplaySnapshot* DrmGpuDisplayManager::FindDisplaySnapshot(int64_t id) { | 259 DrmDisplaySnapshot* DrmGpuDisplayManager::FindDisplaySnapshot(int64_t id) { |
240 for (size_t i = 0; i < cached_displays_.size(); ++i) | 260 for (size_t i = 0; i < cached_displays_.size(); ++i) |
241 if (cached_displays_[i]->display_id() == id) | 261 if (cached_displays_[i]->display_id() == id) |
242 return cached_displays_[i]; | 262 return cached_displays_[i]; |
243 | 263 |
244 return NULL; | 264 return NULL; |
245 } | 265 } |
246 | 266 |
247 const DrmDisplayMode* DrmGpuDisplayManager::FindDisplayMode( | 267 const DrmDisplayMode* DrmGpuDisplayManager::FindDisplayMode( |
248 const gfx::Size& size, | 268 const gfx::Size& size, |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 | 426 |
407 if (it == old_displays.end()) { | 427 if (it == old_displays.end()) { |
408 screen_manager_->AddDisplayController(new_displays[i]->drm(), | 428 screen_manager_->AddDisplayController(new_displays[i]->drm(), |
409 new_displays[i]->crtc(), | 429 new_displays[i]->crtc(), |
410 new_displays[i]->connector()); | 430 new_displays[i]->connector()); |
411 } | 431 } |
412 } | 432 } |
413 } | 433 } |
414 | 434 |
415 } // namespace ui | 435 } // namespace ui |
OLD | NEW |