diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2008-04-07 23:42:47 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2008-04-08 07:52:47 +0100 |
commit | 9aac5916bcb4a3e62194315b12961d97f193a585 (patch) | |
tree | 3f9d65ea6c401c9fd20d0c90d70cc4ea63d46f3a | |
parent | f6afba8f5453b8e3af9101fa2cde4c05a67f6d4b (diff) |
[test/xlib-surface] Check for mismatching Visuals and XRenderPictFormats
Vladimir Vukicevic reported that surfaces were being created with
mismatching Visuals and XRenderPictFormats - and demonstated here.
-rw-r--r-- | test/xlib-surface.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/test/xlib-surface.c b/test/xlib-surface.c index deb288970..eda085f50 100644 --- a/test/xlib-surface.c +++ b/test/xlib-surface.c @@ -39,6 +39,63 @@ cairo_bool_t result = 0; +#if CAIRO_HAS_XLIB_XRENDER_SURFACE + +#include "cairo-xlib-xrender.h" + +/* Vladimir Vukicevic reported that surfaces were being created with + * mismatching Visuals and XRenderPictFormats. + */ +static cairo_bool_t +surface_compare_visual_and_format (cairo_surface_t *surface) +{ + Display *dpy; + Visual *visual; + XRenderPictFormat *format; + + dpy = cairo_xlib_surface_get_display (surface); + + visual = cairo_xlib_surface_get_visual (surface); + if (visual == NULL) + return TRUE; + + format = cairo_xlib_surface_get_xrender_format (surface); + if (format == NULL) + return TRUE; + + return format == XRenderFindVisualFormat (dpy, visual); + +} +#else + +static cairo_bool_t +surface_compare_visual_and_format (cairo_surface_t *surface) +{ + return TRUE; +} + +#endif + +static cairo_bool_t +check_similar_visual_and_format (cairo_surface_t *surface) +{ + cairo_surface_t *similar; + cairo_bool_t ret; + + similar = cairo_surface_create_similar (surface, + CAIRO_CONTENT_COLOR_ALPHA, + 1, 1); + if (cairo_surface_status (similar)) + return FALSE; + + ret = surface_compare_visual_and_format (similar); + + cairo_surface_destroy (similar); + + return ret; +} + + static void draw_pattern (cairo_surface_t *surface) { @@ -123,6 +180,9 @@ do_test (Display *dpy, DefaultVisual (dpy, screen), SIZE, SIZE); + if (! surface_compare_visual_and_format (surface)) + return CAIRO_TEST_FAILURE; + if (!use_render) cairo_boilerplate_xlib_surface_disable_render (surface); @@ -134,6 +194,9 @@ do_test (Display *dpy, return CAIRO_TEST_FAILURE; } + if (! check_similar_visual_and_format (surface)) + return CAIRO_TEST_FAILURE; + draw_pattern (surface); test_surface = cairo_image_surface_create_for_data (test_data, |