[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/qt5 vcl/unx

Caolán McNamara caolanm at redhat.com
Wed Apr 11 14:43:52 UTC 2018


 vcl/headless/svpinst.cxx   |    2 +-
 vcl/headless/svpvd.cxx     |   34 ++++++++++++++++++----------------
 vcl/inc/headless/svpvd.hxx |    3 +--
 vcl/qt5/Qt5Instance.cxx    |    3 +--
 vcl/unx/gtk/gtkinst.cxx    |    2 +-
 5 files changed, 22 insertions(+), 22 deletions(-)

New commits:
commit b524de950c6eb0bc61d05d41fe69b67ab59b16c6
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Apr 11 12:09:45 2018 +0100

    Related: rhbz#1396729 use cairo_surface_create_similar
    
    where we can
    
    Change-Id: If6fd729a9cbf834faef33586b5bd886aad2fbe1d
    Reviewed-on: https://gerrit.libreoffice.org/52726
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx
index 81a8f332723b..664547a69a52 100644
--- a/vcl/headless/svpinst.cxx
+++ b/vcl/headless/svpinst.cxx
@@ -243,7 +243,7 @@ SalVirtualDevice* SvpSalInstance::CreateVirtualDevice( SalGraphics* pGraphics,
 {
     SvpSalGraphics *pSvpSalGraphics = dynamic_cast<SvpSalGraphics*>(pGraphics);
     assert(pSvpSalGraphics);
-    SvpSalVirtualDevice* pNew = new SvpSalVirtualDevice(eFormat, pSvpSalGraphics->getScale(), pSvpSalGraphics->getSurface());
+    SvpSalVirtualDevice* pNew = new SvpSalVirtualDevice(eFormat, pSvpSalGraphics->getSurface());
     pNew->SetSize( nDX, nDY );
     return pNew;
 }
diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx
index decca08a76eb..4172fc383744 100644
--- a/vcl/headless/svpvd.cxx
+++ b/vcl/headless/svpvd.cxx
@@ -30,11 +30,10 @@
 
 using namespace basegfx;
 
-SvpSalVirtualDevice::SvpSalVirtualDevice(DeviceFormat eFormat, double fScale, cairo_surface_t* pRefSurface)
+SvpSalVirtualDevice::SvpSalVirtualDevice(DeviceFormat eFormat, cairo_surface_t* pRefSurface)
     : m_eFormat(eFormat)
     , m_pRefSurface(pRefSurface)
     , m_pSurface(nullptr)
-    , m_fScale(fScale)
 {
     cairo_surface_reference(m_pRefSurface);
 }
@@ -77,9 +76,6 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY,
     {
         m_aFrameSize = basegfx::B2IVector(nNewDX, nNewDY);
 
-        nNewDX *= m_fScale;
-        nNewDY *= m_fScale;
-
         if (m_pSurface)
         {
             cairo_surface_destroy(m_pSurface);
@@ -87,23 +83,29 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY,
 
         if (m_eFormat == DeviceFormat::BITMASK)
         {
-            m_pSurface = cairo_surface_create_similar_image(m_pRefSurface, CAIRO_FORMAT_A1,
+            m_pSurface = cairo_surface_create_similar(m_pRefSurface, CAIRO_CONTENT_ALPHA,
                                 nNewDX, nNewDY);
         }
-        else
+        else if (pBuffer)
         {
-            m_pSurface = pBuffer ?
-                             cairo_image_surface_create_for_data(pBuffer, CAIRO_FORMAT_ARGB32,
-                                   nNewDX, nNewDY,
-                                   cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, nNewDX))
-                                 :
-                             cairo_surface_create_similar_image(m_pRefSurface, CAIRO_FORMAT_ARGB32,
-                                   nNewDX, nNewDY);
-        }
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
+            double fXScale, fYScale;
+            cairo_surface_get_device_scale(m_pRefSurface, &fXScale, &fYScale);
+            nNewDX *= fXScale;
+            nNewDY *= fYScale;
+#endif
+
+            m_pSurface = cairo_image_surface_create_for_data(pBuffer, CAIRO_FORMAT_ARGB32,
+                                nNewDX, nNewDY, cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, nNewDX));
 
 #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
-        cairo_surface_set_device_scale(m_pSurface, m_fScale, m_fScale);
+            cairo_surface_set_device_scale(m_pSurface, fXScale, fYScale);
 #endif
+        }
+        else
+        {
+            m_pSurface = cairo_surface_create_similar(m_pRefSurface, CAIRO_CONTENT_COLOR_ALPHA, nNewDX, nNewDY);
+        }
 
         // update device in existing graphics
         for (auto const& graphic : m_aGraphics)
diff --git a/vcl/inc/headless/svpvd.hxx b/vcl/inc/headless/svpvd.hxx
index 990915169d56..51d6af9cb499 100644
--- a/vcl/inc/headless/svpvd.hxx
+++ b/vcl/inc/headless/svpvd.hxx
@@ -33,11 +33,10 @@ class VCL_DLLPUBLIC SvpSalVirtualDevice : public SalVirtualDevice
     cairo_surface_t*                    m_pRefSurface;
     cairo_surface_t*                    m_pSurface;
     basegfx::B2IVector                  m_aFrameSize;
-    double                              m_fScale;
     std::vector< SvpSalGraphics* >      m_aGraphics;
 
 public:
-    SvpSalVirtualDevice(DeviceFormat eFormat, double fScale, cairo_surface_t* pRefSurface);
+    SvpSalVirtualDevice(DeviceFormat eFormat, cairo_surface_t* pRefSurface);
     virtual ~SvpSalVirtualDevice() override;
 
     // SalVirtualDevice
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index 26f0fafcafb8..7eb734195756 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -92,8 +92,7 @@ SalVirtualDevice* Qt5Instance::CreateVirtualDevice(SalGraphics* pGraphics, long&
     {
         SvpSalGraphics* pSvpSalGraphics = dynamic_cast<SvpSalGraphics*>(pGraphics);
         assert(pSvpSalGraphics);
-        SvpSalVirtualDevice* pVD = new SvpSalVirtualDevice(eFormat, pSvpSalGraphics->getScale(),
-                                                           pSvpSalGraphics->getSurface());
+        SvpSalVirtualDevice* pVD = new SvpSalVirtualDevice(eFormat, pSvpSalGraphics->getSurface());
         pVD->SetSize(nDX, nDY);
         return pVD;
     }
diff --git a/vcl/unx/gtk/gtkinst.cxx b/vcl/unx/gtk/gtkinst.cxx
index 3899e2d5d692..dbd0d64ab32b 100644
--- a/vcl/unx/gtk/gtkinst.cxx
+++ b/vcl/unx/gtk/gtkinst.cxx
@@ -331,7 +331,7 @@ SalVirtualDevice* GtkInstance::CreateVirtualDevice( SalGraphics *pG,
     (void) pGd;
     SvpSalGraphics *pSvpSalGraphics = dynamic_cast<SvpSalGraphics*>(pG);
     assert(pSvpSalGraphics);
-    SvpSalVirtualDevice* pNew = new SvpSalVirtualDevice(eFormat, pSvpSalGraphics->getScale(), pSvpSalGraphics->getSurface());
+    SvpSalVirtualDevice* pNew = new SvpSalVirtualDevice(eFormat, pSvpSalGraphics->getSurface());
     pNew->SetSize( nDX, nDY );
     return pNew;
 #else


More information about the Libreoffice-commits mailing list