Chromium Code Reviews| Index: ash/display/display_util_x11.cc |
| diff --git a/ash/display/display_util_x11.cc b/ash/display/display_util_x11.cc |
| index 984ed53f135d8b1b33cc011620deb0fe73f7e2c6..09acfc38f79644918ad1f7e9ad5de894292f9889 100644 |
| --- a/ash/display/display_util_x11.cc |
| +++ b/ash/display/display_util_x11.cc |
| @@ -6,12 +6,13 @@ |
| #include <algorithm> |
| #include <map> |
| -#include <X11/extensions/Xrandr.h> |
| #include "ash/display/display_info.h" |
| #include "base/logging.h" |
| #include "chromeos/display/output_util.h" |
| +using chromeos::OutputConfigurator; |
| + |
| namespace ash { |
| namespace internal { |
| namespace { |
| @@ -55,32 +56,24 @@ bool ShouldIgnoreSize(unsigned long mm_width, unsigned long mm_height) { |
| } |
| std::vector<Resolution> GetResolutionList( |
| - XRRScreenResources* screen_resources, |
| - XRROutputInfo* output_info) { |
| + const OutputConfigurator::OutputSnapshot& output) { |
|
oshima
2013/08/16 23:13:05
isn't it better to get this in output_configurator
Daniel Erat
2013/08/16 23:35:36
You mean, move this method to OutputConfigurator?
oshima
2013/08/16 23:54:06
On second thought, no, but we should remove this t
|
| typedef std::map<std::pair<int,int>, Resolution> ResolutionMap; |
| - |
| ResolutionMap resolution_map; |
| - for (int i = 0; i < output_info->nmode; i++) { |
| - RRMode mode = output_info->modes[i]; |
| - const XRRModeInfo* info = chromeos::FindXRRModeInfo(screen_resources, mode); |
| - DCHECK(info); |
| - // Just ignore bad entry on Release build. |
| - if (!info) |
| - continue; |
| - ResolutionMap::key_type size = std::make_pair(info->width, info->height); |
| - bool interlaced = (info->modeFlags & RR_Interlace) != 0; |
| + for (std::map<RRMode, OutputConfigurator::ModeInfo>::const_iterator it = |
| + output.mode_infos.begin(); it != output.mode_infos.end(); ++it) { |
| + const OutputConfigurator::ModeInfo& mode_info = it->second; |
| + const std::pair<int, int> size(mode_info.width, mode_info.height); |
| + const Resolution resolution(gfx::Size(mode_info.width, mode_info.height), |
| + mode_info.interlaced); |
| - ResolutionMap::iterator iter = resolution_map.find(size); |
| - |
| - // Add new resolution if it's new size or override interlaced mode. |
| - if (iter == resolution_map.end()) { |
| - resolution_map.insert(ResolutionMap::value_type( |
| - size, |
| - Resolution(gfx::Size(info->width, info->height), interlaced))); |
| - } else if (iter->second.interlaced && !interlaced) { |
| - iter->second.interlaced = false; |
| - } |
| + // Add the resolution if it isn't already present and override interlaced |
| + // resolutions with non-interlaced ones. |
| + ResolutionMap::iterator resolution_it = resolution_map.find(size); |
| + if (resolution_it == resolution_map.end()) |
| + resolution_map.insert(std::make_pair(size, resolution)); |
| + else if (resolution_it->second.interlaced && !resolution.interlaced) |
| + resolution_it->second = resolution; |
| } |
| std::vector<Resolution> resolution_list; |