diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-06-20 16:47:17 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-06-21 10:00:38 +0200 |
commit | 3e76985d5efe47a8c79945049831e791a9277498 (patch) | |
tree | e60743ebf818e94c5d5fae0af1b3fdb6e2aeb679 /vcl | |
parent | b3df3494174243e691d1be74bab4d7f5177ad3b7 (diff) |
take the surface directly from the SvpSalVirtualDevice
Change-Id: I5e0d46fa863a9a74063063cc3d22ea15d2544d8b
Reviewed-on: https://gerrit.libreoffice.org/56208
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/headless/svpinst.cxx | 5 | ||||
-rw-r--r-- | vcl/inc/headless/svpinst.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/headless/svpvd.hxx | 2 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 19 |
4 files changed, 11 insertions, 17 deletions
diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx index 22146014dbfc..be7e408feca4 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 810374c03802..6ae378ceb665 100644 --- a/vcl/inc/headless/svpinst.hxx +++ b/vcl/inc/headless/svpinst.hxx @@ -193,6 +193,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); |