Bug 1570927 [hidpi] apply scale factor also to the translation matrix; r=stransky
authorJan Horak <jhorak@redhat.com>
Fri, 02 Aug 2019 10:58:07 +0000
changeset 485959 80d4b26885e46cd2e106e8ec1b47fb5c219adcfd
parent 485958 d780672e184a445f70d63643fce313e75d5da3c9
child 485960 5313c2e63f0946974d5b53c96d8f4f5f3dcb2290
push id113825
push useropoprus@mozilla.com
push dateFri, 02 Aug 2019 22:01:10 +0000
treeherdermozilla-inbound@37229cef2cc7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstransky
bugs1570927
milestone70.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 1570927 [hidpi] apply scale factor also to the translation matrix; r=stransky Differential Revision: https://phabricator.services.mozilla.com/D40404
widget/gtk/nsNativeThemeGTK.cpp
--- a/widget/gtk/nsNativeThemeGTK.cpp
+++ b/widget/gtk/nsNativeThemeGTK.cpp
@@ -797,16 +797,19 @@ bool nsNativeThemeGTK::GetGtkWidgetAndSt
 class SystemCairoClipper : public ClipExporter {
  public:
   explicit SystemCairoClipper(cairo_t* aContext, gint aScaleFactor = 1)
       : mContext(aContext), mScaleFactor(aScaleFactor) {}
 
   void BeginClip(const Matrix& aTransform) override {
     cairo_matrix_t mat;
     GfxMatrixToCairoMatrix(aTransform, mat);
+    // We also need to remove the scale factor effect from the matrix
+    mat.y0 = mat.y0 / mScaleFactor;
+    mat.x0 = mat.x0 / mScaleFactor;
     cairo_set_matrix(mContext, &mat);
 
     cairo_new_path(mContext);
   }
 
   void MoveTo(const Point& aPoint) override {
     cairo_move_to(mContext, aPoint.x / mScaleFactor, aPoint.y / mScaleFactor);
     mBeginPoint = aPoint;
@@ -862,19 +865,18 @@ static void DrawThemeWithCairo(gfxContex
                                bool aSnapped, const Point& aDrawOrigin,
                                const nsIntSize& aDrawSize,
                                GdkRectangle& aGDKRect,
                                nsITheme::Transparency aTransparency) {
   bool isX11Display = GDK_IS_X11_DISPLAY(gdk_display_get_default());
   static auto sCairoSurfaceSetDeviceScalePtr =
       (void (*)(cairo_surface_t*, double, double))dlsym(
           RTLD_DEFAULT, "cairo_surface_set_device_scale");
-  // Support HiDPI widget styles on Wayland only for now.
-  bool useHiDPIWidgets = !isX11Display && (aScaleFactor != 1) &&
-                         (sCairoSurfaceSetDeviceScalePtr != nullptr);
+  bool useHiDPIWidgets =
+      (aScaleFactor != 1) && (sCairoSurfaceSetDeviceScalePtr != nullptr);
 
   Point drawOffsetScaled;
   Point drawOffsetOriginal;
   Matrix transform;
   if (!aSnapped) {
     // If we are not snapped, we depend on the DT for translation.
     drawOffsetOriginal = aDrawOrigin;
     drawOffsetScaled = useHiDPIWidgets ? drawOffsetOriginal / aScaleFactor