#include <dlfcn.h>
#include <stdarg.h>
#include "glxclient.h"
-#include "glcontextmodes.h"
#include "dri_common.h"
#ifndef RTLD_NOW
};
#define __ATTRIB(attrib, field) \
- { attrib, offsetof(__GLcontextModes, field) }
+ { attrib, offsetof(struct glx_config, field) }
static const struct
{
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;
}
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;
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;
glxValue = GLX_SLOW_CONFIG;
else
glxValue = GLX_NONE;
- if (glxValue != modes->visualRating)
+ if (glxValue != config->visualRating)
return GL_FALSE;
break;
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;
}
}
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;
tail = tail->next;
}
- _gl_context_modes_destroy(modes);
+ glx_config_destroy_list(configs);
return head.next;
}
free(configs);
}
+_X_HIDDEN __GLXDRIdrawable *
+driFetchDrawable(struct glx_context *gc, GLXDrawable glxDrawable)
+{
+ struct glx_display *const priv = __glXInitialize(gc->psc->dpy);
+ __GLXDRIdrawable *pdraw;
+ struct glx_screen *psc;
+
+ if (priv == NULL)
+ return NULL;
+
+ psc = priv->screens[gc->screen];
+ if (priv->drawHash == NULL)
+ return NULL;
+
+ if (__glxHashLookup(priv->drawHash, glxDrawable, (void *) &pdraw) == 0)
+ return pdraw;
+
+ pdraw = psc->driScreen->createDrawable(psc, glxDrawable,
+ glxDrawable, gc->config);
+ if (__glxHashInsert(priv->drawHash, glxDrawable, pdraw)) {
+ (*pdraw->destroyDrawable) (pdraw);
+ return NULL;
+ }
+
+ return pdraw;
+}
+
+_X_HIDDEN void
+driReleaseDrawables(struct glx_context *gc)
+{
+ struct glx_display *const priv = __glXInitialize(gc->psc->dpy);
+ __GLXDRIdrawable *pdraw;
+
+ if (priv == NULL)
+ return;
+
+ if (__glxHashLookup(priv->drawHash,
+ gc->currentDrawable, (void *) &pdraw) == 0) {
+ if (pdraw->drawable == pdraw->xDrawable) {
+ (*pdraw->destroyDrawable)(pdraw);
+ __glxHashDelete(priv->drawHash, gc->currentDrawable);
+ }
+ }
+
+ if (gc->currentDrawable != gc->currentReadable &&
+ __glxHashLookup(priv->drawHash,
+ gc->currentReadable, (void *) &pdraw) == 0) {
+ if (pdraw->drawable == pdraw->xDrawable) {
+ (*pdraw->destroyDrawable)(pdraw);
+ __glxHashDelete(priv->drawHash, gc->currentReadable);
+ }
+ }
+}
+
#endif /* GLX_DIRECT_RENDERING */