Index: Xrender.c =================================================================== RCS file: /local/src/CVS/Xrender/Xrender.c,v retrieving revision 1.16 diff -u -r1.16 Xrender.c --- Xrender.c 24 Apr 2003 03:29:15 -0000 1.16 +++ Xrender.c 8 May 2003 15:28:29 -0000 @@ -64,6 +64,42 @@ } /* + * If the server is missing support for any of the required depths on + * any screen, tell the application that Render is not present. + */ + +#define DEPTH_MASK(d) (1 << ((d) - 1)) + +/* + * Render requires support for depth 1, 4, 8, 24 and 32 pixmaps + */ + +#define REQUIRED_DEPTHS (DEPTH_MASK(1) | \ + DEPTH_MASK(4) | \ + DEPTH_MASK(8) | \ + DEPTH_MASK(24) | \ + DEPTH_MASK(32)) + +static Bool +XRenderHasDepths (Display *dpy) +{ + int s; + + for (s = 0; s < ScreenCount (dpy); s++) + { + CARD32 depths = 0; + Screen *scr = ScreenOfDisplay (dpy, s); + int d; + + for (d = 0; d < scr->ndepths; d++) + depths |= DEPTH_MASK(scr->depths[d].depth); + if (~depths & REQUIRED_DEPTHS) + return False; + } + return True; +} + +/* * XRenderExtAddDisplay - add a display to this extension. (Replaces * XextAddDisplay) */ @@ -77,8 +113,12 @@ dpyinfo = (XRenderExtDisplayInfo *) Xmalloc (sizeof (XRenderExtDisplayInfo)); if (!dpyinfo) return NULL; dpyinfo->display = dpy; dpyinfo->data = NULL; - dpyinfo->codes = XInitExtension (dpy, ext_name); + + if (XRenderHasDepths (dpy)) + dpyinfo->codes = XInitExtension (dpy, ext_name); + else + dpyinfo->codes = NULL; /* * if the server has the extension, then we can initialize the