Fix build on systems with older Xrender headers.

This patch revises xlib so that it doesn't depend on having recent
Xrender headers to build.  In particular, some definitions were added
to the private xrender header file, and an ifdef render version check
CAIRO_SURFACE_RENDER_SUPPORTS_OPERATOR was changed to a run-time
check using CAIRO_SURFACE_RENDER_HAS_PDF_OPERATORS.
This commit is contained in:
Damian Frank 2009-08-14 11:35:55 -05:00 committed by Chris Wilson
parent 17ef949b6a
commit 06ca0b1475
3 changed files with 93 additions and 34 deletions

View file

@ -284,7 +284,14 @@ _cairo_xlib_display_get (Display *dpy,
memset (display->cached_xrender_formats, 0,
sizeof (display->cached_xrender_formats));
/* Prior to Render 0.10, there is no protocol support for gradients and
* we call function stubs instead, which would silently consume the drawing.
*/
#if RENDER_MAJOR == 0 && RENDER_MINOR < 10
display->buggy_gradients = TRUE;
#else
display->buggy_gradients = FALSE;
#endif
display->buggy_pad_reflect = TRUE;
display->buggy_repeat = FALSE;

View file

@ -156,13 +156,10 @@ static const XTransform identity = { {
#define CAIRO_SURFACE_RENDER_HAS_PDF_OPERATORS(surface) CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 11)
#if RENDER_MAJOR > 0 || RENDER_MINOR >= 11
#define CAIRO_SURFACE_RENDER_SUPPORTS_OPERATOR(surface, op) \
(((op) <= CAIRO_OPERATOR_SATURATE) ? TRUE : (CAIRO_SURFACE_RENDER_HAS_PDF_OPERATORS (surface) ? (op) <= CAIRO_OPERATOR_HSL_LUMINOSITY : FALSE))
#else
#define CAIRO_SURFACE_RENDER_SUPPORTS_OPERATOR(surface, op) \
((op) <= CAIRO_OPERATOR_SATURATE)
#endif
#define CAIRO_SURFACE_RENDER_SUPPORTS_OPERATOR(surface, op) \
((op) <= CAIRO_OPERATOR_SATURATE || \
(CAIRO_SURFACE_RENDER_HAS_PDF_OPERATORS(surface) && \
(op) <= CAIRO_OPERATOR_HSL_LUMINOSITY))
static cairo_status_t
_cairo_xlib_surface_set_clip_region (cairo_xlib_surface_t *surface,
@ -1832,7 +1829,6 @@ _render_operator (cairo_operator_t op)
case CAIRO_OPERATOR_SATURATE:
return PictOpSaturate;
#if RENDER_MAJOR > 0 || RENDER_MINOR >= 11
case CAIRO_OPERATOR_MULTIPLY:
return PictOpMultiply;
case CAIRO_OPERATOR_SCREEN:
@ -1863,24 +1859,6 @@ _render_operator (cairo_operator_t op)
return PictOpHSLColor;
case CAIRO_OPERATOR_HSL_LUMINOSITY:
return PictOpHSLLuminosity;
#else
case CAIRO_OPERATOR_MULTIPLY:
case CAIRO_OPERATOR_SCREEN:
case CAIRO_OPERATOR_OVERLAY:
case CAIRO_OPERATOR_DARKEN:
case CAIRO_OPERATOR_LIGHTEN:
case CAIRO_OPERATOR_COLOR_DODGE:
case CAIRO_OPERATOR_COLOR_BURN:
case CAIRO_OPERATOR_HARD_LIGHT:
case CAIRO_OPERATOR_SOFT_LIGHT:
case CAIRO_OPERATOR_DIFFERENCE:
case CAIRO_OPERATOR_EXCLUSION:
case CAIRO_OPERATOR_HSL_HUE:
case CAIRO_OPERATOR_HSL_SATURATION:
case CAIRO_OPERATOR_HSL_COLOR:
case CAIRO_OPERATOR_HSL_LUMINOSITY:
/* silence the compiler */
#endif
default:
ASSERT_NOT_REACHED;

View file

@ -45,6 +45,16 @@
#include <X11/extensions/Xrender.h>
#include <X11/extensions/renderproto.h>
/* These prototypes are used when defining interfaces missing from the
* render headers. As it happens, it is the case that all libxrender
* functions take a pointer as first argument. */
__attribute__((__unused__)) static void _void_consume (void *p, ...) { }
__attribute__((__unused__)) static void * _voidp_consume (void *p, ...) { return (void *)0; }
__attribute__((__unused__)) static int _int_consume (void *p, ...) { return 0; }
__attribute__((__unused__)) static void _void_consume_free (Display *p, XID n) { }
/* We require Render >= 0.6. The following defines were only added in
* 0.10. Make sure they are defined.
*/
@ -63,6 +73,57 @@
#endif
#ifndef PictOptBlendMinimum
/*
* Operators only available in version 0.11
*/
#define PictOpBlendMinimum 0x30
#define PictOpMultiply 0x30
#define PictOpScreen 0x31
#define PictOpOverlay 0x32
#define PictOpDarken 0x33
#define PictOpLighten 0x34
#define PictOpColorDodge 0x35
#define PictOpColorBurn 0x36
#define PictOpHardLight 0x37
#define PictOpSoftLight 0x38
#define PictOpDifference 0x39
#define PictOpExclusion 0x3a
#define PictOpHSLHue 0x3b
#define PictOpHSLSaturation 0x3c
#define PictOpHSLColor 0x3d
#define PictOpHSLLuminosity 0x3e
#define PictOpBlendMaximum 0x3e
#endif
/* There doesn't appear to be a simple #define that we can conditionalize
* on. Instead, use the version; gradients were introdiced in 0.10. */
#if RENDER_MAJOR == 0 && RENDER_MINOR < 10
#define XRenderCreateLinearGradient _int_consume
#define XRenderCreateRadialGradient _int_consume
#define XRenderCreateConicalGradient _int_consume
typedef struct _XCircle {
XFixed x;
XFixed y;
XFixed radius;
} XCircle;
typedef struct _XLinearGradient {
XPointFixed p1;
XPointFixed p2;
} XLinearGradient;
typedef struct _XRadialGradient {
XCircle inner;
XCircle outer;
} XRadialGradient;
typedef struct _XConicalGradient {
XPointFixed center;
XFixed angle; /* in degrees */
} XConicalGradient;
#endif
#else /* !CAIRO_HAS_XLIB_XRENDER_SURFACE */
/* Provide dummy symbols and macros to get it compile and take the fallback
@ -71,14 +132,6 @@
/* Functions */
/* As it happens, it is the case that, all libxrender functions
* take a pointer as first argument */
__attribute__((__unused__)) static void _void_consume (void *p, ...) { }
__attribute__((__unused__)) static void * _voidp_consume (void *p, ...) { return (void *)0; }
__attribute__((__unused__)) static int _int_consume (void *p, ...) { return 0; }
__attribute__((__unused__)) static void _void_consume_free (Display *p, XID n) { }
#define XRenderQueryExtension _int_consume
#define XRenderQueryVersion _int_consume
#define XRenderQueryFormats _int_consume
@ -221,6 +274,27 @@ typedef unsigned long PictFormat;
#define PictOpConjointXor 0x2b
#define PictOpConjointMaximum 0x2b
/*
* Operators only available in version 0.11
*/
#define PictOpBlendMinimum 0x30
#define PictOpMultiply 0x30
#define PictOpScreen 0x31
#define PictOpOverlay 0x32
#define PictOpDarken 0x33
#define PictOpLighten 0x34
#define PictOpColorDodge 0x35
#define PictOpColorBurn 0x36
#define PictOpHardLight 0x37
#define PictOpSoftLight 0x38
#define PictOpDifference 0x39
#define PictOpExclusion 0x3a
#define PictOpHSLHue 0x3b
#define PictOpHSLSaturation 0x3c
#define PictOpHSLColor 0x3d
#define PictOpHSLLuminosity 0x3e
#define PictOpBlendMaximum 0x3e
#define PolyEdgeSharp 0
#define PolyEdgeSmooth 1