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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/display/display_util.h ('k') | ui/display/display_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/display/display_util.cc
diff --git a/ui/display/display_util.cc b/ui/display/display_util.cc
index a51b19af886bb4f3f1d43640d1fcac999a67a2dc..aeaeed939a012be95236d0301219dde5d880529f 100644
--- a/ui/display/display_util.cc
+++ b/ui/display/display_util.cc
@@ -20,6 +20,21 @@ const int kInvalidDisplaySizeList[][2] = {
{160, 100},
};
+// The DPI threshold to detect high density screen.
+// Higher DPI than this will use device_scale_factor=2.
+const unsigned int kHighDensityDPIThresholdSmall = 170;
+
+// The HiDPI threshold for large (usually external) monitors. Lower threshold
+// makes sense for large monitors, because such monitors should be located
+// farther from the user's face usually. See http://crbug.com/348279
+const unsigned int kHighDensityDPIThresholdLarge = 150;
+
+// The width threshold in mm for "large" monitors.
+const int kLargeDisplayWidthThresholdMM = 500;
+
+// 1 inch in mm.
+const float kInchInMm = 25.4f;
+
} // namespace
bool IsDisplaySizeBlackListed(const gfx::Size& physical_size) {
@@ -40,4 +55,17 @@ bool IsDisplaySizeBlackListed(const gfx::Size& physical_size) {
return false;
}
+float GetScaleFactor(const gfx::Size& physical_size_in_mm,
+ const gfx::Size& screen_size_in_pixels) {
+ if (IsDisplaySizeBlackListed(physical_size_in_mm))
+ return 1.0f;
+
+ const unsigned int dpi = (kInchInMm * screen_size_in_pixels.width() /
+ physical_size_in_mm.width());
+ const unsigned int threshold =
+ (physical_size_in_mm.width() >= kLargeDisplayWidthThresholdMM) ?
+ kHighDensityDPIThresholdLarge : kHighDensityDPIThresholdSmall;
+ return (dpi > threshold) ? 2.0f : 1.0f;
+}
+
} // namespace ui
« 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