[Commit] Xrender Filter.c,1.3,1.4 Makefile.am,1.7,1.8 Xrender.c,1.16,1.17 Xrenderint.h,1.11,1.12 configure.ac,1.9,1.10

Keith Packard commit at keithp.com
Sun Jun 8 11:56:40 PDT 2003


Committed by: keithp

Update of /local/src/CVS/Xrender
In directory home.keithp.com:/tmp/cvs-serv29962

Modified Files:
	Filter.c Makefile.am Xrender.c Xrenderint.h configure.ac 
Log Message:
Bail on bogus Xsun servers, compile with -DXTHREADS if necessary, get rid of unecessary cast to XRenderInfo *

Index: Filter.c
===================================================================
RCS file: /local/src/CVS/Xrender/Filter.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Filter.c	24 Apr 2003 03:29:15 -0000	1.3
+++ Filter.c	8 Jun 2003 17:56:37 -0000	1.4
@@ -43,7 +43,7 @@
     if (!XRenderQueryFormats (dpy))
 	return 0;
 
-    xri = (XRenderInfo *) info->data;
+    xri = info->info;
     if (xri->minor_version < 6)
 	return 0;
     

Index: Makefile.am
===================================================================
RCS file: /local/src/CVS/Xrender/Makefile.am,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- Makefile.am	3 May 2003 20:00:16 -0000	1.7
+++ Makefile.am	8 Jun 2003 17:56:37 -0000	1.8
@@ -21,7 +21,8 @@
 #  TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 #  PERFORMANCE OF THIS SOFTWARE.
 
-AM_CFLAGS = $(RENDER_CFLAGS) $(X_CFLAGS) 
+XTHREADS_CFLAGS=@XTHREADS_CFLAGS@
+AM_CFLAGS = $(RENDER_CFLAGS) $(X_CFLAGS) $(XTHREADS_CFLAGS)
 
 lib_LTLIBRARIES = libXrender.la
 

Index: Xrender.c
===================================================================
RCS file: /local/src/CVS/Xrender/Xrender.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- Xrender.c	24 Apr 2003 03:29:15 -0000	1.16
+++ Xrender.c	8 Jun 2003 17:56:37 -0000	1.17
@@ -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);
+    dpyinfo->info = NULL;
+
+    if (XRenderHasDepths (dpy))
+	dpyinfo->codes = XInitExtension (dpy, ext_name);
+    else
+	dpyinfo->codes = NULL;
 
     /*
      * if the server has the extension, then we can initialize the 
@@ -171,7 +211,7 @@
 XRenderCloseDisplay (Display *dpy, XExtCodes *codes)
 {
     XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
-    if (info->data) XFree (info->data);
+    if (info->info) XFree (info->info);
     
     return XRenderExtRemoveDisplay (&XRenderExtensionInfo, dpy);
 }
@@ -209,7 +249,7 @@
     if (!XRenderQueryFormats (dpy))
 	return 0;
     
-    xri = (XRenderInfo *) info->data; 
+    xri = info->info; 
     *major_versionp = xri->major_version;
     *minor_versionp = xri->minor_version;
     return 1;
@@ -293,7 +333,7 @@
     
     RenderCheckExtension (dpy, info, 0);
     LockDisplay (dpy);
-    if (info->data)
+    if (info->info)
     {
 	UnlockDisplay (dpy);
 	return 1;
@@ -425,7 +465,7 @@
 	xSubpixel++;
 	screen++;
     }
-    info->data = (XPointer) xri;
+    info->info = xri;
     /*
      * Skip any extra data
      */
@@ -450,7 +490,7 @@
     if (!XRenderQueryFormats (dpy))
 	return SubPixelUnknown;
 
-    xri = (XRenderInfo *) info->data;
+    xri = info->info;
     return xri->screen[screen].subpixel;
 }
 
@@ -466,7 +506,7 @@
     if (!XRenderQueryFormats (dpy))
 	return False;
 
-    xri = (XRenderInfo *) info->data;
+    xri = info->info;
     xri->screen[screen].subpixel = subpixel;
     return True;
 }
@@ -482,7 +522,7 @@
     RenderCheckExtension (dpy, info, 0);
     if (!XRenderQueryFormats (dpy))
         return 0;
-    xri = (XRenderInfo *) info->data;
+    xri = info->info;
     for (nv = 0, xrv = xri->visual; nv < xri->nvisual; nv++, xrv++)
 	if (xrv->visual == visual)
 	    return xrv->format;
@@ -502,7 +542,7 @@
     RenderCheckExtension (dpy, info, 0);
     if (!XRenderQueryFormats (dpy))
 	return 0;
-    xri = (XRenderInfo *) info->data;
+    xri = info->info;
     for (nf = 0; nf < xri->nformat; nf++)
     {
 	if (mask & PictFormatID)

Index: Xrenderint.h
===================================================================
RCS file: /local/src/CVS/Xrender/Xrenderint.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- Xrenderint.h	6 May 2003 02:06:41 -0000	1.11
+++ Xrenderint.h	8 Jun 2003 17:56:37 -0000	1.12
@@ -75,7 +75,7 @@
     struct _XRenderExtDisplayInfo *next;    /* keep a linked list */
     Display                       *display; /* which display this is */
     XExtCodes                     *codes;   /* the extension protocol codes */
-    XPointer                       data;    /* extra data for the extension to use */
+    XRenderInfo                   *info;    /* extra data for the extension to use */
 } XRenderExtDisplayInfo;
 
 /* replaces XExtensionInfo */

Index: configure.ac
===================================================================
RCS file: /local/src/CVS/Xrender/configure.ac,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- configure.ac	6 May 2003 03:49:18 -0000	1.9
+++ configure.ac	8 Jun 2003 17:56:37 -0000	1.10
@@ -48,6 +48,32 @@
         AC_MSG_ERROR([X is required, but it was either disabled or not found.])
 fi
 
+# Check for XTHREADS
+
+save_LIBS="$LIBS"
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $X_CFLAGS"
+LIBS="$LIBS $X_LIBS -lX11"
+
+AC_MSG_CHECKING([for XTHREADS in Xlib])
+AC_RUN_IFELSE(
+   [AC_LANG_PROGRAM([[#include <X11/Xlib.h>]],
+		    [[return XInitThreads() == 0 ? 0 : 1;]])],
+   [xthreads=no],
+   [xthreads=yes],
+   [xthreads=yes])
+   
+AC_MSG_RESULT($xthreads)
+
+LIBS="$save_LIBS"
+CFLAGS="$save_CFLAGS"
+
+if test "x$xthreads" = "xyes"
+then
+	XTHREADS_CFLAGS="-DXTHREADS"
+	AC_SUBST(XTHREADS_CFLAGS)
+fi
+
 # Check render configuration, strip extra digits from package version to
 # find the required protocol version
 




More information about the Commit mailing list