From 01e522b2000997c20e994adf0161504fdcc44ec8 Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Mon, 27 Apr 2026 18:44:06 +0200 Subject: [PATCH] Fix build with CAIRO_NO_MUTEX The LibreOffice project builds Cairo with -DCAIRO_NO_MUTEX. IMHO that's quite risky for big projects where you don't control all the code that uses Cairo, but I assume they know what they're doing. This change should have been part of commit 87f7c60bf7, but admittetly CAIRO_NO_MUTEX builds are not actively tested. Fixes #921 --- src/cairo-image-source.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/cairo-image-source.c b/src/cairo-image-source.c index eaf72e2cc..b752041cf 100644 --- a/src/cairo-image-source.c +++ b/src/cairo-image-source.c @@ -62,9 +62,10 @@ #endif #if PIXMAN_HAS_ATOMIC_OPS -static pixman_image_t *__pixman_transparent_image; -static pixman_image_t *__pixman_black_image; -static pixman_image_t *__pixman_white_image; + +static cairo_atomic_intptr_t __pixman_transparent_image; /* (pixman_image_t *) */ +static cairo_atomic_intptr_t __pixman_black_image; +static cairo_atomic_intptr_t __pixman_white_image; static pixman_image_t * _pixman_transparent_image (void) @@ -73,7 +74,7 @@ _pixman_transparent_image (void) TRACE ((stderr, "%s\n", __FUNCTION__)); - image = __pixman_transparent_image; + image = (pixman_image_t *) _cairo_atomic_ptr_get (&__pixman_transparent_image); if (unlikely (image == NULL)) { pixman_color_t color; @@ -105,7 +106,7 @@ _pixman_black_image (void) TRACE ((stderr, "%s\n", __FUNCTION__)); - image = __pixman_black_image; + image = (pixman_image_t *) _cairo_atomic_ptr_get (&__pixman_black_image); if (unlikely (image == NULL)) { pixman_color_t color; @@ -137,7 +138,7 @@ _pixman_white_image (void) TRACE ((stderr, "%s\n", __FUNCTION__)); - image = __pixman_white_image; + image = (pixman_image_t *) _cairo_atomic_ptr_get (&__pixman_white_image); if (unlikely (image == NULL)) { pixman_color_t color; @@ -178,6 +179,7 @@ static struct { static int n_cached; #else /* !PIXMAN_HAS_ATOMIC_OPS */ + static pixman_image_t * _pixman_transparent_image (void) { @@ -198,6 +200,7 @@ _pixman_white_image (void) TRACE ((stderr, "%s\n", __FUNCTION__)); return _pixman_image_for_color (CAIRO_COLOR_WHITE); } + #endif /* !PIXMAN_HAS_ATOMIC_OPS */