Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "ash/display/display_change_observer_chromeos.h" | 5 #include "ash/display/display_change_observer_chromeos.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "ash/ash_switches.h" | 12 #include "ash/ash_switches.h" |
| 13 #include "ash/display/display_info.h" | 13 #include "ash/display/display_info.h" |
| 14 #include "ash/display/display_layout_store.h" | 14 #include "ash/display/display_layout_store.h" |
| 15 #include "ash/display/display_manager.h" | 15 #include "ash/display/display_manager.h" |
| 16 #include "ash/shell.h" | 16 #include "ash/shell.h" |
| 17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 18 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "chromeos/display/output_util.h" | 19 #include "chromeos/display/output_util.h" |
| 20 #include "grit/ash_strings.h" | 20 #include "grit/ash_strings.h" |
| 21 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 22 #include "ui/base/x/x11_util.h" | |
| 22 #include "ui/compositor/dip_util.h" | 23 #include "ui/compositor/dip_util.h" |
| 23 #include "ui/gfx/display.h" | 24 #include "ui/gfx/display.h" |
| 24 | 25 |
| 25 namespace ash { | 26 namespace ash { |
| 26 namespace internal { | 27 namespace internal { |
| 27 | 28 |
| 28 using chromeos::OutputConfigurator; | 29 using chromeos::OutputConfigurator; |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 // The DPI threshold to detect high density screen. | 33 // The DPI threshold to detect high density screen. |
| 33 // Higher DPI than this will use device_scale_factor=2. | 34 // Higher DPI than this will use device_scale_factor=2. |
| 34 const unsigned int kHighDensityDPIThreshold = 160; | 35 const unsigned int kHighDensityDPIThreshold = 160; |
| 35 | 36 |
| 36 // 1 inch in mm. | 37 // 1 inch in mm. |
| 37 const float kInchInMm = 25.4f; | 38 const float kInchInMm = 25.4f; |
| 38 | 39 |
| 39 // A list of bogus sizes in mm that X detects that should be ignored. | |
| 40 // See crbug.com/136533. The first element maintains the minimum | |
| 41 // size required to be valid size. | |
| 42 const unsigned long kInvalidDisplaySizeList[][2] = { | |
| 43 {40, 30}, | |
| 44 {50, 40}, | |
| 45 {160, 90}, | |
| 46 {160, 100}, | |
| 47 }; | |
| 48 | |
| 49 // Resolution list are sorted by the area in pixels and the larger | 40 // Resolution list are sorted by the area in pixels and the larger |
| 50 // one comes first. | 41 // one comes first. |
| 51 struct ResolutionSorter { | 42 struct ResolutionSorter { |
| 52 bool operator()(const Resolution& a, const Resolution& b) { | 43 bool operator()(const Resolution& a, const Resolution& b) { |
| 53 return a.size.width() * a.size.height() > b.size.width() * b.size.height(); | 44 return a.size.width() * a.size.height() > b.size.width() * b.size.height(); |
| 54 } | 45 } |
| 55 }; | 46 }; |
| 56 | 47 |
| 57 } // namespace | 48 } // namespace |
| 58 | 49 |
| 59 // static | 50 // static |
| 60 bool DisplayChangeObserver::ShouldIgnoreSize(unsigned long mm_width, | 51 bool DisplayChangeObserver::ShouldIgnoreSize(unsigned long mm_width, |
|
Daniel Erat
2013/10/29 14:28:25
please remove this method and make the caller call
Mikhail
2013/10/29 14:50:55
Actually I was planning to make it as a separate C
| |
| 61 unsigned long mm_height) { | 52 unsigned long mm_height) { |
| 62 // Ignore if the reported display is smaller than minimum size. | 53 return ui::IsXDisplaySizeBlackListed(mm_width, mm_height); |
| 63 if (mm_width <= kInvalidDisplaySizeList[0][0] || | |
| 64 mm_height <= kInvalidDisplaySizeList[0][1]) { | |
| 65 LOG(WARNING) << "Smaller than minimum display size"; | |
| 66 return true; | |
| 67 } | |
| 68 for (unsigned long i = 1 ; i < arraysize(kInvalidDisplaySizeList); ++i) { | |
| 69 const unsigned long* size = kInvalidDisplaySizeList[i]; | |
| 70 if (mm_width == size[0] && mm_height == size[1]) { | |
| 71 LOG(WARNING) << "Black listed display size detected:" | |
| 72 << size[0] << "x" << size[1]; | |
| 73 return true; | |
| 74 } | |
| 75 } | |
| 76 return false; | |
| 77 } | 54 } |
| 78 | 55 |
| 79 // static | 56 // static |
| 80 std::vector<Resolution> DisplayChangeObserver::GetResolutionList( | 57 std::vector<Resolution> DisplayChangeObserver::GetResolutionList( |
| 81 const OutputConfigurator::OutputSnapshot& output) { | 58 const OutputConfigurator::OutputSnapshot& output) { |
| 82 typedef std::map<std::pair<int,int>, Resolution> ResolutionMap; | 59 typedef std::map<std::pair<int,int>, Resolution> ResolutionMap; |
| 83 ResolutionMap resolution_map; | 60 ResolutionMap resolution_map; |
| 84 | 61 |
| 85 for (std::map<RRMode, OutputConfigurator::ModeInfo>::const_iterator it = | 62 for (std::map<RRMode, OutputConfigurator::ModeInfo>::const_iterator it = |
| 86 output.mode_infos.begin(); it != output.mode_infos.end(); ++it) { | 63 output.mode_infos.begin(); it != output.mode_infos.end(); ++it) { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 void DisplayChangeObserver::OnAppTerminating() { | 183 void DisplayChangeObserver::OnAppTerminating() { |
| 207 #if defined(USE_ASH) | 184 #if defined(USE_ASH) |
| 208 // Stop handling display configuration events once the shutdown | 185 // Stop handling display configuration events once the shutdown |
| 209 // process starts. crbug.com/177014. | 186 // process starts. crbug.com/177014. |
| 210 Shell::GetInstance()->output_configurator()->Stop(); | 187 Shell::GetInstance()->output_configurator()->Stop(); |
| 211 #endif | 188 #endif |
| 212 } | 189 } |
| 213 | 190 |
| 214 } // namespace internal | 191 } // namespace internal |
| 215 } // namespace ash | 192 } // namespace ash |
| OLD | NEW |