bump required cairo version to 1.12.0

Desktop / LibreOffice - Noel Grandin [collabora.co.uk] - 14 November 2022 19:49 UTC

Change-Id: I7fbfb21f2facdd6371fba821fd30e625115dc72d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142710

###

diff --git a/configure.ac b/configure.ac
index f6937648fe2d..51d5508ad248 100644
--- a/configure.ac
+++ b/configure.ac
@@ -13593,7 +13593,7 @@ if test "$test_cairo" = "yes"; then
SYSTEM_CAIRO=TRUE
AC_MSG_RESULT([yes])

- PKG_CHECK_MODULES( CAIRO, cairo >= 1.8.0 )
+ PKG_CHECK_MODULES( CAIRO, cairo >= 1.12.0 )
CAIRO_CFLAGS=$(printf '%s' "$CAIRO_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
FilterLibs "${CAIRO_LIBS}"
CAIRO_LIBS="${filteredlibs}"
diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx
index ee4234c3c79f..be0e6919f99e 100644
--- a/vcl/headless/CairoCommon.cxx
+++ b/vcl/headless/CairoCommon.cxx
@@ -30,6 +30,10 @@
#include
#include

+#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 12, 0)
+#error "require at least cairo 1.12.0"
+#endif
+
void dl_cairo_surface_set_device_scale(cairo_surface_t* surface, double x_scale, double y_scale)
{
#if !HAVE_DLAPI
@@ -472,19 +476,9 @@ void CairoCommon::doXorOnRelease(sal_Int32 nExtentsLeft, sal_Int32 nExtentsTop,
cairo_surface_t* target_surface = m_pSurface;
if (cairo_surface_get_type(target_surface) != CAIRO_SURFACE_TYPE_IMAGE)
{
- //in the unlikely case we can't use m_pSurface directly, copy contents
- //to another temp image surface
-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
+ //in the unlikely case we can't use m_pSurface directly, copy contents
+ //to another temp image surface
target_surface = cairo_surface_map_to_image(target_surface, nullptr);
-#else
- cairo_t* copycr = createTmpCompatibleCairoContext();
- cairo_rectangle(copycr, nExtentsLeft, nExtentsTop, nExtentsRight - nExtentsLeft,
- nExtentsBottom - nExtentsTop);
- cairo_set_source_surface(copycr, m_pSurface, 0, 0);
- cairo_fill(copycr);
- target_surface = cairo_get_target(copycr);
- cairo_destroy(copycr);
-#endif
}

cairo_surface_flush(target_surface);
@@ -554,19 +548,7 @@ void CairoCommon::doXorOnRelease(sal_Int32 nExtentsLeft, sal_Int32 nExtentsTop,

if (target_surface != m_pSurface)
{
-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
cairo_surface_unmap_image(m_pSurface, target_surface);
-#else
- cairo_t* copycr = cairo_create(m_pSurface);
- //unlikely case we couldn't use m_pSurface directly, copy contents
- //back from image surface
- cairo_rectangle(copycr, nExtentsLeft, nExtentsTop, nExtentsRight - nExtentsLeft,
- nExtentsBottom - nExtentsTop);
- cairo_set_source_surface(copycr, target_surface, 0, 0);
- cairo_fill(copycr);
- cairo_destroy(copycr);
- cairo_surface_destroy(target_surface);
-#endif
}

cairo_surface_destroy(surface);
@@ -574,13 +556,9 @@ void CairoCommon::doXorOnRelease(sal_Int32 nExtentsLeft, sal_Int32 nExtentsTop,

cairo_t* CairoCommon::createTmpCompatibleCairoContext() const
{
-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
- cairo_surface_t* target = cairo_surface_create_similar_image(
- m_pSurface,
-#else
- cairo_surface_t* target = cairo_image_surface_create(
-#endif
- CAIRO_FORMAT_ARGB32, m_aFrameSize.getX() * m_fScale, m_aFrameSize.getY() * m_fScale);
+ cairo_surface_t* target = cairo_surface_create_similar_image(m_pSurface, CAIRO_FORMAT_ARGB32,
+ m_aFrameSize.getX() * m_fScale,
+ m_aFrameSize.getY() * m_fScale);

dl_cairo_surface_set_device_scale(target, m_fScale, m_fScale);

@@ -1002,10 +980,6 @@ cairo_pattern_t* create_stipple()
}
} // end anonymous ns

-#if defined CAIRO_VERSION && CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 10, 0)
-#define CAIRO_OPERATOR_DIFFERENCE (static_cast(23))
-#endif
-
void CairoCommon::invert(const basegfx::B2DPolygon& rPoly, SalInvert nFlags, bool bAntiAlias)
{
cairo_t* cr = getCairoContext(false, bAntiAlias);
@@ -1018,14 +992,7 @@ void CairoCommon::invert(const basegfx::B2DPolygon& rPoly, SalInvert nFlags, boo

cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);

- if (cairo_version() >= CAIRO_VERSION_ENCODE(1, 10, 0))
- {
- cairo_set_operator(cr, CAIRO_OPERATOR_DIFFERENCE);
- }
- else
- {
- SAL_WARN("vcl.gdi", "SvpSalGraphics::invert, archaic cairo");
- }
+ cairo_set_operator(cr, CAIRO_OPERATOR_DIFFERENCE);

if (nFlags & SalInvert::TrackFrame)
{
diff --git a/vcl/headless/SvpGraphicsBackend.cxx b/vcl/headless/SvpGraphicsBackend.cxx
index a0bbd789b9a0..cd5487031a63 100644
--- a/vcl/headless/SvpGraphicsBackend.cxx
+++ b/vcl/headless/SvpGraphicsBackend.cxx
@@ -593,12 +593,8 @@ void SvpGraphicsBackend::drawBitmapBuffer(const SalTwoRect& rTR, const BitmapBuf

Color SvpGraphicsBackend::getPixel(tools::Long nX, tools::Long nY)
{
-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
cairo_surface_t* target
= cairo_surface_create_similar_image(m_rCairoCommon.m_pSurface, CAIRO_FORMAT_ARGB32, 1, 1);
-#else
- cairo_surface_t* target = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1);
-#endif

cairo_t* cr = cairo_create(target);

diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx
index 38936733f7b3..969490bfecce 100644
--- a/vcl/source/bitmap/BitmapTools.cxx
+++ b/vcl/source/bitmap/BitmapTools.cxx
@@ -267,11 +267,7 @@ BitmapEx* CreateFromCairoSurface(Size aSize, cairo_surface_t * pSurface)
// FIXME: if we could teach VCL/ about cairo handles, life could
// be significantly better here perhaps.

-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
cairo_surface_t *pPixels = cairo_surface_create_similar_image(pSurface,
-#else
- cairo_surface_t *pPixels = cairo_image_surface_create(
-#endif
CAIRO_FORMAT_ARGB32, aSize.Width(), aSize.Height());
cairo_t *pCairo = cairo_create( pPixels );
if( !pPixels || !pCairo || cairo_status(pCairo) != CAIRO_STATUS_SUCCESS )

bb943222e659 bump required cairo version to 1.12.0
configure.ac | 2 +-
vcl/headless/CairoCommon.cxx | 53 +++++++------------------------------
vcl/headless/SvpGraphicsBackend.cxx | 4 ---
vcl/source/bitmap/BitmapTools.cxx | 4 ---
4 files changed, 11 insertions(+), 52 deletions(-)

Upstream: cgit.freedesktop.org


  • Share