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

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: fix 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 14 matching lines...) Expand all
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. 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 kHighDensityDPIThresholdSmall = 170;
36
37 // The HiDPI threshold for large (usually external) monitors. Lower threshold
38 // makes sense for large monitors, because such monitors should be located
39 // farther from the user's face usually. See http://crbug.com/348279
40 const unsigned int kHighDensityDPIThresholdLarge = 150;
41
42 // The width threshold in mm for "large" monitors.
43 const int kLargeDisplayWidthThresholdMM = 500;
36 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())
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 for (DisplayModeMap::const_iterator iter = display_mode_map.begin(); 89 for (DisplayModeMap::const_iterator iter = display_mode_map.begin();
82 iter != display_mode_map.end(); 90 iter != display_mode_map.end();
83 ++iter) { 91 ++iter) {
84 display_mode_list.push_back(iter->second); 92 display_mode_list.push_back(iter->second);
85 } 93 }
86 std::sort( 94 std::sort(
87 display_mode_list.begin(), display_mode_list.end(), DisplayModeSorter()); 95 display_mode_list.begin(), display_mode_list.end(), DisplayModeSorter());
88 return display_mode_list; 96 return display_mode_list;
89 } 97 }
90 98
99 // static
100 float DisplayChangeObserver::GetScaleFactor(
oshima 2014/04/09 23:07:37 can you move this (plus constants) to ui/display/d
Jun Mukai 2014/04/09 23:16:00 Done.
101 const gfx::Size& physical_size,
102 const gfx::Size& screen_size) {
103 if (ui::IsDisplaySizeBlackListed(physical_size))
104 return 1.0f;
105
106 const unsigned int dpi = (kInchInMm * screen_size.width() /
107 physical_size.width());
108 const unsigned int threshold =
109 (physical_size.width() >= kLargeDisplayWidthThresholdMM) ?
110 kHighDensityDPIThresholdLarge : kHighDensityDPIThresholdSmall;
111 return (dpi > threshold) ? 2.0f : 1.0f;
112 }
113
91 DisplayChangeObserver::DisplayChangeObserver() { 114 DisplayChangeObserver::DisplayChangeObserver() {
92 Shell::GetInstance()->AddShellObserver(this); 115 Shell::GetInstance()->AddShellObserver(this);
93 } 116 }
94 117
95 DisplayChangeObserver::~DisplayChangeObserver() { 118 DisplayChangeObserver::~DisplayChangeObserver() {
96 Shell::GetInstance()->RemoveShellObserver(this); 119 Shell::GetInstance()->RemoveShellObserver(this);
97 } 120 }
98 121
99 ui::MultipleDisplayState DisplayChangeObserver::GetStateForDisplayIds( 122 ui::MultipleDisplayState DisplayChangeObserver::GetStateForDisplayIds(
100 const std::vector<int64>& display_ids) const { 123 const std::vector<int64>& display_ids) const {
(...skipping 25 matching lines...) Expand all
126 149
127 if (state.display->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL && 150 if (state.display->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL &&
128 gfx::Display::InternalDisplayId() == gfx::Display::kInvalidDisplayID) { 151 gfx::Display::InternalDisplayId() == gfx::Display::kInvalidDisplayID) {
129 gfx::Display::SetInternalDisplayId(state.display->display_id()); 152 gfx::Display::SetInternalDisplayId(state.display->display_id());
130 } 153 }
131 154
132 const ui::DisplayMode* mode_info = state.display->current_mode(); 155 const ui::DisplayMode* mode_info = state.display->current_mode();
133 if (!mode_info) 156 if (!mode_info)
134 continue; 157 continue;
135 158
136 float device_scale_factor = 1.0f; 159 float device_scale_factor = GetScaleFactor(
137 if (!ui::IsDisplaySizeBlackListed(state.display->physical_size()) && 160 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()); 161 gfx::Rect display_bounds(state.display->origin(), mode_info->size());
143 162
144 std::vector<DisplayMode> display_modes = GetDisplayModeList(state); 163 std::vector<DisplayMode> display_modes = GetDisplayModeList(state);
145 164
146 std::string name = 165 std::string name =
147 state.display->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL ? 166 state.display->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL ?
148 l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME) : 167 l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME) :
149 state.display->display_name(); 168 state.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 23 matching lines...) Expand all
175 194
176 void DisplayChangeObserver::OnAppTerminating() { 195 void DisplayChangeObserver::OnAppTerminating() {
177 #if defined(USE_ASH) 196 #if defined(USE_ASH)
178 // Stop handling display configuration events once the shutdown 197 // Stop handling display configuration events once the shutdown
179 // process starts. crbug.com/177014. 198 // process starts. crbug.com/177014.
180 Shell::GetInstance()->display_configurator()->PrepareForExit(); 199 Shell::GetInstance()->display_configurator()->PrepareForExit();
181 #endif 200 #endif
182 } 201 }
183 202
184 } // namespace ash 203 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698