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

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

Issue 411763004: Use 1.25 DSF for 150~180 DPI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 12 matching lines...) Expand all
23 #include "ui/display/types/chromeos/display_snapshot.h" 23 #include "ui/display/types/chromeos/display_snapshot.h"
24 #include "ui/display/util/display_util.h" 24 #include "ui/display/util/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. 33 // The DPI threshold to determine the device scale factor.
34 // Higher DPI than this will use device_scale_factor=2. 34 // DPI higher than |dpi| will use |device_scale_factor|.
35 const unsigned int kHighDensityDPIThreshold = 170; 35 struct DeviceScaleFactorDPIThreshold {
36 float dpi;
37 float device_scale_factor;
38 };
39
40 const DeviceScaleFactorDPIThreshold kThresholdTable[] = {
41 {180.0f, 2.0f},
42 {150.0f, 1.25f},
43 {0.0f, 1.0f},
44 };
36 45
37 // 1 inch in mm. 46 // 1 inch in mm.
38 const float kInchInMm = 25.4f; 47 const float kInchInMm = 25.4f;
39 48
40 // Display mode list is sorted by (in descending priority): 49 // Display mode list is sorted by (in descending priority):
41 // * the area in pixels. 50 // * the area in pixels.
42 // * refresh rate. 51 // * refresh rate.
43 struct DisplayModeSorter { 52 struct DisplayModeSorter {
44 bool operator()(const DisplayMode& a, const DisplayMode& b) { 53 bool operator()(const DisplayMode& a, const DisplayMode& b) {
45 if (a.size.GetArea() == b.size.GetArea()) 54 if (a.size.GetArea() == b.size.GetArea())
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 if (state.display->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL && 136 if (state.display->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL &&
128 gfx::Display::InternalDisplayId() == gfx::Display::kInvalidDisplayID) { 137 gfx::Display::InternalDisplayId() == gfx::Display::kInvalidDisplayID) {
129 gfx::Display::SetInternalDisplayId(state.display->display_id()); 138 gfx::Display::SetInternalDisplayId(state.display->display_id());
130 } 139 }
131 140
132 const ui::DisplayMode* mode_info = state.display->current_mode(); 141 const ui::DisplayMode* mode_info = state.display->current_mode();
133 if (!mode_info) 142 if (!mode_info)
134 continue; 143 continue;
135 144
136 float device_scale_factor = 1.0f; 145 float device_scale_factor = 1.0f;
137 if (!ui::IsDisplaySizeBlackListed(state.display->physical_size()) && 146 if (!ui::IsDisplaySizeBlackListed(state.display->physical_size())) {
138 (kInchInMm * mode_info->size().width() / 147 device_scale_factor =
139 state.display->physical_size().width()) > kHighDensityDPIThreshold) { 148 FindDeviceScaleFactor((kInchInMm * mode_info->size().width() /
140 device_scale_factor = 2.0f; 149 state.display->physical_size().width()));
141 } 150 }
142 gfx::Rect display_bounds(state.display->origin(), mode_info->size()); 151 gfx::Rect display_bounds(state.display->origin(), mode_info->size());
143 152
144 std::vector<DisplayMode> display_modes = GetDisplayModeList(state); 153 std::vector<DisplayMode> display_modes = GetDisplayModeList(state);
145 154
146 std::string name = 155 std::string name =
147 state.display->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL ? 156 state.display->type() == ui::DISPLAY_CONNECTION_TYPE_INTERNAL ?
148 l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME) : 157 l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME) :
149 state.display->display_name(); 158 state.display->display_name();
150 if (name.empty()) 159 if (name.empty())
(...skipping 26 matching lines...) Expand all
177 } 186 }
178 187
179 void DisplayChangeObserver::OnAppTerminating() { 188 void DisplayChangeObserver::OnAppTerminating() {
180 #if defined(USE_ASH) 189 #if defined(USE_ASH)
181 // Stop handling display configuration events once the shutdown 190 // Stop handling display configuration events once the shutdown
182 // process starts. crbug.com/177014. 191 // process starts. crbug.com/177014.
183 Shell::GetInstance()->display_configurator()->PrepareForExit(); 192 Shell::GetInstance()->display_configurator()->PrepareForExit();
184 #endif 193 #endif
185 } 194 }
186 195
196 // static
197 float DisplayChangeObserver::FindDeviceScaleFactor(float dpi) {
198 for (size_t i = 0; i < arraysize(kThresholdTable); ++i) {
199 if (dpi > kThresholdTable[i].dpi)
200 return kThresholdTable[i].device_scale_factor;
201 }
202 return 1.0f;
203 }
204
187 } // namespace ash 205 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_change_observer_chromeos.h ('k') | ash/display/display_change_observer_chromeos_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698