[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - vcl/headless

Caolán McNamara caolanm at redhat.com
Wed Feb 1 16:26:59 UTC 2017


 vcl/headless/svpgdi.cxx |   21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

New commits:
commit 0c6728a675a5844c384a34d5538f10e6d2916efa
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Feb 1 12:50:47 2017 +0000

    gtk3 hidpi xor hack needs to use unscaled extents
    
    so that e.g. the xor cursor in csv dialog can be seen when moving
    the mouse across the ruler
    
    Change-Id: Ia2f367d5f610d486a8e10b6bc278cbc8029cf2a1
    (cherry picked from commit 00c4679641bc2b84c6496258c0c5bd84df75ae42)
    Reviewed-on: https://gerrit.libreoffice.org/33792
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 57093f6..11f408a 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -1270,12 +1270,17 @@ cairo_surface_t* SvpSalGraphics::createCairoSurface(const BitmapBuffer *pBuffer)
     return target;
 }
 
-static cairo_t* createTmpCompatibleCairoContext(cairo_surface_t* pSurface)
+static cairo_t* createTmpCompatibleCairoContext(cairo_surface_t* pSurface, double fScale)
 {
     cairo_surface_t *target = cairo_image_surface_create(
                                 cairo_image_surface_get_format(pSurface),
                                 cairo_image_surface_get_width(pSurface),
                                 cairo_image_surface_get_height(pSurface));
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
+    cairo_surface_set_device_scale(target, fScale, fScale);
+#else
+    (void)fScale;
+#endif
     return cairo_create(target);
 }
 
@@ -1283,7 +1288,7 @@ cairo_t* SvpSalGraphics::getCairoContext(bool bXorModeAllowed) const
 {
     cairo_t* cr;
     if (m_ePaintMode == XOR && bXorModeAllowed)
-        cr = createTmpCompatibleCairoContext(m_pSurface);
+        cr = createTmpCompatibleCairoContext(m_pSurface, m_fScale);
     else
         cr = cairo_create(m_pSurface);
     cairo_set_line_width(cr, 1);
@@ -1335,13 +1340,17 @@ void SvpSalGraphics::releaseCairoContext(cairo_t* cr, bool bXorModeAllowed, cons
         cairo_format_t nFormat = cairo_image_surface_get_format(m_pSurface);
         assert(nFormat == CAIRO_FORMAT_ARGB32 && "need to implement CAIRO_FORMAT_A1 after all here");
         sal_Int32 nStride = cairo_format_stride_for_width(nFormat, nWidth);
-        for (sal_Int32 y = nExtentsTop; y < nExtentsBottom; ++y)
+        sal_Int32 nUnscaledExtentsLeft = nExtentsLeft * m_fScale;
+        sal_Int32 nUnscaledExtentsRight = nExtentsRight * m_fScale;
+        sal_Int32 nUnscaledExtentsTop = nExtentsTop * m_fScale;
+        sal_Int32 nUnscaledExtentsBottom = nExtentsBottom * m_fScale;
+        for (sal_Int32 y = nUnscaledExtentsTop; y < nUnscaledExtentsBottom; ++y)
         {
             unsigned char *true_row = true_surface_data + (nStride*y);
             unsigned char *xor_row = xor_surface_data + (nStride*y);
-            unsigned char *true_data = true_row + (nExtentsLeft * 4);
-            unsigned char *xor_data = xor_row + (nExtentsLeft * 4);
-            for (sal_Int32 x = nExtentsLeft; x < nExtentsRight; ++x)
+            unsigned char *true_data = true_row + (nUnscaledExtentsLeft * 4);
+            unsigned char *xor_data = xor_row + (nUnscaledExtentsLeft * 4);
+            for (sal_Int32 x = nUnscaledExtentsLeft; x < nUnscaledExtentsRight; ++x)
             {
                 sal_uInt8 b = unpremultiply(true_data[SVP_CAIRO_BLUE], true_data[SVP_CAIRO_ALPHA]) ^
                               unpremultiply(xor_data[SVP_CAIRO_BLUE], xor_data[SVP_CAIRO_ALPHA]);


More information about the Libreoffice-commits mailing list