From 6ddf66e9230ee862ac341c4767cf6b3b2dd2552b Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Wed, 28 Jul 2010 10:07:52 -0400 Subject: glx: Rename __GLcontextModes to struct glx_config With this rename, we use 'config' consitently to refer to GLX configurations instead of the modes/configs/visual mess before. --- src/glx/apple/apple_glx_drawable.h | 2 +- src/glx/apple/apple_glx_pbuffer.c | 2 +- src/glx/apple/apple_glx_pixmap.c | 2 +- src/glx/apple/apple_visual.c | 2 +- src/glx/apple/apple_visual.h | 2 +- src/glx/dri2_glx.c | 10 +- src/glx/dri_common.c | 50 +++++---- src/glx/dri_common.h | 6 +- src/glx/dri_glx.c | 14 +-- src/glx/drisw_glx.c | 8 +- src/glx/glcontextmodes.c | 106 ++++++------------- src/glx/glcontextmodes.h | 27 ++--- src/glx/glx_pbuffer.c | 60 +++++------ src/glx/glxclient.h | 18 ++-- src/glx/glxcmds.c | 205 ++++++++++++++++++------------------- src/glx/glxcurrent.c | 2 +- src/glx/glxext.c | 31 ++++-- 17 files changed, 258 insertions(+), 289 deletions(-) (limited to 'src/glx') diff --git a/src/glx/apple/apple_glx_drawable.h b/src/glx/apple/apple_glx_drawable.h index e49eae355e..af79e0590e 100644 --- a/src/glx/apple/apple_glx_drawable.h +++ b/src/glx/apple/apple_glx_drawable.h @@ -211,7 +211,7 @@ bool apple_glx_pbuffer_get_event_mask(GLXDrawable d, unsigned long *mask); /* Pixmaps */ -/* mode is a __GLcontextModes * */ +/* mode is a struct glx_config * */ /* Returns true if an error occurred. */ bool apple_glx_pixmap_create(Display * dpy, int screen, Pixmap pixmap, const void *mode); diff --git a/src/glx/apple/apple_glx_pbuffer.c b/src/glx/apple/apple_glx_pbuffer.c index 1466fea487..a5ef59ccf8 100644 --- a/src/glx/apple/apple_glx_pbuffer.c +++ b/src/glx/apple/apple_glx_pbuffer.c @@ -128,7 +128,7 @@ apple_glx_pbuffer_create(Display * dpy, GLXFBConfig config, Window root; int screen; Pixmap xid; - __GLcontextModes *modes = (__GLcontextModes *) config; + struct glx_config *modes = (__GLcontextModes *) config; root = DefaultRootWindow(dpy); screen = DefaultScreen(dpy); diff --git a/src/glx/apple/apple_glx_pixmap.c b/src/glx/apple/apple_glx_pixmap.c index af1791afb7..fec05e02de 100644 --- a/src/glx/apple/apple_glx_pixmap.c +++ b/src/glx/apple/apple_glx_pixmap.c @@ -125,7 +125,7 @@ apple_glx_pixmap_create(Display * dpy, int screen, Pixmap pixmap, bool double_buffered; bool uses_stereo; CGLError error; - const __GLcontextModes *cmodes = mode; + const struct glx_config *cmodes = mode; if (apple_glx_drawable_create(dpy, screen, pixmap, &d, &callbacks)) return true; diff --git a/src/glx/apple/apple_visual.c b/src/glx/apple/apple_visual.c index da5aa05fd5..7a9525e817 100644 --- a/src/glx/apple/apple_visual.c +++ b/src/glx/apple/apple_visual.c @@ -61,7 +61,7 @@ apple_visual_create_pfobj(CGLPixelFormatObj * pfobj, const void *mode, bool offscreen) { CGLPixelFormatAttribute attr[MAX_ATTR]; - const __GLcontextModes *c = mode; + const struct glx_config *c = mode; int numattr = 0; GLint vsref = 0; CGLError error = 0; diff --git a/src/glx/apple/apple_visual.h b/src/glx/apple/apple_visual.h index ebfafa340b..2cf9a9e251 100644 --- a/src/glx/apple/apple_visual.h +++ b/src/glx/apple/apple_visual.h @@ -33,7 +33,7 @@ #include #include -/* mode is expected to be of type __GLcontextModes. */ +/* mode is expected to be of type struct glx_config. */ void apple_visual_create_pfobj(CGLPixelFormatObj * pfobj, const void *mode, bool * double_buffered, bool * uses_stereo, bool offscreen); diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index a2c2b9785e..2429e0df03 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -156,12 +156,12 @@ dri2UnbindContext(__GLXcontext *context) static __GLXcontext * dri2_create_context(__GLXscreenConfigs *base, - const __GLcontextModes * mode, + struct glx_config *config_base, GLXContext shareList, int renderType) { struct dri2_context *pcp, *pcp_shared; struct dri2_screen *psc = (struct dri2_screen *) base; - __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode; + __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base; __DRIcontext *shared = NULL; if (shareList) { @@ -174,7 +174,7 @@ dri2_create_context(__GLXscreenConfigs *base, return NULL; memset(pcp, 0, sizeof *pcp); - if (!glx_context_init(&pcp->base, &psc->base, mode)) { + if (!glx_context_init(&pcp->base, &psc->base, &config->base)) { Xfree(pcp); return NULL; } @@ -212,11 +212,11 @@ dri2DestroyDrawable(__GLXDRIdrawable *base) static __GLXDRIdrawable * dri2CreateDrawable(__GLXscreenConfigs *base, XID xDrawable, - GLXDrawable drawable, const __GLcontextModes * modes) + GLXDrawable drawable, struct glx_config *config_base) { struct dri2_drawable *pdraw; struct dri2_screen *psc = (struct dri2_screen *) base; - __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes; + __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base; __GLXdisplayPrivate *dpyPriv; struct dri2_display *pdp; GLint vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1; diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c index 9b7da3e7df..7866521e42 100644 --- a/src/glx/dri_common.c +++ b/src/glx/dri_common.c @@ -176,7 +176,7 @@ _X_HIDDEN const __DRIsystemTimeExtension systemTimeExtension = { }; #define __ATTRIB(attrib, field) \ - { attrib, offsetof(__GLcontextModes, field) } + { attrib, offsetof(struct glx_config, field) } static const struct { @@ -225,10 +225,8 @@ __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGB, bindToTextureRgb), bindToMipmapTexture), __ATTRIB(__DRI_ATTRIB_YINVERTED, yInverted),}; -#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) - static int -scalarEqual(__GLcontextModes * mode, unsigned int attrib, unsigned int value) +scalarEqual(struct glx_config *mode, unsigned int attrib, unsigned int value) { unsigned int glxValue; int i; @@ -243,8 +241,8 @@ scalarEqual(__GLcontextModes * mode, unsigned int attrib, unsigned int value) } static int -driConfigEqual(const __DRIcoreExtension * core, - __GLcontextModes * modes, const __DRIconfig * driConfig) +driConfigEqual(const __DRIcoreExtension *core, + struct glx_config *config, const __DRIconfig *driConfig) { unsigned int attrib, value, glxValue; int i; @@ -260,7 +258,7 @@ driConfigEqual(const __DRIcoreExtension * core, else if (value & __DRI_ATTRIB_COLOR_INDEX_BIT) { glxValue |= GLX_COLOR_INDEX_BIT; } - if (glxValue != modes->renderType) + if (glxValue != config->renderType) return GL_FALSE; break; @@ -271,7 +269,7 @@ driConfigEqual(const __DRIcoreExtension * core, glxValue = GLX_SLOW_CONFIG; else glxValue = GLX_NONE; - if (glxValue != modes->visualRating) + if (glxValue != config->visualRating) return GL_FALSE; break; @@ -283,13 +281,13 @@ driConfigEqual(const __DRIcoreExtension * core, glxValue |= GLX_TEXTURE_2D_BIT_EXT; if (value & __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT) glxValue |= GLX_TEXTURE_RECTANGLE_BIT_EXT; - if (modes->bindToTextureTargets != GLX_DONT_CARE && - glxValue != modes->bindToTextureTargets) + if (config->bindToTextureTargets != GLX_DONT_CARE && + glxValue != config->bindToTextureTargets) return GL_FALSE; break; default: - if (!scalarEqual(modes, attrib, value)) + if (!scalarEqual(config, attrib, value)) return GL_FALSE; } } @@ -297,41 +295,41 @@ driConfigEqual(const __DRIcoreExtension * core, return GL_TRUE; } -static __GLcontextModes * +static struct glx_config * createDriMode(const __DRIcoreExtension * core, - __GLcontextModes * modes, const __DRIconfig ** driConfigs) + struct glx_config *config, const __DRIconfig **driConfigs) { - __GLXDRIconfigPrivate *config; + __GLXDRIconfigPrivate *driConfig; int i; for (i = 0; driConfigs[i]; i++) { - if (driConfigEqual(core, modes, driConfigs[i])) + if (driConfigEqual(core, config, driConfigs[i])) break; } if (driConfigs[i] == NULL) return NULL; - config = Xmalloc(sizeof *config); - if (config == NULL) + driConfig = Xmalloc(sizeof *driConfig); + if (driConfig == NULL) return NULL; - config->modes = *modes; - config->driConfig = driConfigs[i]; + driConfig->base = *config; + driConfig->driConfig = driConfigs[i]; - return &config->modes; + return &driConfig->base; } -_X_HIDDEN __GLcontextModes * +_X_HIDDEN struct glx_config * driConvertConfigs(const __DRIcoreExtension * core, - __GLcontextModes * modes, const __DRIconfig ** configs) + struct glx_config *configs, const __DRIconfig **driConfigs) { - __GLcontextModes head, *tail, *m; + struct glx_config head, *tail, *m; tail = &head; head.next = NULL; - for (m = modes; m; m = m->next) { - tail->next = createDriMode(core, m, configs); + for (m = configs; m; m = m->next) { + tail->next = createDriMode(core, m, driConfigs); if (tail->next == NULL) { /* no matching dri config for m */ continue; @@ -341,7 +339,7 @@ driConvertConfigs(const __DRIcoreExtension * core, tail = tail->next; } - _gl_context_modes_destroy(modes); + glx_config_destroy_list(configs); return head.next; } diff --git a/src/glx/dri_common.h b/src/glx/dri_common.h index f3da50ecf0..32d98ed3c1 100644 --- a/src/glx/dri_common.h +++ b/src/glx/dri_common.h @@ -42,12 +42,12 @@ typedef struct __GLXDRIconfigPrivateRec __GLXDRIconfigPrivate; struct __GLXDRIconfigPrivateRec { - __GLcontextModes modes; + struct glx_config base; const __DRIconfig *driConfig; }; -extern __GLcontextModes *driConvertConfigs(const __DRIcoreExtension * core, - __GLcontextModes * modes, +extern struct glx_config *driConvertConfigs(const __DRIcoreExtension * core, + struct glx_config * modes, const __DRIconfig ** configs); extern void driDestroyConfigs(const __DRIconfig **configs); diff --git a/src/glx/dri_glx.c b/src/glx/dri_glx.c index fd14285a48..291b9aacaf 100644 --- a/src/glx/dri_glx.c +++ b/src/glx/dri_glx.c @@ -337,7 +337,7 @@ CallCreateNewScreen(Display *dpy, int scrn, struct dri_screen *psc, drm_handle_t hFB; int junk; const __DRIconfig **driver_configs; - __GLcontextModes *visual; + struct glx_config *visual; /* DRI protocol version. */ dri_version.major = driDpy->driMajor; @@ -551,14 +551,14 @@ static const struct glx_context_vtable dri_context_vtable = { static __GLXcontext * dri_create_context(__GLXscreenConfigs *base, - const __GLcontextModes *mode, + struct glx_config *config_base, GLXContext shareList, int renderType) { struct dri_context *pcp, *pcp_shared; struct dri_screen *psc = (struct dri_screen *) base; drm_context_t hwContext; __DRIcontext *shared = NULL; - __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode; + __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base; if (!psc->base.driScreen) return NULL; @@ -573,13 +573,13 @@ dri_create_context(__GLXscreenConfigs *base, return NULL; memset(pcp, 0, sizeof *pcp); - if (!glx_context_init(&pcp->base, &psc->base, mode)) { + if (!glx_context_init(&pcp->base, &psc->base, &config->base)) { Xfree(pcp); return NULL; } if (!XF86DRICreateContextWithConfig(psc->base.dpy, psc->base.scr, - mode->visualID, + config->base.visualID, &pcp->hwContextID, &hwContext)) { Xfree(pcp); return NULL; @@ -617,11 +617,11 @@ driDestroyDrawable(__GLXDRIdrawable * pdraw) static __GLXDRIdrawable * driCreateDrawable(__GLXscreenConfigs *base, XID xDrawable, - GLXDrawable drawable, const __GLcontextModes * modes) + GLXDrawable drawable, struct glx_config *config_base) { drm_drawable_t hwDrawable; void *empty_attribute_list = NULL; - __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes; + __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base; struct dri_screen *psc = (struct dri_screen *) base; struct dri_drawable *pdp; diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index 5f7185de4c..39d71513a8 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -291,11 +291,11 @@ static const struct glx_context_vtable drisw_context_vtable = { static __GLXcontext * drisw_create_context(__GLXscreenConfigs *base, - const __GLcontextModes *mode, + struct glx_config *config_base, GLXContext shareList, int renderType) { struct drisw_context *pcp, *pcp_shared; - __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode; + __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base; struct drisw_screen *psc = (struct drisw_screen *) base; __DRIcontext *shared = NULL; @@ -312,7 +312,7 @@ drisw_create_context(__GLXscreenConfigs *base, return NULL; memset(pcp, 0, sizeof *pcp); - if (!glx_context_init(&pcp->base, &psc->base, mode)) { + if (!glx_context_init(&pcp->base, &psc->base, &config->base)) { Xfree(pcp); return NULL; } @@ -347,7 +347,7 @@ driDestroyDrawable(__GLXDRIdrawable * pdraw) static __GLXDRIdrawable * driCreateDrawable(__GLXscreenConfigs *base, XID xDrawable, - GLXDrawable drawable, const __GLcontextModes * modes) + GLXDrawable drawable, struct glx_config *modes) { struct drisw_drawable *pdp; __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes; diff --git a/src/glx/glcontextmodes.c b/src/glx/glcontextmodes.c index 18c45d59d7..186de485ff 100644 --- a/src/glx/glcontextmodes.c +++ b/src/glx/glcontextmodes.c @@ -24,7 +24,7 @@ /** * \file glcontextmodes.c - * Utility routines for working with \c __GLcontextModes structures. At + * Utility routines for working with \c struct glx_config structures. At * some point most or all of these functions will be moved to the Mesa * code base. * @@ -41,28 +41,7 @@ #define NUM_VISUAL_TYPES 6 /** - * Convert an X visual type to a GLX visual type. - * - * \param visualType X visual type (i.e., \c TrueColor, \c StaticGray, etc.) - * to be converted. - * \return If \c visualType is a valid X visual type, a GLX visual type will - * be returned. Otherwise \c GLX_NONE will be returned. - */ -GLint -_gl_convert_from_x_visual_type(int visualType) -{ - static const int glx_visual_types[NUM_VISUAL_TYPES] = { - GLX_STATIC_GRAY, GLX_GRAY_SCALE, - GLX_STATIC_COLOR, GLX_PSEUDO_COLOR, - GLX_TRUE_COLOR, GLX_DIRECT_COLOR - }; - - return ((unsigned) visualType < NUM_VISUAL_TYPES) - ? glx_visual_types[visualType] : GLX_NONE; -} - -/** - * Get data from a GL context mode. + * Get data from a GLX config * * \param mode GL context mode whose data is to be returned. * \param attribute Attribute of \c mode that is to be returned. @@ -70,9 +49,8 @@ _gl_convert_from_x_visual_type(int visualType) * \return If \c attribute is a valid attribute of \c mode, zero is * returned. Otherwise \c GLX_BAD_ATTRIBUTE is returned. */ -int -_gl_get_context_mode_data(const __GLcontextModes * mode, int attribute, - int *value_return) +_X_HIDDEN int +glx_config_get(struct glx_config * mode, int attribute, int *value_return) { switch (attribute) { case GLX_USE_GL: @@ -222,7 +200,7 @@ _gl_get_context_mode_data(const __GLcontextModes * mode, int attribute, /** - * Allocate a linked list of \c __GLcontextModes structures. The fields of + * Allocate a linked list of \c struct glx_config structures. The fields of * each structure will be initialized to "reasonable" default values. In * most cases this is the default value defined by table 3.4 of the GLX * 1.3 specification. This means that most values are either initialized to @@ -233,36 +211,26 @@ _gl_get_context_mode_data(const __GLcontextModes * mode, int attribute, * \param count Number of structures to allocate. * \param minimum_size Minimum size of a structure to allocate. This allows * for differences in the version of the - * \c __GLcontextModes stucture used in libGL and in a + * \c struct glx_config stucture used in libGL and in a * DRI-based driver. * \returns A pointer to the first element in a linked list of \c count * stuctures on success, or \c NULL on failure. - * - * \warning Use of \c minimum_size does \b not guarantee binary compatibility. - * The fundamental assumption is that if the \c minimum_size - * specified by the driver and the size of the \c __GLcontextModes - * structure in libGL is the same, then the meaning of each byte in - * the structure is the same in both places. \b Be \b careful! - * Basically this means that fields have to be added in libGL and - * then propagated to drivers. Drivers should \b never arbitrarilly - * extend the \c __GLcontextModes data-structure. */ -__GLcontextModes * -_gl_context_modes_create(unsigned count, size_t minimum_size) +_X_HIDDEN struct glx_config * +glx_config_create_list(unsigned count) { - const size_t size = (minimum_size > sizeof(__GLcontextModes)) - ? minimum_size : sizeof(__GLcontextModes); - __GLcontextModes *base = NULL; - __GLcontextModes **next; + const size_t size = sizeof(struct glx_config); + struct glx_config *base = NULL; + struct glx_config **next; unsigned i; next = &base; for (i = 0; i < count; i++) { - *next = (__GLcontextModes *) malloc(size); + *next = (struct glx_config *) malloc(size); if (*next == NULL) { - _gl_context_modes_destroy(base); - base = NULL; - break; + glx_config_destroy_list(base); + base = NULL; + break; } (void) memset(*next, 0, size); @@ -290,22 +258,14 @@ _gl_context_modes_create(unsigned count, size_t minimum_size) return base; } - -/** - * Destroy a linked list of \c __GLcontextModes structures created by - * \c _gl_context_modes_create. - * - * \param modes Linked list of structures to be destroyed. All structres - * in the list will be freed. - */ -void -_gl_context_modes_destroy(__GLcontextModes * modes) +_X_HIDDEN void +glx_config_destroy_list(struct glx_config *configs) { - while (modes != NULL) { - __GLcontextModes *const next = modes->next; + while (configs != NULL) { + struct glx_config *const next = configs->next; - free(modes); - modes = next; + free(configs); + configs = next; } } @@ -319,26 +279,26 @@ _gl_context_modes_destroy(__GLcontextModes * modes) * the list, or \c NULL if it was not. */ -__GLcontextModes * -_gl_context_modes_find_visual(__GLcontextModes * modes, int vid) +_X_HIDDEN struct glx_config * +glx_config_find_visual(struct glx_config *configs, int vid) { - __GLcontextModes *m; + struct glx_config *c; - for (m = modes; m != NULL; m = m->next) - if (m->visualID == vid) - return m; + for (c = configs; c != NULL; c = c->next) + if (c->visualID == vid) + return c; return NULL; } -__GLcontextModes * -_gl_context_modes_find_fbconfig(__GLcontextModes * modes, int fbid) +_X_HIDDEN struct glx_config * +glx_config_find_fbconfig(struct glx_config *configs, int fbid) { - __GLcontextModes *m; + struct glx_config *c; - for (m = modes; m != NULL; m = m->next) - if (m->fbconfigID == fbid) - return m; + for (c = configs; c != NULL; c = c->next) + if (c->fbconfigID == fbid) + return c; return NULL; } diff --git a/src/glx/glcontextmodes.h b/src/glx/glcontextmodes.h index be2b29a195..f7ee958e4b 100644 --- a/src/glx/glcontextmodes.h +++ b/src/glx/glcontextmodes.h @@ -30,8 +30,8 @@ #ifndef GLCONTEXTMODES_H #define GLCONTEXTMODES_H -typedef struct __GLcontextModesRec { - struct __GLcontextModesRec * next; +struct glx_config { + struct glx_config * next; GLboolean rgbMode; GLboolean floatMode; @@ -100,7 +100,7 @@ typedef struct __GLcontextModesRec { GLint bindToMipmapTexture; GLint bindToTextureTargets; GLint yInverted; -} __GLcontextModes; +}; #define __GLX_MIN_CONFIG_PROPS 18 #define __GLX_MAX_CONFIG_PROPS 500 @@ -117,14 +117,17 @@ typedef struct __GLcontextModesRec { (__GLX_MIN_CONFIG_PROPS + 2 * __GLX_EXT_CONFIG_PROPS) extern GLint _gl_convert_from_x_visual_type(int visualType); -extern int _gl_get_context_mode_data(const __GLcontextModes * mode, - int attribute, int *value_return); -extern __GLcontextModes *_gl_context_modes_create(unsigned count, - size_t minimum_size); -extern void _gl_context_modes_destroy(__GLcontextModes * modes); -extern __GLcontextModes *_gl_context_modes_find_visual(__GLcontextModes * - modes, int vid); -extern __GLcontextModes *_gl_context_modes_find_fbconfig(__GLcontextModes * - modes, int fbid); + +extern int +glx_config_get(struct glx_config * mode, int attribute, int *value_return); +extern struct glx_config * +glx_config_create_list(unsigned count); +extern void +glx_config_destroy_list(struct glx_config *configs); +extern struct glx_config * +glx_config_find_visual(struct glx_config *configs, int vid); +extern struct glx_config * +glx_config_find_fbconfig(struct glx_config *configs, int fbid); #endif /* GLCONTEXTMODES_H */ + diff --git a/src/glx/glx_pbuffer.c b/src/glx/glx_pbuffer.c index 02809aacfa..abe618ddb3 100644 --- a/src/glx/glx_pbuffer.c +++ b/src/glx/glx_pbuffer.c @@ -183,7 +183,7 @@ determineTextureFormat(const int *attribs, int numAttribs) } static void -CreateDRIDrawable(Display *dpy, const __GLcontextModes *fbconfig, +CreateDRIDrawable(Display *dpy, struct glx_config *config, XID drawable, XID glxdrawable, const int *attrib_list, size_t num_attribs) { @@ -191,12 +191,12 @@ CreateDRIDrawable(Display *dpy, const __GLcontextModes *fbconfig, __GLXDRIdrawable *pdraw; __GLXscreenConfigs *psc; - psc = priv->screenConfigs[fbconfig->screen]; + psc = priv->screenConfigs[config->screen]; if (psc->driScreen == NULL) return; pdraw = psc->driScreen->createDrawable(psc, drawable, - glxdrawable, fbconfig); + glxdrawable, config); if (pdraw == NULL) { fprintf(stderr, "failed to create drawable\n"); return; @@ -228,7 +228,7 @@ DestroyDRIDrawable(Display *dpy, GLXDrawable drawable, int destroy_xdrawable) #else static void -CreateDRIDrawable(Display *dpy, const __GLcontextModes * fbconfig, +CreateDRIDrawable(Display *dpy, const struct glx_config * fbconfig, XID drawable, XID glxdrawable, const int *attrib_list, size_t num_attribs) { @@ -367,7 +367,7 @@ GetDrawableAttribute(Display * dpy, GLXDrawable drawable, * This function needs to be modified to work with direct-rendering drivers. */ static GLXDrawable -CreateDrawable(Display * dpy, const __GLcontextModes * fbconfig, +CreateDrawable(Display *dpy, struct glx_config *config, Drawable drawable, const int *attrib_list, CARD8 glxCode) { xGLXCreateWindowReq *req; @@ -391,11 +391,11 @@ CreateDrawable(Display * dpy, const __GLcontextModes * fbconfig, req->reqType = opcode; req->glxCode = glxCode; - req->screen = (CARD32) fbconfig->screen; - req->fbconfig = fbconfig->fbconfigID; - req->window = (CARD32) drawable; - req->glxwindow = (GLXWindow) XAllocID(dpy); - req->numAttribs = (CARD32) i; + req->screen = config->screen; + req->fbconfig = config->fbconfigID; + req->window = drawable; + req->glxwindow = XAllocID(dpy); + req->numAttribs = i; if (attrib_list) memcpy(data, attrib_list, 8 * i); @@ -403,9 +403,9 @@ CreateDrawable(Display * dpy, const __GLcontextModes * fbconfig, UnlockDisplay(dpy); SyncHandle(); - CreateDRIDrawable(dpy, fbconfig, drawable, req->glxwindow, attrib_list, i); + CreateDRIDrawable(dpy, config, drawable, req->glxwindow, attrib_list, i); - return (GLXDrawable) req->glxwindow; + return req->glxwindow; } @@ -457,7 +457,7 @@ DestroyDrawable(Display * dpy, GLXDrawable drawable, CARD32 glxCode) * This function needs to be modified to work with direct-rendering drivers. */ static GLXDrawable -CreatePbuffer(Display * dpy, const __GLcontextModes * fbconfig, +CreatePbuffer(Display * dpy, struct glx_config *config, unsigned int width, unsigned int height, const int *attrib_list, GLboolean size_in_attribs) { @@ -490,10 +490,10 @@ CreatePbuffer(Display * dpy, const __GLcontextModes * fbconfig, req->reqType = opcode; req->glxCode = X_GLXCreatePbuffer; - req->screen = (CARD32) fbconfig->screen; - req->fbconfig = fbconfig->fbconfigID; - req->pbuffer = (GLXPbuffer) id; - req->numAttribs = (CARD32) (i + extra); + req->screen = config->screen; + req->fbconfig = config->fbconfigID; + req->pbuffer = id; + req->numAttribs = i + extra; if (!size_in_attribs) { data[(2 * i) + 0] = GLX_PBUFFER_WIDTH; @@ -513,11 +513,11 @@ CreatePbuffer(Display * dpy, const __GLcontextModes * fbconfig, vpreq->glxCode = X_GLXVendorPrivate; vpreq->vendorCode = X_GLXvop_CreateGLXPbufferSGIX; - data[0] = (CARD32) fbconfig->screen; - data[1] = (CARD32) fbconfig->fbconfigID; - data[2] = (CARD32) id; - data[3] = (CARD32) width; - data[4] = (CARD32) height; + data[0] = config->screen; + data[1] = config->fbconfigID; + data[2] = id; + data[3] = width; + data[4] = height; data += 5; } @@ -526,10 +526,10 @@ CreatePbuffer(Display * dpy, const __GLcontextModes * fbconfig, UnlockDisplay(dpy); SyncHandle(); - pixmap = XCreatePixmap(dpy, RootWindow(dpy, fbconfig->screen), - width, height, fbconfig->rgbBits); + pixmap = XCreatePixmap(dpy, RootWindow(dpy, config->screen), + width, height, config->rgbBits); - CreateDRIDrawable(dpy, fbconfig, pixmap, id, attrib_list, i); + CreateDRIDrawable(dpy, config, pixmap, id, attrib_list, i); return id; } @@ -598,7 +598,7 @@ glXCreateGLXPbufferSGIX(Display * dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list) { - return (GLXPbufferSGIX) CreatePbuffer(dpy, (__GLcontextModes *) config, + return (GLXPbufferSGIX) CreatePbuffer(dpy, (struct glx_config *) config, width, height, attrib_list, GL_FALSE); } @@ -674,7 +674,7 @@ glXCreatePbuffer(Display * dpy, GLXFBConfig config, const int *attrib_list) } } - return (GLXPbuffer) CreatePbuffer(dpy, (__GLcontextModes *) config, + return (GLXPbuffer) CreatePbuffer(dpy, (struct glx_config *) config, width, height, attrib_list, GL_TRUE); #endif } @@ -836,14 +836,14 @@ glXCreatePixmap(Display * dpy, GLXFBConfig config, Pixmap pixmap, WARN_ONCE_GLX_1_3(dpy, __func__); #ifdef GLX_USE_APPLEGL - const __GLcontextModes *modes = (const __GLcontextModes *) config; + const struct glx_config *modes = (const __GLcontextModes *) config; if (apple_glx_pixmap_create(dpy, modes->screen, pixmap, modes)) return None; return pixmap; #else - return CreateDrawable(dpy, (__GLcontextModes *) config, + return CreateDrawable(dpy, (struct glx_config *) config, (Drawable) pixmap, attrib_list, X_GLXCreatePixmap); #endif } @@ -878,7 +878,7 @@ glXCreateWindow(Display * dpy, GLXFBConfig config, Window win, return win; #else - return CreateDrawable(dpy, (__GLcontextModes *) config, + return CreateDrawable(dpy, (struct glx_config *) config, (Drawable) win, attrib_list, X_GLXCreateWindow); #endif } diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h index 01087d035f..3a8d294dab 100644 --- a/src/glx/glxclient.h +++ b/src/glx/glxclient.h @@ -74,7 +74,7 @@ # define USED #endif - +#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) #define GLX_MAJOR_VERSION 1 /* current version numbers */ #define GLX_MINOR_VERSION 4 @@ -127,13 +127,13 @@ struct __GLXDRIscreenRec { void (*destroyScreen)(__GLXscreenConfigs *psc); __GLXcontext *(*createContext)(__GLXscreenConfigs *psc, - const __GLcontextModes *mode, + struct glx_config *config, GLXContext shareList, int renderType); __GLXDRIdrawable *(*createDrawable)(__GLXscreenConfigs *psc, XID drawable, GLXDrawable glxDrawable, - const __GLcontextModes *modes); + struct glx_config *config); int64_t (*swapBuffers)(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor, int64_t remainder); @@ -403,9 +403,9 @@ struct __GLXcontextRec GLint majorOpcode; /** - * Pointer to the mode used to create this context. + * Pointer to the config used to create this context. */ - const __GLcontextModes *mode; + struct glx_config *config; #ifdef GLX_DIRECT_RENDERING #ifdef GLX_USE_APPLEGL @@ -462,7 +462,7 @@ struct __GLXcontextRec extern Bool glx_context_init(__GLXcontext *gc, - __GLXscreenConfigs *psc, const __GLcontextModes *fbconfig); + __GLXscreenConfigs *psc, struct glx_config *fbconfig); #define __glXSetError(gc,code) \ if (!(gc)->error) { \ @@ -505,7 +505,7 @@ extern void __glFreeAttributeState(__GLXcontext *); */ struct glx_screen_vtable { __GLXcontext *(*create_context)(__GLXscreenConfigs *psc, - const __GLcontextModes *mode, + struct glx_config *config, GLXContext shareList, int renderType); }; @@ -539,7 +539,7 @@ struct __GLXscreenConfigsRec /** * Linked list of glx visuals and fbconfigs for this screen. */ - __GLcontextModes *visuals, *configs; + struct glx_config *visuals, *configs; /** * Per-screen dynamic GLX extension tracking. The \c direct_support @@ -766,7 +766,7 @@ extern void _XSend(Display *, const void *, long); #endif -extern void __glXInitializeVisualConfigFromTags(__GLcontextModes * config, +extern void __glXInitializeVisualConfigFromTags(struct glx_config * config, int count, const INT32 * bp, Bool tagged_only, Bool fbconfig_style_tags); diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c index 0782b1d70f..85bfa657e0 100644 --- a/src/glx/glxcmds.c +++ b/src/glx/glxcmds.c @@ -208,26 +208,25 @@ GetGLXPrivScreenConfig(Display * dpy, int scrn, __GLXdisplayPrivate ** ppriv, * \param config Application supplied \c GLXFBConfig. * * \returns If the \c GLXFBConfig is valid, the a pointer to the matching - * \c __GLcontextModes structure is returned. Otherwise, \c NULL + * \c struct glx_config structure is returned. Otherwise, \c NULL * is returned. */ -static __GLcontextModes * -ValidateGLXFBConfig(Display * dpy, GLXFBConfig config) +static struct glx_config * +ValidateGLXFBConfig(Display * dpy, GLXFBConfig fbconfig) { __GLXdisplayPrivate *const priv = __glXInitialize(dpy); - const unsigned num_screens = ScreenCount(dpy); + int num_screens = ScreenCount(dpy); unsigned i; - const __GLcontextModes *modes; - + struct glx_config *config; if (priv != NULL) { for (i = 0; i < num_screens; i++) { - for (modes = priv->screenConfigs[i]->configs; modes != NULL; - modes = modes->next) { - if (modes == (__GLcontextModes *) config) { - return (__GLcontextModes *) config; - } - } + for (config = priv->screenConfigs[i]->configs; config != NULL; + config = config->next) { + if (config == (struct glx_config *) fbconfig) { + return config; + } + } } } @@ -240,8 +239,8 @@ static const struct glx_context_vtable applegl_context_vtable; static __GLcontext * applegl_create_context(__GLXscreenConfigs *psc, - const __GLcontextModes *mode, - GLXContext shareList, int renderType) + struct glx_config *mode, + GLXContext shareList, int renderType) { __GLXcontext *gc; int errorcode; @@ -296,7 +295,7 @@ applegl_create_context(__GLXscreenConfigs *psc, */ static GLXContext indirect_create_context(__GLXscreenConfigs *psc, - const __GLcontextModes *mode, + struct glx_config *mode, GLXContext shareList, int renderType) { GLXContext gc; @@ -416,7 +415,7 @@ indirect_create_screen(int screen, __GLXdisplayPrivate * priv) _X_HIDDEN Bool glx_context_init(__GLXcontext *gc, - __GLXscreenConfigs *psc, const __GLcontextModes *fbconfig) + __GLXscreenConfigs *psc, struct glx_config *config) { gc->majorOpcode = __glXSetupForCommand(psc->display->dpy); if (!gc->majorOpcode) @@ -424,7 +423,7 @@ glx_context_init(__GLXcontext *gc, gc->screen = psc->scr; gc->psc = psc; - gc->mode = fbconfig; + gc->config = config; gc->isDirect = GL_TRUE; return GL_TRUE; @@ -442,7 +441,7 @@ glx_context_init(__GLXcontext *gc, static GLXContext CreateContext(Display * dpy, int generic_id, - const __GLcontextModes * const fbconfig, + struct glx_config *config, GLXContext shareList, Bool allowDirect, unsigned code, int renderType, int screen) @@ -458,10 +457,9 @@ CreateContext(Display * dpy, int generic_id, gc = NULL; if (allowDirect && psc->vtable->create_context) - gc = psc->vtable->create_context(psc, fbconfig, - shareList, renderType); + gc = psc->vtable->create_context(psc, config, shareList, renderType); if (!gc) - gc = indirect_create_context(psc, fbconfig, shareList, renderType); + gc = indirect_create_context(psc, config, shareList, renderType); if (!gc) return NULL; @@ -539,14 +537,14 @@ PUBLIC GLXContext glXCreateContext(Display * dpy, XVisualInfo * vis, GLXContext shareList, Bool allowDirect) { - const __GLcontextModes *mode = NULL; + struct glx_config *config = NULL; int renderType = 0; #if defined(GLX_DIRECT_RENDERING) || defined(GLX_USE_APPLEGL) __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, vis->screen); - mode = _gl_context_modes_find_visual(psc->visuals, vis->visualid); - if (mode == NULL) { + config = glx_config_find_visual(psc->visuals, vis->visualid); + if (config == NULL) { xError error; error.errorCode = BadValue; @@ -559,10 +557,10 @@ glXCreateContext(Display * dpy, XVisualInfo * vis, return None; } - renderType = mode->rgbMode ? GLX_RGBA_TYPE : GLX_COLOR_INDEX_TYPE; + renderType = config->rgbMode ? GLX_RGBA_TYPE : GLX_COLOR_INDEX_TYPE; #endif - return CreateContext(dpy, vis->visualid, mode, shareList, allowDirect, + return CreateContext(dpy, vis->visualid, config, shareList, allowDirect, X_GLXCreateContext, renderType, vis->screen); } @@ -942,11 +940,11 @@ glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap) #ifdef GLX_USE_APPLEGL int screen = vis->screen; __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen); - const __GLcontextModes *modes; + const struct glx_config *config; - modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid); + config = _gl_context_modes_find_visual(psc->visuals, vis->visualid); - if(apple_glx_pixmap_create(dpy, vis->screen, pixmap, modes)) + if(apple_glx_pixmap_create(dpy, vis->screen, pixmap, config)) return None; return pixmap; @@ -980,13 +978,13 @@ glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap) __GLXdisplayPrivate *const priv = __glXInitialize(dpy); __GLXDRIdrawable *pdraw; __GLXscreenConfigs *psc; - __GLcontextModes *modes; + struct glx_config *config; psc = priv->screenConfigs[vis->screen]; if (psc->driScreen == NULL) break; - modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid); - pdraw = psc->driScreen->createDrawable(psc, pixmap, req->glxpixmap, modes); + config = glx_config_find_visual(psc->visuals, vis->visualid); + pdraw = psc->driScreen->createDrawable(psc, pixmap, req->glxpixmap, config); if (pdraw == NULL) { fprintf(stderr, "failed to create pixmap\n"); break; @@ -1123,16 +1121,16 @@ glXGetConfig(Display * dpy, XVisualInfo * vis, int attribute, { __GLXdisplayPrivate *priv; __GLXscreenConfigs *psc; - __GLcontextModes *modes; + struct glx_config *config; int status; status = GetGLXPrivScreenConfig(dpy, vis->screen, &priv, &psc); if (status == Success) { - modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid); + config = glx_config_find_visual(psc->visuals, vis->visualid); /* Lookup attribute after first finding a match on the visual */ - if (modes != NULL) { - return _gl_get_context_mode_data(modes, attribute, value_return); + if (config != NULL) { + return glx_config_get(config, attribute, value_return); } status = GLX_BAD_VISUAL; @@ -1153,10 +1151,10 @@ glXGetConfig(Display * dpy, XVisualInfo * vis, int attribute, /************************************************************************/ static void -init_fbconfig_for_chooser(__GLcontextModes * config, +init_fbconfig_for_chooser(struct glx_config * config, GLboolean fbconfig_style_tags) { - memset(config, 0, sizeof(__GLcontextModes)); + memset(config, 0, sizeof(struct glx_config)); config->visualID = (XID) GLX_DONT_CARE; config->visualType = GLX_DONT_CARE; @@ -1222,8 +1220,8 @@ init_fbconfig_for_chooser(__GLcontextModes * config, * \param b Server specified config to test against \c a. */ static Bool -fbconfigs_compatible(const __GLcontextModes * const a, - const __GLcontextModes * const b) +fbconfigs_compatible(const struct glx_config * const a, + const struct glx_config * const b) { MATCH_DONT_CARE(doubleBufferMode); MATCH_DONT_CARE(visualType); @@ -1342,8 +1340,7 @@ fbconfigs_compatible(const __GLcontextModes * const a, * \sa qsort, glXChooseVisual, glXChooseFBConfig, glXChooseFBConfigSGIX */ static int -fbconfig_compare(const __GLcontextModes * const *const a, - const __GLcontextModes * const *const b) +fbconfig_compare(struct glx_config **a, struct glx_config **b) { /* The order of these comparisons must NOT change. It is defined by * the GLX 1.3 spec and ARB_multisample. @@ -1428,10 +1425,10 @@ fbconfig_compare(const __GLcontextModes * const *const a, * \sa glXChooseVisual, glXChooseFBConfig, glXChooseFBConfigSGIX */ static int -choose_visual(__GLcontextModes ** configs, int num_configs, +choose_visual(struct glx_config ** configs, int num_configs, const int *attribList, GLboolean fbconfig_style_tags) { - __GLcontextModes test_config; + struct glx_config test_config; int base; int i; @@ -1467,7 +1464,7 @@ choose_visual(__GLcontextModes ** configs, int num_configs, * specifications. */ - qsort(configs, base, sizeof(__GLcontextModes *), + qsort(configs, base, sizeof(struct glx_config *), (int (*)(const void *, const void *)) fbconfig_compare); return base; } @@ -1485,9 +1482,9 @@ glXChooseVisual(Display * dpy, int screen, int *attribList) XVisualInfo *visualList = NULL; __GLXdisplayPrivate *priv; __GLXscreenConfigs *psc; - __GLcontextModes test_config; - __GLcontextModes *modes; - const __GLcontextModes *best_config = NULL; + struct glx_config test_config; + struct glx_config *config; + struct glx_config *best_config = NULL; /* ** Get a list of all visuals, return if list is empty @@ -1514,26 +1511,23 @@ glXChooseVisual(Display * dpy, int screen, int *attribList) ** Otherwise, create an XVisualInfo list with just the selected X visual ** and return this. */ - for (modes = psc->visuals; modes != NULL; modes = modes->next) { - if (fbconfigs_compatible(&test_config, modes) - && ((best_config == NULL) - || - (fbconfig_compare - ((const __GLcontextModes * const *const) &modes, - &best_config) < 0))) { + for (config = psc->visuals; config != NULL; config = config->next) { + if (fbconfigs_compatible(&test_config, config) + && ((best_config == NULL) || + (fbconfig_compare (&config, &best_config) < 0))) { XVisualInfo visualTemplate; XVisualInfo *newList; int i; visualTemplate.screen = screen; - visualTemplate.visualid = modes->visualID; + visualTemplate.visualid = config->visualID; newList = XGetVisualInfo(dpy, VisualScreenMask | VisualIDMask, &visualTemplate, &i); if (newList) { Xfree(visualList); visualList = newList; - best_config = modes; + best_config = config; } } } @@ -1689,7 +1683,7 @@ glXImportContextEXT(Display *dpy, GLXContextID contextID) int propList[__GLX_MAX_CONTEXT_PROPS * 2], *pProp, nPropListBytes; int i, renderType; XID share; - __GLcontextModes *mode; + struct glx_config *mode; if (contextID == None || __glXIsDirect(dpy, contextID)) return NULL; @@ -1753,10 +1747,10 @@ glXImportContextEXT(Display *dpy, GLXContextID contextID) share = pProp[1]; break; case GLX_VISUAL_ID_EXT: - mode = _gl_context_modes_find_visual(psc->visuals, pProp[1]); + mode = glx_config_find_visual(psc->visuals, pProp[1]); break; case GLX_FBCONFIG_ID: - mode = _gl_context_modes_find_fbconfig(psc->configs, pProp[1]); + mode = glx_config_find_fbconfig(psc->configs, pProp[1]); break; case GLX_RENDER_TYPE: renderType = pProp[1]; @@ -1787,13 +1781,13 @@ glXQueryContext(Display * dpy, GLXContext ctx, int attribute, int *value) *value = ctx->share_xid; break; case GLX_VISUAL_ID_EXT: - *value = ctx->mode ? ctx->mode->visualID : None; + *value = ctx->config ? ctx->config->visualID : None; break; case GLX_SCREEN: *value = ctx->screen; break; case GLX_FBCONFIG_ID: - *value = ctx->mode ? ctx->mode->fbconfigID : None; + *value = ctx->config ? ctx->config->fbconfigID : None; break; case GLX_RENDER_TYPE: *value = ctx->renderType; @@ -1825,11 +1819,11 @@ PUBLIC GLXFBConfig * glXChooseFBConfig(Display * dpy, int screen, const int *attribList, int *nitems) { - __GLcontextModes **config_list; + struct glx_config **config_list; int list_size; - config_list = (__GLcontextModes **) + config_list = (struct glx_config **) glXGetFBConfigs(dpy, screen, &list_size); if ((config_list != NULL) && (list_size > 0) && (attribList != NULL)) { @@ -1846,15 +1840,14 @@ glXChooseFBConfig(Display * dpy, int screen, PUBLIC GLXContext -glXCreateNewContext(Display * dpy, GLXFBConfig config, +glXCreateNewContext(Display * dpy, GLXFBConfig fbconfig, int renderType, GLXContext shareList, Bool allowDirect) { - const __GLcontextModes *const fbconfig = - (const __GLcontextModes *const) config; + struct glx_config *config = (struct glx_config *) fbconfig; - return CreateContext(dpy, fbconfig->fbconfigID, fbconfig, shareList, - allowDirect, X_GLXCreateNewContext, renderType, - fbconfig->screen); + return CreateContext(dpy, config->fbconfigID, config, shareList, + allowDirect, X_GLXCreateNewContext, renderType, + config->screen); } @@ -1870,7 +1863,9 @@ PUBLIC GLXFBConfig * glXGetFBConfigs(Display * dpy, int screen, int *nelements) { __GLXdisplayPrivate *priv = __glXInitialize(dpy); - __GLcontextModes **config = NULL; + struct glx_config **config_list = NULL; + struct glx_config *config; + unsigned num_configs = 0; int i; *nelements = 0; @@ -1879,58 +1874,56 @@ glXGetFBConfigs(Display * dpy, int screen, int *nelements) && (priv->screenConfigs[screen]->configs != NULL) && (priv->screenConfigs[screen]->configs->fbconfigID != (int) GLX_DONT_CARE)) { - unsigned num_configs = 0; - __GLcontextModes *modes; - - for (modes = priv->screenConfigs[screen]->configs; modes != NULL; - modes = modes->next) { - if (modes->fbconfigID != (int) GLX_DONT_CARE) { + for (config = priv->screenConfigs[screen]->configs; config != NULL; + config = config->next) { + if (config->fbconfigID != (int) GLX_DONT_CARE) { num_configs++; } } - config = (__GLcontextModes **) Xmalloc(sizeof(__GLcontextModes *) - * num_configs); - if (config != NULL) { + config_list = Xmalloc(num_configs * sizeof *config_list); + if (config_list != NULL) { *nelements = num_configs; i = 0; - for (modes = priv->screenConfigs[screen]->configs; modes != NULL; - modes = modes->next) { - if (modes->fbconfigID != (int) GLX_DONT_CARE) { - config[i] = modes; + for (config = priv->screenConfigs[screen]->configs; config != NULL; + config = config->next) { + if (config->fbconfigID != (int) GLX_DONT_CARE) { + config_list[i] = config; i++; } } } } - return (GLXFBConfig *) config; + + return (GLXFBConfig *) config_list; } PUBLIC int -glXGetFBConfigAttrib(Display * dpy, GLXFBConfig config, +glXGetFBConfigAttrib(Display * dpy, GLXFBConfig fbconfig, int attribute, int *value) { - __GLcontextModes *const modes = ValidateGLXFBConfig(dpy, config); + struct glx_config *config = ValidateGLXFBConfig(dpy, fbconfig); + + if (config == NULL) + return GLXBadFBConfig; - return (modes != NULL) - ? _gl_get_context_mode_data(modes, attribute, value) - : GLXBadFBConfig; + return glx_config_get(config, attribute, value); } PUBLIC XVisualInfo * -glXGetVisualFromFBConfig(Display * dpy, GLXFBConfig config) +glXGetVisualFromFBConfig(Display * dpy, GLXFBConfig fbconfig) { XVisualInfo visualTemplate; - __GLcontextModes *fbconfig = (__GLcontextModes *) config; + struct glx_config *config = (struct glx_config *) fbconfig; int count; /* ** Get a list of all visuals, return if list is empty */ - visualTemplate.visualid = fbconfig->visualID; + visualTemplate.visualid = config->visualID; return XGetVisualInfo(dpy, VisualIDMask, &visualTemplate, &count); } @@ -2144,7 +2137,7 @@ PUBLIC GLX_ALIAS(XVisualInfo *, glXGetVisualFromFBConfigSGIX, PUBLIC GLXPixmap glXCreateGLXPixmapWithConfigSGIX(Display * dpy, - GLXFBConfigSGIX config, + GLXFBConfigSGIX fbconfig, Pixmap pixmap) { #ifndef GLX_USE_APPLEGL @@ -2154,19 +2147,19 @@ glXCreateGLXPixmapWithConfigSGIX(Display * dpy, CARD8 opcode; __GLXscreenConfigs *psc; #endif - const __GLcontextModes *const fbconfig = (__GLcontextModes *) config; + struct glx_config *config = (struct glx_config *) fbconfig; if ((dpy == NULL) || (config == NULL)) { return None; } #ifdef GLX_USE_APPLEGL - if(apple_glx_pixmap_create(dpy, fbconfig->screen, pixmap, fbconfig)) + if(apple_glx_pixmap_create(dpy, config->screen, pixmap, config)) return None; return pixmap; #else - psc = GetGLXScreenConfigs(dpy, fbconfig->screen); + psc = GetGLXScreenConfigs(dpy, config->screen); if ((psc != NULL) && __glXExtensionBitIsEnabled(psc, SGIX_fbconfig_bit)) { opcode = __glXSetupForCommand(dpy); @@ -2183,8 +2176,8 @@ glXCreateGLXPixmapWithConfigSGIX(Display * dpy, req->reqType = opcode; req->glxCode = X_GLXVendorPrivateWithReply; req->vendorCode = X_GLXvop_CreateGLXPixmapWithConfigSGIX; - req->screen = fbconfig->screen; - req->fbconfig = fbconfig->fbconfigID; + req->screen = config->screen; + req->fbconfig = config->fbconfigID; req->pixmap = pixmap; req->glxpixmap = xid = XAllocID(dpy); UnlockDisplay(dpy); @@ -2197,11 +2190,11 @@ glXCreateGLXPixmapWithConfigSGIX(Display * dpy, PUBLIC GLXContext glXCreateContextWithConfigSGIX(Display * dpy, - GLXFBConfigSGIX config, int renderType, + GLXFBConfigSGIX fbconfig, int renderType, GLXContext shareList, Bool allowDirect) { GLXContext gc = NULL; - const __GLcontextModes *const fbconfig = (__GLcontextModes *) config; + struct glx_config *config = (struct glx_config *) fbconfig; __GLXscreenConfigs *psc; @@ -2209,13 +2202,13 @@ glXCreateContextWithConfigSGIX(Display * dpy, return None; } - psc = GetGLXScreenConfigs(dpy, fbconfig->screen); + psc = GetGLXScreenConfigs(dpy, config->screen); if ((psc != NULL) && __glXExtensionBitIsEnabled(psc, SGIX_fbconfig_bit)) { - gc = CreateContext(dpy, fbconfig->fbconfigID, fbconfig, shareList, + gc = CreateContext(dpy, config->fbconfigID, config, shareList, allowDirect, X_GLXvop_CreateContextWithConfigSGIX, renderType, - fbconfig->screen); + config->screen); } return gc; @@ -2231,8 +2224,8 @@ glXGetFBConfigFromVisualSGIX(Display * dpy, XVisualInfo * vis) if ((GetGLXPrivScreenConfig(dpy, vis->screen, &priv, &psc) != Success) && __glXExtensionBitIsEnabled(psc, SGIX_fbconfig_bit) && (psc->configs->fbconfigID != (int) GLX_DONT_CARE)) { - return (GLXFBConfigSGIX) _gl_context_modes_find_visual(psc->configs, - vis->visualid); + return (GLXFBConfigSGIX) glx_config_find_visual(psc->configs, + vis->visualid); } return NULL; diff --git a/src/glx/glxcurrent.c b/src/glx/glxcurrent.c index e8649b6765..416e9c42c5 100644 --- a/src/glx/glxcurrent.c +++ b/src/glx/glxcurrent.c @@ -303,7 +303,7 @@ FetchDRIDrawable(Display * dpy, GLXDrawable glxDrawable, GLXContext gc) return pdraw; pdraw = psc->driScreen->createDrawable(psc, glxDrawable, - glxDrawable, gc->mode); + glxDrawable, gc->config); if (__glxHashInsert(priv->drawHash, glxDrawable, pdraw)) { (*pdraw->destroyDrawable) (pdraw); return NULL; diff --git a/src/glx/glxext.c b/src/glx/glxext.c index 7612e5e834..8e8b362d10 100644 --- a/src/glx/glxext.c +++ b/src/glx/glxext.c @@ -208,14 +208,14 @@ FreeScreenConfigs(__GLXdisplayPrivate * priv) for (i = 0; i < screens; i++) { psc = priv->screenConfigs[i]; if (psc->configs) { - _gl_context_modes_destroy(psc->configs); + glx_config_destroy_list(psc->configs); if (psc->effectiveGLXexts) Xfree(psc->effectiveGLXexts); psc->configs = NULL; /* NOTE: just for paranoia */ } if (psc->visuals) { - _gl_context_modes_destroy(psc->visuals); - psc->visuals = NULL; /* NOTE: just for paranoia */ + glx_config_destroy_list(psc->visuals); + psc->visuals = NULL; /* NOTE: just for paranoia */ } Xfree((char *) psc->serverGLXexts); @@ -349,12 +349,27 @@ enum { }; +static GLint +convert_from_x_visual_type(int visualType) +{ + static const int glx_visual_types[] = { + GLX_STATIC_GRAY, GLX_GRAY_SCALE, + GLX_STATIC_COLOR, GLX_PSEUDO_COLOR, + GLX_TRUE_COLOR, GLX_DIRECT_COLOR + }; + + if (visualType < ARRAY_SIZE(glx_visual_types)) + return glx_visual_types[visualType]; + + return GLX_NONE; +} + /* * getVisualConfigs uses the !tagged_only path. * getFBConfigs uses the tagged_only path. */ _X_HIDDEN void -__glXInitializeVisualConfigFromTags(__GLcontextModes * config, int count, +__glXInitializeVisualConfigFromTags(struct glx_config * config, int count, const INT32 * bp, Bool tagged_only, Bool fbconfig_style_tags) { @@ -364,7 +379,7 @@ __glXInitializeVisualConfigFromTags(__GLcontextModes * config, int count, /* Copy in the first set of properties */ config->visualID = *bp++; - config->visualType = _gl_convert_from_x_visual_type(*bp++); + config->visualType = convert_from_x_visual_type(*bp++); config->rgbMode = *bp++; @@ -575,13 +590,13 @@ __glXInitializeVisualConfigFromTags(__GLcontextModes * config, int count, (config->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT; } -static __GLcontextModes * +static struct glx_config * createConfigsFromProperties(Display * dpy, int nvisuals, int nprops, int screen, GLboolean tagged_only) { INT32 buf[__GLX_TOTAL_CONFIG], *props; unsigned prop_size; - __GLcontextModes *modes, *m; + struct glx_config *modes, *m; int i; if (nprops == 0) @@ -594,7 +609,7 @@ createConfigsFromProperties(Display * dpy, int nvisuals, int nprops, return NULL; /* Allocate memory for our config structure */ - modes = _gl_context_modes_create(nvisuals, sizeof(__GLcontextModes)); + modes = glx_config_create_list(nvisuals); if (!modes) return NULL; -- cgit v1.2.3