2004-06-30 22:06:56 +02:00
|
|
|
/*
|
Update to SGI FreeB 2.0.
Under the terms of version 1.1, "once Covered Code has been published
under a particular version of the License, Recipient may, for the
duration of the License, continue to use it under the terms of that
version, or choose to use such Covered Code under the terms of any
subsequent version published by SGI."
FreeB 2.0 license refers to "dates of first publication". They are here
taken to be 1991-2000, as noted in the original license text:
** Original Code. The Original Code is: OpenGL Sample Implementation,
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
** Copyright in any portions created by third parties is as indicated
** elsewhere herein. All Rights Reserved.
Official FreeB 2.0 text:
http://oss.sgi.com/projects/FreeB/SGIFreeSWLicB.2.0.pdf
As always, this code has not been tested for conformance with the OpenGL
specification. OpenGL conformance testing is available from
http://khronos.org/ and is required for use of the OpenGL logo in
product advertising and promotion.
2008-09-19 18:02:28 +02:00
|
|
|
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
|
|
|
|
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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, sublicense,
|
|
|
|
* 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 including the dates of first publication and
|
|
|
|
* either this permission notice or a reference to
|
|
|
|
* http://oss.sgi.com/projects/FreeB/
|
|
|
|
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* SILICON GRAPHICS, INC. 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.
|
|
|
|
*
|
|
|
|
* Except as contained in this notice, the name of Silicon Graphics, Inc.
|
|
|
|
* shall not be used in advertising or otherwise to promote the sale, use or
|
|
|
|
* other dealings in this Software without prior written authorization from
|
|
|
|
* Silicon Graphics, Inc.
|
|
|
|
*/
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2005-07-27 10:16:35 +02:00
|
|
|
#ifdef HAVE_DMX_CONFIG_H
|
|
|
|
#include <dmx-config.h>
|
|
|
|
#endif
|
|
|
|
|
2004-06-30 22:06:56 +02:00
|
|
|
#include "dmx.h"
|
|
|
|
#include "dmxwindow.h"
|
|
|
|
#include "dmxpixmap.h"
|
|
|
|
#include "dmxfont.h"
|
|
|
|
#include "dmxsync.h"
|
|
|
|
|
|
|
|
#include "glxserver.h"
|
|
|
|
#include <GL/glxtokens.h>
|
|
|
|
#include "g_disptab.h"
|
|
|
|
#include <pixmapstr.h>
|
|
|
|
#include <windowstr.h>
|
|
|
|
#include "glxutil.h"
|
|
|
|
#include "glxext.h"
|
|
|
|
#include "unpack.h"
|
|
|
|
|
|
|
|
#include "GL/glxproto.h"
|
|
|
|
#include "glxvendor.h"
|
|
|
|
#include "glxvisuals.h"
|
|
|
|
#include "glxswap.h"
|
|
|
|
|
2011-11-07 23:14:30 +01:00
|
|
|
#include "glxcmds.h"
|
|
|
|
|
2004-06-30 22:06:56 +02:00
|
|
|
#ifdef PANORAMIX
|
|
|
|
#include "panoramiXsrv.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern __GLXFBConfig **__glXFBConfigs;
|
2012-03-21 20:55:09 +01:00
|
|
|
extern int __glXNumFBConfigs;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
extern int glxIsExtensionSupported(char *ext);
|
|
|
|
extern int __glXGetFBConfigsSGIX(__GLXclientState * cl, GLbyte * pc);
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
#define BE_TO_CLIENT_ERROR(x) \
|
|
|
|
( (x) >= __glXerrorBase ? \
|
|
|
|
(x) - dmxScreen->glxErrorBase + __glXerrorBase \
|
|
|
|
: (x) )
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
static __GLXFBConfig *
|
|
|
|
glxLookupFBConfig(GLXFBConfigID id)
|
2010-05-26 01:23:31 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
int i, j;
|
2010-05-26 01:23:31 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
for (i = 0, j = 0; i < __glXNumFBConfigs;
|
|
|
|
i++, j += (__glXNumActiveScreens + 1)) {
|
|
|
|
if (__glXFBConfigs[j]->id == id)
|
|
|
|
return __glXFBConfigs[j];
|
|
|
|
}
|
2010-05-26 01:23:31 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
return NULL;
|
2010-05-26 01:23:31 +02:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
static __GLXFBConfig *
|
|
|
|
glxLookupFBConfigByVID(VisualID vid)
|
2010-05-26 01:23:31 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
int i, j;
|
2010-05-26 01:23:31 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
for (i = 0, j = 0; i < __glXNumFBConfigs;
|
|
|
|
i++, j += (__glXNumActiveScreens + 1)) {
|
|
|
|
if (__glXFBConfigs[j]->associatedVisualId == vid)
|
|
|
|
return __glXFBConfigs[j];
|
|
|
|
}
|
2010-05-26 01:23:31 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
return NULL;
|
2010-05-26 01:23:31 +02:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
static __GLXFBConfig *
|
|
|
|
glxLookupBackEndFBConfig(GLXFBConfigID id, int screen)
|
2010-05-26 01:23:31 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
int i;
|
|
|
|
int j;
|
2010-05-26 01:23:31 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
for (i = 0, j = 0; i < __glXNumFBConfigs;
|
|
|
|
i++, j += (__glXNumActiveScreens + 1)) {
|
|
|
|
if (__glXFBConfigs[j]->id == id)
|
|
|
|
return __glXFBConfigs[j + screen + 1];
|
|
|
|
}
|
2010-05-26 01:23:31 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
return NULL;
|
2010-05-26 01:23:31 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
Display *
|
|
|
|
GetBackEndDisplay(__GLXclientState * cl, int s)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!cl->be_displays[s]) {
|
|
|
|
cl->be_displays[s] =
|
|
|
|
XOpenDisplay(DisplayString(dmxScreens[s].beDisplay));
|
|
|
|
}
|
|
|
|
return cl->be_displays[s];
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
2013-10-21 19:57:53 +02:00
|
|
|
/**
|
|
|
|
* Convert the render type bits from fbconfig into context render type.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
renderTypeBitsToRenderTypeEnum(int fbRenderType)
|
|
|
|
{
|
|
|
|
if (fbRenderType & GLX_RGBA_BIT)
|
|
|
|
return GLX_RGBA_TYPE;
|
|
|
|
|
|
|
|
if (fbRenderType & GLX_COLOR_INDEX_BIT)
|
|
|
|
return GLX_COLOR_INDEX_TYPE;
|
|
|
|
|
|
|
|
if (fbRenderType & GLX_RGBA_FLOAT_BIT_ARB)
|
|
|
|
return GLX_RGBA_FLOAT_TYPE_ARB;
|
|
|
|
|
|
|
|
if (fbRenderType & GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT)
|
|
|
|
return GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT;
|
|
|
|
|
|
|
|
/* There's no recognized renderType in the config */
|
|
|
|
return GLX_RGBA_TYPE;
|
|
|
|
}
|
|
|
|
|
2004-06-30 22:06:56 +02:00
|
|
|
/*
|
|
|
|
** Create a GL context with the given properties.
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
static int
|
|
|
|
CreateContext(__GLXclientState * cl,
|
|
|
|
GLXContextID gcId,
|
|
|
|
VisualID vid, GLXFBConfigID fbconfigId,
|
|
|
|
int screen, GLXContextID shareList, int isDirect)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
ClientPtr client = cl->client;
|
|
|
|
xGLXCreateContextReq *be_req;
|
|
|
|
xGLXCreateNewContextReq *be_new_req;
|
|
|
|
VisualPtr pVisual;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
__GLXcontext *glxc, *shareglxc;
|
|
|
|
__GLXvisualConfig *pGlxVisual;
|
|
|
|
__GLXscreenInfo *pGlxScreen;
|
|
|
|
VisualID visual = vid;
|
|
|
|
GLint i;
|
|
|
|
int from_screen = screen;
|
|
|
|
int to_screen = screen;
|
|
|
|
DMXScreenInfo *dmxScreen;
|
2011-02-08 20:07:20 +01:00
|
|
|
VisualID be_vid = 0;
|
|
|
|
GLXFBConfigID be_fbconfigId = 0;
|
2004-06-30 22:06:56 +02:00
|
|
|
int num_be_screens;
|
|
|
|
Display *dpy;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2004-06-30 22:06:56 +02:00
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Check if screen exists.
|
|
|
|
*/
|
2004-06-30 22:06:56 +02:00
|
|
|
if (screen >= screenInfo.numScreens) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = screen;
|
|
|
|
return BadValue;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
if (!noPanoramiXExtension) {
|
2012-03-21 20:55:09 +01:00
|
|
|
from_screen = 0;
|
|
|
|
to_screen = screenInfo.numScreens - 1;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Find the display list space that we want to share.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
if (shareList == None) {
|
2012-03-21 20:55:09 +01:00
|
|
|
shareglxc = NULL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dixLookupResourceByType((pointer *) &shareglxc, shareList,
|
|
|
|
__glXContextRes, NullClient, DixUnknownAccess);
|
|
|
|
if (!shareglxc) {
|
|
|
|
client->errorValue = shareList;
|
|
|
|
return __glXBadContext;
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Allocate memory for the new context
|
|
|
|
*/
|
2010-05-25 22:28:32 +02:00
|
|
|
glxc = calloc(1, sizeof(__GLXcontext));
|
2004-06-30 22:06:56 +02:00
|
|
|
if (!glxc) {
|
2012-03-21 20:55:09 +01:00
|
|
|
return BadAlloc;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
pScreen = screenInfo.screens[screen];
|
|
|
|
pGlxScreen = &__glXActiveScreens[screen];
|
|
|
|
|
|
|
|
if (fbconfigId != None) {
|
2012-03-21 20:55:09 +01:00
|
|
|
glxc->pFBConfig = glxLookupFBConfig(fbconfigId);
|
|
|
|
if (!glxc->pFBConfig) {
|
|
|
|
client->errorValue = fbconfigId;
|
|
|
|
free(glxc);
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
visual = glxc->pFBConfig->associatedVisualId;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
else {
|
2012-03-21 20:55:09 +01:00
|
|
|
glxc->pFBConfig = NULL;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (visual != None) {
|
2012-03-21 20:55:09 +01:00
|
|
|
/*
|
|
|
|
** Check if the visual ID is valid for this screen.
|
|
|
|
*/
|
|
|
|
pVisual = pScreen->visuals;
|
|
|
|
for (i = 0; i < pScreen->numVisuals; i++, pVisual++) {
|
|
|
|
if (pVisual->vid == visual) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == pScreen->numVisuals) {
|
|
|
|
client->errorValue = visual;
|
|
|
|
free(glxc);
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
pGlxVisual = pGlxScreen->pGlxVisual;
|
|
|
|
for (i = 0; i < pGlxScreen->numVisuals; i++, pGlxVisual++) {
|
|
|
|
if (pGlxVisual->vid == visual) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == pGlxScreen->numVisuals) {
|
|
|
|
/*
|
|
|
|
** Visual not support on this screen by this OpenGL implementation.
|
|
|
|
*/
|
|
|
|
client->errorValue = visual;
|
|
|
|
free(glxc);
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (glxc->pFBConfig == NULL) {
|
|
|
|
glxc->pFBConfig = glxLookupFBConfigByVID(visual);
|
|
|
|
|
|
|
|
if (glxc->pFBConfig == NULL) {
|
|
|
|
/*
|
|
|
|
* visual does not have an FBConfig ???
|
|
|
|
client->errorValue = visual;
|
|
|
|
free( glxc );
|
|
|
|
return BadValue;
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
else {
|
2012-03-21 20:55:09 +01:00
|
|
|
pVisual = NULL;
|
|
|
|
pGlxVisual = NULL;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
glxc->pScreen = pScreen;
|
|
|
|
glxc->pGlxScreen = pGlxScreen;
|
|
|
|
glxc->pVisual = pVisual;
|
|
|
|
glxc->pGlxVisual = pGlxVisual;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* allocate memory for back-end servers info
|
|
|
|
*/
|
|
|
|
num_be_screens = to_screen - from_screen + 1;
|
2012-03-21 20:55:09 +01:00
|
|
|
glxc->real_ids = (XID *) malloc(sizeof(XID) * num_be_screens);
|
2004-06-30 22:06:56 +02:00
|
|
|
if (!glxc->real_ids) {
|
2012-03-21 20:55:09 +01:00
|
|
|
return BadAlloc;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
glxc->real_vids = (XID *) malloc(sizeof(XID) * num_be_screens);
|
2004-06-30 22:06:56 +02:00
|
|
|
if (!glxc->real_vids) {
|
2012-03-21 20:55:09 +01:00
|
|
|
return BadAlloc;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (screen = from_screen; screen <= to_screen; screen++) {
|
2012-03-21 20:55:09 +01:00
|
|
|
int sent = 0;
|
|
|
|
|
|
|
|
pScreen = screenInfo.screens[screen];
|
|
|
|
pGlxScreen = &__glXActiveScreens[screen];
|
|
|
|
dmxScreen = &dmxScreens[screen];
|
|
|
|
|
|
|
|
if (glxc->pFBConfig) {
|
|
|
|
__GLXFBConfig *beFBConfig =
|
|
|
|
glxLookupBackEndFBConfig(glxc->pFBConfig->id,
|
|
|
|
screen);
|
|
|
|
|
|
|
|
be_fbconfigId = beFBConfig->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pGlxVisual) {
|
|
|
|
|
|
|
|
be_vid = glxMatchGLXVisualInConfigList(pGlxVisual,
|
|
|
|
dmxScreen->glxVisuals,
|
|
|
|
dmxScreen->numGlxVisuals);
|
|
|
|
|
|
|
|
if (!be_vid) {
|
|
|
|
/* visual is not supported on the back-end server */
|
|
|
|
free(glxc->real_ids);
|
|
|
|
free(glxc->real_vids);
|
|
|
|
free(glxc);
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
glxc->real_ids[screen - from_screen] =
|
|
|
|
XAllocID(GetBackEndDisplay(cl, screen));
|
|
|
|
|
|
|
|
/* send the create context request to the back-end server */
|
|
|
|
dpy = GetBackEndDisplay(cl, screen);
|
|
|
|
if (glxc->pFBConfig) {
|
2013-10-21 19:57:53 +02:00
|
|
|
/* For a specific visual, multiple render types (i.e., both RGB
|
|
|
|
* and COLOR INDEX) can be accessible. The only parameter to
|
|
|
|
* choose the renderType should be the class of the colormap,
|
|
|
|
* since the first classes do not support RGB mode (only COLOR
|
|
|
|
* INDEX), and TrueColor and DirectColor do not support COLOR
|
|
|
|
* INDEX.
|
|
|
|
*/
|
|
|
|
int renderType = GLX_RGBA_TYPE;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
if (pVisual) {
|
|
|
|
switch (pVisual->class) {
|
|
|
|
case PseudoColor:
|
|
|
|
case StaticColor:
|
|
|
|
case GrayScale:
|
|
|
|
case StaticGray:
|
|
|
|
renderType = GLX_COLOR_INDEX_TYPE;
|
|
|
|
break;
|
|
|
|
case TrueColor:
|
|
|
|
case DirectColor:
|
|
|
|
default:
|
|
|
|
renderType = GLX_RGBA_TYPE;
|
|
|
|
break;
|
|
|
|
}
|
2013-10-21 19:57:53 +02:00
|
|
|
} else {
|
|
|
|
renderType =
|
|
|
|
renderTypeBitsToRenderTypeEnum(glxc->pFBConfig->renderType);
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
2013-10-21 19:57:53 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (__GLX_IS_VERSION_SUPPORTED(1, 3)) {
|
|
|
|
LockDisplay(dpy);
|
|
|
|
GetReq(GLXCreateNewContext, be_new_req);
|
|
|
|
be_new_req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
be_new_req->glxCode = X_GLXCreateNewContext;
|
|
|
|
be_new_req->context =
|
|
|
|
(unsigned int) glxc->real_ids[screen - from_screen];
|
|
|
|
be_new_req->fbconfig = (unsigned int) be_fbconfigId;
|
|
|
|
be_new_req->screen = DefaultScreen(dpy);
|
|
|
|
be_new_req->renderType = renderType;
|
|
|
|
|
|
|
|
be_new_req->shareList =
|
|
|
|
(shareglxc ? shareglxc->real_ids[screen - from_screen] : 0);
|
|
|
|
be_new_req->isDirect = 0;
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
glxc->real_vids[screen - from_screen] = be_fbconfigId;
|
|
|
|
sent = 1;
|
|
|
|
}
|
|
|
|
else if (glxIsExtensionSupported("GLX_SGIX_fbconfig")) {
|
|
|
|
|
|
|
|
xGLXCreateContextWithConfigSGIXReq *ext_req;
|
|
|
|
xGLXVendorPrivateReq *vpreq;
|
|
|
|
|
|
|
|
LockDisplay(dpy);
|
|
|
|
GetReqExtra(GLXVendorPrivate,
|
|
|
|
sz_xGLXCreateContextWithConfigSGIXReq -
|
|
|
|
sz_xGLXVendorPrivateReq, vpreq);
|
|
|
|
ext_req = (xGLXCreateContextWithConfigSGIXReq *) vpreq;
|
|
|
|
ext_req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
ext_req->glxCode = X_GLXVendorPrivate;
|
|
|
|
ext_req->vendorCode = X_GLXvop_CreateContextWithConfigSGIX;
|
|
|
|
ext_req->context =
|
|
|
|
(unsigned int) glxc->real_ids[screen - from_screen];
|
|
|
|
ext_req->fbconfig = (unsigned int) be_fbconfigId;
|
|
|
|
ext_req->screen = DefaultScreen(dpy);
|
|
|
|
ext_req->renderType = renderType;
|
|
|
|
ext_req->shareList =
|
|
|
|
(shareglxc ? shareglxc->real_ids[screen - from_screen] : 0);
|
|
|
|
ext_req->isDirect = 0;
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
glxc->real_vids[screen - from_screen] = be_fbconfigId;
|
|
|
|
sent = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!sent) {
|
|
|
|
LockDisplay(dpy);
|
|
|
|
GetReq(GLXCreateContext, be_req);
|
|
|
|
be_req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
be_req->glxCode = X_GLXCreateContext;
|
|
|
|
be_req->context =
|
|
|
|
(unsigned int) glxc->real_ids[screen - from_screen];
|
|
|
|
be_req->visual = (unsigned int) be_vid;
|
|
|
|
be_req->screen = DefaultScreen(dpy);
|
|
|
|
be_req->shareList =
|
|
|
|
(shareglxc ? shareglxc->real_ids[screen - from_screen] : 0);
|
|
|
|
be_req->isDirect = 0;
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
glxc->real_vids[screen - from_screen] = be_vid;
|
|
|
|
}
|
|
|
|
SyncHandle();
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Register this context as a resource.
|
|
|
|
*/
|
|
|
|
if (!AddResource(gcId, __glXContextRes, (pointer) glxc)) {
|
|
|
|
free(glxc->real_ids);
|
|
|
|
free(glxc->real_vids);
|
|
|
|
free(glxc);
|
|
|
|
client->errorValue = gcId;
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
|
2004-06-30 22:06:56 +02:00
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Finally, now that everything is working, setup the rest of the
|
|
|
|
** context.
|
|
|
|
*/
|
2004-06-30 22:06:56 +02:00
|
|
|
glxc->id = gcId;
|
|
|
|
glxc->share_id = shareList;
|
|
|
|
glxc->idExists = GL_TRUE;
|
|
|
|
glxc->isCurrent = GL_FALSE;
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXCreateContext(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
return (CreateContext(cl, req->context, req->visual, None,
|
|
|
|
req->screen, req->shareList, req->isDirect));
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXCreateNewContext(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
return (CreateContext(cl, req->context, None, req->fbconfig,
|
|
|
|
req->screen, req->shareList, req->isDirect));
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXCreateContextWithConfigSGIX(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
xGLXCreateContextWithConfigSGIXReq *req =
|
|
|
|
(xGLXCreateContextWithConfigSGIXReq *) pc;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
return (CreateContext(cl, req->context, None, req->fbconfig,
|
|
|
|
req->screen, req->shareList, req->isDirect));
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXQueryMaxSwapBarriersSGIX(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
ClientPtr client = cl->client;
|
|
|
|
xGLXQueryMaxSwapBarriersSGIXReq *req =
|
2012-03-21 20:55:09 +01:00
|
|
|
(xGLXQueryMaxSwapBarriersSGIXReq *) pc;
|
2012-07-10 04:12:43 +02:00
|
|
|
xGLXQueryMaxSwapBarriersSGIXReply reply = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.max = QueryMaxSwapBarriersSGIX(req->screen)
|
|
|
|
};
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
if (client->swapped) {
|
2012-03-21 20:55:09 +01:00
|
|
|
__glXSwapQueryMaxSwapBarriersSGIXReply(client, &reply);
|
|
|
|
}
|
|
|
|
else {
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, sz_xGLXQueryMaxSwapBarriersSGIXReply, &reply);
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXBindSwapBarrierSGIX(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
ClientPtr client = cl->client;
|
2012-03-21 20:55:09 +01:00
|
|
|
xGLXBindSwapBarrierSGIXReq *req = (xGLXBindSwapBarrierSGIXReq *) pc;
|
2004-06-30 22:06:56 +02:00
|
|
|
DrawablePtr pDraw;
|
|
|
|
__GLXpixmap *pGlxPixmap = NULL;
|
|
|
|
__glXWindow *pGlxWindow = NULL;
|
2006-12-15 22:36:29 +01:00
|
|
|
int rc;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2008-02-28 22:43:43 +01:00
|
|
|
rc = dixLookupDrawable(&pDraw, req->drawable, client, 0, DixGetAttrAccess);
|
2006-12-15 22:36:29 +01:00
|
|
|
if (rc != Success) {
|
2012-03-21 20:55:09 +01:00
|
|
|
dixLookupResourceByType((pointer *) &pGlxPixmap, req->drawable,
|
|
|
|
__glXPixmapRes, NullClient, DixUnknownAccess);
|
|
|
|
if (pGlxPixmap)
|
|
|
|
pDraw = pGlxPixmap->pDraw;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1, 3)) {
|
|
|
|
dixLookupResourceByType((pointer *) &pGlxWindow, req->drawable,
|
|
|
|
__glXWindowRes, NullClient, DixUnknownAccess);
|
|
|
|
if (pGlxWindow)
|
|
|
|
pDraw = pGlxWindow->pDraw;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!pDraw) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = req->drawable;
|
|
|
|
return __glXBadDrawable;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return BindSwapBarrierSGIX(pDraw, req->barrier);
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXJoinSwapGroupSGIX(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
ClientPtr client = cl->client;
|
2012-03-21 20:55:09 +01:00
|
|
|
xGLXJoinSwapGroupSGIXReq *req = (xGLXJoinSwapGroupSGIXReq *) pc;
|
2004-06-30 22:06:56 +02:00
|
|
|
DrawablePtr pDraw, pMember = NULL;
|
|
|
|
__GLXpixmap *pGlxPixmap = NULL;
|
|
|
|
__glXWindow *pGlxWindow = NULL;
|
2006-12-15 22:36:29 +01:00
|
|
|
int rc;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2008-02-28 22:43:43 +01:00
|
|
|
rc = dixLookupDrawable(&pDraw, req->drawable, client, 0, DixManageAccess);
|
2006-12-15 22:36:29 +01:00
|
|
|
if (rc != Success) {
|
2012-03-21 20:55:09 +01:00
|
|
|
dixLookupResourceByType((pointer *) &pGlxPixmap, req->drawable,
|
|
|
|
__glXPixmapRes, NullClient, DixUnknownAccess);
|
|
|
|
if (pGlxPixmap)
|
|
|
|
pDraw = pGlxPixmap->pDraw;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1, 3)) {
|
|
|
|
dixLookupResourceByType((pointer *) &pGlxWindow, req->drawable,
|
|
|
|
__glXWindowRes, NullClient, DixUnknownAccess);
|
|
|
|
if (pGlxWindow)
|
|
|
|
pDraw = pGlxWindow->pDraw;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!pDraw) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = req->drawable;
|
|
|
|
return __glXBadDrawable;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (req->member != None) {
|
2012-03-21 20:55:09 +01:00
|
|
|
rc = dixLookupDrawable(&pMember, req->member, client, 0,
|
|
|
|
DixGetAttrAccess);
|
|
|
|
if (rc != Success) {
|
|
|
|
dixLookupResourceByType((pointer *) &pGlxPixmap, req->member,
|
Replace LookupIDByType() with dixLookupResourceByType(), take 1.
This patch has been prepared with the following Coccinelle semantic patch:
@@
expression x, y;
type t;
identifier r;
@@
-r = (t) LookupIDByType(x, y);
+dixLookupResourceByType((pointer*)&r, x, y, NullClient, DixUnknownAccess);
@@
expression x, y;
type t;
identifier r;
@@
-t r = (t) LookupIDByType(x, y);
+t r;
+dixLookupResourceByType((pointer*)&r, x, y, NullClient, DixUnknownAccess);
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Cyril Brulebois <kibi@debian.org>
2010-11-11 15:30:15 +01:00
|
|
|
__glXPixmapRes, NullClient,
|
|
|
|
DixUnknownAccess);
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pGlxPixmap)
|
|
|
|
pMember = pGlxPixmap->pDraw;
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!pMember && __GLX_IS_VERSION_SUPPORTED(1, 3)) {
|
|
|
|
dixLookupResourceByType((pointer *) &pGlxWindow, req->member,
|
Replace LookupIDByType() with dixLookupResourceByType(), take 1.
This patch has been prepared with the following Coccinelle semantic patch:
@@
expression x, y;
type t;
identifier r;
@@
-r = (t) LookupIDByType(x, y);
+dixLookupResourceByType((pointer*)&r, x, y, NullClient, DixUnknownAccess);
@@
expression x, y;
type t;
identifier r;
@@
-t r = (t) LookupIDByType(x, y);
+t r;
+dixLookupResourceByType((pointer*)&r, x, y, NullClient, DixUnknownAccess);
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Cyril Brulebois <kibi@debian.org>
2010-11-11 15:30:15 +01:00
|
|
|
__glXWindowRes, NullClient,
|
|
|
|
DixUnknownAccess);
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pGlxWindow)
|
|
|
|
pMember = pGlxWindow->pDraw;
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!pMember) {
|
|
|
|
client->errorValue = req->member;
|
|
|
|
return __glXBadDrawable;
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return JoinSwapGroupSGIX(pDraw, pMember);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Destroy a GL context as an X resource.
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXDestroyContext(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
ClientPtr client = cl->client;
|
|
|
|
xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc;
|
|
|
|
xGLXDestroyContextReq *be_req;
|
|
|
|
GLXContextID gcId = req->context;
|
|
|
|
__GLXcontext *glxc;
|
|
|
|
int from_screen = 0;
|
|
|
|
int to_screen = 0;
|
|
|
|
int s;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
dixLookupResourceByType((pointer *) &glxc, gcId, __glXContextRes,
|
|
|
|
NullClient, DixUnknownAccess);
|
2004-06-30 22:06:56 +02:00
|
|
|
if (glxc) {
|
2012-03-21 20:55:09 +01:00
|
|
|
/*
|
|
|
|
** Just free the resource; don't actually destroy the context,
|
|
|
|
** because it might be in use. The
|
|
|
|
** destroy method will be called by the resource destruction routine
|
|
|
|
** if necessary.
|
|
|
|
*/
|
|
|
|
FreeResourceByType(gcId, __glXContextRes, FALSE);
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
from_screen = to_screen = glxc->pScreen->myNum;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
client->errorValue = gcId;
|
|
|
|
return __glXBadContext;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
if (!noPanoramiXExtension) {
|
2012-03-21 20:55:09 +01:00
|
|
|
from_screen = 0;
|
|
|
|
to_screen = screenInfo.numScreens - 1;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* send DestroyContext request to all back-end servers
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
for (s = from_screen; s <= to_screen; s++) {
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[s];
|
|
|
|
Display *dpy = GetBackEndDisplay(cl, s);
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
LockDisplay(dpy);
|
|
|
|
GetReq(GLXDestroyContext, be_req);
|
|
|
|
be_req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
be_req->glxCode = X_GLXDestroyContext;
|
|
|
|
be_req->context = glxc->real_ids[s - from_screen];
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
** For each client, the server keeps a table of all the contexts that are
|
|
|
|
** current for that client (each thread of a client may have its own current
|
|
|
|
** context). These routines add, change, and lookup contexts in the table.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Add a current context, and return the tag that will be used to refer to it.
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
static int
|
|
|
|
AddCurrentContext(__GLXclientState * cl, __GLXcontext * glxc, DrawablePtr pDraw)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int num = cl->numCurrentContexts;
|
|
|
|
__GLXcontext **table = cl->currentContexts;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!glxc)
|
|
|
|
return -1;
|
|
|
|
|
2004-06-30 22:06:56 +02:00
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Try to find an empty slot and use it.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < num; i++) {
|
|
|
|
if (!table[i]) {
|
|
|
|
table[i] = glxc;
|
|
|
|
return i + 1;
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Didn't find a free slot, so we'll have to grow the table.
|
|
|
|
*/
|
2004-06-30 22:06:56 +02:00
|
|
|
if (!num) {
|
2012-03-21 20:55:09 +01:00
|
|
|
table = (__GLXcontext **) malloc(sizeof(__GLXcontext *));
|
|
|
|
cl->currentDrawables = (DrawablePtr *) malloc(sizeof(DrawablePtr));
|
|
|
|
cl->be_currentCTag =
|
|
|
|
(GLXContextTag *) malloc(screenInfo.numScreens *
|
|
|
|
sizeof(GLXContextTag));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
table = (__GLXcontext **) realloc(table,
|
|
|
|
(num + 1) * sizeof(__GLXcontext *));
|
|
|
|
cl->currentDrawables = (DrawablePtr *) realloc(cl->currentDrawables,
|
|
|
|
(num +
|
|
|
|
1) *
|
|
|
|
sizeof(DrawablePtr));
|
|
|
|
cl->be_currentCTag =
|
|
|
|
(GLXContextTag *) realloc(cl->be_currentCTag,
|
|
|
|
(num +
|
|
|
|
1) * screenInfo.numScreens *
|
|
|
|
sizeof(GLXContextTag));
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
table[num] = glxc;
|
|
|
|
cl->currentDrawables[num] = pDraw;
|
|
|
|
cl->currentContexts = table;
|
|
|
|
cl->numCurrentContexts++;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
memset(cl->be_currentCTag + num * screenInfo.numScreens, 0,
|
|
|
|
screenInfo.numScreens * sizeof(GLXContextTag));
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
return num + 1;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Given a tag, change the current context for the corresponding entry.
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
static void
|
|
|
|
ChangeCurrentContext(__GLXclientState * cl, __GLXcontext * glxc,
|
|
|
|
GLXContextTag tag)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
__GLXcontext **table = cl->currentContexts;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
table[tag - 1] = glxc;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Given a tag, and back-end screen number, retrives the current back-end
|
|
|
|
** tag.
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
GetCurrentBackEndTag(__GLXclientState * cl, GLXContextTag tag, int s)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
if (tag > 0) {
|
|
|
|
return (cl->be_currentCTag[(tag - 1) * screenInfo.numScreens + s]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return 0;
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Given a tag, and back-end screen number, sets the current back-end
|
|
|
|
** tag.
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
static void
|
|
|
|
SetCurrentBackEndTag(__GLXclientState * cl, GLXContextTag tag, int s,
|
|
|
|
GLXContextTag be_tag)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
if (tag > 0) {
|
|
|
|
cl->be_currentCTag[(tag - 1) * screenInfo.numScreens + s] = be_tag;
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** For this implementation we have chosen to simply use the index of the
|
|
|
|
** context's entry in the table as the context tag. A tag must be greater
|
|
|
|
** than 0.
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
__GLXcontext *
|
|
|
|
__glXLookupContextByTag(__GLXclientState * cl, GLXContextTag tag)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
int num = cl->numCurrentContexts;
|
|
|
|
|
|
|
|
if (tag < 1 || tag > num) {
|
2012-03-21 20:55:09 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return cl->currentContexts[tag - 1];
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
DrawablePtr
|
|
|
|
__glXLookupDrawableByTag(__GLXclientState * cl, GLXContextTag tag)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
int num = cl->numCurrentContexts;
|
|
|
|
|
|
|
|
if (tag < 1 || tag > num) {
|
2012-03-21 20:55:09 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return cl->currentDrawables[tag - 1];
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
static void
|
|
|
|
StopUsingContext(__GLXcontext * glxc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
if (glxc) {
|
2012-03-21 20:55:09 +01:00
|
|
|
if (glxc == __glXLastContext) {
|
|
|
|
/* Tell server GL library */
|
|
|
|
__glXLastContext = 0;
|
|
|
|
}
|
|
|
|
glxc->isCurrent = GL_FALSE;
|
|
|
|
if (!glxc->idExists) {
|
|
|
|
__glXFreeContext(glxc);
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
static void
|
|
|
|
StartUsingContext(__GLXclientState * cl, __GLXcontext * glxc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
glxc->isCurrent = GL_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*
|
|
|
|
** Make an OpenGL context and drawable current.
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
static int
|
|
|
|
MakeCurrent(__GLXclientState * cl,
|
|
|
|
GLXDrawable drawable,
|
|
|
|
GLXDrawable readdrawable,
|
|
|
|
GLXContextID context, GLXContextTag oldContextTag)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
ClientPtr client = cl->client;
|
|
|
|
DrawablePtr pDraw = NULL;
|
|
|
|
DrawablePtr pReadDraw = NULL;
|
2012-07-10 04:12:43 +02:00
|
|
|
xGLXMakeCurrentReadSGIReply new_reply = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0
|
|
|
|
};
|
2004-06-30 22:06:56 +02:00
|
|
|
xGLXMakeCurrentReq *be_req;
|
|
|
|
xGLXMakeCurrentReply be_reply;
|
|
|
|
xGLXMakeContextCurrentReq *be_new_req;
|
|
|
|
xGLXMakeContextCurrentReply be_new_reply;
|
|
|
|
GLXDrawable drawId = drawable;
|
|
|
|
GLXDrawable readId = readdrawable;
|
|
|
|
GLXContextID contextId = context;
|
|
|
|
__GLXpixmap *pGlxPixmap = 0;
|
|
|
|
__GLXpixmap *pReadGlxPixmap = 0;
|
|
|
|
__GLXcontext *glxc, *prevglxc;
|
|
|
|
GLXContextTag tag = oldContextTag;
|
|
|
|
WindowPtr pWin = NULL;
|
|
|
|
WindowPtr pReadWin = NULL;
|
|
|
|
__glXWindow *pGlxWindow = NULL;
|
|
|
|
__glXWindow *pGlxReadWindow = NULL;
|
|
|
|
__glXPbuffer *pGlxPbuffer = NULL;
|
|
|
|
__glXPbuffer *pGlxReadPbuffer = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2004-06-30 22:06:56 +02:00
|
|
|
#ifdef PANORAMIX
|
|
|
|
PanoramiXRes *pXinDraw = NULL;
|
|
|
|
PanoramiXRes *pXinReadDraw = NULL;
|
|
|
|
#endif
|
|
|
|
int from_screen = 0;
|
|
|
|
int to_screen = 0;
|
2006-12-15 22:36:29 +01:00
|
|
|
int s, rc;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** If one is None and the other isn't, it's a bad match.
|
|
|
|
*/
|
2004-06-30 22:06:56 +02:00
|
|
|
if ((drawId == None && contextId != None) ||
|
2012-03-21 20:55:09 +01:00
|
|
|
(drawId != None && contextId == None)) {
|
|
|
|
return BadMatch;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2004-06-30 22:06:56 +02:00
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Lookup old context. If we have one, it must be in a usable state.
|
|
|
|
*/
|
2004-06-30 22:06:56 +02:00
|
|
|
if (tag != 0) {
|
2012-03-21 20:55:09 +01:00
|
|
|
prevglxc = __glXLookupContextByTag(cl, tag);
|
|
|
|
if (!prevglxc) {
|
|
|
|
/*
|
|
|
|
** Tag for previous context is invalid.
|
|
|
|
*/
|
|
|
|
return __glXBadContextTag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
prevglxc = 0;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Lookup new context. It must not be current for someone else.
|
|
|
|
*/
|
2004-06-30 22:06:56 +02:00
|
|
|
if (contextId != None) {
|
2012-03-21 20:55:09 +01:00
|
|
|
dixLookupResourceByType((pointer *) &glxc, contextId, __glXContextRes,
|
|
|
|
NullClient, DixUnknownAccess);
|
|
|
|
if (!glxc) {
|
|
|
|
client->errorValue = contextId;
|
|
|
|
return __glXBadContext;
|
|
|
|
}
|
|
|
|
if ((glxc != prevglxc) && glxc->isCurrent) {
|
|
|
|
/* Context is current to somebody else */
|
|
|
|
return BadAccess;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Switching to no context. Ignore new drawable. */
|
|
|
|
glxc = 0;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (drawId != None) {
|
2012-03-21 20:55:09 +01:00
|
|
|
rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixWriteAccess);
|
|
|
|
if (rc == Success) {
|
|
|
|
if (pDraw->type == DRAWABLE_WINDOW) {
|
|
|
|
/*
|
|
|
|
** Drawable is an X Window.
|
|
|
|
*/
|
|
|
|
VisualID vid;
|
|
|
|
|
|
|
|
pWin = (WindowPtr) pDraw;
|
|
|
|
vid = wVisual(pWin);
|
|
|
|
|
|
|
|
new_reply.writeVid =
|
|
|
|
(glxc->pFBConfig ? glxc->pFBConfig->id : vid);
|
|
|
|
new_reply.writeType = GLX_WINDOW_TYPE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Check if window and context are similar.
|
|
|
|
*/
|
|
|
|
if ((vid != glxc->pVisual->vid) ||
|
|
|
|
(pWin->drawable.pScreen != glxc->pScreen)) {
|
|
|
|
client->errorValue = drawId;
|
|
|
|
return BadMatch;
|
|
|
|
}
|
|
|
|
|
|
|
|
from_screen = to_screen = pWin->drawable.pScreen->myNum;
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
** An X Pixmap is not allowed as a parameter (a GLX Pixmap
|
|
|
|
** is, but it must first be created with glxCreateGLXPixmap).
|
|
|
|
*/
|
|
|
|
client->errorValue = drawId;
|
|
|
|
return __glXBadDrawable;
|
|
|
|
}
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
if (!pDraw) {
|
2012-03-21 20:55:09 +01:00
|
|
|
dixLookupResourceByType((pointer *) &pGlxPixmap, drawId,
|
|
|
|
__glXPixmapRes, NullClient,
|
|
|
|
DixUnknownAccess);
|
|
|
|
if (pGlxPixmap) {
|
|
|
|
/*
|
|
|
|
** Check if pixmap and context are similar.
|
|
|
|
*/
|
|
|
|
if (pGlxPixmap->pScreen != glxc->pScreen ||
|
|
|
|
pGlxPixmap->pGlxVisual != glxc->pGlxVisual) {
|
|
|
|
client->errorValue = drawId;
|
|
|
|
return BadMatch;
|
|
|
|
}
|
|
|
|
pDraw = pGlxPixmap->pDraw;
|
|
|
|
|
|
|
|
new_reply.writeVid = (glxc->pFBConfig ? glxc->pFBConfig->id :
|
|
|
|
pGlxPixmap->pGlxVisual->vid);
|
|
|
|
|
|
|
|
new_reply.writeType = GLX_PIXMAP_TYPE;
|
|
|
|
|
|
|
|
from_screen = to_screen = pGlxPixmap->pScreen->myNum;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1, 3)) {
|
|
|
|
dixLookupResourceByType((pointer *) &pGlxWindow, drawId,
|
|
|
|
__glXWindowRes, NullClient,
|
|
|
|
DixUnknownAccess);
|
2004-06-30 22:06:56 +02:00
|
|
|
if (pGlxWindow) {
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Drawable is a GLXWindow.
|
|
|
|
**
|
|
|
|
** Check if GLX window and context are similar.
|
|
|
|
*/
|
2004-06-30 22:06:56 +02:00
|
|
|
if (pGlxWindow->pScreen != glxc->pScreen ||
|
|
|
|
pGlxWindow->pGlxFBConfig != glxc->pFBConfig) {
|
|
|
|
client->errorValue = drawId;
|
|
|
|
return BadMatch;
|
|
|
|
}
|
|
|
|
|
|
|
|
pDraw = pGlxWindow->pDraw;
|
|
|
|
new_reply.writeVid = pGlxWindow->pGlxFBConfig->id;
|
|
|
|
new_reply.writeType = GLX_GLXWINDOW_TYPE;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1, 3)) {
|
|
|
|
dixLookupResourceByType((pointer *) &pGlxPbuffer, drawId,
|
|
|
|
__glXPbufferRes, NullClient,
|
|
|
|
DixUnknownAccess);
|
|
|
|
if (pGlxPbuffer) {
|
2004-06-30 22:06:56 +02:00
|
|
|
if (pGlxPbuffer->pScreen != glxc->pScreen ||
|
|
|
|
pGlxPbuffer->pFBConfig != glxc->pFBConfig) {
|
|
|
|
client->errorValue = drawId;
|
|
|
|
return BadMatch;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
pDraw = (DrawablePtr) pGlxPbuffer;
|
2004-06-30 22:06:56 +02:00
|
|
|
new_reply.writeVid = pGlxPbuffer->pFBConfig->id;
|
|
|
|
new_reply.writeType = GLX_PBUFFER_TYPE;
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pDraw) {
|
|
|
|
/*
|
|
|
|
** Drawable is not a Window , GLXWindow or a GLXPixmap.
|
|
|
|
*/
|
|
|
|
client->errorValue = drawId;
|
|
|
|
return __glXBadDrawable;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pDraw = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (readId != None && readId != drawId) {
|
|
|
|
rc = dixLookupDrawable(&pReadDraw, readId, client, 0, DixReadAccess);
|
|
|
|
if (rc == Success) {
|
|
|
|
if (pReadDraw->type == DRAWABLE_WINDOW) {
|
|
|
|
/*
|
|
|
|
** Drawable is an X Window.
|
|
|
|
*/
|
|
|
|
VisualID vid;
|
|
|
|
|
|
|
|
pReadWin = (WindowPtr) pDraw;
|
|
|
|
vid = wVisual(pReadWin);
|
|
|
|
|
|
|
|
new_reply.readVid =
|
|
|
|
(glxc->pFBConfig ? glxc->pFBConfig->id : vid);
|
|
|
|
new_reply.readType = GLX_WINDOW_TYPE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Check if window and context are similar.
|
|
|
|
*/
|
|
|
|
if ((vid != glxc->pVisual->vid) ||
|
|
|
|
(pReadWin->drawable.pScreen != glxc->pScreen)) {
|
|
|
|
client->errorValue = readId;
|
|
|
|
return BadMatch;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
/*
|
|
|
|
** An X Pixmap is not allowed as a parameter (a GLX Pixmap
|
|
|
|
** is, but it must first be created with glxCreateGLXPixmap).
|
|
|
|
*/
|
|
|
|
client->errorValue = readId;
|
|
|
|
return __glXBadDrawable;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pReadDraw) {
|
|
|
|
dixLookupResourceByType((pointer *) &pReadGlxPixmap, readId,
|
|
|
|
__glXPixmapRes, NullClient,
|
|
|
|
DixUnknownAccess);
|
|
|
|
if (pReadGlxPixmap) {
|
|
|
|
/*
|
|
|
|
** Check if pixmap and context are similar.
|
|
|
|
*/
|
|
|
|
if (pReadGlxPixmap->pScreen != glxc->pScreen ||
|
|
|
|
pReadGlxPixmap->pGlxVisual != glxc->pGlxVisual) {
|
|
|
|
client->errorValue = readId;
|
|
|
|
return BadMatch;
|
|
|
|
}
|
|
|
|
pReadDraw = pReadGlxPixmap->pDraw;
|
|
|
|
|
|
|
|
new_reply.readVid = (glxc->pFBConfig ? glxc->pFBConfig->id :
|
|
|
|
pReadGlxPixmap->pGlxVisual->vid);
|
|
|
|
new_reply.readType = GLX_PIXMAP_TYPE;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pReadDraw && __GLX_IS_VERSION_SUPPORTED(1, 3)) {
|
|
|
|
dixLookupResourceByType((pointer *) &pGlxReadWindow, readId,
|
|
|
|
__glXWindowRes, NullClient,
|
|
|
|
DixUnknownAccess);
|
2004-06-30 22:06:56 +02:00
|
|
|
if (pGlxReadWindow) {
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Drawable is a GLXWindow.
|
|
|
|
**
|
|
|
|
** Check if GLX window and context are similar.
|
|
|
|
*/
|
2004-06-30 22:06:56 +02:00
|
|
|
if (pGlxReadWindow->pScreen != glxc->pScreen ||
|
|
|
|
pGlxReadWindow->pGlxFBConfig != glxc->pFBConfig) {
|
|
|
|
client->errorValue = readId;
|
|
|
|
return BadMatch;
|
|
|
|
}
|
|
|
|
|
|
|
|
pReadDraw = pGlxReadWindow->pDraw;
|
|
|
|
new_reply.readVid = pGlxReadWindow->pGlxFBConfig->id;
|
|
|
|
new_reply.readType = GLX_GLXWINDOW_TYPE;
|
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!pReadDraw && __GLX_IS_VERSION_SUPPORTED(1, 3)) {
|
|
|
|
dixLookupResourceByType((pointer *) &pGlxReadPbuffer, readId,
|
|
|
|
__glXPbufferRes, NullClient,
|
|
|
|
DixUnknownAccess);
|
|
|
|
if (pGlxReadPbuffer) {
|
2004-06-30 22:06:56 +02:00
|
|
|
if (pGlxReadPbuffer->pScreen != glxc->pScreen ||
|
|
|
|
pGlxReadPbuffer->pFBConfig != glxc->pFBConfig) {
|
|
|
|
client->errorValue = drawId;
|
|
|
|
return BadMatch;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
pReadDraw = (DrawablePtr) pGlxReadPbuffer;
|
2004-06-30 22:06:56 +02:00
|
|
|
new_reply.readVid = pGlxReadPbuffer->pFBConfig->id;
|
|
|
|
new_reply.readType = GLX_PBUFFER_TYPE;
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!pReadDraw) {
|
|
|
|
/*
|
|
|
|
** Drawable is neither a Window nor a GLXPixmap.
|
|
|
|
*/
|
|
|
|
client->errorValue = readId;
|
|
|
|
return __glXBadDrawable;
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
pReadDraw = pDraw;
|
|
|
|
pReadGlxPixmap = pGlxPixmap;
|
|
|
|
pReadWin = pWin;
|
|
|
|
new_reply.readVid = new_reply.writeVid;
|
|
|
|
new_reply.readType = new_reply.writeType;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (prevglxc) {
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (prevglxc->pGlxPixmap) {
|
|
|
|
/*
|
|
|
|
** The previous drawable was a glx pixmap, release it.
|
|
|
|
*/
|
|
|
|
prevglxc->pGlxPixmap->refcnt--;
|
|
|
|
__glXFreeGLXPixmap(prevglxc->pGlxPixmap);
|
|
|
|
prevglxc->pGlxPixmap = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (prevglxc->pGlxReadPixmap) {
|
|
|
|
/*
|
|
|
|
** The previous drawable was a glx pixmap, release it.
|
|
|
|
*/
|
|
|
|
prevglxc->pGlxReadPixmap->refcnt--;
|
|
|
|
__glXFreeGLXPixmap(prevglxc->pGlxReadPixmap);
|
|
|
|
prevglxc->pGlxReadPixmap = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (prevglxc->pGlxWindow) {
|
|
|
|
/*
|
|
|
|
** The previous drawable was a glx window, release it.
|
|
|
|
*/
|
|
|
|
prevglxc->pGlxWindow->refcnt--;
|
|
|
|
__glXFreeGLXWindow(prevglxc->pGlxWindow);
|
|
|
|
prevglxc->pGlxWindow = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (prevglxc->pGlxReadWindow) {
|
|
|
|
/*
|
|
|
|
** The previous drawable was a glx window, release it.
|
|
|
|
*/
|
|
|
|
prevglxc->pGlxReadWindow->refcnt--;
|
|
|
|
__glXFreeGLXWindow(prevglxc->pGlxReadWindow);
|
|
|
|
prevglxc->pGlxReadWindow = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (prevglxc->pGlxPbuffer) {
|
|
|
|
/*
|
|
|
|
** The previous drawable was a glx Pbuffer, release it.
|
|
|
|
*/
|
|
|
|
prevglxc->pGlxPbuffer->refcnt--;
|
|
|
|
__glXFreeGLXPbuffer(prevglxc->pGlxPbuffer);
|
|
|
|
prevglxc->pGlxPbuffer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (prevglxc->pGlxReadPbuffer) {
|
|
|
|
/*
|
|
|
|
** The previous drawable was a glx Pbuffer, release it.
|
|
|
|
*/
|
|
|
|
prevglxc->pGlxReadPbuffer->refcnt--;
|
|
|
|
__glXFreeGLXPbuffer(prevglxc->pGlxReadPbuffer);
|
|
|
|
prevglxc->pGlxReadPbuffer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ChangeCurrentContext(cl, glxc, tag);
|
|
|
|
ChangeCurrentContext(cl, glxc, tag);
|
|
|
|
StopUsingContext(prevglxc);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
tag = AddCurrentContext(cl, glxc, pDraw);
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
if (glxc) {
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
glxc->pGlxPixmap = pGlxPixmap;
|
|
|
|
glxc->pGlxReadPixmap = pReadGlxPixmap;
|
|
|
|
glxc->pGlxWindow = pGlxWindow;
|
|
|
|
glxc->pGlxReadWindow = pGlxReadWindow;
|
|
|
|
glxc->pGlxPbuffer = pGlxPbuffer;
|
|
|
|
glxc->pGlxReadPbuffer = pGlxReadPbuffer;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pGlxPixmap) {
|
|
|
|
pGlxPixmap->refcnt++;
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pReadGlxPixmap) {
|
|
|
|
pReadGlxPixmap->refcnt++;
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pGlxWindow) {
|
|
|
|
pGlxWindow->refcnt++;
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pGlxReadWindow) {
|
|
|
|
pGlxReadWindow->refcnt++;
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pGlxPbuffer) {
|
|
|
|
pGlxPbuffer->refcnt++;
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pGlxReadPbuffer) {
|
|
|
|
pGlxReadPbuffer->refcnt++;
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
StartUsingContext(cl, glxc);
|
|
|
|
new_reply.contextTag = tag;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
new_reply.contextTag = 0;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
if (!noPanoramiXExtension) {
|
2012-03-21 20:55:09 +01:00
|
|
|
from_screen = 0;
|
|
|
|
to_screen = screenInfo.numScreens - 1;
|
|
|
|
|
|
|
|
if (pDraw && new_reply.writeType != GLX_PBUFFER_TYPE) {
|
|
|
|
dixLookupResourceByClass((pointer *) &pXinDraw,
|
|
|
|
pDraw->id, XRC_DRAWABLE,
|
|
|
|
client, DixReadAccess);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pReadDraw && pReadDraw != pDraw &&
|
|
|
|
new_reply.readType != GLX_PBUFFER_TYPE) {
|
|
|
|
dixLookupResourceByClass((pointer *) &pXinReadDraw,
|
|
|
|
pReadDraw->id, XRC_DRAWABLE,
|
|
|
|
client, DixReadAccess);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pXinReadDraw = pXinDraw;
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* send the MakeCurrent request to all required
|
|
|
|
* back-end servers.
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
for (s = from_screen; s <= to_screen; s++) {
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[s];
|
|
|
|
Display *dpy = GetBackEndDisplay(cl, s);
|
|
|
|
unsigned int be_draw = None;
|
|
|
|
unsigned int be_read_draw = None;
|
|
|
|
|
|
|
|
if (pGlxPixmap) {
|
|
|
|
be_draw = pGlxPixmap->be_xids[s];
|
|
|
|
}
|
|
|
|
else if (pGlxPbuffer) {
|
|
|
|
be_draw = pGlxPbuffer->be_xids[s];
|
|
|
|
}
|
2004-07-07 01:51:00 +02:00
|
|
|
#ifdef PANORAMIX
|
2012-03-21 20:55:09 +01:00
|
|
|
else if (pXinDraw) {
|
|
|
|
dixLookupWindow(&pWin, pXinDraw->info[s].id, client, DixReadAccess);
|
|
|
|
}
|
2004-07-07 01:51:00 +02:00
|
|
|
#endif
|
2012-03-21 20:55:09 +01:00
|
|
|
else if (pGlxWindow) {
|
|
|
|
pWin = (WindowPtr) pGlxWindow->pDraw;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pWin && be_draw == None) {
|
|
|
|
be_draw = (unsigned int) (DMX_GET_WINDOW_PRIV(pWin))->window;
|
|
|
|
if (!be_draw) {
|
|
|
|
/* it might be that the window did not created yet on the */
|
|
|
|
/* back-end server (lazy window creation option), force */
|
|
|
|
/* creation of the window */
|
|
|
|
dmxCreateAndRealizeWindow(pWin, TRUE);
|
|
|
|
be_draw = (unsigned int) (DMX_GET_WINDOW_PRIV(pWin))->window;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Before sending the MakeCurrent request - sync the
|
|
|
|
* X11 connection to the back-end servers to make sure
|
|
|
|
* that drawable is already created
|
|
|
|
*/
|
|
|
|
dmxSync(dmxScreen, 1);
|
|
|
|
|
|
|
|
if (drawId == readId) {
|
|
|
|
LockDisplay(dpy);
|
|
|
|
GetReq(GLXMakeCurrent, be_req);
|
|
|
|
be_req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
be_req->glxCode = X_GLXMakeCurrent;
|
|
|
|
be_req->drawable = be_draw;
|
|
|
|
be_req->context =
|
|
|
|
(unsigned int) (glxc ? glxc->real_ids[s - from_screen] : 0);
|
|
|
|
be_req->oldContextTag = GetCurrentBackEndTag(cl, tag, s);
|
2012-11-06 06:50:58 +01:00
|
|
|
if (!_XReply(dpy, (xReply *) &be_reply, 0, False)) {
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
/* The make current failed */
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
|
|
|
return (BE_TO_CLIENT_ERROR(dmxLastErrorEvent.error_code));
|
|
|
|
}
|
|
|
|
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
|
|
|
|
|
|
|
SetCurrentBackEndTag(cl, tag, s, be_reply.contextTag);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
if (pReadGlxPixmap) {
|
|
|
|
be_read_draw = pReadGlxPixmap->be_xids[s];
|
|
|
|
}
|
|
|
|
else if (pGlxReadPbuffer) {
|
|
|
|
be_read_draw = pGlxReadPbuffer->be_xids[s];
|
|
|
|
}
|
2004-07-07 01:51:00 +02:00
|
|
|
#ifdef PANORAMIX
|
2012-03-21 20:55:09 +01:00
|
|
|
else if (pXinReadDraw) {
|
|
|
|
dixLookupWindow(&pReadWin, pXinReadDraw->info[s].id, client,
|
|
|
|
DixReadAccess);
|
|
|
|
}
|
2004-07-07 01:51:00 +02:00
|
|
|
#endif
|
2012-03-21 20:55:09 +01:00
|
|
|
else if (pGlxReadWindow) {
|
|
|
|
pReadWin = (WindowPtr) pGlxReadWindow->pDraw;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pReadWin && be_read_draw == None) {
|
|
|
|
be_read_draw =
|
|
|
|
(unsigned int) (DMX_GET_WINDOW_PRIV(pReadWin))->window;
|
|
|
|
if (!be_read_draw) {
|
|
|
|
/* it might be that the window did not created yet on the */
|
|
|
|
/* back-end server (lazy window creation option), force */
|
|
|
|
/* creation of the window */
|
|
|
|
dmxCreateAndRealizeWindow(pReadWin, TRUE);
|
|
|
|
be_read_draw =
|
|
|
|
(unsigned int) (DMX_GET_WINDOW_PRIV(pReadWin))->window;
|
|
|
|
dmxSync(dmxScreen, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (__GLX_IS_VERSION_SUPPORTED(1, 3)) {
|
|
|
|
LockDisplay(dpy);
|
|
|
|
GetReq(GLXMakeContextCurrent, be_new_req);
|
|
|
|
be_new_req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
be_new_req->glxCode = X_GLXMakeContextCurrent;
|
|
|
|
be_new_req->drawable = be_draw;
|
|
|
|
be_new_req->readdrawable = be_read_draw;
|
|
|
|
be_new_req->context =
|
|
|
|
(unsigned int) (glxc ? glxc->real_ids[s - from_screen] : 0);
|
|
|
|
be_new_req->oldContextTag = GetCurrentBackEndTag(cl, tag, s);
|
2012-11-06 06:50:58 +01:00
|
|
|
if (!_XReply(dpy, (xReply *) &be_new_reply, 0, False)) {
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
/* The make current failed */
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
|
|
|
return (BE_TO_CLIENT_ERROR(dmxLastErrorEvent.error_code));
|
|
|
|
}
|
|
|
|
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
|
|
|
|
|
|
|
SetCurrentBackEndTag(cl, tag, s, be_new_reply.contextTag);
|
|
|
|
}
|
|
|
|
else if (glxIsExtensionSupported("GLX_SGI_make_current_read")) {
|
|
|
|
xGLXMakeCurrentReadSGIReq *ext_req;
|
|
|
|
xGLXVendorPrivateWithReplyReq *vpreq;
|
|
|
|
xGLXMakeCurrentReadSGIReply ext_reply;
|
|
|
|
|
|
|
|
LockDisplay(dpy);
|
|
|
|
GetReqExtra(GLXVendorPrivateWithReply,
|
|
|
|
sz_xGLXMakeCurrentReadSGIReq -
|
|
|
|
sz_xGLXVendorPrivateWithReplyReq, vpreq);
|
|
|
|
ext_req = (xGLXMakeCurrentReadSGIReq *) vpreq;
|
|
|
|
ext_req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
ext_req->glxCode = X_GLXVendorPrivateWithReply;
|
|
|
|
ext_req->vendorCode = X_GLXvop_MakeCurrentReadSGI;
|
|
|
|
ext_req->drawable = be_draw;
|
|
|
|
ext_req->readable = be_read_draw;
|
|
|
|
ext_req->context =
|
|
|
|
(unsigned int) (glxc ? glxc->real_ids[s - from_screen] : 0);
|
|
|
|
ext_req->oldContextTag = GetCurrentBackEndTag(cl, tag, s);
|
2012-11-06 06:50:58 +01:00
|
|
|
if (!_XReply(dpy, (xReply *) &ext_reply, 0, False)) {
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
/* The make current failed */
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
|
|
|
return (BE_TO_CLIENT_ERROR(dmxLastErrorEvent.error_code));
|
|
|
|
}
|
|
|
|
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
|
|
|
|
|
|
|
SetCurrentBackEndTag(cl, tag, s, ext_reply.contextTag);
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return BadMatch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
XFlush(dpy);
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (client->swapped) {
|
2012-03-21 20:55:09 +01:00
|
|
|
__glXSwapMakeCurrentReply(client, &new_reply);
|
|
|
|
}
|
|
|
|
else {
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, sz_xGLXMakeContextCurrentReply, &new_reply);
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXMakeCurrent(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) pc;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
return (MakeCurrent(cl, req->drawable, req->drawable,
|
|
|
|
req->context, req->oldContextTag));
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXMakeContextCurrent(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) pc;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
return (MakeCurrent(cl, req->drawable, req->readdrawable,
|
|
|
|
req->context, req->oldContextTag));
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXMakeCurrentReadSGI(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) pc;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
return (MakeCurrent(cl, req->drawable, req->readable,
|
|
|
|
req->context, req->oldContextTag));
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXIsDirect(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
ClientPtr client = cl->client;
|
|
|
|
xGLXIsDirectReq *req = (xGLXIsDirectReq *) pc;
|
|
|
|
xGLXIsDirectReply reply;
|
|
|
|
__GLXcontext *glxc;
|
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Find the GL context.
|
|
|
|
*/
|
|
|
|
dixLookupResourceByType((pointer *) &glxc, req->context, __glXContextRes,
|
Replace LookupIDByType() with dixLookupResourceByType(), take 1.
This patch has been prepared with the following Coccinelle semantic patch:
@@
expression x, y;
type t;
identifier r;
@@
-r = (t) LookupIDByType(x, y);
+dixLookupResourceByType((pointer*)&r, x, y, NullClient, DixUnknownAccess);
@@
expression x, y;
type t;
identifier r;
@@
-t r = (t) LookupIDByType(x, y);
+t r;
+dixLookupResourceByType((pointer*)&r, x, y, NullClient, DixUnknownAccess);
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Cyril Brulebois <kibi@debian.org>
2010-11-11 15:30:15 +01:00
|
|
|
NullClient, DixUnknownAccess);
|
2004-06-30 22:06:56 +02:00
|
|
|
if (!glxc) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = req->context;
|
|
|
|
return __glXBadContext;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
2012-07-10 04:12:43 +02:00
|
|
|
reply = (xGLXIsDirectReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.isDirect = 0
|
|
|
|
};
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
if (client->swapped) {
|
2012-03-21 20:55:09 +01:00
|
|
|
__glXSwapIsDirectReply(client, &reply);
|
|
|
|
}
|
|
|
|
else {
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, sz_xGLXIsDirectReply, &reply);
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXQueryVersion(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
ClientPtr client = cl->client;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2004-06-30 22:06:56 +02:00
|
|
|
/* xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) pc; */
|
|
|
|
|
2012-07-10 04:12:43 +02:00
|
|
|
xGLXQueryVersionReply reply = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
2004-06-30 22:06:56 +02:00
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Server should take into consideration the version numbers sent by the
|
|
|
|
** client if it wants to work with older clients; however, in this
|
|
|
|
** implementation the server just returns its version number.
|
|
|
|
*/
|
2012-07-10 04:12:43 +02:00
|
|
|
.majorVersion = __glXVersionMajor,
|
|
|
|
.minorVersion = __glXVersionMinor
|
|
|
|
};
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
if (client->swapped) {
|
2012-03-21 20:55:09 +01:00
|
|
|
__glXSwapQueryVersionReply(client, &reply);
|
|
|
|
}
|
|
|
|
else {
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, sz_xGLXQueryVersionReply, &reply);
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXWaitGL(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
xGLXWaitGLReq *req = (xGLXWaitGLReq *) pc;
|
|
|
|
xGLXWaitGLReq *be_req = (xGLXWaitGLReq *) pc;
|
2004-06-30 22:06:56 +02:00
|
|
|
int from_screen = 0;
|
|
|
|
int to_screen = 0;
|
|
|
|
int s;
|
|
|
|
__GLXcontext *glxc = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2004-06-30 22:06:56 +02:00
|
|
|
if (req->contextTag != 0) {
|
2012-03-21 20:55:09 +01:00
|
|
|
glxc = __glXLookupContextByTag(cl, req->contextTag);
|
|
|
|
if (glxc) {
|
|
|
|
from_screen = to_screen = glxc->pScreen->myNum;
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
if (!noPanoramiXExtension) {
|
2012-03-21 20:55:09 +01:00
|
|
|
from_screen = 0;
|
|
|
|
to_screen = screenInfo.numScreens - 1;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
for (s = from_screen; s <= to_screen; s++) {
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[s];
|
|
|
|
Display *dpy = GetBackEndDisplay(cl, s);
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
LockDisplay(dpy);
|
|
|
|
GetReq(GLXWaitGL, be_req);
|
|
|
|
be_req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
be_req->glxCode = X_GLXWaitGL;
|
|
|
|
be_req->contextTag =
|
|
|
|
(glxc ? GetCurrentBackEndTag(cl, req->contextTag, s) : 0);
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
XSync(dpy, False);
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2004-06-30 22:06:56 +02:00
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXWaitX(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
xGLXWaitXReq *req = (xGLXWaitXReq *) pc;
|
2004-06-30 22:06:56 +02:00
|
|
|
xGLXWaitXReq *be_req;
|
|
|
|
int from_screen = 0;
|
|
|
|
int to_screen = 0;
|
|
|
|
int s;
|
|
|
|
__GLXcontext *glxc = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2004-06-30 22:06:56 +02:00
|
|
|
if (req->contextTag != 0) {
|
2012-03-21 20:55:09 +01:00
|
|
|
glxc = __glXLookupContextByTag(cl, req->contextTag);
|
|
|
|
if (glxc) {
|
|
|
|
from_screen = to_screen = glxc->pScreen->myNum;
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
if (!noPanoramiXExtension) {
|
2012-03-21 20:55:09 +01:00
|
|
|
from_screen = 0;
|
|
|
|
to_screen = screenInfo.numScreens - 1;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
for (s = from_screen; s <= to_screen; s++) {
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[s];
|
|
|
|
Display *dpy = GetBackEndDisplay(cl, s);
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
dmxSync(dmxScreen, 1);
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
LockDisplay(dpy);
|
|
|
|
GetReq(GLXWaitX, be_req);
|
|
|
|
be_req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
be_req->glxCode = X_GLXWaitX;
|
|
|
|
be_req->contextTag =
|
|
|
|
(glxc ? GetCurrentBackEndTag(cl, req->contextTag, s) : 0);
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
XFlush(dpy);
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXCopyContext(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
ClientPtr client = cl->client;
|
|
|
|
xGLXCopyContextReq *be_req;
|
|
|
|
xGLXCopyContextReq *req = (xGLXCopyContextReq *) pc;
|
|
|
|
GLXContextID source = req->source;
|
|
|
|
GLXContextID dest = req->dest;
|
|
|
|
GLXContextTag tag = req->contextTag;
|
|
|
|
unsigned long mask = req->mask;
|
|
|
|
__GLXcontext *src, *dst;
|
|
|
|
int s;
|
|
|
|
int from_screen = 0;
|
|
|
|
int to_screen = 0;
|
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Check that each context exists.
|
|
|
|
*/
|
|
|
|
dixLookupResourceByType((pointer *) &src, source, __glXContextRes,
|
Replace LookupIDByType() with dixLookupResourceByType(), take 1.
This patch has been prepared with the following Coccinelle semantic patch:
@@
expression x, y;
type t;
identifier r;
@@
-r = (t) LookupIDByType(x, y);
+dixLookupResourceByType((pointer*)&r, x, y, NullClient, DixUnknownAccess);
@@
expression x, y;
type t;
identifier r;
@@
-t r = (t) LookupIDByType(x, y);
+t r;
+dixLookupResourceByType((pointer*)&r, x, y, NullClient, DixUnknownAccess);
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Cyril Brulebois <kibi@debian.org>
2010-11-11 15:30:15 +01:00
|
|
|
NullClient, DixUnknownAccess);
|
2004-06-30 22:06:56 +02:00
|
|
|
if (!src) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = source;
|
|
|
|
return __glXBadContext;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
dixLookupResourceByType((pointer *) &dst, dest, __glXContextRes,
|
Replace LookupIDByType() with dixLookupResourceByType(), take 1.
This patch has been prepared with the following Coccinelle semantic patch:
@@
expression x, y;
type t;
identifier r;
@@
-r = (t) LookupIDByType(x, y);
+dixLookupResourceByType((pointer*)&r, x, y, NullClient, DixUnknownAccess);
@@
expression x, y;
type t;
identifier r;
@@
-t r = (t) LookupIDByType(x, y);
+t r;
+dixLookupResourceByType((pointer*)&r, x, y, NullClient, DixUnknownAccess);
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Cyril Brulebois <kibi@debian.org>
2010-11-11 15:30:15 +01:00
|
|
|
NullClient, DixUnknownAccess);
|
2004-06-30 22:06:56 +02:00
|
|
|
if (!dst) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = dest;
|
|
|
|
return __glXBadContext;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** They must be in the same address space, and same screen.
|
|
|
|
*/
|
2004-06-30 22:06:56 +02:00
|
|
|
if (src->pGlxScreen != dst->pGlxScreen) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = source;
|
|
|
|
return BadMatch;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** The destination context must not be current for any client.
|
|
|
|
*/
|
2004-06-30 22:06:56 +02:00
|
|
|
if (dst->isCurrent) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = dest;
|
|
|
|
return BadAccess;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (tag) {
|
2012-03-21 20:55:09 +01:00
|
|
|
__GLXcontext *tagcx = __glXLookupContextByTag(cl, tag);
|
|
|
|
|
|
|
|
if (!tagcx) {
|
|
|
|
return __glXBadContextTag;
|
|
|
|
}
|
|
|
|
if (tagcx != src) {
|
|
|
|
/*
|
|
|
|
** This would be caused by a faulty implementation of the client
|
|
|
|
** library.
|
|
|
|
*/
|
|
|
|
return BadMatch;
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
from_screen = to_screen = src->pScreen->myNum;
|
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
if (!noPanoramiXExtension) {
|
2012-03-21 20:55:09 +01:00
|
|
|
from_screen = 0;
|
|
|
|
to_screen = screenInfo.numScreens - 1;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
for (s = from_screen; s <= to_screen; s++) {
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[s];
|
|
|
|
Display *dpy = GetBackEndDisplay(cl, s);
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
LockDisplay(dpy);
|
|
|
|
GetReq(GLXCopyContext, be_req);
|
|
|
|
be_req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
be_req->glxCode = X_GLXCopyContext;
|
|
|
|
be_req->source = (unsigned int) src->real_ids[s - from_screen];
|
|
|
|
be_req->dest = (unsigned int) dst->real_ids[s - from_screen];
|
|
|
|
be_req->mask = mask;
|
|
|
|
be_req->contextTag =
|
|
|
|
(tag ? GetCurrentBackEndTag(cl, req->contextTag, s) : 0);
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXGetVisualConfigs(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
ClientPtr client = cl->client;
|
|
|
|
xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc;
|
|
|
|
xGLXGetVisualConfigsReply reply;
|
|
|
|
__GLXscreenInfo *pGlxScreen;
|
|
|
|
__GLXvisualConfig *pGlxVisual;
|
|
|
|
CARD32 buf[__GLX_TOTAL_CONFIG];
|
|
|
|
unsigned int screen;
|
|
|
|
int i, p;
|
|
|
|
|
|
|
|
screen = req->screen;
|
2010-12-01 14:12:55 +01:00
|
|
|
if (screen >= screenInfo.numScreens) {
|
2012-03-21 20:55:09 +01:00
|
|
|
/* The client library must send a valid screen number. */
|
|
|
|
client->errorValue = screen;
|
|
|
|
return BadValue;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
pGlxScreen = &__glXActiveScreens[screen];
|
|
|
|
|
2012-07-10 04:12:43 +02:00
|
|
|
reply = (xGLXGetVisualConfigsReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.numVisuals = pGlxScreen->numGLXVisuals,
|
|
|
|
.numProps = __GLX_TOTAL_CONFIG,
|
|
|
|
.length = (pGlxScreen->numGLXVisuals * __GLX_SIZE_CARD32 *
|
|
|
|
__GLX_TOTAL_CONFIG) >> 2
|
|
|
|
};
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, sz_xGLXGetVisualConfigsReply, &reply);
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
for (i = 0; i < pGlxScreen->numVisuals; i++) {
|
|
|
|
pGlxVisual = &pGlxScreen->pGlxVisual[i];
|
|
|
|
if (!pGlxScreen->isGLXvis[i] || pGlxVisual->vid == 0) {
|
|
|
|
/* not a usable visual */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
p = 0;
|
|
|
|
buf[p++] = pGlxVisual->vid;
|
|
|
|
buf[p++] = pGlxVisual->class;
|
|
|
|
buf[p++] = pGlxVisual->rgba;
|
|
|
|
|
|
|
|
buf[p++] = pGlxVisual->redSize;
|
|
|
|
buf[p++] = pGlxVisual->greenSize;
|
|
|
|
buf[p++] = pGlxVisual->blueSize;
|
|
|
|
buf[p++] = pGlxVisual->alphaSize;
|
|
|
|
buf[p++] = pGlxVisual->accumRedSize;
|
|
|
|
buf[p++] = pGlxVisual->accumGreenSize;
|
|
|
|
buf[p++] = pGlxVisual->accumBlueSize;
|
|
|
|
buf[p++] = pGlxVisual->accumAlphaSize;
|
|
|
|
|
|
|
|
buf[p++] = pGlxVisual->doubleBuffer;
|
|
|
|
buf[p++] = pGlxVisual->stereo;
|
|
|
|
|
|
|
|
buf[p++] = pGlxVisual->bufferSize;
|
|
|
|
buf[p++] = pGlxVisual->depthSize;
|
|
|
|
buf[p++] = pGlxVisual->stencilSize;
|
|
|
|
buf[p++] = pGlxVisual->auxBuffers;
|
|
|
|
buf[p++] = pGlxVisual->level;
|
|
|
|
/*
|
|
|
|
** Add token/value pairs for extensions.
|
|
|
|
*/
|
|
|
|
buf[p++] = GLX_VISUAL_CAVEAT_EXT;
|
|
|
|
buf[p++] = pGlxVisual->visualRating;
|
|
|
|
buf[p++] = GLX_TRANSPARENT_TYPE_EXT;
|
|
|
|
buf[p++] = pGlxVisual->transparentPixel;
|
|
|
|
buf[p++] = GLX_TRANSPARENT_RED_VALUE_EXT;
|
|
|
|
buf[p++] = pGlxVisual->transparentRed;
|
|
|
|
buf[p++] = GLX_TRANSPARENT_GREEN_VALUE_EXT;
|
|
|
|
buf[p++] = pGlxVisual->transparentGreen;
|
|
|
|
buf[p++] = GLX_TRANSPARENT_BLUE_VALUE_EXT;
|
|
|
|
buf[p++] = pGlxVisual->transparentBlue;
|
|
|
|
buf[p++] = GLX_TRANSPARENT_ALPHA_VALUE_EXT;
|
|
|
|
buf[p++] = pGlxVisual->transparentAlpha;
|
|
|
|
buf[p++] = GLX_TRANSPARENT_INDEX_VALUE_EXT;
|
|
|
|
buf[p++] = pGlxVisual->transparentIndex;
|
|
|
|
buf[p++] = GLX_SAMPLES_SGIS;
|
|
|
|
buf[p++] = pGlxVisual->multiSampleSize;
|
|
|
|
buf[p++] = GLX_SAMPLE_BUFFERS_SGIS;
|
|
|
|
buf[p++] = pGlxVisual->nMultiSampleBuffers;
|
|
|
|
buf[p++] = GLX_VISUAL_SELECT_GROUP_SGIX;
|
|
|
|
buf[p++] = pGlxVisual->visualSelectGroup;
|
|
|
|
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, __GLX_SIZE_CARD32 * __GLX_TOTAL_CONFIG, buf);
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Create a GLX Pixmap from an X Pixmap.
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
static int
|
|
|
|
CreateGLXPixmap(__GLXclientState * cl,
|
|
|
|
VisualID visual, GLXFBConfigID fbconfigId,
|
|
|
|
int screenNum, XID pixmapId, XID glxpixmapId)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
ClientPtr client = cl->client;
|
|
|
|
xGLXCreateGLXPixmapReq *be_req;
|
|
|
|
xGLXCreatePixmapReq *be_new_req;
|
|
|
|
DrawablePtr pDraw;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
VisualPtr pVisual;
|
|
|
|
__GLXpixmap *pGlxPixmap;
|
|
|
|
__GLXscreenInfo *pGlxScreen;
|
|
|
|
__GLXvisualConfig *pGlxVisual;
|
|
|
|
__GLXFBConfig *pFBConfig;
|
2006-12-15 22:36:29 +01:00
|
|
|
int i, s, rc;
|
2004-06-30 22:06:56 +02:00
|
|
|
int from_screen, to_screen;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2004-06-30 22:06:56 +02:00
|
|
|
#ifdef PANORAMIX
|
|
|
|
PanoramiXRes *pXinDraw = NULL;
|
|
|
|
#endif
|
|
|
|
|
2006-12-15 22:36:29 +01:00
|
|
|
rc = dixLookupDrawable(&pDraw, pixmapId, client, M_DRAWABLE_PIXMAP,
|
2012-03-21 20:55:09 +01:00
|
|
|
DixAddAccess);
|
2006-12-15 22:36:29 +01:00
|
|
|
if (rc != Success)
|
2012-03-21 20:55:09 +01:00
|
|
|
return rc;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Check if screen of visual matches screen of pixmap.
|
|
|
|
*/
|
2004-06-30 22:06:56 +02:00
|
|
|
pScreen = pDraw->pScreen;
|
|
|
|
if (screenNum != pScreen->myNum) {
|
2012-03-21 20:55:09 +01:00
|
|
|
return BadMatch;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
2011-02-08 20:32:54 +01:00
|
|
|
if (fbconfigId == 0 && visual == 0) {
|
2012-03-21 20:55:09 +01:00
|
|
|
return BadValue;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fbconfigId != None) {
|
2012-03-21 20:55:09 +01:00
|
|
|
pFBConfig = glxLookupFBConfig(fbconfigId);
|
|
|
|
if (!pFBConfig) {
|
|
|
|
client->errorValue = fbconfigId;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
visual = pFBConfig->associatedVisualId;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
else {
|
2012-03-21 20:55:09 +01:00
|
|
|
pFBConfig = NULL;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (visual != None) {
|
2012-03-21 20:55:09 +01:00
|
|
|
/*
|
|
|
|
** Find the VisualRec for this visual.
|
|
|
|
*/
|
|
|
|
pVisual = pScreen->visuals;
|
|
|
|
for (i = 0; i < pScreen->numVisuals; i++, pVisual++) {
|
|
|
|
if (pVisual->vid == visual) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == pScreen->numVisuals) {
|
|
|
|
client->errorValue = visual;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
** Check if depth of visual matches depth of pixmap.
|
|
|
|
*/
|
|
|
|
if (pVisual->nplanes != pDraw->depth) {
|
|
|
|
client->errorValue = visual;
|
|
|
|
return BadMatch;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Get configuration of the visual.
|
|
|
|
*/
|
|
|
|
pGlxScreen = &__glXActiveScreens[screenNum];
|
|
|
|
pGlxVisual = pGlxScreen->pGlxVisual;
|
|
|
|
for (i = 0; i < pGlxScreen->numVisuals; i++, pGlxVisual++) {
|
|
|
|
if (pGlxVisual->vid == visual) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == pGlxScreen->numVisuals) {
|
|
|
|
/*
|
|
|
|
** Visual not support on this screen by this OpenGL implementation.
|
|
|
|
*/
|
|
|
|
client->errorValue = visual;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* find the FBConfig for that visual (if any) */
|
|
|
|
if (pFBConfig == NULL) {
|
|
|
|
pFBConfig = glxLookupFBConfigByVID(visual);
|
|
|
|
|
|
|
|
if (pFBConfig == NULL) {
|
|
|
|
/*
|
|
|
|
* visual does not have an FBConfig ???
|
|
|
|
client->errorValue = visual;
|
|
|
|
return BadValue;
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
else {
|
2012-03-21 20:55:09 +01:00
|
|
|
pVisual = NULL;
|
|
|
|
pGlxVisual = NULL;
|
|
|
|
pGlxScreen = &__glXActiveScreens[pDraw->pScreen->myNum];
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
2010-05-25 22:28:32 +02:00
|
|
|
pGlxPixmap = (__GLXpixmap *) malloc(sizeof(__GLXpixmap));
|
2004-06-30 22:06:56 +02:00
|
|
|
if (!pGlxPixmap) {
|
2012-03-21 20:55:09 +01:00
|
|
|
return BadAlloc;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
2010-05-25 22:28:32 +02:00
|
|
|
pGlxPixmap->be_xids = (XID *) malloc(sizeof(XID) * screenInfo.numScreens);
|
2004-06-30 22:06:56 +02:00
|
|
|
if (!pGlxPixmap->be_xids) {
|
2012-03-21 20:55:09 +01:00
|
|
|
free(pGlxPixmap);
|
|
|
|
return BadAlloc;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
pGlxPixmap->pDraw = pDraw;
|
|
|
|
pGlxPixmap->pGlxScreen = pGlxScreen;
|
|
|
|
pGlxPixmap->pGlxVisual = pGlxVisual;
|
|
|
|
pGlxPixmap->pFBConfig = pFBConfig;
|
|
|
|
pGlxPixmap->pScreen = pScreen;
|
|
|
|
pGlxPixmap->idExists = True;
|
|
|
|
pGlxPixmap->refcnt = 0;
|
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Bump the ref count on the X pixmap so it won't disappear.
|
|
|
|
*/
|
2004-06-30 22:06:56 +02:00
|
|
|
((PixmapPtr) pDraw)->refcnt++;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* send the request to the back-end server(s)
|
|
|
|
*/
|
|
|
|
from_screen = to_screen = screenNum;
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
if (!noPanoramiXExtension) {
|
2012-03-21 20:55:09 +01:00
|
|
|
from_screen = 0;
|
|
|
|
to_screen = screenInfo.numScreens - 1;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
dixLookupResourceByClass((pointer *) &pXinDraw,
|
|
|
|
pDraw->id, XRC_DRAWABLE,
|
|
|
|
client, DixReadAccess);
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
for (s = from_screen; s <= to_screen; s++) {
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[s];
|
|
|
|
Display *dpy = GetBackEndDisplay(cl, s);
|
|
|
|
Pixmap be_pixmap;
|
|
|
|
DrawablePtr pRealDraw = pDraw;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2004-07-07 01:51:00 +02:00
|
|
|
#ifdef PANORAMIX
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pXinDraw) {
|
|
|
|
dixLookupDrawable(&pRealDraw, pXinDraw->info[s].id, client, 0,
|
|
|
|
DixAddAccess);
|
|
|
|
}
|
2004-07-07 01:51:00 +02:00
|
|
|
#endif
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
be_pixmap = (DMX_GET_PIXMAP_PRIV((PixmapPtr) pRealDraw))->pixmap;
|
|
|
|
|
|
|
|
/* make sure pixmap already created on back-end */
|
|
|
|
dmxSync(dmxScreen, 1);
|
|
|
|
|
|
|
|
if (pFBConfig && __GLX_IS_VERSION_SUPPORTED(1, 3)) {
|
|
|
|
__GLXFBConfig *be_FBConfig =
|
|
|
|
glxLookupBackEndFBConfig(pFBConfig->id, s);
|
|
|
|
|
|
|
|
LockDisplay(dpy);
|
|
|
|
pGlxPixmap->be_xids[s] = XAllocID(dpy);
|
|
|
|
GetReq(GLXCreatePixmap, be_new_req);
|
|
|
|
be_new_req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
be_new_req->glxCode = X_GLXCreatePixmap;
|
|
|
|
be_new_req->screen = DefaultScreen(dpy);
|
|
|
|
be_new_req->fbconfig = be_FBConfig->id;
|
|
|
|
be_new_req->pixmap = (unsigned int) be_pixmap;
|
|
|
|
be_new_req->glxpixmap = (unsigned int) pGlxPixmap->be_xids[s];
|
|
|
|
be_new_req->numAttribs = 0;
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
|
|
|
}
|
|
|
|
else if (pFBConfig && glxIsExtensionSupported("GLX_SGIX_fbconfig")) {
|
|
|
|
__GLXFBConfig *be_FBConfig =
|
|
|
|
glxLookupBackEndFBConfig(pFBConfig->id, s);
|
|
|
|
xGLXCreateGLXPixmapWithConfigSGIXReq *ext_req;
|
|
|
|
xGLXVendorPrivateReq *vpreq;
|
|
|
|
|
|
|
|
LockDisplay(dpy);
|
|
|
|
pGlxPixmap->be_xids[s] = XAllocID(dpy);
|
|
|
|
GetReqExtra(GLXVendorPrivate,
|
|
|
|
sz_xGLXCreateGLXPixmapWithConfigSGIXReq -
|
|
|
|
sz_xGLXVendorPrivateReq, vpreq);
|
|
|
|
ext_req = (xGLXCreateGLXPixmapWithConfigSGIXReq *) vpreq;
|
|
|
|
ext_req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
ext_req->glxCode = X_GLXVendorPrivate;
|
|
|
|
ext_req->vendorCode = X_GLXvop_CreateGLXPixmapWithConfigSGIX;
|
|
|
|
ext_req->screen = DefaultScreen(dpy);
|
|
|
|
ext_req->fbconfig = be_FBConfig->id;
|
|
|
|
ext_req->pixmap = (unsigned int) be_pixmap;
|
|
|
|
ext_req->glxpixmap = (unsigned int) pGlxPixmap->be_xids[s];
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
|
|
|
}
|
|
|
|
else if (pGlxVisual) {
|
|
|
|
LockDisplay(dpy);
|
|
|
|
pGlxPixmap->be_xids[s] = XAllocID(dpy);
|
|
|
|
GetReq(GLXCreateGLXPixmap, be_req);
|
|
|
|
be_req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
be_req->glxCode = X_GLXCreateGLXPixmap;
|
|
|
|
be_req->screen = DefaultScreen(dpy);
|
|
|
|
be_req->visual =
|
|
|
|
(unsigned int) glxMatchGLXVisualInConfigList(pGlxVisual,
|
|
|
|
dmxScreen->
|
|
|
|
glxVisuals,
|
|
|
|
dmxScreen->
|
|
|
|
numGlxVisuals);
|
|
|
|
be_req->pixmap = (unsigned int) be_pixmap;
|
|
|
|
be_req->glxpixmap = (unsigned int) pGlxPixmap->be_xids[s];
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
client->errorValue = (visual ? visual : fbconfigId);
|
|
|
|
free(pGlxPixmap);
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
XFlush(dpy);
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!(AddResource(glxpixmapId, __glXPixmapRes, pGlxPixmap))) {
|
2012-03-21 20:55:09 +01:00
|
|
|
free(pGlxPixmap);
|
|
|
|
return BadAlloc;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXCreateGLXPixmap(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
return (CreateGLXPixmap(cl, req->visual, None,
|
|
|
|
req->screen, req->pixmap, req->glxpixmap));
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXCreatePixmap(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
return (CreateGLXPixmap(cl, None, req->fbconfig,
|
|
|
|
req->screen, req->pixmap, req->glxpixmap));
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXDestroyGLXPixmap(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
ClientPtr client = cl->client;
|
|
|
|
xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc;
|
|
|
|
XID glxpixmap = req->glxpixmap;
|
|
|
|
__GLXpixmap *pGlxPixmap;
|
|
|
|
int s;
|
|
|
|
int from_screen, to_screen;
|
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Check if it's a valid GLX pixmap.
|
|
|
|
*/
|
|
|
|
dixLookupResourceByType((pointer *) &pGlxPixmap, glxpixmap,
|
Replace LookupIDByType() with dixLookupResourceByType(), take 1.
This patch has been prepared with the following Coccinelle semantic patch:
@@
expression x, y;
type t;
identifier r;
@@
-r = (t) LookupIDByType(x, y);
+dixLookupResourceByType((pointer*)&r, x, y, NullClient, DixUnknownAccess);
@@
expression x, y;
type t;
identifier r;
@@
-t r = (t) LookupIDByType(x, y);
+t r;
+dixLookupResourceByType((pointer*)&r, x, y, NullClient, DixUnknownAccess);
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Cyril Brulebois <kibi@debian.org>
2010-11-11 15:30:15 +01:00
|
|
|
__glXPixmapRes, NullClient, DixUnknownAccess);
|
2004-06-30 22:06:56 +02:00
|
|
|
if (!pGlxPixmap) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = glxpixmap;
|
|
|
|
return __glXBadPixmap;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
FreeResource(glxpixmap, FALSE);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* destroy the pixmap on the back-end server(s).
|
|
|
|
*/
|
|
|
|
from_screen = to_screen = pGlxPixmap->pDraw->pScreen->myNum;
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
if (!noPanoramiXExtension) {
|
2012-03-21 20:55:09 +01:00
|
|
|
from_screen = 0;
|
|
|
|
to_screen = screenInfo.numScreens - 1;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
for (s = from_screen; s <= to_screen; s++) {
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[s];
|
|
|
|
Display *dpy = GetBackEndDisplay(cl, s);
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
/* make sure pixmap exist in back-end */
|
|
|
|
dmxSync(dmxScreen, 1);
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
LockDisplay(dpy);
|
|
|
|
GetReq(GLXDestroyGLXPixmap, req);
|
|
|
|
req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
req->glxCode = X_GLXDestroyGLXPixmap;
|
|
|
|
req->glxpixmap = (unsigned int) pGlxPixmap->be_xids[s];
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
** NOTE: There is no portable implementation for swap buffers as of
|
|
|
|
** this time that is of value. Consequently, this code must be
|
|
|
|
** implemented by somebody other than SGI.
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXDoSwapBuffers(__GLXclientState * cl, XID drawId, GLXContextTag tag)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
ClientPtr client = cl->client;
|
|
|
|
DrawablePtr pDraw;
|
|
|
|
xGLXSwapBuffersReq *be_req;
|
|
|
|
WindowPtr pWin = NULL;
|
|
|
|
__GLXpixmap *pGlxPixmap = NULL;
|
|
|
|
__GLXcontext *glxc = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2004-07-07 01:51:00 +02:00
|
|
|
#ifdef PANORAMIX
|
2004-06-30 22:06:56 +02:00
|
|
|
PanoramiXRes *pXinDraw = NULL;
|
2004-07-07 01:51:00 +02:00
|
|
|
#endif
|
2004-06-30 22:06:56 +02:00
|
|
|
__glXWindow *pGlxWindow = NULL;
|
|
|
|
int from_screen = 0;
|
|
|
|
int to_screen = 0;
|
2006-12-15 22:36:29 +01:00
|
|
|
int s, rc;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2004-06-30 22:06:56 +02:00
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Check that the GLX drawable is valid.
|
|
|
|
*/
|
2008-02-28 22:43:43 +01:00
|
|
|
rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixWriteAccess);
|
2006-12-15 22:36:29 +01:00
|
|
|
if (rc == Success) {
|
2004-06-30 22:06:56 +02:00
|
|
|
from_screen = to_screen = pDraw->pScreen->myNum;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pDraw->type == DRAWABLE_WINDOW) {
|
|
|
|
/*
|
|
|
|
** Drawable is an X window.
|
|
|
|
*/
|
|
|
|
pWin = (WindowPtr) pDraw;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
** Drawable is an X pixmap, which is not allowed.
|
|
|
|
*/
|
|
|
|
client->errorValue = drawId;
|
|
|
|
return __glXBadDrawable;
|
|
|
|
}
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
if (!pDraw) {
|
2012-03-21 20:55:09 +01:00
|
|
|
dixLookupResourceByType((pointer *) &pGlxPixmap, drawId,
|
|
|
|
__glXPixmapRes, NullClient, DixUnknownAccess);
|
|
|
|
if (pGlxPixmap) {
|
|
|
|
/*
|
|
|
|
** Drawable is a GLX pixmap.
|
|
|
|
*/
|
|
|
|
pDraw = pGlxPixmap->pDraw;
|
|
|
|
from_screen = to_screen = pGlxPixmap->pScreen->myNum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1, 3)) {
|
|
|
|
dixLookupResourceByType((pointer *) &pGlxWindow, drawId,
|
|
|
|
__glXWindowRes, NullClient, DixUnknownAccess);
|
|
|
|
if (pGlxWindow) {
|
|
|
|
/*
|
|
|
|
** Drawable is a GLXWindow.
|
|
|
|
*/
|
|
|
|
pDraw = pGlxWindow->pDraw;
|
|
|
|
from_screen = to_screen = pGlxWindow->pScreen->myNum;
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!pDraw) {
|
2012-03-21 20:55:09 +01:00
|
|
|
/*
|
|
|
|
** Drawable is neither a X window nor a GLX pixmap.
|
|
|
|
*/
|
|
|
|
client->errorValue = drawId;
|
|
|
|
return __glXBadDrawable;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (tag) {
|
2012-03-21 20:55:09 +01:00
|
|
|
glxc = __glXLookupContextByTag(cl, tag);
|
|
|
|
if (!glxc) {
|
|
|
|
return __glXBadContextTag;
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
if (!noPanoramiXExtension) {
|
2012-03-21 20:55:09 +01:00
|
|
|
from_screen = 0;
|
|
|
|
to_screen = screenInfo.numScreens - 1;
|
|
|
|
dixLookupResourceByClass((pointer *) &pXinDraw,
|
|
|
|
pDraw->id, XRC_DRAWABLE,
|
|
|
|
client, DixReadAccess);
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* If requested, send a glFinish to all back-end servers before swapping. */
|
|
|
|
if (dmxGLXFinishSwap) {
|
2012-03-21 20:55:09 +01:00
|
|
|
for (s = from_screen; s <= to_screen; s++) {
|
|
|
|
Display *dpy = GetBackEndDisplay(cl, s);
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[s];
|
|
|
|
xGLXSingleReq *finishReq;
|
|
|
|
xGLXSingleReply reply;
|
|
|
|
|
|
|
|
#define X_GLXSingle 0 /* needed by GetReq below */
|
|
|
|
|
|
|
|
LockDisplay(dpy);
|
|
|
|
GetReq(GLXSingle, finishReq);
|
|
|
|
finishReq->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
finishReq->glxCode = X_GLsop_Finish;
|
|
|
|
finishReq->contextTag =
|
|
|
|
(tag ? GetCurrentBackEndTag(cl, tag, s) : 0);
|
2012-11-06 06:50:58 +01:00
|
|
|
(void) _XReply(dpy, (xReply *) &reply, 0, False);
|
2012-03-21 20:55:09 +01:00
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If requested, send an XSync to all back-end servers before swapping. */
|
|
|
|
if (dmxGLXSyncSwap) {
|
2012-03-21 20:55:09 +01:00
|
|
|
for (s = from_screen; s <= to_screen; s++)
|
|
|
|
XSync(GetBackEndDisplay(cl, s), False);
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* send the SwapBuffers request to all back-end servers */
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
for (s = from_screen; s <= to_screen; s++) {
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[s];
|
|
|
|
Display *dpy = GetBackEndDisplay(cl, s);
|
|
|
|
unsigned int be_draw = 0;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pGlxPixmap) {
|
|
|
|
be_draw = (unsigned int) pGlxPixmap->be_xids[s];
|
|
|
|
}
|
2004-07-07 01:51:00 +02:00
|
|
|
#ifdef PANORAMIX
|
2012-03-21 20:55:09 +01:00
|
|
|
else if (pXinDraw) {
|
|
|
|
dixLookupWindow(&pWin, pXinDraw->info[s].id, client, DixReadAccess);
|
|
|
|
}
|
2004-07-07 01:51:00 +02:00
|
|
|
#endif
|
2012-03-21 20:55:09 +01:00
|
|
|
else if (pGlxWindow) {
|
|
|
|
pWin = (WindowPtr) pGlxWindow->pDraw;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pWin && !be_draw) {
|
|
|
|
be_draw = (unsigned int) (DMX_GET_WINDOW_PRIV(pWin))->window;
|
|
|
|
if (!be_draw) {
|
|
|
|
/* it might be that the window did not created yet on the */
|
|
|
|
/* back-end server (lazy window creation option), force */
|
|
|
|
/* creation of the window */
|
|
|
|
dmxCreateAndRealizeWindow(pWin, TRUE);
|
|
|
|
be_draw = (unsigned int) (DMX_GET_WINDOW_PRIV(pWin))->window;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dmxSync(dmxScreen, 1);
|
|
|
|
|
|
|
|
LockDisplay(dpy);
|
|
|
|
GetReq(GLXSwapBuffers, be_req);
|
|
|
|
be_req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
be_req->glxCode = X_GLXSwapBuffers;
|
|
|
|
be_req->drawable = be_draw;
|
|
|
|
be_req->contextTag = (tag ? GetCurrentBackEndTag(cl, tag, s) : 0);
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
|
|
|
XFlush(dpy);
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXSwapBuffers(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
ClientPtr client = cl->client;
|
|
|
|
DrawablePtr pDraw;
|
|
|
|
xGLXSwapBuffersReq *req = (xGLXSwapBuffersReq *) pc;
|
|
|
|
GLXContextTag tag = req->contextTag;
|
|
|
|
XID drawId = req->drawable;
|
|
|
|
__GLXpixmap *pGlxPixmap = NULL;
|
|
|
|
__GLXcontext *glxc = NULL;
|
|
|
|
__glXWindow *pGlxWindow = NULL;
|
2006-12-15 22:36:29 +01:00
|
|
|
int rc;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2004-06-30 22:06:56 +02:00
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Check that the GLX drawable is valid.
|
|
|
|
*/
|
2008-02-28 22:43:43 +01:00
|
|
|
rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixWriteAccess);
|
2006-12-15 22:36:29 +01:00
|
|
|
if (rc == Success) {
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pDraw->type != DRAWABLE_WINDOW) {
|
|
|
|
/*
|
|
|
|
** Drawable is an X pixmap, which is not allowed.
|
|
|
|
*/
|
|
|
|
client->errorValue = drawId;
|
|
|
|
return __glXBadDrawable;
|
|
|
|
}
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
if (!pDraw) {
|
2012-03-21 20:55:09 +01:00
|
|
|
dixLookupResourceByType((pointer *) &pGlxPixmap, drawId,
|
|
|
|
__glXPixmapRes, NullClient, DixUnknownAccess);
|
|
|
|
if (pGlxPixmap) {
|
|
|
|
/*
|
|
|
|
** Drawable is a GLX pixmap.
|
|
|
|
*/
|
|
|
|
pDraw = pGlxPixmap->pDraw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1, 3)) {
|
|
|
|
dixLookupResourceByType((pointer *) &pGlxWindow, drawId,
|
|
|
|
__glXWindowRes, NullClient, DixUnknownAccess);
|
|
|
|
if (pGlxWindow) {
|
|
|
|
/*
|
|
|
|
** Drawable is a GLXWindow.
|
|
|
|
*/
|
|
|
|
pDraw = pGlxWindow->pDraw;
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!pDraw) {
|
2012-03-21 20:55:09 +01:00
|
|
|
/*
|
|
|
|
** Drawable is neither a X window nor a GLX pixmap.
|
|
|
|
*/
|
|
|
|
client->errorValue = drawId;
|
|
|
|
return __glXBadDrawable;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (tag) {
|
2012-03-21 20:55:09 +01:00
|
|
|
glxc = __glXLookupContextByTag(cl, tag);
|
|
|
|
if (!glxc) {
|
|
|
|
return __glXBadContextTag;
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pDraw &&
|
2012-03-21 20:55:09 +01:00
|
|
|
pDraw->type == DRAWABLE_WINDOW &&
|
|
|
|
DMX_GET_WINDOW_PRIV((WindowPtr) pDraw)->swapGroup) {
|
|
|
|
return SGSwapBuffers(cl, drawId, tag, pDraw);
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return __glXDoSwapBuffers(cl, drawId, tag);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Render and Renderlarge are not in the GLX API. They are used by the GLX
|
|
|
|
** client library to send batches of GL rendering commands.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Execute all the drawing commands in a request.
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXRender(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
xGLXRenderReq *req;
|
|
|
|
xGLXRenderReq *be_req;
|
|
|
|
int size;
|
|
|
|
__GLXcontext *glxc;
|
|
|
|
int from_screen = 0;
|
|
|
|
int to_screen = 0;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** NOTE: much of this code also appears in the byteswapping version of this
|
|
|
|
** routine, __glXSwapRender(). Any changes made here should also be
|
|
|
|
** duplicated there.
|
|
|
|
*/
|
|
|
|
|
2004-06-30 22:06:56 +02:00
|
|
|
req = (xGLXRenderReq *) pc;
|
|
|
|
|
|
|
|
glxc = __glXLookupContextByTag(cl, req->contextTag);
|
|
|
|
if (!glxc) {
|
2012-03-21 20:55:09 +01:00
|
|
|
return 0;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
from_screen = to_screen = glxc->pScreen->myNum;
|
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
if (!noPanoramiXExtension) {
|
2012-03-21 20:55:09 +01:00
|
|
|
from_screen = 0;
|
|
|
|
to_screen = screenInfo.numScreens - 1;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
pc += sz_xGLXRenderReq;
|
|
|
|
size = (req->length << 2) - sz_xGLXRenderReq;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* just forward the request to back-end server(s)
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
for (s = from_screen; s <= to_screen; s++) {
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[s];
|
|
|
|
Display *dpy = GetBackEndDisplay(cl, s);
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
LockDisplay(dpy);
|
|
|
|
GetReq(GLXRender, be_req);
|
|
|
|
be_req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
be_req->glxCode = X_GLXRender;
|
|
|
|
be_req->length = req->length;
|
|
|
|
be_req->contextTag = GetCurrentBackEndTag(cl, req->contextTag, s);
|
|
|
|
_XSend(dpy, (const char *) pc, size);
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Execute a large rendering request (one that spans multiple X requests).
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXRenderLarge(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
xGLXRenderLargeReq *req;
|
|
|
|
xGLXRenderLargeReq *be_req;
|
|
|
|
__GLXcontext *glxc;
|
|
|
|
int from_screen = 0;
|
|
|
|
int to_screen = 0;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** NOTE: much of this code also appears in the byteswapping version of this
|
|
|
|
** routine, __glXSwapRenderLarge(). Any changes made here should also be
|
|
|
|
** duplicated there.
|
|
|
|
*/
|
|
|
|
|
2004-06-30 22:06:56 +02:00
|
|
|
req = (xGLXRenderLargeReq *) pc;
|
|
|
|
glxc = __glXLookupContextByTag(cl, req->contextTag);
|
|
|
|
if (!glxc) {
|
2012-03-21 20:55:09 +01:00
|
|
|
return 0;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
from_screen = to_screen = glxc->pScreen->myNum;
|
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
if (!noPanoramiXExtension) {
|
2012-03-21 20:55:09 +01:00
|
|
|
from_screen = 0;
|
|
|
|
to_screen = screenInfo.numScreens - 1;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
pc += sz_xGLXRenderLargeReq;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* just forward the request to back-end server(s)
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
for (s = from_screen; s <= to_screen; s++) {
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[s];
|
|
|
|
Display *dpy = GetBackEndDisplay(cl, s);
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
GetReq(GLXRenderLarge, be_req);
|
|
|
|
be_req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
be_req->glxCode = X_GLXRenderLarge;
|
|
|
|
be_req->contextTag = GetCurrentBackEndTag(cl, req->contextTag, s);
|
|
|
|
be_req->length = req->length;
|
|
|
|
be_req->requestNumber = req->requestNumber;
|
|
|
|
be_req->requestTotal = req->requestTotal;
|
|
|
|
be_req->dataBytes = req->dataBytes;
|
|
|
|
Data(dpy, (const char *) pc, req->dataBytes);
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXVendorPrivate(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
xGLXVendorPrivateReq *req;
|
|
|
|
|
|
|
|
req = (xGLXVendorPrivateReq *) pc;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
switch (req->vendorCode) {
|
|
|
|
|
|
|
|
case X_GLvop_DeleteTexturesEXT:
|
|
|
|
return __glXVForwardSingleReq(cl, pc);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case X_GLXvop_SwapIntervalSGI:
|
|
|
|
if (glxIsExtensionSupported("SGI_swap_control")) {
|
|
|
|
return __glXVForwardSingleReq(cl, pc);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
#if 0 /* glx 1.3 */
|
|
|
|
case X_GLXvop_CreateGLXVideoSourceSGIX:
|
|
|
|
break;
|
|
|
|
case X_GLXvop_DestroyGLXVideoSourceSGIX:
|
|
|
|
break;
|
|
|
|
case X_GLXvop_CreateGLXPixmapWithConfigSGIX:
|
|
|
|
break;
|
|
|
|
case X_GLXvop_DestroyGLXPbufferSGIX:
|
|
|
|
break;
|
|
|
|
case X_GLXvop_ChangeDrawableAttributesSGIX:
|
|
|
|
break;
|
2004-06-30 22:06:56 +02:00
|
|
|
#endif
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
case X_GLXvop_BindSwapBarrierSGIX:
|
|
|
|
return __glXBindSwapBarrierSGIX(cl, pc);
|
|
|
|
break;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
case X_GLXvop_JoinSwapGroupSGIX:
|
|
|
|
return __glXJoinSwapGroupSGIX(cl, pc);
|
|
|
|
break;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
case X_GLXvop_CreateContextWithConfigSGIX:
|
|
|
|
return __glXCreateContextWithConfigSGIX(cl, pc);
|
|
|
|
break;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
default:
|
|
|
|
/*
|
|
|
|
** unsupported private request
|
|
|
|
*/
|
|
|
|
cl->client->errorValue = req->vendorCode;
|
|
|
|
return __glXUnsupportedPrivateRequest;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cl->client->errorValue = req->vendorCode;
|
|
|
|
return __glXUnsupportedPrivateRequest;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXVendorPrivateWithReply(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
xGLXVendorPrivateWithReplyReq *req;
|
|
|
|
|
|
|
|
req = (xGLXVendorPrivateWithReplyReq *) pc;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
switch (req->vendorCode) {
|
|
|
|
|
|
|
|
case X_GLvop_GetConvolutionFilterEXT:
|
|
|
|
case X_GLvop_GetConvolutionParameterfvEXT:
|
|
|
|
case X_GLvop_GetConvolutionParameterivEXT:
|
|
|
|
case X_GLvop_GetSeparableFilterEXT:
|
|
|
|
case X_GLvop_GetHistogramEXT:
|
|
|
|
case X_GLvop_GetHistogramParameterivEXT:
|
|
|
|
case X_GLvop_GetMinmaxEXT:
|
|
|
|
case X_GLvop_GetMinmaxParameterfvEXT:
|
|
|
|
case X_GLvop_GetMinmaxParameterivEXT:
|
|
|
|
case X_GLvop_AreTexturesResidentEXT:
|
|
|
|
case X_GLvop_IsTextureEXT:
|
|
|
|
return (__glXVForwardPipe0WithReply(cl, pc));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case X_GLvop_GenTexturesEXT:
|
|
|
|
return (__glXVForwardAllWithReply(cl, pc));
|
|
|
|
break;
|
|
|
|
|
|
|
|
#if 0 /* glx1.3 */
|
|
|
|
case X_GLvop_GetDetailTexFuncSGIS:
|
|
|
|
case X_GLvop_GetSharpenTexFuncSGIS:
|
|
|
|
case X_GLvop_GetColorTableSGI:
|
|
|
|
case X_GLvop_GetColorTableParameterfvSGI:
|
|
|
|
case X_GLvop_GetColorTableParameterivSGI:
|
|
|
|
case X_GLvop_GetTexFilterFuncSGIS:
|
|
|
|
case X_GLvop_GetInstrumentsSGIX:
|
|
|
|
case X_GLvop_InstrumentsBufferSGIX:
|
|
|
|
case X_GLvop_PollInstrumentsSGIX:
|
|
|
|
case X_GLvop_FlushRasterSGIX:
|
|
|
|
case X_GLXvop_CreateGLXPbufferSGIX:
|
|
|
|
case X_GLXvop_GetDrawableAttributesSGIX:
|
|
|
|
case X_GLXvop_QueryHyperpipeNetworkSGIX:
|
|
|
|
case X_GLXvop_QueryHyperpipeConfigSGIX:
|
|
|
|
case X_GLXvop_HyperpipeConfigSGIX:
|
|
|
|
case X_GLXvop_DestroyHyperpipeConfigSGIX:
|
2004-06-30 22:06:56 +02:00
|
|
|
#endif
|
2012-03-21 20:55:09 +01:00
|
|
|
case X_GLXvop_QueryMaxSwapBarriersSGIX:
|
|
|
|
return (__glXQueryMaxSwapBarriersSGIX(cl, pc));
|
|
|
|
break;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
case X_GLXvop_GetFBConfigsSGIX:
|
|
|
|
return (__glXGetFBConfigsSGIX(cl, pc));
|
|
|
|
break;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
case X_GLXvop_MakeCurrentReadSGI:
|
|
|
|
return (__glXMakeCurrentReadSGI(cl, pc));
|
|
|
|
break;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
case X_GLXvop_QueryContextInfoEXT:
|
|
|
|
return (__glXQueryContextInfoEXT(cl, pc));
|
|
|
|
break;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
default:
|
|
|
|
/*
|
|
|
|
** unsupported private request
|
|
|
|
*/
|
|
|
|
cl->client->errorValue = req->vendorCode;
|
|
|
|
return __glXUnsupportedPrivateRequest;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXQueryExtensionsString(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
ClientPtr client = cl->client;
|
|
|
|
xGLXQueryExtensionsStringReq *req = (xGLXQueryExtensionsStringReq *) pc;
|
|
|
|
xGLXQueryExtensionsStringReply reply;
|
|
|
|
GLint screen;
|
|
|
|
size_t length;
|
|
|
|
int len, numbytes;
|
|
|
|
char *be_buf;
|
|
|
|
|
|
|
|
#ifdef FWD_QUERY_REQ
|
|
|
|
xGLXQueryExtensionsStringReq *be_req;
|
|
|
|
xGLXQueryExtensionsStringReply be_reply;
|
|
|
|
DMXScreenInfo *dmxScreen;
|
|
|
|
Display *dpy;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
screen = req->screen;
|
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Check if screen exists.
|
|
|
|
*/
|
2004-06-30 22:06:56 +02:00
|
|
|
if ((screen < 0) || (screen >= screenInfo.numScreens)) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = screen;
|
|
|
|
return BadValue;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef FWD_QUERY_REQ
|
|
|
|
dmxScreen = &dmxScreens[screen];
|
|
|
|
|
|
|
|
/* Send the glXQueryServerString request */
|
2012-03-21 20:55:09 +01:00
|
|
|
dpy = GetBackEndDisplay(cl, screen);
|
2004-06-30 22:06:56 +02:00
|
|
|
LockDisplay(dpy);
|
2012-03-21 20:55:09 +01:00
|
|
|
GetReq(GLXQueryExtensionsString, be_req);
|
2004-06-30 22:06:56 +02:00
|
|
|
be_req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
be_req->glxCode = X_GLXQueryServerString;
|
|
|
|
be_req->screen = DefaultScreen(dpy);
|
2012-11-06 06:50:58 +01:00
|
|
|
_XReply(dpy, (xReply *) &be_reply, 0, False);
|
2012-03-21 20:55:09 +01:00
|
|
|
len = (int) be_reply.length;
|
|
|
|
numbytes = (int) be_reply.n;
|
|
|
|
be_buf = (char *) malloc(numbytes);
|
2004-06-30 22:06:56 +02:00
|
|
|
if (!be_buf) {
|
|
|
|
/* Throw data on the floor */
|
2013-07-06 07:35:32 +02:00
|
|
|
_XEatDataWords(dpy, len);
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
else {
|
2013-07-06 07:32:10 +02:00
|
|
|
_XReadPad(dpy, (char *) be_buf, numbytes);
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
be_buf = __glXGetServerString(GLX_EXTENSIONS);
|
|
|
|
numbytes = strlen(be_buf) + 1;
|
|
|
|
len = __GLX_PAD(numbytes) >> 2;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
length = len;
|
2012-07-10 04:12:43 +02:00
|
|
|
reply = (xGLXQueryExtensionsStringReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = len,
|
|
|
|
.n = numbytes
|
|
|
|
};
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
if (client->swapped) {
|
|
|
|
glxSwapQueryExtensionsStringReply(client, &reply, be_buf);
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
else {
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, sz_xGLXQueryExtensionsStringReply, &reply);
|
|
|
|
WriteToClient(client, (int) (length << 2), be_buf);
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXQueryServerString(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
ClientPtr client = cl->client;
|
|
|
|
xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *) pc;
|
|
|
|
xGLXQueryServerStringReply reply;
|
|
|
|
int name;
|
|
|
|
GLint screen;
|
|
|
|
size_t length;
|
|
|
|
int len, numbytes;
|
|
|
|
char *be_buf;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2004-06-30 22:06:56 +02:00
|
|
|
#ifdef FWD_QUERY_REQ
|
|
|
|
xGLXQueryServerStringReq *be_req;
|
|
|
|
xGLXQueryServerStringReply be_reply;
|
|
|
|
DMXScreenInfo *dmxScreen;
|
|
|
|
Display *dpy;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
name = req->name;
|
|
|
|
screen = req->screen;
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Check if screen exists.
|
|
|
|
*/
|
2004-06-30 22:06:56 +02:00
|
|
|
if ((screen < 0) || (screen >= screenInfo.numScreens)) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = screen;
|
|
|
|
return BadValue;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef FWD_QUERY_REQ
|
|
|
|
dmxScreen = &dmxScreens[screen];
|
|
|
|
|
|
|
|
/* Send the glXQueryServerString request */
|
2012-03-21 20:55:09 +01:00
|
|
|
dpy = GetBackEndDisplay(cl, screen);
|
2004-06-30 22:06:56 +02:00
|
|
|
LockDisplay(dpy);
|
2012-03-21 20:55:09 +01:00
|
|
|
GetReq(GLXQueryServerString, be_req);
|
2004-06-30 22:06:56 +02:00
|
|
|
be_req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
be_req->glxCode = X_GLXQueryServerString;
|
|
|
|
be_req->screen = DefaultScreen(dpy);
|
|
|
|
be_req->name = name;
|
2012-11-06 06:50:58 +01:00
|
|
|
_XReply(dpy, (xReply *) &be_reply, 0, False);
|
2012-03-21 20:55:09 +01:00
|
|
|
len = (int) be_reply.length;
|
|
|
|
numbytes = (int) be_reply.n;
|
|
|
|
be_buf = (char *) malloc(numbytes);
|
2004-06-30 22:06:56 +02:00
|
|
|
if (!be_buf) {
|
|
|
|
/* Throw data on the floor */
|
2013-07-06 07:35:32 +02:00
|
|
|
_XEatDataWords(dpy, len);
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
else {
|
2013-07-06 07:32:10 +02:00
|
|
|
_XReadPad(dpy, (char *) be_buf, numbytes);
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
|
|
|
|
|
|
|
#else
|
|
|
|
be_buf = __glXGetServerString(name);
|
|
|
|
numbytes = strlen(be_buf) + 1;
|
|
|
|
len = __GLX_PAD(numbytes) >> 2;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
length = len;
|
2012-07-10 04:12:43 +02:00
|
|
|
reply = (xGLXQueryServerStringReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = length,
|
|
|
|
.n = numbytes
|
|
|
|
};
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
if (client->swapped) {
|
|
|
|
glxSwapQueryServerStringReply(client, &reply, be_buf);
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
else {
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, sz_xGLXQueryServerStringReply, &reply);
|
2012-03-21 20:55:09 +01:00
|
|
|
WriteToClient(client, (int) (length << 2), be_buf);
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXClientInfo(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
xGLXClientInfoReq *req = (xGLXClientInfoReq *) pc;
|
|
|
|
xGLXClientInfoReq *be_req;
|
|
|
|
const char *buf;
|
|
|
|
int from_screen = 0;
|
|
|
|
int to_screen = 0;
|
|
|
|
int s;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2010-11-08 23:35:32 +01:00
|
|
|
free(cl->GLClientextensions);
|
2012-03-21 20:55:09 +01:00
|
|
|
buf = (const char *) (req + 1);
|
2006-07-16 04:05:38 +02:00
|
|
|
cl->GLClientextensions = strdup(buf);
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
to_screen = screenInfo.numScreens - 1;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
for (s = from_screen; s <= to_screen; s++) {
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[s];
|
|
|
|
Display *dpy = GetBackEndDisplay(cl, s);
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
LockDisplay(dpy);
|
|
|
|
GetReq(GLXClientInfo, be_req);
|
|
|
|
be_req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
be_req->glxCode = X_GLXClientInfo;
|
|
|
|
be_req->major = req->major;
|
|
|
|
be_req->minor = req->minor;
|
|
|
|
be_req->length = req->length;
|
|
|
|
be_req->numbytes = req->numbytes;
|
|
|
|
Data(dpy, buf, req->numbytes);
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXUseXFont(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
ClientPtr client = cl->client;
|
|
|
|
xGLXUseXFontReq *req;
|
|
|
|
xGLXUseXFontReq *be_req;
|
|
|
|
FontPtr pFont;
|
|
|
|
__GLXcontext *glxc = NULL;
|
|
|
|
int from_screen = 0;
|
|
|
|
int to_screen = 0;
|
|
|
|
int s;
|
2012-03-21 20:55:09 +01:00
|
|
|
dmxFontPrivPtr pFontPriv;
|
2004-06-30 22:06:56 +02:00
|
|
|
DMXScreenInfo *dmxScreen;
|
|
|
|
Display *dpy;
|
|
|
|
|
|
|
|
req = (xGLXUseXFontReq *) pc;
|
|
|
|
|
|
|
|
if (req->contextTag != 0) {
|
2012-03-21 20:55:09 +01:00
|
|
|
glxc = __glXLookupContextByTag(cl, req->contextTag);
|
|
|
|
if (glxc) {
|
|
|
|
from_screen = to_screen = glxc->pScreen->myNum;
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Font can actually be either the ID of a font or the ID of a GC
|
|
|
|
** containing a font.
|
|
|
|
*/
|
|
|
|
dixLookupResourceByType((pointer *) &pFont, req->font, RT_FONT,
|
Replace LookupIDByType() with dixLookupResourceByType(), take 1.
This patch has been prepared with the following Coccinelle semantic patch:
@@
expression x, y;
type t;
identifier r;
@@
-r = (t) LookupIDByType(x, y);
+dixLookupResourceByType((pointer*)&r, x, y, NullClient, DixUnknownAccess);
@@
expression x, y;
type t;
identifier r;
@@
-t r = (t) LookupIDByType(x, y);
+t r;
+dixLookupResourceByType((pointer*)&r, x, y, NullClient, DixUnknownAccess);
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Cyril Brulebois <kibi@debian.org>
2010-11-11 15:30:15 +01:00
|
|
|
NullClient, DixUnknownAccess);
|
2004-06-30 22:06:56 +02:00
|
|
|
if (!pFont) {
|
Replace LookupIDByType() with dixLookupResourceByType(), take 1.
This patch has been prepared with the following Coccinelle semantic patch:
@@
expression x, y;
type t;
identifier r;
@@
-r = (t) LookupIDByType(x, y);
+dixLookupResourceByType((pointer*)&r, x, y, NullClient, DixUnknownAccess);
@@
expression x, y;
type t;
identifier r;
@@
-t r = (t) LookupIDByType(x, y);
+t r;
+dixLookupResourceByType((pointer*)&r, x, y, NullClient, DixUnknownAccess);
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Cyril Brulebois <kibi@debian.org>
2010-11-11 15:30:15 +01:00
|
|
|
GC *pGC;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
dixLookupResourceByType((pointer *) &pGC, req->font,
|
|
|
|
RT_GC, NullClient, DixUnknownAccess);
|
2004-06-30 22:06:56 +02:00
|
|
|
if (!pGC) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = req->font;
|
2004-06-30 22:06:56 +02:00
|
|
|
return BadFont;
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
pFont = pGC->font;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
pFontPriv = FontGetPrivate(pFont, dmxFontPrivateIndex);
|
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
if (!noPanoramiXExtension) {
|
2012-03-21 20:55:09 +01:00
|
|
|
from_screen = 0;
|
|
|
|
to_screen = screenInfo.numScreens - 1;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
for (s = from_screen; s <= to_screen; s++) {
|
|
|
|
dmxScreen = &dmxScreens[s];
|
|
|
|
dpy = GetBackEndDisplay(cl, s);
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
dmxSync(dmxScreen, 1);
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
LockDisplay(dpy);
|
|
|
|
GetReq(GLXUseXFont, be_req);
|
|
|
|
be_req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
be_req->glxCode = X_GLXUseXFont;
|
|
|
|
be_req->contextTag =
|
|
|
|
(glxc ? GetCurrentBackEndTag(cl, req->contextTag, s) : 0);
|
|
|
|
be_req->font = pFontPriv->font[s]->fid;
|
|
|
|
be_req->first = req->first;
|
|
|
|
be_req->count = req->count;
|
|
|
|
be_req->listBase = req->listBase;
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
XSync(dpy, False);
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* start GLX 1.3 here
|
|
|
|
*/
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXGetFBConfigs(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
ClientPtr client = cl->client;
|
|
|
|
xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc;
|
|
|
|
xGLXGetFBConfigsReply reply;
|
|
|
|
__GLXFBConfig *pFBConfig;
|
|
|
|
CARD32 buf[2 * __GLX_TOTAL_FBCONFIG_PROPS];
|
|
|
|
int numAttribs = __GLX_TOTAL_FBCONFIG_PROPS;
|
|
|
|
unsigned int screen = req->screen;
|
|
|
|
int numFBConfigs, i, p;
|
|
|
|
__GLXscreenInfo *pGlxScreen;
|
|
|
|
|
2010-12-01 14:12:55 +01:00
|
|
|
if (screen >= screenInfo.numScreens) {
|
2012-03-21 20:55:09 +01:00
|
|
|
/* The client library must send a valid screen number. */
|
|
|
|
client->errorValue = screen;
|
|
|
|
return BadValue;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
pGlxScreen = &__glXActiveScreens[screen];
|
|
|
|
numFBConfigs = __glXNumFBConfigs;
|
|
|
|
|
2012-07-10 04:12:43 +02:00
|
|
|
reply = (xGLXGetFBConfigsReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = (numFBConfigs * 2 * numAttribs * __GLX_SIZE_CARD32) >> 2,
|
|
|
|
.numFBConfigs = numFBConfigs,
|
|
|
|
.numAttribs = numAttribs
|
|
|
|
};
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
if (client->swapped) {
|
2012-03-21 20:55:09 +01:00
|
|
|
__GLX_DECLARE_SWAP_VARIABLES;
|
|
|
|
__GLX_SWAP_SHORT(&reply.sequenceNumber);
|
|
|
|
__GLX_SWAP_INT(&reply.length);
|
|
|
|
__GLX_SWAP_INT(&reply.numFBConfigs);
|
|
|
|
__GLX_SWAP_INT(&reply.numAttribs);
|
|
|
|
}
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, sz_xGLXGetFBConfigsReply, &reply);
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
for (i = 0; i < numFBConfigs; i++) {
|
|
|
|
int associatedVisualId = 0;
|
|
|
|
int drawableTypeIndex;
|
|
|
|
|
|
|
|
pFBConfig = __glXFBConfigs[i * (screenInfo.numScreens + 1)];
|
|
|
|
|
|
|
|
p = 0;
|
|
|
|
/* core attributes */
|
|
|
|
buf[p++] = GLX_FBCONFIG_ID;
|
|
|
|
buf[p++] = pFBConfig->id;
|
|
|
|
buf[p++] = GLX_BUFFER_SIZE;
|
|
|
|
buf[p++] = pFBConfig->indexBits;
|
|
|
|
buf[p++] = GLX_LEVEL;
|
|
|
|
buf[p++] = pFBConfig->level;
|
|
|
|
buf[p++] = GLX_DOUBLEBUFFER;
|
|
|
|
buf[p++] = pFBConfig->doubleBufferMode;
|
|
|
|
buf[p++] = GLX_STEREO;
|
|
|
|
buf[p++] = pFBConfig->stereoMode;
|
|
|
|
buf[p++] = GLX_AUX_BUFFERS;
|
|
|
|
buf[p++] = pFBConfig->maxAuxBuffers;
|
|
|
|
buf[p++] = GLX_RED_SIZE;
|
|
|
|
buf[p++] = pFBConfig->redBits;
|
|
|
|
buf[p++] = GLX_GREEN_SIZE;
|
|
|
|
buf[p++] = pFBConfig->greenBits;
|
|
|
|
buf[p++] = GLX_BLUE_SIZE;
|
|
|
|
buf[p++] = pFBConfig->blueBits;
|
|
|
|
buf[p++] = GLX_ALPHA_SIZE;
|
|
|
|
buf[p++] = pFBConfig->alphaBits;
|
|
|
|
buf[p++] = GLX_DEPTH_SIZE;
|
|
|
|
buf[p++] = pFBConfig->depthBits;
|
|
|
|
buf[p++] = GLX_STENCIL_SIZE;
|
|
|
|
buf[p++] = pFBConfig->stencilBits;
|
|
|
|
buf[p++] = GLX_ACCUM_RED_SIZE;
|
|
|
|
buf[p++] = pFBConfig->accumRedBits;
|
|
|
|
buf[p++] = GLX_ACCUM_GREEN_SIZE;
|
|
|
|
buf[p++] = pFBConfig->accumGreenBits;
|
|
|
|
buf[p++] = GLX_ACCUM_BLUE_SIZE;
|
|
|
|
buf[p++] = pFBConfig->accumBlueBits;
|
|
|
|
buf[p++] = GLX_ACCUM_ALPHA_SIZE;
|
|
|
|
buf[p++] = pFBConfig->accumAlphaBits;
|
|
|
|
buf[p++] = GLX_RENDER_TYPE;
|
|
|
|
buf[p++] = pFBConfig->renderType;
|
|
|
|
buf[p++] = GLX_DRAWABLE_TYPE;
|
|
|
|
drawableTypeIndex = p;
|
|
|
|
buf[p++] = pFBConfig->drawableType;
|
|
|
|
buf[p++] = GLX_X_VISUAL_TYPE;
|
|
|
|
buf[p++] = pFBConfig->visualType;
|
|
|
|
buf[p++] = GLX_CONFIG_CAVEAT;
|
|
|
|
buf[p++] = pFBConfig->visualCaveat;
|
|
|
|
buf[p++] = GLX_TRANSPARENT_TYPE;
|
|
|
|
buf[p++] = pFBConfig->transparentType;
|
|
|
|
buf[p++] = GLX_TRANSPARENT_RED_VALUE;
|
|
|
|
buf[p++] = pFBConfig->transparentRed;
|
|
|
|
buf[p++] = GLX_TRANSPARENT_GREEN_VALUE;
|
|
|
|
buf[p++] = pFBConfig->transparentGreen;
|
|
|
|
buf[p++] = GLX_TRANSPARENT_BLUE_VALUE;
|
|
|
|
buf[p++] = pFBConfig->transparentBlue;
|
|
|
|
buf[p++] = GLX_TRANSPARENT_ALPHA_VALUE;
|
|
|
|
buf[p++] = pFBConfig->transparentAlpha;
|
|
|
|
buf[p++] = GLX_TRANSPARENT_INDEX_VALUE;
|
|
|
|
buf[p++] = pFBConfig->transparentIndex;
|
|
|
|
buf[p++] = GLX_MAX_PBUFFER_WIDTH;
|
|
|
|
buf[p++] = pFBConfig->maxPbufferWidth;
|
|
|
|
buf[p++] = GLX_MAX_PBUFFER_HEIGHT;
|
|
|
|
buf[p++] = pFBConfig->maxPbufferHeight;
|
|
|
|
buf[p++] = GLX_MAX_PBUFFER_PIXELS;
|
|
|
|
buf[p++] = pFBConfig->maxPbufferPixels;
|
|
|
|
|
|
|
|
/*
|
2004-06-30 22:06:56 +02:00
|
|
|
* find the visual of the back-end server and match a visual
|
2012-03-21 20:55:09 +01:00
|
|
|
* on the proxy.
|
|
|
|
* do only once - if a visual is not yet associated.
|
|
|
|
*/
|
|
|
|
if (pFBConfig->associatedVisualId == (unsigned int) -1) {
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[screen];
|
|
|
|
__GLXFBConfig *be_pFBConfig =
|
|
|
|
__glXFBConfigs[i * (screenInfo.numScreens + 1) + screen + 1];
|
|
|
|
__GLXvisualConfig *pGlxVisual = NULL;
|
|
|
|
int v;
|
|
|
|
int found = 0;
|
|
|
|
|
|
|
|
for (v = 0; v < dmxScreen->numGlxVisuals; v++) {
|
|
|
|
if (dmxScreen->glxVisuals[v].vid ==
|
|
|
|
be_pFBConfig->associatedVisualId) {
|
|
|
|
pGlxVisual = &dmxScreen->glxVisuals[v];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pGlxVisual) {
|
|
|
|
for (v = 0; v < pGlxScreen->numVisuals; v++) {
|
|
|
|
if (glxVisualsMatch(&pGlxScreen->pGlxVisual[v], pGlxVisual)) {
|
|
|
|
associatedVisualId = pGlxScreen->pGlxVisual[v].vid;
|
|
|
|
found = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found) {
|
|
|
|
associatedVisualId = 0;
|
|
|
|
pFBConfig->drawableType &= ~(GLX_WINDOW_BIT);
|
|
|
|
buf[drawableTypeIndex] = pFBConfig->drawableType;
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
#ifdef PANORAMIX
|
2012-03-21 20:55:09 +01:00
|
|
|
else if (!noPanoramiXExtension) {
|
|
|
|
/* convert the associated visualId to the panoramix one */
|
|
|
|
pFBConfig->associatedVisualId =
|
|
|
|
PanoramiXTranslateVisualID(screen, v);
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
#endif
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
associatedVisualId = pFBConfig->associatedVisualId;
|
|
|
|
}
|
|
|
|
|
|
|
|
buf[p++] = GLX_VISUAL_ID;
|
|
|
|
buf[p++] = associatedVisualId;
|
|
|
|
|
|
|
|
/* SGIS_multisample attributes */
|
|
|
|
buf[p++] = GLX_SAMPLES_SGIS;
|
|
|
|
buf[p++] = pFBConfig->multiSampleSize;
|
|
|
|
buf[p++] = GLX_SAMPLE_BUFFERS_SGIS;
|
|
|
|
buf[p++] = pFBConfig->nMultiSampleBuffers;
|
|
|
|
|
|
|
|
/* SGIX_pbuffer specific attributes */
|
|
|
|
buf[p++] = GLX_OPTIMAL_PBUFFER_WIDTH_SGIX;
|
|
|
|
buf[p++] = pFBConfig->optimalPbufferWidth;
|
|
|
|
buf[p++] = GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX;
|
|
|
|
buf[p++] = pFBConfig->optimalPbufferHeight;
|
|
|
|
|
|
|
|
buf[p++] = GLX_VISUAL_SELECT_GROUP_SGIX;
|
|
|
|
buf[p++] = pFBConfig->visualSelectGroup;
|
|
|
|
|
|
|
|
if (client->swapped) {
|
|
|
|
__GLX_DECLARE_SWAP_VARIABLES;
|
|
|
|
__GLX_DECLARE_SWAP_ARRAY_VARIABLES;
|
|
|
|
__GLX_SWAP_INT_ARRAY((int *) buf, 2 * numAttribs);
|
|
|
|
}
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, 2 * numAttribs * __GLX_SIZE_CARD32, buf);
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXGetFBConfigsSGIX(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc;
|
|
|
|
xGLXGetFBConfigsReq new_req;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
new_req.reqType = req->reqType;
|
|
|
|
new_req.glxCode = req->glxCode;
|
|
|
|
new_req.length = req->length;
|
|
|
|
new_req.screen = req->screen;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-11-06 06:50:58 +01:00
|
|
|
return (__glXGetFBConfigs(cl, (GLbyte *) &new_req));
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXCreateWindow(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
ClientPtr client = cl->client;
|
|
|
|
xGLXCreateWindowReq *req = (xGLXCreateWindowReq *) pc;
|
|
|
|
int screen = req->screen;
|
|
|
|
GLXFBConfigID fbconfigId = req->fbconfig;
|
|
|
|
XID windowId = req->window;
|
|
|
|
XID glxwindowId = req->glxwindow;
|
|
|
|
DrawablePtr pDraw;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
__glXWindow *pGlxWindow;
|
|
|
|
__GLXFBConfig *pGlxFBConfig = NULL;
|
|
|
|
VisualPtr pVisual;
|
|
|
|
VisualID visId;
|
2006-12-15 22:36:29 +01:00
|
|
|
int i, rc;
|
2010-11-11 15:40:13 +01:00
|
|
|
pointer val;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Check if windowId is valid
|
|
|
|
*/
|
2006-12-15 22:36:29 +01:00
|
|
|
rc = dixLookupDrawable(&pDraw, windowId, client, M_DRAWABLE_WINDOW,
|
2012-03-21 20:55:09 +01:00
|
|
|
DixAddAccess);
|
2006-12-15 22:36:29 +01:00
|
|
|
if (rc != Success)
|
2012-03-21 20:55:09 +01:00
|
|
|
return rc;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Check if screen of window matches screen of fbconfig.
|
|
|
|
*/
|
2004-06-30 22:06:56 +02:00
|
|
|
pScreen = pDraw->pScreen;
|
|
|
|
if (screen != pScreen->myNum) {
|
2012-03-21 20:55:09 +01:00
|
|
|
return BadMatch;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Find the FBConfigRec for this fbconfigid.
|
|
|
|
*/
|
2004-06-30 22:06:56 +02:00
|
|
|
if (!(pGlxFBConfig = glxLookupFBConfig(fbconfigId))) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = fbconfigId;
|
|
|
|
return __glXBadFBConfig;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
visId = pGlxFBConfig->associatedVisualId;
|
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Check if the fbconfig supports rendering to windows
|
|
|
|
*/
|
|
|
|
if (!(pGlxFBConfig->drawableType & GLX_WINDOW_BIT)) {
|
|
|
|
return BadMatch;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (visId != None) {
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Check if the visual ID is valid for this screen.
|
|
|
|
*/
|
|
|
|
pVisual = pScreen->visuals;
|
|
|
|
for (i = 0; i < pScreen->numVisuals; i++, pVisual++) {
|
|
|
|
if (pVisual->vid == visId) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == pScreen->numVisuals) {
|
|
|
|
client->errorValue = visId;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Check if color buffer depth of fbconfig matches depth
|
|
|
|
** of window.
|
|
|
|
*/
|
2004-06-30 22:06:56 +02:00
|
|
|
if (pVisual->nplanes != pDraw->depth) {
|
2012-03-21 20:55:09 +01:00
|
|
|
return BadMatch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
/*
|
|
|
|
** The window was created with no visual that corresponds
|
|
|
|
** to fbconfig
|
|
|
|
*/
|
|
|
|
return BadMatch;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Check if there is already a fbconfig associated with this window
|
|
|
|
*/
|
2010-11-11 15:40:13 +01:00
|
|
|
if (Success == dixLookupResourceByType(&val,
|
2012-03-21 20:55:09 +01:00
|
|
|
glxwindowId, __glXWindowRes,
|
|
|
|
NullClient, DixUnknownAccess)) {
|
|
|
|
client->errorValue = glxwindowId;
|
|
|
|
return BadAlloc;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
pGlxWindow = (__glXWindow *) malloc(sizeof(__glXWindow));
|
2004-06-30 22:06:56 +02:00
|
|
|
if (!pGlxWindow) {
|
2012-03-21 20:55:09 +01:00
|
|
|
return BadAlloc;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Register this GLX window as a resource
|
|
|
|
*/
|
2004-06-30 22:06:56 +02:00
|
|
|
if (!(AddResource(glxwindowId, __glXWindowRes, pGlxWindow))) {
|
2012-03-21 20:55:09 +01:00
|
|
|
return BadAlloc;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
pGlxWindow->pDraw = pDraw;
|
|
|
|
pGlxWindow->type = GLX_GLXWINDOW_TYPE;
|
|
|
|
pGlxWindow->idExists = True;
|
|
|
|
pGlxWindow->refcnt = 0;
|
|
|
|
pGlxWindow->pGlxFBConfig = pGlxFBConfig;
|
|
|
|
pGlxWindow->pScreen = pScreen;
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXDestroyWindow(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
ClientPtr client = cl->client;
|
|
|
|
xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc;
|
|
|
|
XID glxwindow = req->glxwindow;
|
2010-11-11 15:40:13 +01:00
|
|
|
pointer val;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Check if it's a valid GLX window.
|
|
|
|
*/
|
2010-11-11 15:40:13 +01:00
|
|
|
if (Success != dixLookupResourceByType(&val,
|
2012-03-21 20:55:09 +01:00
|
|
|
glxwindow, __glXWindowRes,
|
|
|
|
NullClient, DixUnknownAccess)) {
|
|
|
|
client->errorValue = glxwindow;
|
|
|
|
return __glXBadDrawable;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** The glx window destructor will check whether it's current before
|
|
|
|
** freeing anything.
|
|
|
|
*/
|
|
|
|
FreeResource(glxwindow, RT_NONE);
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXQueryContext(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
ClientPtr client = cl->client;
|
|
|
|
__GLXcontext *ctx;
|
|
|
|
xGLXQueryContextReq *req;
|
|
|
|
xGLXQueryContextReply reply;
|
|
|
|
int nProps;
|
|
|
|
int *sendBuf, *pSendBuf;
|
|
|
|
int nReplyBytes;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
req = (xGLXQueryContextReq *) pc;
|
|
|
|
dixLookupResourceByType((pointer *) &ctx, req->context, __glXContextRes,
|
Replace LookupIDByType() with dixLookupResourceByType(), take 1.
This patch has been prepared with the following Coccinelle semantic patch:
@@
expression x, y;
type t;
identifier r;
@@
-r = (t) LookupIDByType(x, y);
+dixLookupResourceByType((pointer*)&r, x, y, NullClient, DixUnknownAccess);
@@
expression x, y;
type t;
identifier r;
@@
-t r = (t) LookupIDByType(x, y);
+t r;
+dixLookupResourceByType((pointer*)&r, x, y, NullClient, DixUnknownAccess);
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Cyril Brulebois <kibi@debian.org>
2010-11-11 15:30:15 +01:00
|
|
|
NullClient, DixUnknownAccess);
|
2004-06-30 22:06:56 +02:00
|
|
|
if (!ctx) {
|
|
|
|
client->errorValue = req->context;
|
|
|
|
return __glXBadContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
nProps = 3;
|
|
|
|
|
2012-07-10 04:12:43 +02:00
|
|
|
reply = (xGLXQueryContextReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = nProps << 1,
|
|
|
|
.n = nProps
|
|
|
|
};
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
nReplyBytes = reply.length << 2;
|
2012-03-21 20:55:09 +01:00
|
|
|
sendBuf = (int *) malloc(nReplyBytes);
|
2004-06-30 22:06:56 +02:00
|
|
|
pSendBuf = sendBuf;
|
|
|
|
*pSendBuf++ = GLX_FBCONFIG_ID;
|
2012-03-21 20:55:09 +01:00
|
|
|
*pSendBuf++ = (int) (ctx->pFBConfig->id);
|
2004-06-30 22:06:56 +02:00
|
|
|
*pSendBuf++ = GLX_RENDER_TYPE;
|
2013-10-21 19:57:53 +02:00
|
|
|
*pSendBuf++ = renderTypeBitsToRenderTypeEnum(ctx->pFBConfig->renderType);
|
2004-06-30 22:06:56 +02:00
|
|
|
*pSendBuf++ = GLX_SCREEN;
|
2012-03-21 20:55:09 +01:00
|
|
|
*pSendBuf++ = (int) (ctx->pScreen->myNum);
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
if (client->swapped) {
|
|
|
|
__glXSwapQueryContextReply(client, &reply, sendBuf);
|
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
else {
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, sz_xGLXQueryContextReply, &reply);
|
|
|
|
WriteToClient(client, nReplyBytes, sendBuf);
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
free((char *) sendBuf);
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXQueryContextInfoEXT(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
ClientPtr client = cl->client;
|
|
|
|
__GLXcontext *ctx;
|
|
|
|
xGLXQueryContextInfoEXTReq *req;
|
|
|
|
xGLXQueryContextInfoEXTReply reply;
|
|
|
|
int nProps;
|
|
|
|
int *sendBuf, *pSendBuf;
|
|
|
|
int nReplyBytes;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
req = (xGLXQueryContextInfoEXTReq *) pc;
|
|
|
|
dixLookupResourceByType((pointer *) &ctx,
|
|
|
|
req->context, __glXContextRes,
|
|
|
|
client, DixReadAccess);
|
2010-11-12 11:36:36 +01:00
|
|
|
|
2004-06-30 22:06:56 +02:00
|
|
|
if (!ctx) {
|
|
|
|
client->errorValue = req->context;
|
|
|
|
return __glXBadContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
nProps = 4;
|
|
|
|
|
2012-07-10 04:12:43 +02:00
|
|
|
reply = (xGLXQueryContextInfoEXTReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = nProps << 1,
|
|
|
|
.n = nProps
|
|
|
|
};
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
nReplyBytes = reply.length << 2;
|
2012-03-21 20:55:09 +01:00
|
|
|
sendBuf = (int *) malloc(nReplyBytes);
|
2004-06-30 22:06:56 +02:00
|
|
|
pSendBuf = sendBuf;
|
|
|
|
*pSendBuf++ = GLX_SHARE_CONTEXT_EXT;
|
2012-03-21 20:55:09 +01:00
|
|
|
*pSendBuf++ = (int) (ctx->share_id);
|
2004-06-30 22:06:56 +02:00
|
|
|
*pSendBuf++ = GLX_VISUAL_ID_EXT;
|
2012-03-21 20:55:09 +01:00
|
|
|
*pSendBuf++ = (int) (ctx->pVisual ? ctx->pVisual->vid : 0);
|
2004-06-30 22:06:56 +02:00
|
|
|
*pSendBuf++ = GLX_SCREEN_EXT;
|
2012-03-21 20:55:09 +01:00
|
|
|
*pSendBuf++ = (int) (ctx->pScreen->myNum);
|
2004-06-30 22:06:56 +02:00
|
|
|
*pSendBuf++ = GLX_FBCONFIG_ID;
|
2012-03-21 20:55:09 +01:00
|
|
|
*pSendBuf++ = (int) (ctx->pFBConfig ? ctx->pFBConfig->id : 0);
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
if (client->swapped) {
|
|
|
|
__glXSwapQueryContextInfoEXTReply(client, &reply, sendBuf);
|
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
else {
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, sz_xGLXQueryContextInfoEXTReply, &reply);
|
|
|
|
WriteToClient(client, nReplyBytes, sendBuf);
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
free((char *) sendBuf);
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXCreatePbuffer(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
ClientPtr client = cl->client;
|
2012-03-21 20:55:09 +01:00
|
|
|
xGLXCreatePbufferReq *req = (xGLXCreatePbufferReq *) pc;
|
2004-06-30 22:06:56 +02:00
|
|
|
xGLXCreatePbufferReq *be_req;
|
|
|
|
int screen = req->screen;
|
|
|
|
GLXFBConfigID fbconfigId = req->fbconfig;
|
|
|
|
GLXPbuffer pbuffer = req->pbuffer;
|
|
|
|
__glXPbuffer *pGlxPbuffer;
|
|
|
|
int numAttribs = req->numAttribs;
|
|
|
|
int *attr;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
__GLXFBConfig *pGlxFBConfig;
|
|
|
|
__GLXFBConfig *be_pGlxFBConfig;
|
|
|
|
XID be_xid;
|
|
|
|
Display *dpy;
|
|
|
|
DMXScreenInfo *dmxScreen;
|
|
|
|
int s;
|
|
|
|
int from_screen, to_screen;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
/*
|
|
|
|
** Look up screen and FBConfig.
|
|
|
|
*/
|
2010-12-01 14:12:55 +01:00
|
|
|
if (screen >= screenInfo.numScreens) {
|
2004-06-30 22:06:56 +02:00
|
|
|
/* The client library must send a valid screen number. */
|
|
|
|
client->errorValue = screen;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
pScreen = screenInfo.screens[screen];
|
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Find the FBConfigRec for this fbconfigid.
|
|
|
|
*/
|
2004-06-30 22:06:56 +02:00
|
|
|
if (!(pGlxFBConfig = glxLookupFBConfig(fbconfigId))) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = fbconfigId;
|
|
|
|
return __glXBadFBConfig;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Create the GLX part of the Pbuffer.
|
|
|
|
*/
|
2010-05-05 20:44:06 +02:00
|
|
|
pGlxPbuffer = (__glXPbuffer *) malloc(sizeof(__glXPbuffer));
|
2004-06-30 22:06:56 +02:00
|
|
|
if (!pGlxPbuffer) {
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
pGlxPbuffer->be_xids = (XID *) malloc(sizeof(XID) * screenInfo.numScreens);
|
2004-06-30 22:06:56 +02:00
|
|
|
if (!pGlxPbuffer->be_xids) {
|
2010-05-05 20:44:06 +02:00
|
|
|
free(pGlxPbuffer);
|
2004-06-30 22:06:56 +02:00
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate an XID on the back-end server(s) and send him the request
|
|
|
|
*/
|
|
|
|
from_screen = to_screen = screen;
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
if (!noPanoramiXExtension) {
|
2012-03-21 20:55:09 +01:00
|
|
|
from_screen = 0;
|
|
|
|
to_screen = screenInfo.numScreens - 1;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
for (s = from_screen; s <= to_screen; s++) {
|
|
|
|
dpy = GetBackEndDisplay(cl, s);
|
|
|
|
be_xid = XAllocID(dpy);
|
|
|
|
dmxScreen = &dmxScreens[s];
|
|
|
|
be_pGlxFBConfig = glxLookupBackEndFBConfig(pGlxFBConfig->id, s);
|
|
|
|
|
|
|
|
attr = (int *) (req + 1);
|
|
|
|
|
|
|
|
LockDisplay(dpy);
|
|
|
|
GetReqExtra(GLXCreatePbuffer, 2 * numAttribs * __GLX_SIZE_CARD32,
|
|
|
|
be_req);
|
|
|
|
be_req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
be_req->glxCode = X_GLXCreatePbuffer;
|
|
|
|
be_req->screen = be_pGlxFBConfig->screen;
|
|
|
|
be_req->fbconfig = be_pGlxFBConfig->id;
|
|
|
|
be_req->pbuffer = be_xid;
|
|
|
|
be_req->numAttribs = numAttribs;
|
|
|
|
|
|
|
|
/* Send attributes */
|
|
|
|
if (attr != NULL) {
|
|
|
|
CARD32 *pc = (CARD32 *) (be_req + 1);
|
|
|
|
|
|
|
|
while (numAttribs-- > 0) {
|
|
|
|
*pc++ = *attr++; /* token */
|
|
|
|
*pc++ = *attr++; /* value */
|
|
|
|
}
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
pGlxPbuffer->be_xids[s] = be_xid;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
pGlxPbuffer->idExists = True;
|
|
|
|
pGlxPbuffer->refcnt = 0;
|
|
|
|
pGlxPbuffer->pFBConfig = pGlxFBConfig;
|
|
|
|
pGlxPbuffer->pScreen = pScreen;
|
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Register the resource.
|
|
|
|
*/
|
2004-06-30 22:06:56 +02:00
|
|
|
if (!(AddResource(pbuffer, __glXPbufferRes, pGlxPbuffer))) {
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXDestroyPbuffer(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
|
|
|
ClientPtr client = cl->client;
|
|
|
|
xGLXDestroyPbufferReq *req = (xGLXDestroyPbufferReq *) pc;
|
|
|
|
xGLXDestroyPbufferReq *be_req;
|
|
|
|
GLXPbuffer pbuffer = req->pbuffer;
|
|
|
|
Display *dpy;
|
|
|
|
int screen;
|
|
|
|
DMXScreenInfo *dmxScreen;
|
|
|
|
__glXPbuffer *pGlxPbuffer;
|
|
|
|
int s;
|
|
|
|
int from_screen, to_screen;
|
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Check if it's a valid Pbuffer
|
|
|
|
*/
|
|
|
|
dixLookupResourceByType((pointer *) &pGlxPbuffer, pbuffer,
|
Replace LookupIDByType() with dixLookupResourceByType(), take 1.
This patch has been prepared with the following Coccinelle semantic patch:
@@
expression x, y;
type t;
identifier r;
@@
-r = (t) LookupIDByType(x, y);
+dixLookupResourceByType((pointer*)&r, x, y, NullClient, DixUnknownAccess);
@@
expression x, y;
type t;
identifier r;
@@
-t r = (t) LookupIDByType(x, y);
+t r;
+dixLookupResourceByType((pointer*)&r, x, y, NullClient, DixUnknownAccess);
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Cyril Brulebois <kibi@debian.org>
2010-11-11 15:30:15 +01:00
|
|
|
__glXPbufferRes, NullClient, DixUnknownAccess);
|
2004-06-30 22:06:56 +02:00
|
|
|
if (!pGlxPbuffer) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = pbuffer;
|
|
|
|
return __glXBadPbuffer;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
screen = pGlxPbuffer->pScreen->myNum;
|
|
|
|
|
|
|
|
from_screen = to_screen = screen;
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
if (!noPanoramiXExtension) {
|
2012-03-21 20:55:09 +01:00
|
|
|
from_screen = 0;
|
|
|
|
to_screen = screenInfo.numScreens - 1;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
for (s = from_screen; s <= to_screen; s++) {
|
|
|
|
dpy = GetBackEndDisplay(cl, s);
|
|
|
|
dmxScreen = &dmxScreens[s];
|
2004-06-30 22:06:56 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
/* send the destroy request to the back-end server */
|
|
|
|
LockDisplay(dpy);
|
|
|
|
GetReq(GLXDestroyPbuffer, be_req);
|
|
|
|
be_req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
be_req->glxCode = X_GLXDestroyPbuffer;
|
|
|
|
be_req->pbuffer = pGlxPbuffer->be_xids[s];
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
FreeResource(pbuffer, RT_NONE);
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXGetDrawableAttributes(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *) pc;
|
|
|
|
xGLXGetDrawableAttributesReq *be_req;
|
|
|
|
xGLXGetDrawableAttributesReply reply;
|
|
|
|
ClientPtr client = cl->client;
|
|
|
|
GLXDrawable drawId = req->drawable;
|
|
|
|
GLXDrawable be_drawable = 0;
|
|
|
|
DrawablePtr pDraw = NULL;
|
|
|
|
Display *dpy;
|
|
|
|
int screen, rc;
|
|
|
|
DMXScreenInfo *dmxScreen;
|
|
|
|
CARD32 *attribs = NULL;
|
|
|
|
int attribs_size = 0;
|
|
|
|
|
2004-06-30 22:06:56 +02:00
|
|
|
#ifdef PANORAMIX
|
|
|
|
PanoramiXRes *pXinDraw = NULL;
|
|
|
|
#endif
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (drawId != None) {
|
|
|
|
rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixGetAttrAccess);
|
|
|
|
if (rc == Success && pDraw->type == DRAWABLE_WINDOW) {
|
|
|
|
WindowPtr pWin = (WindowPtr) pDraw;
|
|
|
|
|
|
|
|
be_drawable = 0;
|
|
|
|
screen = pWin->drawable.pScreen->myNum;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
** Drawable is not a Window , GLXWindow or a GLXPixmap.
|
|
|
|
*/
|
|
|
|
client->errorValue = drawId;
|
|
|
|
return __glXBadDrawable;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pDraw) {
|
|
|
|
__GLXpixmap *pGlxPixmap;
|
|
|
|
|
|
|
|
dixLookupResourceByType((pointer *) &pGlxPixmap,
|
|
|
|
drawId, __glXPixmapRes,
|
|
|
|
NullClient, DixUnknownAccess);
|
|
|
|
if (pGlxPixmap) {
|
|
|
|
pDraw = pGlxPixmap->pDraw;
|
|
|
|
screen = pGlxPixmap->pScreen->myNum;
|
2004-06-30 22:06:56 +02:00
|
|
|
be_drawable = pGlxPixmap->be_xids[screen];
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pDraw) {
|
|
|
|
__glXWindow *pGlxWindow;
|
|
|
|
|
|
|
|
dixLookupResourceByType((pointer *) &pGlxWindow,
|
|
|
|
drawId, __glXWindowRes,
|
|
|
|
NullClient, DixUnknownAccess);
|
|
|
|
if (pGlxWindow) {
|
|
|
|
pDraw = pGlxWindow->pDraw;
|
|
|
|
screen = pGlxWindow->pScreen->myNum;
|
|
|
|
be_drawable = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pDraw) {
|
|
|
|
__glXPbuffer *pGlxPbuffer;
|
|
|
|
|
|
|
|
dixLookupResourceByType((pointer *) &pGlxPbuffer,
|
|
|
|
drawId, __glXPbufferRes,
|
|
|
|
NullClient, DixUnknownAccess);
|
|
|
|
if (pGlxPbuffer) {
|
|
|
|
pDraw = (DrawablePtr) pGlxPbuffer;
|
|
|
|
screen = pGlxPbuffer->pScreen->myNum;
|
|
|
|
be_drawable = pGlxPbuffer->be_xids[screen];
|
|
|
|
}
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
2011-02-08 20:02:37 +01:00
|
|
|
if (!pDraw) {
|
2012-03-21 20:55:09 +01:00
|
|
|
/*
|
|
|
|
** Drawable is not a Window , GLXWindow or a GLXPixmap.
|
|
|
|
*/
|
|
|
|
client->errorValue = drawId;
|
|
|
|
return __glXBadDrawable;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if the drawable is a window or GLXWindow -
|
|
|
|
* we need to find the base id on the back-end server
|
|
|
|
*/
|
|
|
|
if (!be_drawable) {
|
|
|
|
WindowPtr pWin = (WindowPtr) pDraw;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!noPanoramiXExtension) {
|
|
|
|
if (Success != dixLookupResourceByClass((pointer *) &pXinDraw,
|
|
|
|
pDraw->id, XRC_DRAWABLE,
|
|
|
|
client, DixReadAccess)) {
|
|
|
|
client->errorValue = drawId;
|
|
|
|
return __glXBadDrawable;
|
|
|
|
}
|
|
|
|
|
|
|
|
dixLookupWindow(&pWin, pXinDraw->info[screen].id, client,
|
|
|
|
DixReadAccess);
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
#endif
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pWin) {
|
|
|
|
be_drawable = (unsigned int) (DMX_GET_WINDOW_PRIV(pWin))->window;
|
|
|
|
if (!be_drawable) {
|
|
|
|
/* it might be that the window did not created yet on the */
|
|
|
|
/* back-end server (lazy window creation option), force */
|
|
|
|
/* creation of the window */
|
|
|
|
dmxCreateAndRealizeWindow(pWin, TRUE);
|
|
|
|
be_drawable =
|
|
|
|
(unsigned int) (DMX_GET_WINDOW_PRIV(pWin))->window;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
client->errorValue = drawId;
|
|
|
|
return __glXBadDrawable;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* send the request to the back-end server */
|
|
|
|
dpy = GetBackEndDisplay(cl, screen);
|
|
|
|
dmxScreen = &dmxScreens[screen];
|
|
|
|
|
|
|
|
/* make sure drawable exists on back-end */
|
|
|
|
dmxSync(dmxScreen, 1);
|
|
|
|
|
|
|
|
LockDisplay(dpy);
|
|
|
|
GetReq(GLXGetDrawableAttributes, be_req);
|
|
|
|
be_req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
be_req->glxCode = X_GLXGetDrawableAttributes;
|
|
|
|
be_req->drawable = be_drawable;
|
|
|
|
be_req->length = req->length;
|
2012-11-06 06:50:58 +01:00
|
|
|
if (!_XReply(dpy, (xReply *) &reply, 0, False)) {
|
2012-03-21 20:55:09 +01:00
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
|
|
|
return (BE_TO_CLIENT_ERROR(dmxLastErrorEvent.error_code));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (reply.numAttribs) {
|
|
|
|
attribs_size = 2 * reply.numAttribs * __GLX_SIZE_CARD32;
|
|
|
|
attribs = (CARD32 *) malloc(attribs_size);
|
|
|
|
if (attribs == NULL) {
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
_XRead(dpy, (char *) attribs, attribs_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
|
|
|
|
|
|
|
/* send the reply back to the client */
|
|
|
|
reply.sequenceNumber = client->sequence;
|
|
|
|
if (client->swapped) {
|
|
|
|
__glXSwapGetDrawableAttributesReply(client, &reply, (int *) attribs);
|
|
|
|
}
|
|
|
|
else {
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, sz_xGLXGetDrawableAttributesReply, &reply);
|
|
|
|
WriteToClient(client, attribs_size, attribs);
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
free(attribs);
|
|
|
|
|
|
|
|
return Success;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXChangeDrawableAttributes(__GLXclientState * cl, GLbyte * pc)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
xGLXChangeDrawableAttributesReq *req =
|
|
|
|
(xGLXChangeDrawableAttributesReq *) pc;
|
|
|
|
xGLXChangeDrawableAttributesReq *be_req;
|
|
|
|
ClientPtr client = cl->client;
|
|
|
|
GLXDrawable drawId = req->drawable;
|
|
|
|
GLXDrawable be_drawable = 0;
|
|
|
|
DrawablePtr pDraw = NULL;
|
|
|
|
Display *dpy;
|
|
|
|
int screen, rc;
|
|
|
|
DMXScreenInfo *dmxScreen;
|
|
|
|
|
|
|
|
if (drawId != None) {
|
|
|
|
rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixSetAttrAccess);
|
|
|
|
if (rc == Success && pDraw->type == DRAWABLE_WINDOW) {
|
|
|
|
be_drawable = 0;
|
|
|
|
screen = pDraw->pScreen->myNum;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
** Drawable is not a Window , GLXWindow or a GLXPixmap.
|
|
|
|
*/
|
|
|
|
client->errorValue = drawId;
|
|
|
|
return __glXBadDrawable;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pDraw) {
|
|
|
|
__GLXpixmap *pGlxPixmap;
|
|
|
|
|
|
|
|
dixLookupResourceByType((pointer *) &pGlxPixmap,
|
|
|
|
drawId, __glXPixmapRes,
|
|
|
|
NullClient, DixUnknownAccess);
|
|
|
|
if (pGlxPixmap) {
|
|
|
|
pDraw = pGlxPixmap->pDraw;
|
|
|
|
screen = pGlxPixmap->pScreen->myNum;
|
2004-06-30 22:06:56 +02:00
|
|
|
be_drawable = pGlxPixmap->be_xids[screen];
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pDraw) {
|
|
|
|
__glXWindow *pGlxWindow;
|
|
|
|
|
|
|
|
dixLookupResourceByType((pointer *) &pGlxWindow,
|
|
|
|
drawId, __glXWindowRes,
|
|
|
|
NullClient, DixUnknownAccess);
|
|
|
|
if (pGlxWindow) {
|
|
|
|
pDraw = pGlxWindow->pDraw;
|
|
|
|
screen = pGlxWindow->pScreen->myNum;
|
|
|
|
be_drawable = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pDraw) {
|
|
|
|
__glXPbuffer *pGlxPbuffer;
|
|
|
|
|
|
|
|
dixLookupResourceByType((pointer *) &pGlxPbuffer,
|
|
|
|
drawId, __glXPbufferRes,
|
|
|
|
NullClient, DixUnknownAccess);
|
|
|
|
if (pGlxPbuffer) {
|
|
|
|
pDraw = (DrawablePtr) pGlxPbuffer;
|
|
|
|
screen = pGlxPbuffer->pScreen->myNum;
|
|
|
|
be_drawable = pGlxPbuffer->be_xids[screen];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pDraw) {
|
|
|
|
/*
|
|
|
|
** Drawable is not a Window , GLXWindow or a GLXPixmap.
|
|
|
|
*/
|
|
|
|
client->errorValue = drawId;
|
|
|
|
return __glXBadDrawable;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if the drawable is a window or GLXWindow -
|
|
|
|
* we need to find the base id on the back-end server
|
|
|
|
*/
|
|
|
|
if (!be_drawable) {
|
|
|
|
WindowPtr pWin = (WindowPtr) pDraw;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!noPanoramiXExtension) {
|
|
|
|
PanoramiXRes *pXinDraw;
|
|
|
|
|
|
|
|
if (Success != dixLookupResourceByClass((pointer *) &pXinDraw,
|
|
|
|
pDraw->id, XRC_DRAWABLE,
|
|
|
|
client, DixReadAccess)) {
|
|
|
|
client->errorValue = drawId;
|
|
|
|
return __glXBadDrawable;
|
|
|
|
}
|
|
|
|
|
|
|
|
dixLookupWindow(&pWin, pXinDraw->info[screen].id, client,
|
|
|
|
DixReadAccess);
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
#endif
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pWin) {
|
|
|
|
be_drawable = (unsigned int) (DMX_GET_WINDOW_PRIV(pWin))->window;
|
|
|
|
if (!be_drawable) {
|
|
|
|
/* it might be that the window did not created yet on the */
|
|
|
|
/* back-end server (lazy window creation option), force */
|
|
|
|
/* creation of the window */
|
|
|
|
dmxCreateAndRealizeWindow(pWin, TRUE);
|
|
|
|
be_drawable =
|
|
|
|
(unsigned int) (DMX_GET_WINDOW_PRIV(pWin))->window;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
client->errorValue = drawId;
|
|
|
|
return __glXBadDrawable;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* send the request to the back-end server */
|
|
|
|
dpy = GetBackEndDisplay(cl, screen);
|
|
|
|
dmxScreen = &dmxScreens[screen];
|
|
|
|
|
|
|
|
/* make sure drawable exists on back-end */
|
|
|
|
dmxSync(dmxScreen, 1);
|
|
|
|
|
|
|
|
LockDisplay(dpy);
|
|
|
|
GetReqExtra(GLXChangeDrawableAttributes,
|
|
|
|
2 * req->numAttribs * __GLX_SIZE_CARD32, be_req);
|
|
|
|
be_req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
be_req->glxCode = X_GLXChangeDrawableAttributes;
|
|
|
|
be_req->drawable = be_drawable;
|
|
|
|
be_req->numAttribs = req->numAttribs;
|
|
|
|
be_req->length = req->length;
|
|
|
|
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
|
|
|
|
|
|
|
return Success;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
int
|
|
|
|
__glXSendLargeCommand(__GLXclientState * cl, GLXContextTag contextTag)
|
2004-06-30 22:06:56 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
ClientPtr client = cl->client;
|
2004-06-30 22:06:56 +02:00
|
|
|
xGLXRenderLargeReq *req;
|
|
|
|
GLint maxSize, amount;
|
|
|
|
GLint totalRequests, requestNumber;
|
|
|
|
GLint dataLen;
|
|
|
|
GLbyte *data;
|
|
|
|
__GLXcontext *glxc;
|
|
|
|
int s;
|
|
|
|
int from_screen, to_screen;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
maxSize = cl->largeCmdMaxReqDataSize - (GLint) sizeof(xGLXRenderLargeReq);
|
2004-06-30 22:06:56 +02:00
|
|
|
dataLen = cl->largeCmdBytesTotal;
|
|
|
|
totalRequests = (dataLen / maxSize);
|
2012-03-21 20:55:09 +01:00
|
|
|
if (dataLen % maxSize)
|
|
|
|
totalRequests++;
|
2004-06-30 22:06:56 +02:00
|
|
|
|
|
|
|
glxc = __glXLookupContextByTag(cl, contextTag);
|
|
|
|
if (!glxc) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = contextTag;
|
|
|
|
return __glXBadContext;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
from_screen = to_screen = glxc->pScreen->myNum;
|
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
if (!noPanoramiXExtension) {
|
2012-03-21 20:55:09 +01:00
|
|
|
from_screen = 0;
|
|
|
|
to_screen = screenInfo.numScreens - 1;
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
2012-03-21 20:55:09 +01:00
|
|
|
** Send enough requests until the whole array is sent.
|
|
|
|
*/
|
2004-06-30 22:06:56 +02:00
|
|
|
requestNumber = 1;
|
|
|
|
data = cl->largeCmdBuf;
|
|
|
|
while (dataLen > 0) {
|
2012-03-21 20:55:09 +01:00
|
|
|
amount = dataLen;
|
|
|
|
if (amount > maxSize) {
|
|
|
|
amount = maxSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (s = from_screen; s <= to_screen; s++) {
|
|
|
|
|
|
|
|
Display *dpy = GetBackEndDisplay(cl, s);
|
|
|
|
DMXScreenInfo *dmxScreen = &dmxScreens[s];
|
|
|
|
|
|
|
|
LockDisplay(dpy);
|
|
|
|
GetReq(GLXRenderLarge, req);
|
|
|
|
req->reqType = dmxScreen->glxMajorOpcode;
|
|
|
|
req->glxCode = X_GLXRenderLarge;
|
|
|
|
req->contextTag = GetCurrentBackEndTag(cl, contextTag, s);
|
|
|
|
req->length += (amount + 3) >> 2;
|
|
|
|
req->requestNumber = requestNumber++;
|
|
|
|
req->requestTotal = totalRequests;
|
|
|
|
req->dataBytes = amount;
|
|
|
|
Data(dpy, ((const char *) data), amount);
|
|
|
|
dataLen -= amount;
|
|
|
|
data = ((GLbyte *) data) + amount;
|
|
|
|
UnlockDisplay(dpy);
|
|
|
|
SyncHandle();
|
|
|
|
}
|
2004-06-30 22:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|