#include <assert.h>
#include <X11/Xlib.h>
#include <X11/Xproto.h>
+#include <X11/Xlibint.h>
#include <X11/extensions/Xext.h>
#include <X11/extensions/extutil.h>
#include <sys/time.h>
+#include "GL/glxproto.h"
+#include "GL/glxtokens.h"
+#include "GL/gl.h" /* for GL types needed by __GLcontextModes */
+#include "GL/internal/glcore.h" /* for __GLcontextModes */
+
#include "glxinit.h"
#ifdef GLX_DIRECT_RENDERING
NULL, /* error_string */
};
-XEXT_GENERATE_FIND_DISPLAY(__glXFindDisplay, __glXExtensionInfo,
- __glXExtensionName, &__glXExtensionHooks,
- __GLX_NUMBER_EVENTS, NULL)
+static XEXT_GENERATE_FIND_DISPLAY(__glXFindDisplay, __glXExtensionInfo,
+ __glXExtensionName, &__glXExtensionHooks,
+ __GLX_NUMBER_EVENTS, NULL)
static GLint
_gl_convert_from_x_visual_type(int visualType)
? glx_visual_types[visualType] : GLX_NONE;
}
+static void
+_gl_context_modes_destroy(__GLcontextModes * modes)
+{
+ while (modes != NULL) {
+ __GLcontextModes *const next = modes->next;
+
+ Xfree(modes);
+ modes = next;
+ }
+}
+
static __GLcontextModes *
_gl_context_modes_create(unsigned count, size_t minimum_size)
{
return base;
}
-_X_HIDDEN void
-_gl_context_modes_destroy(__GLcontextModes * modes)
-{
- while (modes != NULL) {
- __GLcontextModes *const next = modes->next;
-
- Xfree(modes);
- modes = next;
- }
-}
-
-_X_HIDDEN char *
+static char *
__glXQueryServerString(Display * dpy, int opcode, CARD32 screen, CARD32 name)
{
xGLXGenericGetStringReq *req;
_gl_context_modes_destroy(psc->configs);
psc->configs = NULL; /* NOTE: just for paranoia */
}
- if (psc->visuals) {
- _gl_context_modes_destroy(psc->visuals);
- psc->visuals = NULL; /* NOTE: just for paranoia */
- }
Xfree((char *) psc->serverGLXexts);
}
XFree((char *) priv->screenConfigs);
priv = (__GLXdisplayPrivate *) extension->private_data;
FreeScreenConfigs(priv);
- if (priv->serverGLXvendor) {
- Xfree((char *) priv->serverGLXvendor);
- priv->serverGLXvendor = 0x0; /* to protect against double free's */
- }
- if (priv->serverGLXversion) {
+ if (priv->serverGLXversion)
Xfree((char *) priv->serverGLXversion);
- priv->serverGLXversion = 0x0; /* to protect against double free's */
- }
Xfree((char *) priv);
return 0;
** Query the version of the GLX extension. This procedure works even if
** the client extension is not completely set up.
*/
+
+#define GLX_MAJOR_VERSION 1 /* current version numbers */
+#define GLX_MINOR_VERSION 4
+
static Bool
QueryVersion(Display * dpy, int opcode, int *major, int *minor)
{
return GL_TRUE;
}
-_X_HIDDEN void
+#define __GLX_MIN_CONFIG_PROPS 18
+#define __GLX_MAX_CONFIG_PROPS 500
+#define __GLX_EXT_CONFIG_PROPS 10
+#define __GLX_TOTAL_CONFIG (__GLX_MIN_CONFIG_PROPS + \
+ 2 * __GLX_EXT_CONFIG_PROPS)
+
+static void
__glXInitializeVisualConfigFromTags(__GLcontextModes * config, int count,
const INT32 * bp, Bool tagged_only,
Bool fbconfig_style_tags)
return modes;
}
-static GLboolean
-getVisualConfigs(__GLXscreenConfigs *psc,
- __GLXdisplayPrivate *priv, int screen)
-{
- xGLXGetVisualConfigsReq *req;
- xGLXGetVisualConfigsReply reply;
- Display *dpy = priv->dpy;
-
- LockDisplay(dpy);
-
- psc->visuals = NULL;
- GetReq(GLXGetVisualConfigs, req);
- req->reqType = priv->majorOpcode;
- req->glxCode = X_GLXGetVisualConfigs;
- req->screen = screen;
-
- if (!_XReply(dpy, (xReply *) & reply, 0, False))
- goto out;
-
- psc->visuals = createConfigsFromProperties(dpy,
- reply.numVisuals,
- reply.numProps,
- screen, GL_FALSE);
-
- out:
- UnlockDisplay(dpy);
- return psc->visuals != NULL;
-}
-
static GLboolean
getFBConfigs(__GLXscreenConfigs *psc, __GLXdisplayPrivate *priv, int screen)
{
return psc->configs != NULL;
}
-_X_HIDDEN Bool
-glx_screen_init(__GLXscreenConfigs *psc,
- int screen, __GLXdisplayPrivate * priv)
-{
- /* Initialize per screen dynamic client GLX extensions */
- psc->ext_list_first_time = GL_TRUE;
- psc->scr = screen;
- psc->dpy = priv->dpy;
-
- getVisualConfigs(psc, priv, screen);
- getFBConfigs(psc, priv, screen);
-
- return GL_TRUE;
-}
-
-static __GLXscreenConfigs *
-createIndirectScreen()
-{
- __GLXscreenConfigs *psc;
-
- psc = Xmalloc(sizeof *psc);
- memset(psc, 0, sizeof *psc);
-
- return psc;
-}
-
static GLboolean
AllocAndFetchScreenConfigs(Display * dpy, __GLXdisplayPrivate * priv)
{
}
for (i = 0; i < screens; i++) {
- psc = createIndirectScreen();
+ psc = Xcalloc(1, sizeof *psc);
if (!psc)
return GL_FALSE;
- glx_screen_init(psc, i, priv);
+ getFBConfigs(psc, priv, i);
priv->screenConfigs[i] = psc;
}
** structures from the server.
*/
dpyPriv->majorOpcode = info->codes->major_opcode;
- dpyPriv->majorVersion = major;
- dpyPriv->minorVersion = minor;
dpyPriv->dpy = dpy;
- dpyPriv->serverGLXvendor = NULL;
- dpyPriv->serverGLXversion = NULL;
-
if (!AllocAndFetchScreenConfigs(dpy, dpyPriv)) {
Xfree(dpyPriv);
Xfree(private);
#include "glxinit.h"
struct x11_screen {
-#ifdef GLX_DIRECT_RENDERING
- /* dummy base class */
- struct __GLXDRIdisplayRec base;
-#endif
-
Display *dpy;
int number;
#ifdef GLX_DIRECT_RENDERING
/* xscr->glx_dpy will be destroyed with the X display */
if (xscr->glx_dpy)
- xscr->glx_dpy->dri2Display = NULL;
+ xscr->glx_dpy->xscr = NULL;
#endif
if (xscr->visuals)
: NULL;
}
-/**
- * Return the GLX visuals.
- */
-const __GLcontextModes *
-x11_screen_get_glx_visuals(struct x11_screen *xscr)
-{
- return (x11_screen_init_glx(xscr))
- ? xscr->glx_dpy->screenConfigs[xscr->number]->visuals
- : NULL;
-}
-
/**
* Probe the screen for the DRI2 driver name.
*/
close(fd);
return -1;
}
- if (xscr->glx_dpy->dri2Display) {
+ if (xscr->glx_dpy->xscr) {
_eglLog(_EGL_WARNING,
"display is already managed by another x11 screen");
close(fd);
return -1;
}
- xscr->glx_dpy->dri2Display = (__GLXDRIdisplay *) xscr;
+ xscr->glx_dpy->xscr = xscr;
xscr->dri_invalidate_buffers = invalidate_buffers;
xscr->dri_user_data = user_data;
return count;
}
+extern void
+dri2InvalidateBuffers(Display *dpy, XID drawable);
+
/**
* This is called from src/glx/dri2.c.
*/
__GLXdisplayPrivate *priv = __glXInitialize(dpy);
struct x11_screen *xscr = NULL;
- if (priv && priv->dri2Display)
- xscr = (struct x11_screen *) priv->dri2Display;
+ if (priv && priv->xscr)
+ xscr = priv->xscr;
if (!xscr || !xscr->dri_invalidate_buffers)
return;