include/vcl/virdev.hxx       |    3 ++-
 vcl/headless/svpinst.cxx     |    5 +++++
 vcl/inc/headless/svpinst.hxx |    2 ++
 vcl/inc/headless/svpvd.hxx   |    2 ++
 vcl/unx/gtk3/gtk3gtkinst.cxx |   19 ++-----------------
 5 files changed, 13 insertions(+), 18 deletions(-)

New commits:
commit 033400a7524813b4eccf8f90a7647bc0121e75dd
Author: Caolán McNamara <caol...@redhat.com>
Date:   Wed Jun 20 16:47:17 2018 +0100

    take the surface directly from the SvpSalVirtualDevice
    
    Change-Id: I5e0d46fa863a9a74063063cc3d22ea15d2544d8b
    Reviewed-on: https://gerrit.libreoffice.org/56219
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Tested-by: Caolán McNamara <caol...@redhat.com>

diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx
index 3895661649d8..98647fa4b766 100644
--- a/include/vcl/virdev.hxx
+++ b/include/vcl/virdev.hxx
@@ -25,15 +25,16 @@
 #include <vcl/outdev.hxx>
 #include <memory>
 
-
 class SalVirtualDevice;
 struct SystemGraphicsData;
+typedef struct _cairo_surface cairo_surface_t;
 
 class VCL_DLLPUBLIC VirtualDevice : public OutputDevice
 {
     friend class Application;
     friend class ::OutputDevice;
     friend class Printer;
+    friend cairo_surface_t* get_underlying_cairo_suface(VirtualDevice&);
 public:
     // reference device modes for different compatibility levels
     enum class RefDevMode { NONE = 0,
diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx
index 1128f0d61ee6..48f799473b14 100644
--- a/vcl/headless/svpinst.cxx
+++ b/vcl/headless/svpinst.cxx
@@ -248,6 +248,11 @@ std::unique_ptr<SalVirtualDevice> 
SvpSalInstance::CreateVirtualDevice( SalGraphi
     return pNew;
 }
 
+cairo_surface_t* get_underlying_cairo_suface(VirtualDevice& rDevice)
+{
+    return 
static_cast<SvpSalVirtualDevice*>(rDevice.mpVirDev.get())->GetSurface();
+}
+
 #endif
 
 SalTimer* SvpSalInstance::CreateSalTimer()
diff --git a/vcl/inc/headless/svpinst.hxx b/vcl/inc/headless/svpinst.hxx
index 9eef8cdae6f3..3ca4d204cb84 100644
--- a/vcl/inc/headless/svpinst.hxx
+++ b/vcl/inc/headless/svpinst.hxx
@@ -197,6 +197,8 @@ inline void SvpSalInstance::deregisterFrame( SalFrame* 
pFrame )
     eraseFrame( pFrame );
 }
 
+VCL_DLLPUBLIC cairo_surface_t* get_underlying_cairo_suface(VirtualDevice& 
rDevice);
+
 #endif // INCLUDED_VCL_INC_HEADLESS_SVPINST_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/headless/svpvd.hxx b/vcl/inc/headless/svpvd.hxx
index 51d6af9cb499..e68680c79901 100644
--- a/vcl/inc/headless/svpvd.hxx
+++ b/vcl/inc/headless/svpvd.hxx
@@ -48,6 +48,8 @@ public:
                                             sal_uInt8 * pBuffer
                                           ) override;
 
+    cairo_surface_t* GetSurface() const { return m_pSurface; }
+
     // SalGeometryProvider
     virtual long GetWidth() const override;
     virtual long GetHeight() const override;
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index cb5ab02cee52..e454c58df342 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -3820,7 +3820,6 @@ AtkObject* 
(*default_drawing_area_get_accessible)(GtkWidget *widget);
 
 }
 
-
 class GtkInstanceDrawingArea : public GtkInstanceWidget, public virtual 
weld::DrawingArea
 {
 private:
@@ -3828,7 +3827,6 @@ private:
     a11yref m_xAccessible;
     AtkObject *m_pAccessible;
     ScopedVclPtrInstance<VirtualDevice> m_xDevice;
-    std::vector<unsigned char> m_aBuffer;
     cairo_surface_t* m_pSurface;
     sal_uInt16 m_nLastMouseButton;
     gulong m_nDrawSignalId;
@@ -3876,19 +3874,8 @@ private:
     }
     void signal_size_allocate(guint nWidth, guint nHeight)
     {
-        if (m_pSurface)
-            cairo_surface_destroy(m_pSurface);
-
-        const int nScale = 
gtk_widget_get_scale_factor(GTK_WIDGET(m_pDrawingArea));
-        const int nStride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, 
nWidth * nScale);
-        m_aBuffer.resize(nHeight * nScale * nStride);
-        m_xDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nWidth, 
nHeight), Fraction(1.0), Point(),
-                                                          m_aBuffer.data());
-        m_pSurface = cairo_image_surface_create_for_data(m_aBuffer.data(), 
CAIRO_FORMAT_ARGB32,
-                                                         nWidth * nScale, 
nHeight * nScale, nStride);
-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
-        cairo_surface_set_device_scale(m_pSurface, nScale, nScale);
-#endif
+        m_xDevice->SetOutputSizePixel(Size(nWidth, nHeight));
+        m_pSurface = get_underlying_cairo_suface(*m_xDevice);
         m_aSizeAllocateHdl.Call(Size(nWidth, nHeight));
     }
     static void signalStyleUpdated(GtkWidget*, gpointer widget)
@@ -4138,8 +4125,6 @@ public:
         g_object_steal_data(G_OBJECT(m_pDrawingArea), 
"g-lo-GtkInstanceDrawingArea");
         if (m_pAccessible)
             g_object_unref(m_pAccessible);
-        if (m_pSurface)
-            cairo_surface_destroy(m_pSurface);
         g_signal_handler_disconnect(m_pDrawingArea, m_nQueryTooltip);
         g_signal_handler_disconnect(m_pDrawingArea, m_nStyleUpdatedSignalId);
         g_signal_handler_disconnect(m_pDrawingArea, m_nKeyPressSignalId);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to