2008-06-09 15:47:09 +01:00
|
|
|
/*
|
|
|
|
* Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
|
|
|
|
* Copyright © 2008 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Soft-
|
|
|
|
* ware"), to deal in the Software without restriction, including without
|
|
|
|
* limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, provided that the above copyright
|
|
|
|
* notice(s) and this permission notice appear in all copies of the Soft-
|
|
|
|
* ware and that both the above copyright notice(s) and this permission
|
|
|
|
* notice appear in supporting documentation.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
|
|
|
|
* ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
|
|
|
|
* RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
|
|
|
|
* THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
|
|
|
|
* QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
|
|
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
|
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
|
|
|
|
* MANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* Except as contained in this notice, the name of a copyright holder shall
|
|
|
|
* not be used in advertising or otherwise to promote the sale, use or
|
|
|
|
* other dealings in this Software without prior written authorization of
|
|
|
|
* the copyright holder.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Kevin E. Martin <kevin@precisioninsight.com>
|
|
|
|
* Brian Paul <brian@precisioninsight.com>
|
|
|
|
* Kristian Høgsberg (krh@redhat.com)
|
|
|
|
*/
|
|
|
|
|
2010-04-02 09:35:19 +01:00
|
|
|
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
|
2008-06-09 15:47:09 +01:00
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <dlfcn.h>
|
2008-09-18 20:26:30 +01:00
|
|
|
#include <stdarg.h>
|
2008-06-09 15:47:09 +01:00
|
|
|
#include "glxclient.h"
|
|
|
|
#include "dri_common.h"
|
|
|
|
|
|
|
|
#ifndef RTLD_NOW
|
|
|
|
#define RTLD_NOW 0
|
|
|
|
#endif
|
|
|
|
#ifndef RTLD_GLOBAL
|
|
|
|
#define RTLD_GLOBAL 0
|
|
|
|
#endif
|
|
|
|
|
2009-08-12 11:41:22 +01:00
|
|
|
_X_HIDDEN void
|
|
|
|
InfoMessageF(const char *f, ...)
|
2008-06-09 15:47:09 +01:00
|
|
|
{
|
2009-08-12 11:41:22 +01:00
|
|
|
va_list args;
|
|
|
|
const char *env;
|
|
|
|
|
|
|
|
if ((env = getenv("LIBGL_DEBUG")) && strstr(env, "verbose")) {
|
|
|
|
fprintf(stderr, "libGL: ");
|
|
|
|
va_start(args, f);
|
|
|
|
vfprintf(stderr, f, args);
|
|
|
|
va_end(args);
|
|
|
|
}
|
2008-06-09 15:47:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Print error to stderr, unless LIBGL_DEBUG=="quiet".
|
|
|
|
*/
|
2009-08-12 11:41:22 +01:00
|
|
|
_X_HIDDEN void
|
|
|
|
ErrorMessageF(const char *f, ...)
|
2008-06-09 15:47:09 +01:00
|
|
|
{
|
2009-08-12 11:41:22 +01:00
|
|
|
va_list args;
|
|
|
|
const char *env;
|
|
|
|
|
|
|
|
if ((env = getenv("LIBGL_DEBUG")) && !strstr(env, "quiet")) {
|
|
|
|
fprintf(stderr, "libGL error: ");
|
|
|
|
va_start(args, f);
|
|
|
|
vfprintf(stderr, f, args);
|
|
|
|
va_end(args);
|
|
|
|
}
|
2008-06-09 15:47:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef DEFAULT_DRIVER_DIR
|
|
|
|
/* this is normally defined in Mesa/configs/default with DRI_DRIVER_SEARCH_PATH */
|
|
|
|
#define DEFAULT_DRIVER_DIR "/usr/local/lib/dri"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Try to \c dlopen the named driver.
|
|
|
|
*
|
|
|
|
* This function adds the "_dri.so" suffix to the driver name and searches the
|
|
|
|
* directories specified by the \c LIBGL_DRIVERS_PATH environment variable in
|
|
|
|
* order to find the driver.
|
|
|
|
*
|
|
|
|
* \param driverName - a name like "tdfx", "i810", "mga", etc.
|
|
|
|
*
|
|
|
|
* \returns
|
|
|
|
* A handle from \c dlopen, or \c NULL if driver file not found.
|
|
|
|
*/
|
2009-08-12 11:41:22 +01:00
|
|
|
_X_HIDDEN void *
|
|
|
|
driOpenDriver(const char *driverName)
|
2008-06-09 15:47:09 +01:00
|
|
|
{
|
|
|
|
void *glhandle, *handle;
|
|
|
|
const char *libPaths, *p, *next;
|
|
|
|
char realDriverName[200];
|
|
|
|
int len;
|
|
|
|
|
|
|
|
/* Attempt to make sure libGL symbols will be visible to the driver */
|
|
|
|
glhandle = dlopen("libGL.so.1", RTLD_NOW | RTLD_GLOBAL);
|
|
|
|
|
|
|
|
libPaths = NULL;
|
|
|
|
if (geteuid() == getuid()) {
|
|
|
|
/* don't allow setuid apps to use LIBGL_DRIVERS_PATH */
|
|
|
|
libPaths = getenv("LIBGL_DRIVERS_PATH");
|
|
|
|
if (!libPaths)
|
2009-08-12 11:41:22 +01:00
|
|
|
libPaths = getenv("LIBGL_DRIVERS_DIR"); /* deprecated */
|
2008-06-09 15:47:09 +01:00
|
|
|
}
|
|
|
|
if (libPaths == NULL)
|
2009-08-12 11:41:22 +01:00
|
|
|
libPaths = DEFAULT_DRIVER_DIR;
|
2008-06-09 15:47:09 +01:00
|
|
|
|
|
|
|
handle = NULL;
|
|
|
|
for (p = libPaths; *p; p = next) {
|
2009-08-12 11:41:22 +01:00
|
|
|
next = strchr(p, ':');
|
|
|
|
if (next == NULL) {
|
|
|
|
len = strlen(p);
|
|
|
|
next = p + len;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
len = next - p;
|
|
|
|
next++;
|
|
|
|
}
|
2008-06-09 15:47:09 +01:00
|
|
|
|
|
|
|
#ifdef GLX_USE_TLS
|
|
|
|
snprintf(realDriverName, sizeof realDriverName,
|
2009-08-12 11:41:22 +01:00
|
|
|
"%.*s/tls/%s_dri.so", len, p, driverName);
|
2008-06-09 15:47:09 +01:00
|
|
|
InfoMessageF("OpenDriver: trying %s\n", realDriverName);
|
|
|
|
handle = dlopen(realDriverName, RTLD_NOW | RTLD_GLOBAL);
|
|
|
|
#endif
|
|
|
|
|
2009-08-12 11:41:22 +01:00
|
|
|
if (handle == NULL) {
|
|
|
|
snprintf(realDriverName, sizeof realDriverName,
|
|
|
|
"%.*s/%s_dri.so", len, p, driverName);
|
|
|
|
InfoMessageF("OpenDriver: trying %s\n", realDriverName);
|
|
|
|
handle = dlopen(realDriverName, RTLD_NOW | RTLD_GLOBAL);
|
2008-06-09 15:47:09 +01:00
|
|
|
}
|
|
|
|
|
2009-08-12 11:41:22 +01:00
|
|
|
if (handle != NULL)
|
|
|
|
break;
|
2008-06-09 15:47:09 +01:00
|
|
|
else
|
2009-08-12 11:41:22 +01:00
|
|
|
ErrorMessageF("dlopen %s failed (%s)\n", realDriverName, dlerror());
|
2008-06-09 15:47:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!handle)
|
|
|
|
ErrorMessageF("unable to load driver: %s_dri.so\n", driverName);
|
|
|
|
|
|
|
|
if (glhandle)
|
|
|
|
dlclose(glhandle);
|
|
|
|
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
2010-07-21 19:09:49 +01:00
|
|
|
static GLboolean
|
|
|
|
__driGetMSCRate(__DRIdrawable *draw,
|
|
|
|
int32_t * numerator, int32_t * denominator,
|
|
|
|
void *loaderPrivate)
|
|
|
|
{
|
|
|
|
__GLXDRIdrawable *glxDraw = loaderPrivate;
|
|
|
|
|
|
|
|
return __glxGetMscRate(glxDraw, numerator, denominator);
|
|
|
|
}
|
|
|
|
|
2008-06-09 15:47:09 +01:00
|
|
|
_X_HIDDEN const __DRIsystemTimeExtension systemTimeExtension = {
|
2009-08-12 11:41:22 +01:00
|
|
|
{__DRI_SYSTEM_TIME, __DRI_SYSTEM_TIME_VERSION},
|
|
|
|
__glXGetUST,
|
2010-07-21 19:09:49 +01:00
|
|
|
__driGetMSCRate
|
2008-06-09 15:47:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#define __ATTRIB(attrib, field) \
|
2010-07-28 15:07:52 +01:00
|
|
|
{ attrib, offsetof(struct glx_config, field) }
|
2008-06-09 15:47:09 +01:00
|
|
|
|
2009-08-12 11:41:22 +01:00
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
unsigned int attrib, offset;
|
|
|
|
} attribMap[] = {
|
|
|
|
__ATTRIB(__DRI_ATTRIB_BUFFER_SIZE, rgbBits),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_LEVEL, level),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_RED_SIZE, redBits),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_GREEN_SIZE, greenBits),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_BLUE_SIZE, blueBits),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_ALPHA_SIZE, alphaBits),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_DEPTH_SIZE, depthBits),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_STENCIL_SIZE, stencilBits),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_ACCUM_RED_SIZE, accumRedBits),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_ACCUM_GREEN_SIZE, accumGreenBits),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_ACCUM_BLUE_SIZE, accumBlueBits),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_ACCUM_ALPHA_SIZE, accumAlphaBits),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_SAMPLE_BUFFERS, sampleBuffers),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_SAMPLES, samples),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_DOUBLE_BUFFER, doubleBufferMode),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_STEREO, stereoMode),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_AUX_BUFFERS, numAuxBuffers),
|
2008-06-09 15:47:09 +01:00
|
|
|
#if 0
|
2009-08-12 11:41:22 +01:00
|
|
|
__ATTRIB(__DRI_ATTRIB_TRANSPARENT_TYPE, transparentPixel),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_TRANSPARENT_INDEX_VALUE, transparentIndex),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_TRANSPARENT_RED_VALUE, transparentRed),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_TRANSPARENT_GREEN_VALUE, transparentGreen),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_TRANSPARENT_BLUE_VALUE, transparentBlue),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE, transparentAlpha),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_RED_MASK, redMask),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_GREEN_MASK, greenMask),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_BLUE_MASK, blueMask),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_ALPHA_MASK, alphaMask),
|
2008-06-09 15:47:09 +01:00
|
|
|
#endif
|
2009-08-12 11:41:22 +01:00
|
|
|
__ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_WIDTH, maxPbufferWidth),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_HEIGHT, maxPbufferHeight),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_PIXELS, maxPbufferPixels),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH, optimalPbufferWidth),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT, optimalPbufferHeight),
|
2008-06-09 15:47:09 +01:00
|
|
|
#if 0
|
2009-08-12 11:41:22 +01:00
|
|
|
__ATTRIB(__DRI_ATTRIB_SWAP_METHOD, swapMethod),
|
2008-06-09 15:47:09 +01:00
|
|
|
#endif
|
2009-08-12 11:41:22 +01:00
|
|
|
__ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGB, bindToTextureRgb),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGBA, bindToTextureRgba),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE,
|
|
|
|
bindToMipmapTexture),
|
2011-03-06 10:06:42 +00:00
|
|
|
__ATTRIB(__DRI_ATTRIB_YINVERTED, yInverted),
|
|
|
|
__ATTRIB(__DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE, sRGBCapable)
|
|
|
|
};
|
2008-06-09 15:47:09 +01:00
|
|
|
|
|
|
|
static int
|
2010-07-28 15:07:52 +01:00
|
|
|
scalarEqual(struct glx_config *mode, unsigned int attrib, unsigned int value)
|
2008-06-09 15:47:09 +01:00
|
|
|
{
|
2009-08-12 11:41:22 +01:00
|
|
|
unsigned int glxValue;
|
|
|
|
int i;
|
2008-06-09 15:47:09 +01:00
|
|
|
|
2009-08-12 11:41:22 +01:00
|
|
|
for (i = 0; i < ARRAY_SIZE(attribMap); i++)
|
|
|
|
if (attribMap[i].attrib == attrib) {
|
|
|
|
glxValue = *(unsigned int *) ((char *) mode + attribMap[i].offset);
|
|
|
|
return glxValue == GLX_DONT_CARE || glxValue == value;
|
|
|
|
}
|
2008-06-09 15:47:09 +01:00
|
|
|
|
2009-08-12 11:41:22 +01:00
|
|
|
return GL_TRUE; /* Is a non-existing attribute equal to value? */
|
2008-06-09 15:47:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-07-28 15:07:52 +01:00
|
|
|
driConfigEqual(const __DRIcoreExtension *core,
|
|
|
|
struct glx_config *config, const __DRIconfig *driConfig)
|
2008-06-09 15:47:09 +01:00
|
|
|
{
|
2009-08-12 11:41:22 +01:00
|
|
|
unsigned int attrib, value, glxValue;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (core->indexConfigAttrib(driConfig, i++, &attrib, &value)) {
|
|
|
|
switch (attrib) {
|
|
|
|
case __DRI_ATTRIB_RENDER_TYPE:
|
|
|
|
glxValue = 0;
|
|
|
|
if (value & __DRI_ATTRIB_RGBA_BIT) {
|
|
|
|
glxValue |= GLX_RGBA_BIT;
|
|
|
|
}
|
|
|
|
else if (value & __DRI_ATTRIB_COLOR_INDEX_BIT) {
|
|
|
|
glxValue |= GLX_COLOR_INDEX_BIT;
|
|
|
|
}
|
2010-07-28 15:07:52 +01:00
|
|
|
if (glxValue != config->renderType)
|
2009-08-12 11:41:22 +01:00
|
|
|
return GL_FALSE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case __DRI_ATTRIB_CONFIG_CAVEAT:
|
|
|
|
if (value & __DRI_ATTRIB_NON_CONFORMANT_CONFIG)
|
|
|
|
glxValue = GLX_NON_CONFORMANT_CONFIG;
|
|
|
|
else if (value & __DRI_ATTRIB_SLOW_BIT)
|
|
|
|
glxValue = GLX_SLOW_CONFIG;
|
|
|
|
else
|
|
|
|
glxValue = GLX_NONE;
|
2010-07-28 15:07:52 +01:00
|
|
|
if (glxValue != config->visualRating)
|
2009-08-12 11:41:22 +01:00
|
|
|
return GL_FALSE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS:
|
|
|
|
glxValue = 0;
|
|
|
|
if (value & __DRI_ATTRIB_TEXTURE_1D_BIT)
|
|
|
|
glxValue |= GLX_TEXTURE_1D_BIT_EXT;
|
|
|
|
if (value & __DRI_ATTRIB_TEXTURE_2D_BIT)
|
|
|
|
glxValue |= GLX_TEXTURE_2D_BIT_EXT;
|
|
|
|
if (value & __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT)
|
|
|
|
glxValue |= GLX_TEXTURE_RECTANGLE_BIT_EXT;
|
2010-07-28 15:07:52 +01:00
|
|
|
if (config->bindToTextureTargets != GLX_DONT_CARE &&
|
|
|
|
glxValue != config->bindToTextureTargets)
|
2009-08-12 11:41:22 +01:00
|
|
|
return GL_FALSE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2010-07-28 15:07:52 +01:00
|
|
|
if (!scalarEqual(config, attrib, value))
|
2009-08-12 11:41:22 +01:00
|
|
|
return GL_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return GL_TRUE;
|
2008-06-09 15:47:09 +01:00
|
|
|
}
|
|
|
|
|
2010-07-28 15:07:52 +01:00
|
|
|
static struct glx_config *
|
2009-08-12 11:41:22 +01:00
|
|
|
createDriMode(const __DRIcoreExtension * core,
|
2010-07-28 15:07:52 +01:00
|
|
|
struct glx_config *config, const __DRIconfig **driConfigs)
|
2008-06-09 15:47:09 +01:00
|
|
|
{
|
2010-07-28 15:07:52 +01:00
|
|
|
__GLXDRIconfigPrivate *driConfig;
|
2009-08-12 11:41:22 +01:00
|
|
|
int i;
|
2008-06-09 15:47:09 +01:00
|
|
|
|
2009-08-12 11:41:22 +01:00
|
|
|
for (i = 0; driConfigs[i]; i++) {
|
2010-07-28 15:07:52 +01:00
|
|
|
if (driConfigEqual(core, config, driConfigs[i]))
|
2009-08-12 11:41:22 +01:00
|
|
|
break;
|
|
|
|
}
|
2008-06-09 15:47:09 +01:00
|
|
|
|
2009-08-12 11:41:22 +01:00
|
|
|
if (driConfigs[i] == NULL)
|
|
|
|
return NULL;
|
2008-06-09 15:47:09 +01:00
|
|
|
|
2010-07-28 15:07:52 +01:00
|
|
|
driConfig = Xmalloc(sizeof *driConfig);
|
|
|
|
if (driConfig == NULL)
|
2009-08-12 11:41:22 +01:00
|
|
|
return NULL;
|
2008-06-09 15:47:09 +01:00
|
|
|
|
2010-07-28 15:07:52 +01:00
|
|
|
driConfig->base = *config;
|
|
|
|
driConfig->driConfig = driConfigs[i];
|
2008-06-09 15:47:09 +01:00
|
|
|
|
2010-07-28 15:07:52 +01:00
|
|
|
return &driConfig->base;
|
2008-06-09 15:47:09 +01:00
|
|
|
}
|
|
|
|
|
2010-07-28 15:07:52 +01:00
|
|
|
_X_HIDDEN struct glx_config *
|
2009-08-12 11:41:22 +01:00
|
|
|
driConvertConfigs(const __DRIcoreExtension * core,
|
2010-07-28 15:07:52 +01:00
|
|
|
struct glx_config *configs, const __DRIconfig **driConfigs)
|
2008-06-09 15:47:09 +01:00
|
|
|
{
|
2010-07-28 15:07:52 +01:00
|
|
|
struct glx_config head, *tail, *m;
|
2009-08-12 11:41:22 +01:00
|
|
|
|
|
|
|
tail = &head;
|
|
|
|
head.next = NULL;
|
2010-07-28 15:07:52 +01:00
|
|
|
for (m = configs; m; m = m->next) {
|
|
|
|
tail->next = createDriMode(core, m, driConfigs);
|
2009-08-12 11:41:22 +01:00
|
|
|
if (tail->next == NULL) {
|
|
|
|
/* no matching dri config for m */
|
|
|
|
continue;
|
|
|
|
}
|
2008-06-09 15:47:09 +01:00
|
|
|
|
|
|
|
|
2009-08-12 11:41:22 +01:00
|
|
|
tail = tail->next;
|
|
|
|
}
|
2008-06-09 15:47:09 +01:00
|
|
|
|
2010-07-28 15:07:52 +01:00
|
|
|
glx_config_destroy_list(configs);
|
2008-10-15 04:07:42 +01:00
|
|
|
|
2009-08-12 11:41:22 +01:00
|
|
|
return head.next;
|
2008-06-09 15:47:09 +01:00
|
|
|
}
|
|
|
|
|
2010-07-20 03:12:22 +01:00
|
|
|
_X_HIDDEN void
|
|
|
|
driDestroyConfigs(const __DRIconfig **configs)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; configs[i]; i++)
|
|
|
|
free((__DRIconfig *) configs[i]);
|
|
|
|
free(configs);
|
|
|
|
}
|
|
|
|
|
2010-07-28 20:33:09 +01:00
|
|
|
_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;
|
|
|
|
|
2011-06-15 23:09:12 +01:00
|
|
|
if (__glxHashLookup(priv->drawHash, glxDrawable, (void *) &pdraw) == 0) {
|
|
|
|
pdraw->refcount ++;
|
2010-07-28 20:33:09 +01:00
|
|
|
return pdraw;
|
2011-06-15 23:09:12 +01:00
|
|
|
}
|
2010-07-28 20:33:09 +01:00
|
|
|
|
|
|
|
pdraw = psc->driScreen->createDrawable(psc, glxDrawable,
|
|
|
|
glxDrawable, gc->config);
|
|
|
|
if (__glxHashInsert(priv->drawHash, glxDrawable, pdraw)) {
|
|
|
|
(*pdraw->destroyDrawable) (pdraw);
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-06-15 23:09:12 +01:00
|
|
|
pdraw->refcount = 1;
|
2010-07-28 20:33:09 +01:00
|
|
|
|
|
|
|
return pdraw;
|
|
|
|
}
|
|
|
|
|
2010-08-27 17:40:11 +01:00
|
|
|
_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) {
|
2010-09-29 13:32:12 +01:00
|
|
|
if (pdraw->drawable == pdraw->xDrawable) {
|
2011-06-15 23:09:12 +01:00
|
|
|
pdraw->refcount --;
|
|
|
|
if (pdraw->refcount == 0) {
|
|
|
|
(*pdraw->destroyDrawable)(pdraw);
|
|
|
|
__glxHashDelete(priv->drawHash, gc->currentDrawable);
|
|
|
|
}
|
2010-09-29 13:32:12 +01:00
|
|
|
}
|
2010-08-27 17:40:11 +01:00
|
|
|
}
|
|
|
|
|
2011-06-15 23:09:12 +01:00
|
|
|
if (__glxHashLookup(priv->drawHash,
|
2010-08-27 17:40:11 +01:00
|
|
|
gc->currentReadable, (void *) &pdraw) == 0) {
|
2010-09-29 13:32:12 +01:00
|
|
|
if (pdraw->drawable == pdraw->xDrawable) {
|
2011-06-15 23:09:12 +01:00
|
|
|
pdraw->refcount --;
|
|
|
|
if (pdraw->refcount == 0) {
|
|
|
|
(*pdraw->destroyDrawable)(pdraw);
|
|
|
|
__glxHashDelete(priv->drawHash, gc->currentReadable);
|
|
|
|
}
|
2010-09-29 13:32:12 +01:00
|
|
|
}
|
2010-08-27 17:40:11 +01:00
|
|
|
}
|
2011-06-15 23:09:12 +01:00
|
|
|
|
|
|
|
gc->currentDrawable = None;
|
|
|
|
gc->currentReadable = None;
|
|
|
|
|
2010-08-27 17:40:11 +01:00
|
|
|
}
|
|
|
|
|
2008-06-09 15:47:09 +01:00
|
|
|
#endif /* GLX_DIRECT_RENDERING */
|