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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ash/display/display_change_observer_chromeos.cc
diff --git a/ash/display/display_change_observer_chromeos.cc b/ash/display/display_change_observer_chromeos.cc
index 54b39dce7c9e4d1237eaca3b4250dae863df0371..d2e90492dd1c5185e3ea4f04095ab8719bd74dec 100644
--- a/ash/display/display_change_observer_chromeos.cc
+++ b/ash/display/display_change_observer_chromeos.cc
@@ -30,9 +30,18 @@ using ui::DisplayConfigurator;
namespace {
-// The DPI threshold to detect high density screen.
-// Higher DPI than this will use device_scale_factor=2.
-const unsigned int kHighDensityDPIThreshold = 170;
+// The DPI threshold to determine the device scale factor.
+// DPI higher than |dpi| will use |device_scale_factor|.
+struct DeviceScaleFactorDPIThreshold {
+ float dpi;
+ float device_scale_factor;
+};
+
+const DeviceScaleFactorDPIThreshold kThresholdTable[] = {
+ {180.0f, 2.0f},
+ {150.0f, 1.25f},
+ {0.0f, 1.0f},
+};
// 1 inch in mm.
const float kInchInMm = 25.4f;
@@ -134,10 +143,10 @@ void DisplayChangeObserver::OnDisplayModeChanged(
continue;
float device_scale_factor = 1.0f;
- if (!ui::IsDisplaySizeBlackListed(state.display->physical_size()) &&
- (kInchInMm * mode_info->size().width() /
- state.display->physical_size().width()) > kHighDensityDPIThreshold) {
- device_scale_factor = 2.0f;
+ if (!ui::IsDisplaySizeBlackListed(state.display->physical_size())) {
+ device_scale_factor =
+ FindDeviceScaleFactor((kInchInMm * mode_info->size().width() /
+ state.display->physical_size().width()));
}
gfx::Rect display_bounds(state.display->origin(), mode_info->size());
@@ -184,4 +193,13 @@ void DisplayChangeObserver::OnAppTerminating() {
#endif
}
+// static
+float DisplayChangeObserver::FindDeviceScaleFactor(float dpi) {
+ for (size_t i = 0; i < arraysize(kThresholdTable); ++i) {
+ if (dpi > kThresholdTable[i].dpi)
+ return kThresholdTable[i].device_scale_factor;
+ }
+ return 1.0f;
+}
+
} // namespace ash
« 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