bug 1271893 add a 1.5 pixel-scaling step r?acomminos draft
authorKarl Tomlinson <karlt+@karlt.net>
Wed, 11 May 2016 09:21:13 +1200
changeset 365645 d3ea27337585f931dc6c88435b0ca3d24f4c06c3
parent 365494 674a552743785c28c75866969aad513bd8eaf6ae
child 520615 985f959a4fe4b94756a0ba61ff48c3ccb711e1ec
push id17806
push userktomlinson@mozilla.com
push dateWed, 11 May 2016 06:27:29 +0000
reviewersacomminos
bugs1271893
milestone49.0a1
bug 1271893 add a 1.5 pixel-scaling step r?acomminos The only change in behaviour introduced here is that dpi values in the range [144,168) will now use pixel scaling of 1.5 instead of 2. MozReview-Commit-ID: JD6FcZGLYtI
gfx/thebes/gfxPlatformGtk.cpp
--- a/gfx/thebes/gfxPlatformGtk.cpp
+++ b/gfx/thebes/gfxPlatformGtk.cpp
@@ -335,21 +335,29 @@ gfxPlatformGtk::GetDPI()
         }
     }
     return sDPI;
 }
 
 double
 gfxPlatformGtk::GetDPIScale()
 {
-    // We want to set the default CSS to device pixel ratio as the
-    // closest _integer_ multiple, so round the ratio of actual dpi
-    // to CSS dpi (96)
+    // Integer scale factors work well with GTK window scaling, image scaling,
+    // and pixel alignment, but there is a range where 1 is too small and 2 is
+    // too big.  An additional step of 1.5 is added because this is common
+    // scale on WINNT and at this ratio the advantages of larger rendering
+    // outweigh the disadvantages from scaling and pixel mis-alignment.
     int32_t dpi = GetDPI();
-    return (dpi > 96) ? round(dpi/96.0) : 1.0;
+    if (dpi < 144) {
+        return 1.0;
+    } else if (dpi < 168) {
+        return 1.5;
+    } else {
+        return round(dpi/96.0);
+    }
 }
 
 bool
 gfxPlatformGtk::UseImageOffscreenSurfaces()
 {
     return GetDefaultContentBackend() != mozilla::gfx::BackendType::CAIRO ||
            gfxPrefs::UseImageOffscreenSurfaces();
 }