summaryrefslogtreecommitdiff
path: root/vcl/headless
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-04-04 09:38:47 +0100
committerCaolán McNamara <caolanm@redhat.com>2019-04-04 12:12:12 +0200
commitcb7ff6bc57b542a27f6bdcfcaacc2cdf66cdb456 (patch)
treea72127f386b460c481243c8e40f7bce955b7b112 /vcl/headless
parent7aa14e80d2d9d94ba468b83db32fc1049d1d8b65 (diff)
Resolves: tdf#124219 check at runtime for availability of cairo functions
Change-Id: I0ab3055760d8be690bdfff560212db368a0fa261 Reviewed-on: https://gerrit.libreoffice.org/70240 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/headless')
-rw-r--r--vcl/headless/svpgdi.cxx40
-rw-r--r--vcl/headless/svpvd.cxx8
2 files changed, 30 insertions, 18 deletions
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 3ec663c8706b..2cf49ca17696 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -45,6 +45,7 @@
#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <comphelper/lok.hxx>
#include <unx/gendata.hxx>
+#include <dlfcn.h>
#if ENABLE_CAIRO_CANVAS
# if defined CAIRO_VERSION && CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 10, 0)
@@ -614,9 +615,7 @@ void SvpSalGraphics::setSurface(cairo_surface_t* pSurface, const basegfx::B2IVec
{
m_pSurface = pSurface;
m_aFrameSize = rSize;
-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
- cairo_surface_get_device_scale(pSurface, &m_fScale, nullptr);
-#endif
+ dl_cairo_surface_get_device_scale(pSurface, &m_fScale, nullptr);
ResetClipRegion();
}
@@ -1599,9 +1598,7 @@ void SvpSalGraphics::copyBits( const SalTwoRect& rTR,
cairo_surface_get_content(m_pSurface),
aTR.mnSrcWidth * m_fScale,
aTR.mnSrcHeight * m_fScale);
-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
- cairo_surface_set_device_scale(pCopy, m_fScale, m_fScale);
-#endif
+ dl_cairo_surface_set_device_scale(pCopy, m_fScale, m_fScale);
cairo_t* cr = cairo_create(pCopy);
cairo_set_source_surface(cr, source, -aTR.mnSrcX, -aTR.mnSrcY);
cairo_rectangle(cr, 0, 0, aTR.mnSrcWidth, aTR.mnSrcHeight);
@@ -1848,9 +1845,7 @@ void SvpSalGraphics::invert(const basegfx::B2DPolygon &rPoly, SalInvert nFlags)
extents.getWidth() * m_fScale,
extents.getHeight() * m_fScale);
-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
- cairo_surface_set_device_scale(surface, m_fScale, m_fScale);
-#endif
+ dl_cairo_surface_set_device_scale(surface, m_fScale, m_fScale);
cairo_t* stipple_cr = cairo_create(surface);
cairo_set_source_rgb(stipple_cr, 1.0, 1.0, 1.0);
cairo_mask(stipple_cr, pattern);
@@ -2004,9 +1999,7 @@ cairo_t* SvpSalGraphics::createTmpCompatibleCairoContext() const
m_aFrameSize.getX() * m_fScale,
m_aFrameSize.getY() * m_fScale);
-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
- cairo_surface_set_device_scale(target, m_fScale, m_fScale);
-#endif
+ dl_cairo_surface_set_device_scale(target, m_fScale, m_fScale);
return cairo_create(target);
}
@@ -2202,4 +2195,27 @@ GlyphCache& SvpSalGraphics::getPlatformGlyphCache()
return *pSalData->GetGlyphCache();
}
+void dl_cairo_surface_set_device_scale(cairo_surface_t *surface, double x_scale, double y_scale)
+{
+ static auto func = reinterpret_cast<void(*)(cairo_surface_t*, double, double)>(
+ dlsym(nullptr, "cairo_surface_set_device_scale"));
+ if (func)
+ func(surface, x_scale, y_scale);
+}
+
+void dl_cairo_surface_get_device_scale(cairo_surface_t *surface, double* x_scale, double* y_scale)
+{
+ static auto func = reinterpret_cast<void(*)(cairo_surface_t*, double*, double*)>(
+ dlsym(nullptr, "cairo_surface_get_device_scale"));
+ if (func)
+ func(surface, x_scale, y_scale);
+ else
+ {
+ if (x_scale)
+ *x_scale = 1.0;
+ if (y_scale)
+ *y_scale = 1.0;
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx
index 875f22a5d7fc..eeccf2c014a9 100644
--- a/vcl/headless/svpvd.cxx
+++ b/vcl/headless/svpvd.cxx
@@ -89,7 +89,6 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY,
}
else if (pBuffer)
{
-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
double fXScale, fYScale;
if (comphelper::LibreOfficeKit::isActive())
{
@@ -98,18 +97,15 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY,
}
else
{
- cairo_surface_get_device_scale(m_pRefSurface, &fXScale, &fYScale);
+ dl_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, fXScale, fYScale);
-#endif
+ dl_cairo_surface_set_device_scale(m_pSurface, fXScale, fYScale);
}
else
{