From 7c4145490e9ef84dabd240e76ff3af10559f4b25 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 28 Mar 2016 17:51:16 +0200 Subject: [PATCH] Compilation fix for wxCairoRenderer with Cairo < 1.12 cairo_surface_create_similar_image() introduced by the changes of d6afb66388d8bb3f9ff6f4428c1ef7021045a9d4 is only available in 1.12 and later, check for it being available and fall back to cairo_surface_create_similar() with older versions. This should fix Travis CI builds. --- src/generic/graphicc.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/generic/graphicc.cpp b/src/generic/graphicc.cpp index a9f7dc091c..bac5bd8033 100644 --- a/src/generic/graphicc.cpp +++ b/src/generic/graphicc.cpp @@ -2830,9 +2830,21 @@ wxCairoRenderer::CreateSubBitmap(const wxGraphicsBitmap& bitmap, x + dstWidth <= srcWidth && y + dstHeight <= srcHeight, wxNullGraphicsBitmap, wxS("Invalid bitmap region")); - cairo_surface_t* dstSurface = cairo_surface_create_similar_image(srcSurface, - cairo_image_surface_get_format(srcSurface), - dstWidth, dstHeight); + cairo_surface_t* dstSurface; +#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) + if ( cairo_version() >= CAIRO_VERSION_ENCODE(1, 12, 0) ) + { + dstSurface = cairo_surface_create_similar_image(srcSurface, + cairo_image_surface_get_format(srcSurface), + dstWidth, dstHeight); + } + else +#endif // Cairo 1.12 + { + dstSurface = cairo_surface_create_similar(srcSurface, + CAIRO_CONTENT_COLOR_ALPHA, + dstWidth, dstHeight); + } cairo_t* cr = cairo_create(dstSurface); cairo_set_source_surface(cr, srcSurface, -x, -y);