Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(513)

Side by Side Diff: ash/display/display_change_observer_chromeos.cc

Issue 227593011: Modifies the threshold for hidpi displays. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 16 matching lines...) Expand all
27 namespace ash { 27 namespace ash {
28 28
29 using ui::OutputConfigurator; 29 using ui::OutputConfigurator;
30 30
31 namespace { 31 namespace {
32 32
33 // The DPI threshold to detect high density screen. 33 // The DPI threshold to detect high density screen.
34 // Higher DPI than this will use device_scale_factor=2. 34 // Higher DPI than this will use device_scale_factor=2.
35 const unsigned int kHighDensityDPIThreshold = 170; 35 const unsigned int kHighDensityDPIThreshold = 170;
36 36
37 // The HiDPI threshold for bigger (usually external) monitors. Lower threshold
oshima 2014/04/08 20:39:47 "Large" is probably better term. Can you update th
Jun Mukai 2014/04/09 20:20:07 Done.
38 // makes sense for bigger monitors, because such monitors should be located
39 // farther from the user's face usually. See http://crbug.com/348279
40 const unsigned int kHighDensityDPIThresholdBigger = 150;
41
42 // The width threshold in mm for "bigger" monitors.
43 const int kBiggerDisplayWidthThresholdMM = 500;
44
37 // 1 inch in mm. 45 // 1 inch in mm.
38 const float kInchInMm = 25.4f; 46 const float kInchInMm = 25.4f;
39 47
40 // Display mode list is sorted by (in descending priority): 48 // Display mode list is sorted by (in descending priority):
41 // * the area in pixels. 49 // * the area in pixels.
42 // * refresh rate. 50 // * refresh rate.
43 struct DisplayModeSorter { 51 struct DisplayModeSorter {
44 bool operator()(const DisplayMode& a, const DisplayMode& b) { 52 bool operator()(const DisplayMode& a, const DisplayMode& b) {
45 if (a.size.GetArea() == b.size.GetArea()) 53 if (a.size.GetArea() == b.size.GetArea())
46 return (a.refresh_rate > b.refresh_rate); 54 return (a.refresh_rate > b.refresh_rate);
47 return (a.size.GetArea() > b.size.GetArea()); 55 return (a.size.GetArea() > b.size.GetArea());
48 } 56 }
49 }; 57 };
50 58
59 bool ShouldBeHiDPI(const gfx::Size& physical_size,
oshima 2014/04/08 20:39:47 Can you change this to return scale factor (like G
Jun Mukai 2014/04/09 20:20:07 Done.
60 const ui::DisplayMode& mode_info) {
61 if (ui::IsDisplaySizeBlackListed(physical_size))
62 return false;
63
64 const unsigned int dpi = (kInchInMm * mode_info.size().width() /
65 physical_size.width());
66 const unsigned int threshold =
67 (physical_size.width() >= kBiggerDisplayWidthThresholdMM) ?
68 kHighDensityDPIThresholdBigger : kHighDensityDPIThreshold;
69 return dpi > threshold;
70 }
71
51 } // namespace 72 } // namespace
52 73
53 // static 74 // static
54 std::vector<DisplayMode> DisplayChangeObserver::GetDisplayModeList( 75 std::vector<DisplayMode> DisplayChangeObserver::GetDisplayModeList(
55 const OutputConfigurator::DisplayState& output) { 76 const OutputConfigurator::DisplayState& output) {
56 typedef std::map<std::pair<int, int>, DisplayMode> DisplayModeMap; 77 typedef std::map<std::pair<int, int>, DisplayMode> DisplayModeMap;
57 DisplayModeMap display_mode_map; 78 DisplayModeMap display_mode_map;
58 79
59 for (std::vector<const ui::DisplayMode*>::const_iterator it = 80 for (std::vector<const ui::DisplayMode*>::const_iterator it =
60 output.display->modes().begin(); 81 output.display->modes().begin();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 if (output.display->type() == ui::OUTPUT_TYPE_INTERNAL && 148 if (output.display->type() == ui::OUTPUT_TYPE_INTERNAL &&
128 gfx::Display::InternalDisplayId() == gfx::Display::kInvalidDisplayID) { 149 gfx::Display::InternalDisplayId() == gfx::Display::kInvalidDisplayID) {
129 gfx::Display::SetInternalDisplayId(output.display->display_id()); 150 gfx::Display::SetInternalDisplayId(output.display->display_id());
130 } 151 }
131 152
132 const ui::DisplayMode* mode_info = output.display->current_mode(); 153 const ui::DisplayMode* mode_info = output.display->current_mode();
133 if (!mode_info) 154 if (!mode_info)
134 continue; 155 continue;
135 156
136 float device_scale_factor = 1.0f; 157 float device_scale_factor = 1.0f;
137 if (!ui::IsDisplaySizeBlackListed(output.display->physical_size()) && 158 if (ShouldBeHiDPI(output.display->physical_size(), *mode_info))
138 (kInchInMm * mode_info->size().width() /
139 output.display->physical_size().width()) > kHighDensityDPIThreshold) {
140 device_scale_factor = 2.0f; 159 device_scale_factor = 2.0f;
141 } 160
142 gfx::Rect display_bounds(output.display->origin(), mode_info->size()); 161 gfx::Rect display_bounds(output.display->origin(), mode_info->size());
143 162
144 std::vector<DisplayMode> display_modes = GetDisplayModeList(output); 163 std::vector<DisplayMode> display_modes = GetDisplayModeList(output);
145 164
146 std::string name = 165 std::string name =
147 output.display->type() == ui::OUTPUT_TYPE_INTERNAL 166 output.display->type() == ui::OUTPUT_TYPE_INTERNAL
148 ? l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME) : 167 ? l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME) :
149 output.display->display_name(); 168 output.display->display_name();
150 if (name.empty()) 169 if (name.empty())
151 name = l10n_util::GetStringUTF8(IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME); 170 name = l10n_util::GetStringUTF8(IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME);
(...skipping 22 matching lines...) Expand all
174 193
175 void DisplayChangeObserver::OnAppTerminating() { 194 void DisplayChangeObserver::OnAppTerminating() {
176 #if defined(USE_ASH) 195 #if defined(USE_ASH)
177 // Stop handling display configuration events once the shutdown 196 // Stop handling display configuration events once the shutdown
178 // process starts. crbug.com/177014. 197 // process starts. crbug.com/177014.
179 Shell::GetInstance()->output_configurator()->PrepareForExit(); 198 Shell::GetInstance()->output_configurator()->PrepareForExit();
180 #endif 199 #endif
181 } 200 }
182 201
183 } // namespace ash 202 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698