summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEgbert Eich <eich@suse.de>2004-04-15 10:15:05 +0000
committerEgbert Eich <eich@suse.de>2004-04-15 10:15:05 +0000
commit9101bf5dec9a355d3772467a76e0df0d1b8fc1d9 (patch)
tree8a2b0a5e90b77b365a7dc3a0407ce02a6a672ee7 /src
parent5ded9518470018c739dae3a3b24846ead0c35206 (diff)
Diffstat (limited to 'src')
-rw-r--r--src/Color.c3
-rw-r--r--src/Composite.c3
-rw-r--r--src/Cursor.c7
-rw-r--r--src/FillRect.c5
-rw-r--r--src/FillRects.c3
-rw-r--r--src/Filter.c11
-rw-r--r--src/Glyph.c23
-rw-r--r--src/Picture.c15
-rw-r--r--src/Poly.c3
-rw-r--r--src/Trap.c5
-rw-r--r--src/Tri.c9
-rw-r--r--src/Xrender.c326
-rw-r--r--src/Xrenderint.h37
13 files changed, 341 insertions, 109 deletions
diff --git a/src/Color.c b/src/Color.c
index 2330bfd..39d79e0 100644
--- a/src/Color.c
+++ b/src/Color.c
@@ -1,7 +1,6 @@
/*
- * $XFree86$
*
- * 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..274c93b 100644
--- a/src/Composite.c
+++ b/src/Composite.c
@@ -1,5 +1,4 @@
/*
- * $XFree86$
*
* Copyright © 2000 SuSE, Inc.
*
@@ -40,7 +39,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..8b783d8 100644
--- a/src/Cursor.c
+++ b/src/Cursor.c
@@ -1,7 +1,6 @@
/*
- * $XFree86: xc/lib/Xrender/Cursor.c,v 1.2tsi Exp $
*
- * 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 +29,7 @@ XRenderCreateCursor (Display *dpy,
unsigned int x,
unsigned int y)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
Cursor cid;
xRenderCreateCursorReq *req;
@@ -54,7 +53,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..396cfe0 100644
--- a/src/FillRect.c
+++ b/src/FillRect.c
@@ -1,7 +1,6 @@
/*
- * $XFree86$
*
- * 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 +38,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..72e0a90 100644
--- a/src/FillRects.c
+++ b/src/FillRects.c
@@ -1,5 +1,4 @@
/*
- * $XFree86$
*
* Copyright © 2000 SuSE, Inc.
*
@@ -37,7 +36,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..3406669 100644
--- a/src/Filter.c
+++ b/src/Filter.c
@@ -1,7 +1,6 @@
/*
- * $XFree86$
*
- * 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 +26,7 @@
XFilters *
XRenderQueryFilters (Display *dpy, Drawable drawable)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
XRenderInfo *xri;
xRenderQueryFiltersReq *req;
xRenderQueryFiltersReply rep;
@@ -37,13 +36,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 +130,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..d221ea5 100644
--- a/src/Glyph.c
+++ b/src/Glyph.c
@@ -1,5 +1,4 @@
/*
- * $XFree86: xc/lib/Xrender/Glyph.c,v 1.11 2002/10/18 01:13:39 keithp Exp $
*
* Copyright © 2000 SuSE, Inc.
*
@@ -28,7 +27,7 @@
GlyphSet
XRenderCreateGlyphSet (Display *dpy, _Xconst XRenderPictFormat *format)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
GlyphSet gsid;
xRenderCreateGlyphSetReq *req;
@@ -47,7 +46,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 +65,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 +87,7 @@ XRenderAddGlyphs (Display *dpy,
_Xconst char *images,
int nbyte_images)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderAddGlyphsReq *req;
long len;
@@ -116,7 +115,7 @@ XRenderFreeGlyphs (Display *dpy,
_Xconst Glyph *gids,
int nglyphs)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderFreeGlyphsReq *req;
long len;
@@ -148,7 +147,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 +232,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 +312,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 +391,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 +504,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 +615,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..d6652ff 100644
--- a/src/Picture.c
+++ b/src/Picture.c
@@ -1,5 +1,4 @@
/*
- * $XFree86: xc/lib/Xrender/Picture.c,v 1.6 2000/12/05 07:42:29 keithp Exp $
*
* Copyright © 2000 SuSE, Inc.
*
@@ -76,7 +75,7 @@ XRenderCreatePicture (Display *dpy,
unsigned long valuemask,
_Xconst XRenderPictureAttributes *attributes)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
Picture pid;
xRenderCreatePictureReq *req;
@@ -104,7 +103,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 +123,7 @@ XRenderChangePicture (Display *dpy,
static void
_XRenderSetPictureClipRectangles (Display *dpy,
- XExtDisplayInfo *info,
+ XRenderExtDisplayInfo *info,
Picture picture,
int xOrigin,
int yOrigin,
@@ -154,7 +153,7 @@ XRenderSetPictureClipRectangles (Display *dpy,
_Xconst XRectangle *rects,
int n)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
RenderSimpleCheckExtension (dpy, info);
LockDisplay(dpy);
@@ -169,7 +168,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 +199,7 @@ XRenderSetPictureTransform (Display *dpy,
Picture picture,
XTransform *transform)
{
- XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+ XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy);
xRenderSetPictureTransformReq *req;
RenderSimpleCheckExtension (dpy, info);
@@ -227,7 +226,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..12a9732 100644
--- a/src/Poly.c
+++ b/src/Poly.c
@@ -1,7 +1,6 @@
/*
- * $XFree86: xc/lib/Xrender/Poly.c,v 1.6 2002/05/21 20:39:50 keithp Exp $
*
- * 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..e9a7deb 100644
--- a/src/Trap.c
+++ b/src/Trap.c
@@ -1,7 +1,6 @@
/*
- * $XFree86: xc/lib/Xrender/Trap.c,v 1.2 2002/09/27 16:40:11 keithp Exp $
*
- * 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 +34,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..1f0a80a 100644
--- a/src/Tri.c
+++ b/src/Tri.c
@@ -1,7 +1,6 @@
/*
- * $XFree86: xc/lib/Xrender/Tri.c,v 1.2 2002/05/15 06:43:22 keithp Exp $
*
- * 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 +34,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 +79,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 +124,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..4df312b 100644
--- a/src/Xrender.c
+++ b/src/Xrender.c
@@ -1,7 +1,6 @@
/*
- * $XFree86: xc/lib/Xrender/Xrender.c,v 1.12 2002/09/29 23:39:44 keithp Exp $
*
- * 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 +24,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 +319,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 +389,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 +412,7 @@ XRenderQueryFormats (Display *dpy)
RenderCheckExtension (dpy, info, 0);
LockDisplay (dpy);
- if (info->data)
+ if (info->info)
{
UnlockDisplay (dpy);
return 1;
@@ -316,7 +544,7 @@ XRenderQueryFormats (Display *dpy)
xSubpixel++;
screen++;
}
- info->data = (XPointer) xri;
+ info->info = xri;
/*
* Skip any extra data
*/
@@ -332,32 +560,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 +593,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 +601,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 +614,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 +824,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..49a294b 100644
--- a/src/Xrenderint.h
+++ b/src/Xrenderint.h
@@ -1,7 +1,6 @@
/*
- * $XFree86: xc/lib/Xrender/Xrenderint.h,v 1.3 2002/09/26 02:56:52 keithp Exp $
*
- * 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 +25,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 +70,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