Add a new xlib-fallback target to test xlib using image fallbacks instead of the Render extension

This commit is contained in:
Carl Worth 2007-08-20 14:50:02 -07:00
parent 590717f03b
commit d05593a5fb
4 changed files with 90 additions and 1 deletions

View file

@ -35,6 +35,14 @@ _cairo_boilerplate_xlib_create_surface (const char *name,
cairo_boilerplate_mode_t mode,
void **closure);
cairo_surface_t *
_cairo_boilerplate_xlib_fallback_create_surface (const char *name,
cairo_content_t content,
int width,
int height,
cairo_boilerplate_mode_t mode,
void **closure);
void
_cairo_boilerplate_xlib_cleanup (void *closure);

View file

@ -192,6 +192,78 @@ _cairo_boilerplate_xlib_create_surface (const char *name,
return _cairo_boilerplate_xlib_perf_create_surface (dpy, content, width, height, xtc);
}
/* The xlib-fallback target differs from the xlib target in two ways:
*
* 1. It creates its surfaces without relying on the Render extension
*
* 2. It disables use of the Render extension for its surfaces
*
* This provides testing of the non-Render fallback paths we have in
* cairo-xlib-surface.c
*/
cairo_surface_t *
_cairo_boilerplate_xlib_fallback_create_surface (const char *name,
cairo_content_t content,
int width,
int height,
cairo_boilerplate_mode_t mode,
void **closure)
{
xlib_target_closure_t *xtc;
Display *dpy;
int screen;
XSetWindowAttributes attr;
cairo_surface_t *surface;
/* We're not yet bothering to support perf mode for the
* xlib-fallback surface. */
if (mode == CAIRO_BOILERPLATE_MODE_PERF)
return NULL;
/* We also don't support drawing with destination-alpha in the
* xlib-fallback surface. */
if (content == CAIRO_CONTENT_COLOR_ALPHA)
return NULL;
*closure = xtc = xmalloc (sizeof (xlib_target_closure_t));
if (width == 0)
width = 1;
if (height == 0)
height = 1;
xtc->dpy = dpy = XOpenDisplay (NULL);
if (xtc->dpy == NULL) {
CAIRO_BOILERPLATE_LOG ("Failed to open display: %s\n", XDisplayName(0));
return NULL;
}
/* This kills performance, but it makes debugging much
* easier. That's why we have it here only after explicitly not
* supporting PERF mode.*/
XSynchronize (dpy, 1);
screen = DefaultScreen (dpy);
attr.override_redirect = True;
xtc->drawable = XCreateWindow (dpy, DefaultRootWindow (dpy),
0, 0,
width, height, 0,
DefaultDepth (dpy, screen),
InputOutput,
DefaultVisual (dpy, screen),
CWOverrideRedirect, &attr);
XMapWindow (dpy, xtc->drawable);
xtc->drawable_is_pixmap = FALSE;
surface = cairo_xlib_surface_create (dpy, xtc->drawable,
DefaultVisual (dpy, screen),
width, height);
cairo_boilerplate_xlib_surface_disable_render (surface);
return surface;
}
void
_cairo_boilerplate_xlib_cleanup (void *closure)
{

View file

@ -261,6 +261,15 @@ static cairo_boilerplate_target_t targets[] =
_cairo_boilerplate_xlib_cleanup,
_cairo_boilerplate_xlib_synchronize},
#endif
#if CAIRO_HAS_XLIB_SURFACE
/* This is a fallback surface which uses xlib fallbacks instead of
* the Render extension. */
{ "xlib-fallback", CAIRO_SURFACE_TYPE_XLIB, CAIRO_CONTENT_COLOR, 1,
_cairo_boilerplate_xlib_fallback_create_surface,
cairo_surface_write_to_png,
_cairo_boilerplate_xlib_cleanup,
_cairo_boilerplate_xlib_synchronize},
#endif
#if CAIRO_HAS_PS_SURFACE && CAIRO_CAN_TEST_PS_SURFACE
{ "ps", CAIRO_SURFACE_TYPE_PS,
CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED, 0,

View file

@ -70,7 +70,7 @@ static cairo_test_draw_function_t draw;
cairo_test_t test = {
"fill-rule",
"Tests cairo_set_full_rule with some star shapes",
"Tests cairo_set_fill_rule with some star shapes",
BIG_STAR_SIZE * 2 + 3, BIG_STAR_SIZE + LITTLE_STAR_SIZE + 3,
draw
};