| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chromeos/display/output_util.h" | 5 #include "chromeos/display/output_util.h" |
| 6 | 6 |
| 7 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
| 8 #include <X11/extensions/Xrandr.h> | 8 #include <X11/extensions/Xrandr.h> |
| 9 #include <X11/Xatom.h> | 9 #include <X11/Xatom.h> |
| 10 | 10 |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 } | 324 } |
| 325 | 325 |
| 326 return false; | 326 return false; |
| 327 } | 327 } |
| 328 | 328 |
| 329 bool IsInternalOutputName(const std::string& name) { | 329 bool IsInternalOutputName(const std::string& name) { |
| 330 return name.find(kInternal_LVDS) == 0 || name.find(kInternal_eDP) == 0 || | 330 return name.find(kInternal_LVDS) == 0 || name.find(kInternal_eDP) == 0 || |
| 331 name.find(kInternal_DSI) == 0; | 331 name.find(kInternal_DSI) == 0; |
| 332 } | 332 } |
| 333 | 333 |
| 334 const XRRModeInfo* FindModeInfo(const XRRScreenResources* screen_resources, | 334 const XRRModeInfo* FindXRRModeInfo(const XRRScreenResources* screen_resources, |
| 335 XID current_mode) { | 335 XID current_mode) { |
| 336 for (int m = 0; m < screen_resources->nmode; m++) { | 336 for (int m = 0; m < screen_resources->nmode; m++) { |
| 337 XRRModeInfo *mode = &screen_resources->modes[m]; | 337 XRRModeInfo *mode = &screen_resources->modes[m]; |
| 338 if (mode->id == current_mode) | 338 if (mode->id == current_mode) |
| 339 return mode; | 339 return mode; |
| 340 } | 340 } |
| 341 return NULL; | 341 return NULL; |
| 342 } | 342 } |
| 343 | 343 |
| 344 // Find a mode that matches the given size with highest | 344 // Find a mode that matches the given size with highest |
| 345 // reflesh rate. | 345 // reflesh rate. |
| 346 RRMode FindOutputModeMatchingSize( | 346 RRMode FindOutputModeMatchingSize( |
| 347 const XRRScreenResources* screen_resources, | 347 const XRRScreenResources* screen_resources, |
| 348 const XRROutputInfo* output_info, | 348 const XRROutputInfo* output_info, |
| 349 size_t width, | 349 size_t width, |
| 350 size_t height) { | 350 size_t height) { |
| 351 RRMode found = None; | 351 RRMode found = None; |
| 352 float best_rate = 0; | 352 float best_rate = 0; |
| 353 bool non_interlaced_found = false; | 353 bool non_interlaced_found = false; |
| 354 for (int i = 0; i < output_info->nmode; ++i) { | 354 for (int i = 0; i < output_info->nmode; ++i) { |
| 355 RRMode mode = output_info->modes[i]; | 355 RRMode mode = output_info->modes[i]; |
| 356 const XRRModeInfo* info = FindModeInfo(screen_resources, mode); | 356 const XRRModeInfo* info = FindXRRModeInfo(screen_resources, mode); |
| 357 | 357 |
| 358 if (info->width == width && info->height == height) { | 358 if (info->width == width && info->height == height) { |
| 359 float rate = GetRefreshRate(info); | 359 float rate = GetRefreshRate(info); |
| 360 | 360 |
| 361 if (info->modeFlags & RR_Interlace) { | 361 if (info->modeFlags & RR_Interlace) { |
| 362 if (non_interlaced_found) | 362 if (non_interlaced_found) |
| 363 continue; | 363 continue; |
| 364 } else { | 364 } else { |
| 365 // Reset the best rate if the non interlaced is | 365 // Reset the best rate if the non interlaced is |
| 366 // found the first time. | 366 // found the first time. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 396 mode_info.hTotal = 1; | 396 mode_info.hTotal = 1; |
| 397 mode_info.vTotal = 1; | 397 mode_info.vTotal = 1; |
| 398 mode_info.dotClock = refresh_rate; | 398 mode_info.dotClock = refresh_rate; |
| 399 } | 399 } |
| 400 return mode_info; | 400 return mode_info; |
| 401 } | 401 } |
| 402 | 402 |
| 403 } // namespace test | 403 } // namespace test |
| 404 | 404 |
| 405 } // namespace chromeos | 405 } // namespace chromeos |
| OLD | NEW |