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

Side by Side Diff: ui/display/display_util.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
« no previous file with comments | « ui/display/display_util.h ('k') | ui/display/display_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/display/display_util.h" 5 #include "ui/display/display_util.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace ui { 9 namespace ui {
10 10
11 namespace { 11 namespace {
12 12
13 // A list of bogus sizes in mm that should be ignored. 13 // A list of bogus sizes in mm that should be ignored.
14 // See crbug.com/136533. The first element maintains the minimum 14 // See crbug.com/136533. The first element maintains the minimum
15 // size required to be valid size. 15 // size required to be valid size.
16 const int kInvalidDisplaySizeList[][2] = { 16 const int kInvalidDisplaySizeList[][2] = {
17 {40, 30}, 17 {40, 30},
18 {50, 40}, 18 {50, 40},
19 {160, 90}, 19 {160, 90},
20 {160, 100}, 20 {160, 100},
21 }; 21 };
22 22
23 // The DPI threshold to detect high density screen.
24 // Higher DPI than this will use device_scale_factor=2.
25 const unsigned int kHighDensityDPIThresholdSmall = 170;
26
27 // The HiDPI threshold for large (usually external) monitors. Lower threshold
28 // makes sense for large monitors, because such monitors should be located
29 // farther from the user's face usually. See http://crbug.com/348279
30 const unsigned int kHighDensityDPIThresholdLarge = 150;
31
32 // The width threshold in mm for "large" monitors.
33 const int kLargeDisplayWidthThresholdMM = 500;
34
35 // 1 inch in mm.
36 const float kInchInMm = 25.4f;
37
23 } // namespace 38 } // namespace
24 39
25 bool IsDisplaySizeBlackListed(const gfx::Size& physical_size) { 40 bool IsDisplaySizeBlackListed(const gfx::Size& physical_size) {
26 // Ignore if the reported display is smaller than minimum size. 41 // Ignore if the reported display is smaller than minimum size.
27 if (physical_size.width() <= kInvalidDisplaySizeList[0][0] || 42 if (physical_size.width() <= kInvalidDisplaySizeList[0][0] ||
28 physical_size.height() <= kInvalidDisplaySizeList[0][1]) { 43 physical_size.height() <= kInvalidDisplaySizeList[0][1]) {
29 LOG(WARNING) << "Smaller than minimum display size"; 44 LOG(WARNING) << "Smaller than minimum display size";
30 return true; 45 return true;
31 } 46 }
32 for (size_t i = 1; i < arraysize(kInvalidDisplaySizeList); ++i) { 47 for (size_t i = 1; i < arraysize(kInvalidDisplaySizeList); ++i) {
33 const gfx::Size size(kInvalidDisplaySizeList[i][0], 48 const gfx::Size size(kInvalidDisplaySizeList[i][0],
34 kInvalidDisplaySizeList[i][1]); 49 kInvalidDisplaySizeList[i][1]);
35 if (physical_size == size) { 50 if (physical_size == size) {
36 LOG(WARNING) << "Black listed display size detected:" << size.ToString(); 51 LOG(WARNING) << "Black listed display size detected:" << size.ToString();
37 return true; 52 return true;
38 } 53 }
39 } 54 }
40 return false; 55 return false;
41 } 56 }
42 57
58 float GetScaleFactor(const gfx::Size& physical_size_in_mm,
59 const gfx::Size& screen_size_in_pixels) {
60 if (IsDisplaySizeBlackListed(physical_size_in_mm))
61 return 1.0f;
62
63 const unsigned int dpi = (kInchInMm * screen_size_in_pixels.width() /
64 physical_size_in_mm.width());
65 const unsigned int threshold =
66 (physical_size_in_mm.width() >= kLargeDisplayWidthThresholdMM) ?
67 kHighDensityDPIThresholdLarge : kHighDensityDPIThresholdSmall;
68 return (dpi > threshold) ? 2.0f : 1.0f;
69 }
70
43 } // namespace ui 71 } // namespace ui
OLDNEW
« no previous file with comments | « ui/display/display_util.h ('k') | ui/display/display_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698