summaryrefslogtreecommitdiff
path: root/src/glx
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2008-03-08 19:02:10 -0500
committerKristian Høgsberg <krh@redhat.com>2008-03-08 19:10:21 -0500
commit425f9ed44e576aef27f7ab98968043f7f180d0fd (patch)
tree4ec32246623ecb9eb4d10835dca84b74d4115825 /src/glx
parentf585cb29b827104b9ea04cb11e3e3087ef1684c0 (diff)
Abstract __DRIdisplayPrivateRec away in dri_glx.c.
This patch moves __DRIdisplayPrivateRec definition into dri_glx.c and let's dri_glx.c allocate the __DRIdisplay struct pointer to from __GLXdisplayPrivate. A small step towards moving more of the dri functionality into dri_glx.c.
Diffstat (limited to 'src/glx')
-rw-r--r--src/glx/x11/dri_glx.c52
-rw-r--r--src/glx/x11/dri_glx.h56
-rw-r--r--src/glx/x11/glxclient.h15
-rw-r--r--src/glx/x11/glxcmds.c2
-rw-r--r--src/glx/x11/glxext.c13
5 files changed, 37 insertions, 101 deletions
diff --git a/src/glx/x11/dri_glx.c b/src/glx/x11/dri_glx.c
index 01290a4269..fd824f386d 100644
--- a/src/glx/x11/dri_glx.c
+++ b/src/glx/x11/dri_glx.c
@@ -44,7 +44,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "sarea.h"
#include <stdio.h>
#include <dlfcn.h>
-#include "dri_glx.h"
#include <sys/types.h>
#include <stdarg.h>
#include "glcontextmodes.h"
@@ -59,6 +58,17 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define RTLD_GLOBAL 0
#endif
+typedef struct __GLXDRIdisplayPrivateRec __GLXDRIdisplayPrivate;
+struct __GLXDRIdisplayPrivateRec {
+ __GLXDRIdisplay base;
+
+ /*
+ ** XFree86-DRI version information
+ */
+ int driMajor;
+ int driMinor;
+ int driPatch;
+};
#ifndef DEFAULT_DRIVER_DIR
/* this is normally defined in Mesa/configs/default with DRI_DRIVER_SEARCH_PATH */
@@ -469,10 +479,10 @@ static const __DRIextension *loader_extensions[] = {
*/
static void *
CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,
- __DRIdisplay * driDpy,
+ __GLXDRIdisplayPrivate * driDpy,
PFNCREATENEWSCREENFUNC createNewScreen)
{
- __DRIscreenPrivate *psp = NULL;
+ void *psp = NULL;
#ifndef GLX_USE_APPLEGL
drm_handle_t hSAREA;
drmAddress pSAREA = MAP_FAILED;
@@ -486,9 +496,9 @@ CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,
const char * err_msg;
const char * err_extra;
- dri_version.major = driDpy->private->driMajor;
- dri_version.minor = driDpy->private->driMinor;
- dri_version.patch = driDpy->private->driPatch;
+ dri_version.major = driDpy->driMajor;
+ dri_version.minor = driDpy->driMinor;
+ dri_version.patch = driDpy->driPatch;
err_msg = "XF86DRIOpenConnection";
@@ -652,8 +662,9 @@ driCreateScreen(__GLXscreenConfigs *psc, int screen,
__GLXdisplayPrivate *priv)
{
PFNCREATENEWSCREENFUNC createNewScreen;
+ __GLXDRIdisplayPrivate *pdp;
- if (priv->driDisplay.private == NULL)
+ if (priv->driDisplay == NULL)
return;
/* Create drawable hash */
@@ -669,9 +680,9 @@ driCreateScreen(__GLXscreenConfigs *psc, int screen,
if (createNewScreenName == NULL)
return;
+ pdp = (__GLXDRIdisplayPrivate *) priv->driDisplay;
psc->driScreen.private =
- CallCreateNewScreen(psc->dpy, screen, psc,
- &priv->driDisplay, createNewScreen);
+ CallCreateNewScreen(psc->dpy, screen, psc, pdp, createNewScreen);
if (psc->driScreen.private != NULL)
__glXScrEnableDRIExtension(psc);
}
@@ -690,33 +701,22 @@ void driDestroyScreen(__GLXscreenConfigs *psc)
/* Called from __glXFreeDisplayPrivate.
*/
-static void driDestroyDisplay(Display *dpy, void *private)
+static void driDestroyDisplay(__GLXDRIdisplay *dpy)
{
- __DRIdisplayPrivate *pdpyp = (__DRIdisplayPrivate *)private;
-
- if (pdpyp)
- Xfree(pdpyp);
+ Xfree(dpy);
}
-
/*
* Allocate, initialize and return a __DRIdisplayPrivate object.
* This is called from __glXInitialize() when we are given a new
* display pointer.
*/
-void *driCreateDisplay(Display *dpy, __DRIdisplay *pdisp)
+__GLXDRIdisplay *driCreateDisplay(Display *dpy)
{
- __DRIdisplayPrivate *pdpyp;
+ __GLXDRIdisplayPrivate *pdpyp;
int eventBase, errorBase;
int major, minor, patch;
- /* Initialize these fields to NULL in case we fail.
- * If we don't do this we may later get segfaults trying to free random
- * addresses when the display is closed.
- */
- pdisp->private = NULL;
- pdisp->destroyDisplay = NULL;
-
if (!XF86DRIQueryExtension(dpy, &eventBase, &errorBase)) {
return NULL;
}
@@ -725,7 +725,7 @@ void *driCreateDisplay(Display *dpy, __DRIdisplay *pdisp)
return NULL;
}
- pdpyp = (__DRIdisplayPrivate *)Xmalloc(sizeof(__DRIdisplayPrivate));
+ pdpyp = Xmalloc(sizeof *pdpyp);
if (!pdpyp) {
return NULL;
}
@@ -734,7 +734,7 @@ void *driCreateDisplay(Display *dpy, __DRIdisplay *pdisp)
pdpyp->driMinor = minor;
pdpyp->driPatch = patch;
- pdisp->destroyDisplay = driDestroyDisplay;
+ pdpyp->base.destroyDisplay = driDestroyDisplay;
return (void *)pdpyp;
}
diff --git a/src/glx/x11/dri_glx.h b/src/glx/x11/dri_glx.h
deleted file mode 100644
index 4dd62ed113..0000000000
--- a/src/glx/x11/dri_glx.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Kevin E. Martin <kevin@precisioninsight.com>
- * Brian Paul <brian@precisioninsight.com>
- *
- */
-
-#ifndef _DRI_GLX_H_
-#define _DRI_GLX_H_
-
-#ifdef GLX_DIRECT_RENDERING
-
-struct __DRIdisplayPrivateRec {
- /*
- ** XFree86-DRI version information
- */
- int driMajor;
- int driMinor;
- int driPatch;
-};
-
-typedef struct __DRIdisplayPrivateRec __DRIdisplayPrivate;
-typedef struct __DRIscreenPrivateRec __DRIscreenPrivate;
-typedef struct __DRIvisualPrivateRec __DRIvisualPrivate;
-typedef struct __DRIcontextPrivateRec __DRIcontextPrivate;
-typedef struct __DRIdrawablePrivateRec __DRIdrawablePrivate;
-
-#endif
-#endif /* _DRI_GLX_H_ */
diff --git a/src/glx/x11/glxclient.h b/src/glx/x11/glxclient.h
index e62eec822e..b3f07a30b6 100644
--- a/src/glx/x11/glxclient.h
+++ b/src/glx/x11/glxclient.h
@@ -92,24 +92,19 @@ typedef struct _glapi_table __GLapi;
* Display dependent methods. This structure is initialized during the
* \c driCreateDisplay call.
*/
-struct __DRIdisplayRec {
+typedef struct __GLXDRIdisplayRec __GLXDRIdisplay;
+struct __GLXDRIdisplayRec {
/**
* Method to destroy the private DRI display data.
*/
- void (*destroyDisplay)(Display *dpy, void *displayPrivate);
-
- /**
- * Opaque pointer to private per display direct rendering data.
- * \c NULL if direct rendering is not supported on this display.
- */
- struct __DRIdisplayPrivateRec *private;
+ void (*destroyDisplay)(__GLXDRIdisplay *display);
};
/*
** Function to create and DRI display data and initialize the display
** dependent methods.
*/
-extern void *driCreateDisplay(Display *dpy, __DRIdisplay *pdisp);
+extern __GLXDRIdisplay *driCreateDisplay(Display *dpy);
extern void driCreateScreen(__GLXscreenConfigs *psc, int screen,
__GLXdisplayPrivate *priv);
extern void driDestroyScreen(__GLXscreenConfigs *psc);
@@ -529,7 +524,7 @@ struct __GLXdisplayPrivateRec {
/**
* Per display direct rendering interface functions and data.
*/
- __DRIdisplay driDisplay;
+ __GLXDRIdisplay *driDisplay;
#endif
};
diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c
index 1bcfb94030..d194301dd7 100644
--- a/src/glx/x11/glxcmds.c
+++ b/src/glx/x11/glxcmds.c
@@ -129,7 +129,7 @@ GetDRIDrawable( Display *dpy, GLXDrawable drawable, int * const scrn_num )
unsigned i;
__GLXscreenConfigs *sc;
- if (priv == NULL || priv->driDisplay.private == NULL)
+ if (priv == NULL || priv->driDisplay == NULL)
return NULL;
for (i = 0; i < screen_count; i++) {
diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c
index 632da2d84a..b4a03e4057 100644
--- a/src/glx/x11/glxext.c
+++ b/src/glx/x11/glxext.c
@@ -63,7 +63,6 @@
#include "xf86dri.h"
#include "xf86drm.h"
#include "sarea.h"
-#include "dri_glx.h"
#endif
#ifdef USE_XCB
@@ -377,10 +376,9 @@ static int __glXFreeDisplayPrivate(XExtData *extension)
#ifdef GLX_DIRECT_RENDERING
/* Free the direct rendering per display data */
- if (priv->driDisplay.private)
- (*priv->driDisplay.destroyDisplay)(priv->dpy,
- priv->driDisplay.private);
- priv->driDisplay.private = NULL;
+ if (priv->driDisplay)
+ (*priv->driDisplay->destroyDisplay)(priv->driDisplay);
+ priv->driDisplay = NULL;
#endif
Xfree((char*) priv);
@@ -864,8 +862,7 @@ __GLXdisplayPrivate *__glXInitialize(Display* dpy)
** (e.g., those called in AllocAndFetchScreenConfigs).
*/
if (getenv("LIBGL_ALWAYS_INDIRECT") == NULL) {
- dpyPriv->driDisplay.private =
- driCreateDisplay(dpy, &dpyPriv->driDisplay);
+ dpyPriv->driDisplay = driCreateDisplay(dpy);
}
#endif
@@ -1189,7 +1186,7 @@ FetchDRIDrawable( Display *dpy, GLXDrawable drawable, GLXContext gc)
drm_drawable_t hwDrawable;
void *empty_attribute_list = NULL;
- if (priv == NULL || priv->driDisplay.private == NULL)
+ if (priv == NULL || priv->driDisplay == NULL)
return NULL;
sc = &priv->screenConfigs[gc->screen];