Bug 878029 - Update GetDefaultScaleInternal() in Gonk to match AOSP spec. r=mwu
authorTim Chien <timdream@gmail.com>
Mon, 03 Jun 2013 08:30:28 -0400
changeset 133811 8b1bfcf0ce6e56ec8d66bcc6e6e0e84087a38b54
parent 133810 f8a0aa9350c9d594d148c20c5d3ff558b54b6274
child 133812 d2eabe8e27b56ca4e764d1e5f454fecceff11330
child 133844 bb02a59865fe4be440a3509bb91fbfcd57e3bb8c
child 133852 0846a72e1761f09495843a8198a17986b23373f2
push id28905
push userryanvm@gmail.com
push dateMon, 03 Jun 2013 15:58:12 +0000
treeherdermozilla-inbound@d2eabe8e27b5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmwu
bugs878029
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 878029 - Update GetDefaultScaleInternal() in Gonk to match AOSP spec. r=mwu
widget/gonk/nsWindow.cpp
--- a/widget/gonk/nsWindow.cpp
+++ b/widget/gonk/nsWindow.cpp
@@ -542,22 +542,27 @@ float
 nsWindow::GetDPI()
 {
     return GetGonkDisplay()->xdpi;
 }
 
 double
 nsWindow::GetDefaultScaleInternal()
 {
-    double rawscale = GetDPI() / 192.0;
-    if (rawscale < 1.25)
-        return 1;
-    else if (rawscale < 1.75)
-        return 1.5;
-    return 2;
+    float dpi = GetDPI();
+    // The mean pixel density for mdpi devices is 160dpi, 240dpi for hdpi,
+    // and 320dpi for xhdpi, respectively.
+    // We'll take the mid-value between these three numbers as the boundary.
+    if (dpi < 200.0) {
+        return 1.0; // mdpi devices.
+    }
+    if (dpi < 280.0) {
+        return 1.5; // hdpi devices.
+    }
+    return 2.0; // xhdpi devices.
 }
 
 LayerManager *
 nsWindow::GetLayerManager(PLayerTransactionChild* aShadowManager,
                           LayersBackend aBackendHint,
                           LayerManagerPersistence aPersistence,
                           bool* aAllowRetaining)
 {