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> |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "ui/display/chromeos/display_snapshot.h" | 23 #include "ui/display/chromeos/display_snapshot.h" |
24 #include "ui/display/display_util.h" | 24 #include "ui/display/display_util.h" |
25 #include "ui/gfx/display.h" | 25 #include "ui/gfx/display.h" |
26 | 26 |
27 namespace ash { | 27 namespace ash { |
28 | 28 |
29 using ui::DisplayConfigurator; | 29 using ui::DisplayConfigurator; |
30 | 30 |
31 namespace { | 31 namespace { |
32 | 32 |
33 // The DPI threshold to detect high density screen. | |
34 // Higher DPI than this will use device_scale_factor=2. | |
35 const unsigned int kHighDensityDPIThreshold = 170; | |
36 | |
37 // 1 inch in mm. | |
38 const float kInchInMm = 25.4f; | |
39 | |
40 // Display mode list is sorted by (in descending priority): | 33 // Display mode list is sorted by (in descending priority): |
41 // * the area in pixels. | 34 // * the area in pixels. |
42 // * refresh rate. | 35 // * refresh rate. |
43 struct DisplayModeSorter { | 36 struct DisplayModeSorter { |
44 bool operator()(const DisplayMode& a, const DisplayMode& b) { | 37 bool operator()(const DisplayMode& a, const DisplayMode& b) { |
45 if (a.size.GetArea() == b.size.GetArea()) | 38 if (a.size.GetArea() == b.size.GetArea()) |
46 return (a.refresh_rate > b.refresh_rate); | 39 return (a.refresh_rate > b.refresh_rate); |
47 return (a.size.GetArea() > b.size.GetArea()); | 40 return (a.size.GetArea() > b.size.GetArea()); |
48 } | 41 } |
49 }; | 42 }; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 119 |
127 if (state.display->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL && | 120 if (state.display->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL && |
128 gfx::Display::InternalDisplayId() == gfx::Display::kInvalidDisplayID) { | 121 gfx::Display::InternalDisplayId() == gfx::Display::kInvalidDisplayID) { |
129 gfx::Display::SetInternalDisplayId(state.display->display_id()); | 122 gfx::Display::SetInternalDisplayId(state.display->display_id()); |
130 } | 123 } |
131 | 124 |
132 const ui::DisplayMode* mode_info = state.display->current_mode(); | 125 const ui::DisplayMode* mode_info = state.display->current_mode(); |
133 if (!mode_info) | 126 if (!mode_info) |
134 continue; | 127 continue; |
135 | 128 |
136 float device_scale_factor = 1.0f; | 129 float device_scale_factor = ui::GetScaleFactor( |
137 if (!ui::IsDisplaySizeBlackListed(state.display->physical_size()) && | 130 state.display->physical_size(), mode_info->size()); |
138 (kInchInMm * mode_info->size().width() / | |
139 state.display->physical_size().width()) > kHighDensityDPIThreshold) { | |
140 device_scale_factor = 2.0f; | |
141 } | |
142 gfx::Rect display_bounds(state.display->origin(), mode_info->size()); | 131 gfx::Rect display_bounds(state.display->origin(), mode_info->size()); |
143 | 132 |
144 std::vector<DisplayMode> display_modes = GetDisplayModeList(state); | 133 std::vector<DisplayMode> display_modes = GetDisplayModeList(state); |
145 | 134 |
146 std::string name = | 135 std::string name = |
147 state.display->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL ? | 136 state.display->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL ? |
148 l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME) : | 137 l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME) : |
149 state.display->display_name(); | 138 state.display->display_name(); |
150 if (name.empty()) | 139 if (name.empty()) |
151 name = l10n_util::GetStringUTF8(IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME); | 140 name = l10n_util::GetStringUTF8(IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME); |
(...skipping 23 matching lines...) Expand all Loading... |
175 | 164 |
176 void DisplayChangeObserver::OnAppTerminating() { | 165 void DisplayChangeObserver::OnAppTerminating() { |
177 #if defined(USE_ASH) | 166 #if defined(USE_ASH) |
178 // Stop handling display configuration events once the shutdown | 167 // Stop handling display configuration events once the shutdown |
179 // process starts. crbug.com/177014. | 168 // process starts. crbug.com/177014. |
180 Shell::GetInstance()->display_configurator()->PrepareForExit(); | 169 Shell::GetInstance()->display_configurator()->PrepareForExit(); |
181 #endif | 170 #endif |
182 } | 171 } |
183 | 172 |
184 } // namespace ash | 173 } // namespace ash |
OLD | NEW |