Blame 0001-Resolves-tdf-117413-char-doubling-appearing-under-X-.patch

d562fa2
From ba30f47d00850edbbfd157b664d5af97697d7a4a Mon Sep 17 00:00:00 2001
d562fa2
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
d562fa2
Date: Fri, 4 May 2018 17:15:37 +0100
d562fa2
Subject: [PATCH] Resolves: tdf#117413 char doubling appearing under X with
d562fa2
 gtk3
d562fa2
d562fa2
like happened on gtk2, so make the rhbz#1283420 bodge happen for XLIB surfaces,
d562fa2
regardless of the backend
d562fa2
d562fa2
Change-Id: Ic51679a71523e8cc76832858411b102d915638cf
d562fa2
---
d562fa2
 vcl/unx/generic/gdi/cairotextrender.cxx    | 22 +++++++++++++++++++++-
d562fa2
 vcl/unx/generic/gdi/x11cairotextrender.cxx | 16 +---------------
d562fa2
 2 files changed, 22 insertions(+), 16 deletions(-)
d562fa2
d562fa2
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx
d562fa2
index 00532c8644b9..10edfd0e5001 100644
d562fa2
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
d562fa2
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
d562fa2
@@ -151,6 +151,26 @@ namespace
d562fa2
     }
d562fa2
 }
d562fa2
 
d562fa2
+namespace
d562fa2
+{
d562fa2
+    cairo_t* syncCairoContext(cairo_t* cr)
d562fa2
+    {
d562fa2
+        //rhbz#1283420 tdf#117413 bodge to force a read from the underlying surface which has
d562fa2
+        //the side effect of making the mysterious xrender related problem go away
d562fa2
+        cairo_surface_t *target = cairo_get_target(cr);
d562fa2
+        if (cairo_surface_get_type(target) == CAIRO_SURFACE_TYPE_XLIB)
d562fa2
+        {
d562fa2
+            cairo_surface_t *throw_away = cairo_surface_create_similar(target, cairo_surface_get_content(target), 1, 1);
d562fa2
+            cairo_t *force_read_cr = cairo_create(throw_away);
d562fa2
+            cairo_set_source_surface(force_read_cr, target, 0, 0);
d562fa2
+            cairo_paint(force_read_cr);
d562fa2
+            cairo_destroy(force_read_cr);
d562fa2
+            cairo_surface_destroy(throw_away);
d562fa2
+        }
d562fa2
+        return cr;
d562fa2
+    }
d562fa2
+}
d562fa2
+
d562fa2
 void CairoTextRender::DrawTextLayout(const CommonSalLayout& rLayout)
d562fa2
 {
d562fa2
     const FreetypeFont& rFont = *rLayout.getFreetypeFont();
d562fa2
@@ -191,7 +211,7 @@ void CairoTextRender::DrawTextLayout(const CommonSalLayout& rLayout)
d562fa2
      * least change the SalFrame etc impls to dtor the SalGraphics *before* the
d562fa2
      * destruction of the windows they reference
d562fa2
     */
d562fa2
-    cairo_t *cr = getCairoContext();
d562fa2
+    cairo_t *cr = syncCairoContext(getCairoContext());
d562fa2
     if (!cr)
d562fa2
     {
d562fa2
         SAL_WARN("vcl", "no cairo context for text");
d562fa2
diff --git a/vcl/unx/generic/gdi/x11cairotextrender.cxx b/vcl/unx/generic/gdi/x11cairotextrender.cxx
d562fa2
index 105d0a0392bd..8960bd1c6bb1 100644
d562fa2
--- a/vcl/unx/generic/gdi/x11cairotextrender.cxx
d562fa2
+++ b/vcl/unx/generic/gdi/x11cairotextrender.cxx
d562fa2
@@ -36,21 +36,7 @@ GlyphCache& X11CairoTextRender::getPlatformGlyphCache()
d562fa2
 
d562fa2
 cairo_t* X11CairoTextRender::getCairoContext()
d562fa2
 {
d562fa2
-    cairo_t *cr = mrParent.getCairoContext();
d562fa2
-
d562fa2
-    //rhbz#1283420 bodge to force a read from the underlying surface which has
d562fa2
-    //the side effect of making the mysterious xrender related problem go away
d562fa2
-    {
d562fa2
-        cairo_surface_t *target = cairo_get_target(cr);
d562fa2
-        cairo_surface_t *throw_away = cairo_surface_create_similar(target, cairo_surface_get_content(target), 1, 1);
d562fa2
-        cairo_t *force_read_cr = cairo_create(throw_away);
d562fa2
-        cairo_set_source_surface(force_read_cr, target, 0, 0);
d562fa2
-        cairo_paint(force_read_cr);
d562fa2
-        cairo_destroy(force_read_cr);
d562fa2
-        cairo_surface_destroy(throw_away);
d562fa2
-    }
d562fa2
-
d562fa2
-    return cr;
d562fa2
+    return mrParent.getCairoContext();
d562fa2
 }
d562fa2
 
d562fa2
 void X11CairoTextRender::getSurfaceOffset( double& nDX, double& nDY )
d562fa2
-- 
d562fa2
2.14.3
d562fa2