[xserver patch v5 3/5] glx: Enforce a 1:1 correspondence between GLX and X11 windows.
Francisco Jerez
currojerez at riseup.net
Mon Feb 8 15:10:59 PST 2010
The spec says (regarding glXCreateWindow): "If there is already a
GLXFBConfig associated with win (as a result of a previous
glXCreateWindow call), then a BadAlloc error is generated.". It will
also come useful to implement DRI2InvalidateBuffers for the indirect
case.
Signed-off-by: Francisco Jerez <currojerez at riseup.net>
---
v5: Simplification as suggested by Kristian.
glx/glxcmds.c | 24 +++++++++++++++++++++++-
glx/glxserver.h | 1 +
2 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/glx/glxcmds.c b/glx/glxcmds.c
index 77afbf4..cac30e6 100644
--- a/glx/glxcmds.c
+++ b/glx/glxcmds.c
@@ -51,6 +51,15 @@
#include "indirect_table.h"
#include "indirect_util.h"
+static int glxWindowPrivateKeyIndex;
+static DevPrivateKey glxWindowPrivateKey = &glxWindowPrivateKeyIndex;
+
+__GLXdrawable *
+glxGetDrawableFromWindow(WindowPtr pWin)
+{
+ return dixLookupPrivate(&pWin->devPrivates, glxWindowPrivateKey);
+}
+
static int
validGlxScreen(ClientPtr client, int screen, __GLXscreen **pGlxScreen, int *err)
{
@@ -519,6 +528,9 @@ __glXGetDrawable(__GLXcontext *glxc, GLXDrawable drawId, ClientPtr client,
return NULL;
}
+ dixSetPrivate(&((WindowPtr)pDraw)->devPrivates, glxWindowPrivateKey,
+ pGlxDraw);
+
return pGlxDraw;
}
@@ -1107,7 +1119,7 @@ __glXDrawableRelease(__GLXdrawable *drawable)
}
}
-static int
+static int
DoCreateGLXDrawable(ClientPtr client, __GLXscreen *pGlxScreen, __GLXconfig *config,
DrawablePtr pDraw, XID glxDrawableId, int type)
{
@@ -1128,6 +1140,10 @@ DoCreateGLXDrawable(ClientPtr client, __GLXscreen *pGlxScreen, __GLXconfig *conf
return BadAlloc;
}
+ if (type == GLX_DRAWABLE_WINDOW)
+ dixSetPrivate(&((WindowPtr)pDraw)->devPrivates,
+ glxWindowPrivateKey, pGlxDraw);
+
return Success;
}
@@ -1422,6 +1438,12 @@ int __glXDisp_CreateWindow(__GLXclientState *cl, GLbyte *pc)
return BadWindow;
}
+ /* Make sure there're no already associated GLX drawables. */
+ if (glxGetDrawableFromWindow((WindowPtr)pDraw)) {
+ client->errorValue = req->window;
+ return BadAlloc;
+ }
+
if (!validGlxFBConfigForWindow(client, config, pDraw, &err))
return err;
diff --git a/glx/glxserver.h b/glx/glxserver.h
index 1daf977..3c49b5e 100644
--- a/glx/glxserver.h
+++ b/glx/glxserver.h
@@ -80,6 +80,7 @@ typedef struct __GLXcontext __GLXcontext;
extern __GLXscreen *glxGetScreen(ScreenPtr pScreen);
extern __GLXclientState *glxGetClient(ClientPtr pClient);
+extern __GLXdrawable *glxGetDrawableFromWindow(WindowPtr pWin);
/************************************************************************/
--
1.6.4.4
More information about the xorg-devel
mailing list