summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEgbert Eich <eich@suse.de>2004-03-09 16:52:30 +0000
committerEgbert Eich <eich@suse.de>2004-03-09 16:52:30 +0000
commit0196d7c4ce4469e9d4e126c7761da8a5d9bdc2a4 (patch)
tree1e2f6a3d778a7f185ac3733b515f5b298fc8601e
parent5ea5a7c71c016ead4709d3ac6e370c0576df3300 (diff)
-rw-r--r--include/X11/extensions/Xrender.h3
-rw-r--r--src/Color.c4
-rw-r--r--src/Composite.c4
-rw-r--r--src/Cursor.c8
-rw-r--r--src/FillRect.c6
-rw-r--r--src/FillRects.c4
-rw-r--r--src/Filter.c12
-rw-r--r--src/Glyph.c24
-rw-r--r--src/Picture.c16
-rw-r--r--src/Poly.c4
-rw-r--r--src/Trap.c6
-rw-r--r--src/Tri.c10
-rw-r--r--src/Xrender.c327
-rw-r--r--src/Xrenderint.h38
14 files changed, 356 insertions, 110 deletions
diff --git a/include/X11/extensions/Xrender.h b/include/X11/extensions/Xrender.h
index 1c05cea..654e8c1 100644
--- a/include/X11/extensions/Xrender.h
+++ b/include/X11/extensions/Xrender.h
@@ -1,5 +1,5 @@
/*
- * $XFree86: xc/lib/Xrender/Xrender.h,v 1.17 2002/11/06 22:47:49 keithp Exp $
+ * $Id$
*
* Copyright © 2000 SuSE, Inc.
*
@@ -28,6 +28,7 @@
#include <X11/extensions/render.h>
+#include <X11/Xlib.h>
#include <X11/Xfuncproto.h>
#include <X11/Xosdefs.h>
#include <X11/Xutil.h>
diff --git a/src/Color.c b/src/Color.c
index 2330bfd..c9ecfc8 100644
--- a/src/Color.c
+++ b/src/Color.c
@@ -1,7 +1,7 @@
/*
- * $XFree86$
+ * $Id$
*
- * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ * Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
diff --git a/src/Composite.c b/src/Composite.c
index b2c65db..386c042 100644
--- a/src/Composite.c
+++ b/src/Composite.c
@@ -1,5 +1,5 @@
/*
- * $XFree86$
+ * $Id$
*
* Copyright © 2000 SuSE, Inc.
*
@@ -40,7 +40,7 @@ XRenderComposite (Display *dpy,
unsigned int width,
unsigned int height)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderCompositeReq *req;
RenderSimpleCheckExtension (dpy, info);
diff --git a/src/Cursor.c b/src/Cursor.c
index 2ed505e..13a1fae 100644
--- a/src/Cursor.c
+++ b/src/Cursor.c
@@ -1,7 +1,7 @@
/*
- * $XFree86: xc/lib/Xrender/Cursor.c,v 1.2tsi Exp $
+ * $Id$
*
- * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ * Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -30,7 +30,7 @@ XRenderCreateCursor (Display *dpy,
unsigned int x,
unsigned int y)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
Cursor cid;
xRenderCreateCursorReq *req;
@@ -54,7 +54,7 @@ XRenderCreateAnimCursor (Display *dpy,
int ncursor,
XAnimCursor *cursors)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
Cursor cid;
xRenderCreateAnimCursorReq *req;
long len;
diff --git a/src/FillRect.c b/src/FillRect.c
index c9c16f9..11097a8 100644
--- a/src/FillRect.c
+++ b/src/FillRect.c
@@ -1,7 +1,7 @@
/*
- * $XFree86$
+ * $Id$
*
- * Copyright © 2000 SuSE, Inc.
+ * Copyright © 2000 SuSE, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -39,7 +39,7 @@ XRenderFillRectangle (Display *dpy,
unsigned int width,
unsigned int height)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRectangle *rect;
xRenderFillRectanglesReq *req;
#ifdef MUSTCOPY
diff --git a/src/FillRects.c b/src/FillRects.c
index f132d3d..2eebe1a 100644
--- a/src/FillRects.c
+++ b/src/FillRects.c
@@ -1,5 +1,5 @@
/*
- * $XFree86$
+ * $Id$
*
* Copyright © 2000 SuSE, Inc.
*
@@ -37,7 +37,7 @@ XRenderFillRectangles (Display *dpy,
_Xconst XRectangle *rectangles,
int n_rects)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderFillRectanglesReq *req;
long len;
int n;
diff --git a/src/Filter.c b/src/Filter.c
index f4f3bd2..c963768 100644
--- a/src/Filter.c
+++ b/src/Filter.c
@@ -1,7 +1,7 @@
/*
- * $XFree86$
+ * $Id$
*
- * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ * Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -27,7 +27,7 @@
XFilters *
XRenderQueryFilters (Display *dpy, Drawable drawable)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
XRenderInfo *xri;
xRenderQueryFiltersReq *req;
xRenderQueryFiltersReply rep;
@@ -37,13 +37,13 @@ XRenderQueryFilters (Display *dpy, Drawable drawable)
int i;
long nbytes, nbytesAlias, nbytesName;
- if (!XextHasExtension (info))
+ if (!RenderHasExtension (info))
return 0;
if (!XRenderQueryFormats (dpy))
return 0;
- xri = (XRenderInfo *) info->data;
+ xri = info->info;
if (xri->minor_version < 6)
return 0;
@@ -131,7 +131,7 @@ XRenderSetPictureFilter (Display *dpy,
XFixed *params,
int nparams)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderSetPictureFilterReq *req;
int nbytes = strlen (filter);
diff --git a/src/Glyph.c b/src/Glyph.c
index 4d5d4d4..2d0f2c3 100644
--- a/src/Glyph.c
+++ b/src/Glyph.c
@@ -1,5 +1,5 @@
/*
- * $XFree86: xc/lib/Xrender/Glyph.c,v 1.11 2002/10/18 01:13:39 keithp Exp $
+ * $Id$
*
* Copyright © 2000 SuSE, Inc.
*
@@ -28,7 +28,7 @@
GlyphSet
XRenderCreateGlyphSet (Display *dpy, _Xconst XRenderPictFormat *format)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
GlyphSet gsid;
xRenderCreateGlyphSetReq *req;
@@ -47,7 +47,7 @@ XRenderCreateGlyphSet (Display *dpy, _Xconst XRenderPictFormat *format)
GlyphSet
XRenderReferenceGlyphSet (Display *dpy, GlyphSet existing)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
GlyphSet gsid;
xRenderReferenceGlyphSetReq *req;
@@ -66,7 +66,7 @@ XRenderReferenceGlyphSet (Display *dpy, GlyphSet existing)
void
XRenderFreeGlyphSet (Display *dpy, GlyphSet glyphset)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderFreeGlyphSetReq *req;
RenderSimpleCheckExtension (dpy, info);
@@ -88,7 +88,7 @@ XRenderAddGlyphs (Display *dpy,
_Xconst char *images,
int nbyte_images)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderAddGlyphsReq *req;
long len;
@@ -116,7 +116,7 @@ XRenderFreeGlyphs (Display *dpy,
_Xconst Glyph *gids,
int nglyphs)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderFreeGlyphsReq *req;
long len;
@@ -148,7 +148,7 @@ XRenderCompositeString8 (Display *dpy,
_Xconst char *string,
int nchar)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderCompositeGlyphs8Req *req;
long len;
xGlyphElt *elt;
@@ -233,7 +233,7 @@ XRenderCompositeString16 (Display *dpy,
_Xconst unsigned short *string,
int nchar)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderCompositeGlyphs8Req *req;
long len;
xGlyphElt *elt;
@@ -313,7 +313,7 @@ XRenderCompositeString32 (Display *dpy,
_Xconst unsigned int *string,
int nchar)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderCompositeGlyphs8Req *req;
long len;
xGlyphElt *elt;
@@ -392,7 +392,7 @@ XRenderCompositeText8 (Display *dpy,
_Xconst XGlyphElt8 *elts,
int nelt)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderCompositeGlyphs8Req *req;
GlyphSet glyphset;
long len;
@@ -505,7 +505,7 @@ XRenderCompositeText16 (Display *dpy,
_Xconst XGlyphElt16 *elts,
int nelt)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderCompositeGlyphs16Req *req;
GlyphSet glyphset;
long len;
@@ -616,7 +616,7 @@ XRenderCompositeText32 (Display *dpy,
_Xconst XGlyphElt32 *elts,
int nelt)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderCompositeGlyphs32Req *req;
GlyphSet glyphset;
long len;
diff --git a/src/Picture.c b/src/Picture.c
index 1f0e1df..961f551 100644
--- a/src/Picture.c
+++ b/src/Picture.c
@@ -1,5 +1,5 @@
/*
- * $XFree86: xc/lib/Xrender/Picture.c,v 1.6 2000/12/05 07:42:29 keithp Exp $
+ * $Id$
*
* Copyright © 2000 SuSE, Inc.
*
@@ -76,7 +76,7 @@ XRenderCreatePicture (Display *dpy,
unsigned long valuemask,
_Xconst XRenderPictureAttributes *attributes)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
Picture pid;
xRenderCreatePictureReq *req;
@@ -104,7 +104,7 @@ XRenderChangePicture (Display *dpy,
unsigned long valuemask,
_Xconst XRenderPictureAttributes *attributes)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderChangePictureReq *req;
RenderSimpleCheckExtension (dpy, info);
@@ -124,7 +124,7 @@ XRenderChangePicture (Display *dpy,
static void
_XRenderSetPictureClipRectangles (Display *dpy,
- XExtDisplayInfo *info,
+ XRenderExtDisplayInfo *info,
Picture picture,
int xOrigin,
int yOrigin,
@@ -154,7 +154,7 @@ XRenderSetPictureClipRectangles (Display *dpy,
_Xconst XRectangle *rects,
int n)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
@@ -169,7 +169,7 @@ XRenderSetPictureClipRegion (Display *dpy,
Picture picture,
Region r)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
int i;
XRectangle *xr, *pr;
BOX *pb;
@@ -200,7 +200,7 @@ XRenderSetPictureTransform (Display *dpy,
Picture picture,
XTransform *transform)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderSetPictureTransformReq *req;
RenderSimpleCheckExtension (dpy, info);
@@ -227,7 +227,7 @@ void
XRenderFreePicture (Display *dpy,
Picture picture)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderFreePictureReq *req;
RenderSimpleCheckExtension (dpy, info);
diff --git a/src/Poly.c b/src/Poly.c
index fd0df05..5d482e3 100644
--- a/src/Poly.c
+++ b/src/Poly.c
@@ -1,7 +1,7 @@
/*
- * $XFree86: xc/lib/Xrender/Poly.c,v 1.6 2002/05/21 20:39:50 keithp Exp $
+ * $Id$
*
- * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ * Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
diff --git a/src/Trap.c b/src/Trap.c
index 0a4bc3c..8fd4512 100644
--- a/src/Trap.c
+++ b/src/Trap.c
@@ -1,7 +1,7 @@
/*
- * $XFree86: xc/lib/Xrender/Trap.c,v 1.2 2002/09/27 16:40:11 keithp Exp $
+ * $Id$
*
- * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ * Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -35,7 +35,7 @@ XRenderCompositeTrapezoids (Display *dpy,
_Xconst XTrapezoid *traps,
int ntrap)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderTrapezoidsReq *req;
int n;
long len;
diff --git a/src/Tri.c b/src/Tri.c
index 44e87e0..5c60dd6 100644
--- a/src/Tri.c
+++ b/src/Tri.c
@@ -1,7 +1,7 @@
/*
- * $XFree86: xc/lib/Xrender/Tri.c,v 1.2 2002/05/15 06:43:22 keithp Exp $
+ * $Id$
*
- * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ * Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -35,7 +35,7 @@ XRenderCompositeTriangles (Display *dpy,
_Xconst XTriangle *triangles,
int ntriangle)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderTrianglesReq *req;
int n;
long len;
@@ -80,7 +80,7 @@ XRenderCompositeTriStrip (Display *dpy,
_Xconst XPointFixed *points,
int npoint)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderTriStripReq *req;
int n;
long len;
@@ -125,7 +125,7 @@ XRenderCompositeTriFan (Display *dpy,
_Xconst XPointFixed *points,
int npoint)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
_Xconst XPointFixed *first = points;
xPointFixed *p;
xRenderTriFanReq *req;
diff --git a/src/Xrender.c b/src/Xrender.c
index 346115f..976f345 100644
--- a/src/Xrender.c
+++ b/src/Xrender.c
@@ -1,7 +1,7 @@
/*
- * $XFree86: xc/lib/Xrender/Xrender.c,v 1.12 2002/09/29 23:39:44 keithp Exp $
+ * $Id$
*
- * Copyright © 2000 SuSE, Inc.
+ * Copyright © 2000 SuSE, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -25,59 +25,288 @@
#include "Xrenderint.h"
-XExtensionInfo XRenderExtensionInfo;
+XRenderExtInfo XRenderExtensionInfo;
char XRenderExtensionName[] = RENDER_NAME;
-static int XRenderCloseDisplay(Display *dpy, XExtCodes *codes);
-
-static /* const */ XExtensionHooks render_extension_hooks = {
- NULL, /* create_gc */
- NULL, /* copy_gc */
- NULL, /* flush_gc */
- NULL, /* free_gc */
- NULL, /* create_font */
- NULL, /* free_font */
- XRenderCloseDisplay, /* close_display */
- NULL, /* wire_to_event */
- NULL, /* event_to_wire */
- NULL, /* error */
- NULL, /* error_string */
-};
-
-XExtDisplayInfo *
+static int XRenderCloseDisplay (Display *dpy, XExtCodes *codes);
+
+/*
+ * XRenderExtFindDisplay - look for a display in this extension; keeps a
+ * cache of the most-recently used for efficiency. (Replaces
+ * XextFindDisplay.)
+ */
+static XRenderExtDisplayInfo *
+XRenderExtFindDisplay (XRenderExtInfo *extinfo,
+ Display *dpy)
+{
+ XRenderExtDisplayInfo *dpyinfo;
+
+ /*
+ * see if this was the most recently accessed display
+ */
+ if ((dpyinfo = extinfo->cur) && dpyinfo->display == dpy)
+ return dpyinfo;
+
+ /*
+ * look for display in list
+ */
+ _XLockMutex(_Xglobal_lock);
+ for (dpyinfo = extinfo->head; dpyinfo; dpyinfo = dpyinfo->next) {
+ if (dpyinfo->display == dpy) {
+ extinfo->cur = dpyinfo; /* cache most recently used */
+ _XUnlockMutex(_Xglobal_lock);
+ return dpyinfo;
+ }
+ }
+ _XUnlockMutex(_Xglobal_lock);
+
+ return NULL;
+}
+
+/*
+ * 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))
+
+typedef struct _DepthCheckRec {
+ struct _DepthCheckRec *next;
+ Display *dpy;
+ CARD32 missing;
+ unsigned long serial;
+} DepthCheckRec, *DepthCheckPtr;
+
+static DepthCheckPtr depthChecks;
+
+static int
+XRenderDepthCheckErrorHandler (Display *dpy, XErrorEvent *evt)
+{
+ if (evt->request_code == X_CreatePixmap && evt->error_code == BadValue)
+ {
+ DepthCheckPtr d;
+ _XLockMutex(_Xglobal_lock);
+ for (d = depthChecks; d; d = d->next)
+ if (d->dpy == dpy)
+ {
+ if ((long) (evt->serial - d->serial) >= 0)
+ d->missing |= DEPTH_MASK(evt->resourceid);
+ break;
+ }
+ _XUnlockMutex (_Xglobal_lock);
+ }
+}
+
+static Bool
+XRenderHasDepths (Display *dpy)
+{
+ int s;
+
+ for (s = 0; s < ScreenCount (dpy); s++)
+ {
+ CARD32 depths = 0;
+ CARD32 missing;
+ Screen *scr = ScreenOfDisplay (dpy, s);
+ int d;
+
+ for (d = 0; d < scr->ndepths; d++)
+ depths |= DEPTH_MASK(scr->depths[d].depth);
+ missing = ~depths & REQUIRED_DEPTHS;
+ if (missing)
+ {
+ DepthCheckRec dc, **dp;
+ XErrorHandler previousHandler;
+
+ /*
+ * Ok, this is ugly. It should be sufficient at this
+ * point to just return False, but Xinerama is broken at
+ * this point and only advertises depths which have an
+ * associated visual. Of course, the other depths still
+ * work, but the only way to find out is to try them.
+ */
+ dc.dpy = dpy;
+ dc.missing = 0;
+ dc.serial = XNextRequest (dpy);
+ _XLockMutex(_Xglobal_lock);
+ dc.next = depthChecks;
+ depthChecks = &dc;
+ _XUnlockMutex (_Xglobal_lock);
+ /*
+ * I suspect this is not really thread safe, but Xlib doesn't
+ * provide a lot of options here
+ */
+ previousHandler = XSetErrorHandler (XRenderDepthCheckErrorHandler);
+ /*
+ * Try each missing depth and see if pixmap creation succeeds
+ */
+ for (d = 1; d <= 32; d++)
+ /* don't check depth 1 == Xcursor recurses... */
+ if ((missing & DEPTH_MASK(d)) && d != 1)
+ {
+ Pixmap p;
+ p = XCreatePixmap (dpy, RootWindow (dpy, s), 1, 1, d);
+ XFreePixmap (dpy, p);
+ }
+ XSync (dpy, False);
+ XSetErrorHandler (previousHandler);
+ /*
+ * Unhook from the list of depth check records
+ */
+ _XLockMutex(_Xglobal_lock);
+ for (dp = &depthChecks; *dp; dp = &(*dp)->next)
+ {
+ if (*dp == &dc)
+ {
+ *dp = dc.next;
+ break;
+ }
+ }
+ _XUnlockMutex (_Xglobal_lock);
+ if (dc.missing)
+ return False;
+ }
+ }
+ return True;
+}
+
+/*
+ * XRenderExtAddDisplay - add a display to this extension. (Replaces
+ * XextAddDisplay)
+ */
+static XRenderExtDisplayInfo *
+XRenderExtAddDisplay (XRenderExtInfo *extinfo,
+ Display *dpy,
+ char *ext_name)
+{
+ XRenderExtDisplayInfo *dpyinfo;
+
+ dpyinfo = (XRenderExtDisplayInfo *) Xmalloc (sizeof (XRenderExtDisplayInfo));
+ if (!dpyinfo) return NULL;
+ dpyinfo->display = dpy;
+ 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
+ * appropriate function vectors
+ */
+ if (dpyinfo->codes) {
+ XESetCloseDisplay (dpy, dpyinfo->codes->extension,
+ XRenderCloseDisplay);
+ } else {
+ /* The server doesn't have this extension.
+ * Use a private Xlib-internal extension to hang the close_display
+ * hook on so that the "cache" (extinfo->cur) is properly cleaned.
+ * (XBUG 7955)
+ */
+ XExtCodes *codes = XAddExtension(dpy);
+ if (!codes) {
+ XFree(dpyinfo);
+ return NULL;
+ }
+ XESetCloseDisplay (dpy, codes->extension, XRenderCloseDisplay);
+ }
+
+ /*
+ * now, chain it onto the list
+ */
+ _XLockMutex(_Xglobal_lock);
+ dpyinfo->next = extinfo->head;
+ extinfo->head = dpyinfo;
+ extinfo->cur = dpyinfo;
+ extinfo->ndisplays++;
+ _XUnlockMutex(_Xglobal_lock);
+ return dpyinfo;
+}
+
+
+/*
+ * XRenderExtRemoveDisplay - remove the indicated display from the
+ * extension object. (Replaces XextRemoveDisplay.)
+ */
+static int
+XRenderExtRemoveDisplay (XRenderExtInfo *extinfo, Display *dpy)
+{
+ XRenderExtDisplayInfo *dpyinfo, *prev;
+
+ /*
+ * locate this display and its back link so that it can be removed
+ */
+ _XLockMutex(_Xglobal_lock);
+ prev = NULL;
+ for (dpyinfo = extinfo->head; dpyinfo; dpyinfo = dpyinfo->next) {
+ if (dpyinfo->display == dpy) break;
+ prev = dpyinfo;
+ }
+ if (!dpyinfo) {
+ _XUnlockMutex(_Xglobal_lock);
+ return 0; /* hmm, actually an error */
+ }
+
+ /*
+ * remove the display from the list; handles going to zero
+ */
+ if (prev)
+ prev->next = dpyinfo->next;
+ else
+ extinfo->head = dpyinfo->next;
+
+ extinfo->ndisplays--;
+ if (dpyinfo == extinfo->cur) extinfo->cur = NULL; /* flush cache */
+ _XUnlockMutex(_Xglobal_lock);
+
+ Xfree ((char *) dpyinfo);
+ return 1;
+}
+
+
+
+XRenderExtDisplayInfo *
XRenderFindDisplay (Display *dpy)
{
- XExtDisplayInfo *dpyinfo;
+ XRenderExtDisplayInfo *dpyinfo;
- dpyinfo = XextFindDisplay (&XRenderExtensionInfo, dpy);
+ dpyinfo = XRenderExtFindDisplay (&XRenderExtensionInfo, dpy);
if (!dpyinfo)
- dpyinfo = XextAddDisplay (&XRenderExtensionInfo, dpy,
- XRenderExtensionName,
- &render_extension_hooks,
- 0, 0);
+ dpyinfo = XRenderExtAddDisplay (&XRenderExtensionInfo, dpy,
+ XRenderExtensionName);
return dpyinfo;
}
static int
XRenderCloseDisplay (Display *dpy, XExtCodes *codes)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
- if (info->data) XFree (info->data);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ if (info->info) XFree (info->info);
- return XextRemoveDisplay (&XRenderExtensionInfo, dpy);
+ return XRenderExtRemoveDisplay (&XRenderExtensionInfo, dpy);
}
/****************************************************************************
* *
- * Render public interfaces *
+ * Render public interfaces *
* *
****************************************************************************/
Bool XRenderQueryExtension (Display *dpy, int *event_basep, int *error_basep)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
- if (XextHasExtension(info)) {
+ if (RenderHasExtension(info)) {
*event_basep = info->codes->first_event;
*error_basep = info->codes->first_error;
return True;
@@ -91,16 +320,16 @@ Status XRenderQueryVersion (Display *dpy,
int *major_versionp,
int *minor_versionp)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
XRenderInfo *xri;
- if (!XextHasExtension (info))
+ if (!RenderHasExtension (info))
return 0;
if (!XRenderQueryFormats (dpy))
return 0;
- xri = (XRenderInfo *) info->data;
+ xri = info->info;
*major_versionp = xri->major_version;
*minor_versionp = xri->minor_version;
return 1;
@@ -161,7 +390,7 @@ _XRenderVersionHandler (Display *dpy,
Status
XRenderQueryFormats (Display *dpy)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
_XAsyncHandler async;
_XrenderVersionState async_state;
xRenderQueryVersionReq *vreq;
@@ -184,7 +413,7 @@ XRenderQueryFormats (Display *dpy)
RenderCheckExtension (dpy, info, 0);
LockDisplay (dpy);
- if (info->data)
+ if (info->info)
{
UnlockDisplay (dpy);
return 1;
@@ -316,7 +545,7 @@ XRenderQueryFormats (Display *dpy)
xSubpixel++;
screen++;
}
- info->data = (XPointer) xri;
+ info->info = xri;
/*
* Skip any extra data
*/
@@ -332,32 +561,32 @@ XRenderQueryFormats (Display *dpy)
int
XRenderQuerySubpixelOrder (Display *dpy, int screen)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
XRenderInfo *xri;
- if (!XextHasExtension (info))
+ if (!RenderHasExtension (info))
return SubPixelUnknown;
if (!XRenderQueryFormats (dpy))
return SubPixelUnknown;
- xri = (XRenderInfo *) info->data;
+ xri = info->info;
return xri->screen[screen].subpixel;
}
Bool
XRenderSetSubpixelOrder (Display *dpy, int screen, int subpixel)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
XRenderInfo *xri;
- if (!XextHasExtension (info))
+ if (!RenderHasExtension (info))
return False;
if (!XRenderQueryFormats (dpy))
return False;
- xri = (XRenderInfo *) info->data;
+ xri = info->info;
xri->screen[screen].subpixel = subpixel;
return True;
}
@@ -365,7 +594,7 @@ XRenderSetSubpixelOrder (Display *dpy, int screen, int subpixel)
XRenderPictFormat *
XRenderFindVisualFormat (Display *dpy, _Xconst Visual *visual)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
int nv;
XRenderInfo *xri;
XRenderVisual *xrv;
@@ -373,7 +602,7 @@ XRenderFindVisualFormat (Display *dpy, _Xconst Visual *visual)
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;
@@ -386,14 +615,14 @@ XRenderFindFormat (Display *dpy,
_Xconst XRenderPictFormat *template,
int count)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
int nf;
XRenderInfo *xri;
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)
@@ -596,7 +825,7 @@ XRenderQueryPictIndexValues(Display *dpy,
_Xconst XRenderPictFormat *format,
int *num)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderQueryPictIndexValuesReq *req;
xRenderQueryPictIndexValuesReply rep;
XIndexValue *values;
diff --git a/src/Xrenderint.h b/src/Xrenderint.h
index 98f5ddb..41265a5 100644
--- a/src/Xrenderint.h
+++ b/src/Xrenderint.h
@@ -1,7 +1,7 @@
/*
- * $XFree86: xc/lib/Xrender/Xrenderint.h,v 1.3 2002/09/26 02:56:52 keithp Exp $
+ * $Id$
*
- * Copyright © 2000 SuSE, Inc.
+ * Copyright © 2000 SuSE, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -26,14 +26,13 @@
#ifndef _XRENDERINT_H_
#define _XRENDERINT_H_
+#include "config.h"
#define NEED_EVENTS
#define NEED_REPLIES
#include <X11/Xlibint.h>
#include <X11/Xutil.h>
-#include "Xext.h" /* in ../include */
-#include "extutil.h" /* in ../include */
+#include <X11/extensions/renderproto.h>
#include "Xrender.h"
-#include "renderproto.h"
typedef struct {
Visual *visual;
@@ -72,17 +71,34 @@ typedef struct _XRenderInfo {
int nfilter_alias;
} XRenderInfo;
-extern XExtensionInfo XRenderExtensionInfo;
+/* replaces XRenderExtDisplayInfo */
+typedef struct _XRenderExtDisplayInfo {
+ struct _XRenderExtDisplayInfo *next; /* keep a linked list */
+ Display *display; /* which display this is */
+ XExtCodes *codes; /* the extension protocol codes */
+ XRenderInfo *info; /* extra data for the extension to use */
+} XRenderExtDisplayInfo;
+
+/* replaces XExtensionInfo */
+typedef struct _XRenderExtInfo {
+ XRenderExtDisplayInfo *head; /* start of the list */
+ XRenderExtDisplayInfo *cur; /* most recently used */
+ int ndisplays; /* number of displays */
+} XRenderExtInfo;
+
+extern XRenderExtInfo XRenderExtensionInfo;
extern char XRenderExtensionName[];
+XRenderExtDisplayInfo *
+XRenderFindDisplay (Display *dpy);
+
+#define RenderHasExtension(i) ((i) && ((i)->codes))
+
#define RenderCheckExtension(dpy,i,val) \
- XextCheckExtension (dpy, i, XRenderExtensionName, val)
+ if (!RenderHasExtension(i)) { return val; }
#define RenderSimpleCheckExtension(dpy,i) \
- XextSimpleCheckExtension (dpy, i, XRenderExtensionName)
-
-XExtDisplayInfo *
-XRenderFindDisplay (Display *dpy);
+ if (!RenderHasExtension(i)) { return; }
/*
* Xlib uses long for 32-bit values. Xrender uses int. This