add more functionality to miniglx for glitz

This commit is contained in:
Dave Airlie 2005-02-20 10:46:34 +00:00
parent eb6560bf2b
commit dee1c795c2
2 changed files with 179 additions and 96 deletions

View File

@ -52,14 +52,20 @@ extern "C" {
*
* It can have the values #True or #False.
*/
#ifndef MINIGLX_NO_XTYPES
typedef int Bool;
#endif
typedef int MINI_Bool;
/**
* \brief Color map.
*
* Alias for private ::MiniGLXColormapRec structure.
*/
typedef struct MiniGLXColormapRec *MINI_Colormap;
#ifndef MINIGLX_NO_XTYPES
typedef struct MiniGLXColormapRec *Colormap;
#endif
/**
* \brief Window attributes.
@ -67,7 +73,7 @@ typedef struct MiniGLXColormapRec *Colormap;
typedef struct MiniGLXSetWindowAttributesRec {
int background_pixel; /**< \brief background pixel */
int border_pixel; /**< \brief border pixel value */
Colormap colormap; /**< \brief color map to be associated with window */
MINI_Colormap colormap; /**< \brief color map to be associated with window */
int event_mask; /**< \brief set of events that should be saved */
} XSetWindowAttributes;
@ -85,10 +91,13 @@ typedef struct MiniGLXVisualRec Visual;
*
* \sa \ref datatypes.
*/
typedef unsigned int VisualID;
#ifndef MINIGLX_NO_XTYPES
typedef unsigned long VisualID;
#endif
typedef unsigned long MINI_VisualID;
typedef struct MiniGLXXVisualInfoRec {
Visual *visual; /**< \brief pointer to the GLX Visual */
VisualID visualid; /**< \brief visual ID */
MINI_VisualID visualid; /**< \brief visual ID */
int screen; /**< \brief screen number */
int depth; /**< \brief bit depth */
#if defined(__cplusplus) || defined(c_plusplus)
@ -115,7 +124,10 @@ typedef struct MiniGLXFBConfigRec {
*
* \sa \ref datatypes.
*/
#ifndef MINIGLX_NO_XTYPES
typedef struct MiniGLXDisplayRec Display;
#endif
typedef struct MiniGLXDisplayRec MINI_Display;
/**
* \brief Window handle.
@ -124,7 +136,10 @@ typedef struct MiniGLXDisplayRec Display;
*
* \sa \ref datatypes.
*/
#ifndef MINIGLX_NO_XTYPES
typedef struct MiniGLXWindowRec *Window;
#endif
typedef struct MiniGLXWindowRec *MINI_Window;
/**
* \brief Drawable.
@ -136,7 +151,10 @@ typedef struct MiniGLXWindowRec *Window;
*
* \sa \ref datatypes.
*/
#ifndef MINIGLX_NO_XTYPES
typedef struct MiniGLXWindowRec *Drawable;
#endif
typedef struct MiniGLXWindowRec *MINI_Drawable;
/**
* \brief GLX drawable.
@ -174,9 +192,9 @@ typedef struct MiniGLXContextRec *GLXContext;
typedef struct {
int type;
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came from a SendEvent request */
Display *display; /* Display the event was read from */
Window window;
MINI_Bool send_event; /* true if this came from a SendEvent request */
MINI_Display *display; /* Display the event was read from */
MINI_Window window;
int x, y;
int width, height;
int count; /* if non-zero, at least this many more */
@ -185,53 +203,53 @@ typedef struct {
typedef struct {
int type;
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came from a SendEvent request */
Display *display; /* Display the event was read from */
Window parent; /* parent of the window */
Window window; /* window id of window created */
MINI_Bool send_event; /* true if this came from a SendEvent request */
MINI_Display *display; /* Display the event was read from */
MINI_Window parent; /* parent of the window */
MINI_Window window; /* window id of window created */
int x, y; /* window location */
int width, height; /* size of window */
int border_width; /* border width */
Bool override_redirect; /* creation should be overridden */
MINI_Bool override_redirect; /* creation should be overridden */
} XCreateWindowEvent;
typedef struct {
int type;
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came from a SendEvent request */
Display *display; /* Display the event was read from */
Window event;
Window window;
MINI_Bool send_event; /* true if this came from a SendEvent request */
MINI_Display *display; /* Display the event was read from */
MINI_Window event;
MINI_Window window;
} XDestroyWindowEvent;
typedef struct {
int type;
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came from a SendEvent request */
Display *display; /* Display the event was read from */
Window event;
Window window;
Bool from_configure;
MINI_Bool send_event; /* true if this came from a SendEvent request */
MINI_Display *display; /* Display the event was read from */
MINI_Window event;
MINI_Window window;
MINI_Bool from_configure;
} XUnmapEvent;
typedef struct {
int type;
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came from a SendEvent request */
Display *display; /* Display the event was read from */
Window event;
Window window;
Bool override_redirect; /* boolean, is override set... */
MINI_Bool send_event; /* true if this came from a SendEvent request */
MINI_Display *display; /* Display the event was read from */
MINI_Window event;
MINI_Window window;
MINI_Bool override_redirect; /* boolean, is override set... */
} XMapEvent;
typedef struct {
int type;
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came from a SendEvent request */
Display *display; /* Display the event was read from */
Window parent;
Window window;
MINI_Bool send_event; /* true if this came from a SendEvent request */
MINI_Display *display; /* Display the event was read from */
MINI_Window parent;
MINI_Window window;
} XMapRequestEvent;
typedef union _XEvent {
@ -263,6 +281,7 @@ typedef union _XEvent {
#define CWColormap (1L<<13)
#define PseudoColor 3
#define TrueColor 4
#define VisualIDMask 0x1
#define VisualScreenMask 0x2
#define Expose 12
#define CreateNotify 16
@ -318,11 +337,11 @@ typedef union _XEvent {
/**
* \name Server-specific functions
*/
extern Display *
extern MINI_Display *
__miniglx_StartServer( const char *display_name );
extern int
__miniglx_Select( Display *dpy, int maxfd,
__miniglx_Select( MINI_Display *dpy, int maxfd,
fd_set *rfds, fd_set *wfds, fd_set *xfds,
struct timeval *tv );
@ -331,25 +350,25 @@ __miniglx_Select( Display *dpy, int maxfd,
* \name Simulated Xlib functions
*/
/*@{*/
extern Display *
extern MINI_Display *
XOpenDisplay( const char *dpy_name );
extern void
XCloseDisplay( Display *display );
XCloseDisplay( MINI_Display *display );
extern Window
XCreateWindow( Display *display, Window parent, int x, int y,
extern MINI_Window
XCreateWindow( MINI_Display *display, MINI_Window parent, int x, int y,
unsigned int width, unsigned int height,
unsigned int border_width, int depth, unsigned int winclass,
Visual *visual, unsigned long valuemask,
XSetWindowAttributes *attributes );
extern int
XNextEvent(Display *display, XEvent *event_return);
XNextEvent(MINI_Display *display, XEvent *event_return);
extern Bool
XCheckMaskEvent( Display *dpy, long event_mask, XEvent *event_return );
extern MINI_Bool
XCheckMaskEvent( MINI_Display *dpy, long event_mask, XEvent *event_return );
/**
* \brief Return the root window.
@ -365,27 +384,27 @@ XCheckMaskEvent( Display *dpy, long event_mask, XEvent *event_return );
#define DefaultScreen(dpy) 0
extern void
XDestroyWindow( Display *display, Window w );
XDestroyWindow( MINI_Display *display, MINI_Window w );
extern void
XMapWindow( Display *display, Window w );
XMapWindow( MINI_Display *display, MINI_Window w );
/* Should clients have access to this?
*/
extern void
XUnmapWindow( Display *display, Window w );
XUnmapWindow( MINI_Display *display, MINI_Window w );
extern Colormap
XCreateColormap( Display *display, Window w, Visual *visual, int alloc );
extern MINI_Colormap
XCreateColormap( MINI_Display *display, MINI_Window w, Visual *visual, int alloc );
extern void
XFreeColormap( Display *display, Colormap cmap );
XFreeColormap( MINI_Display *display, MINI_Colormap cmap );
extern void
XFree( void *data );
extern XVisualInfo *
XGetVisualInfo( Display *display, long vinfo_mask,
XGetVisualInfo( MINI_Display *display, long vinfo_mask,
XVisualInfo *vinfo_template, int *nitems_return );
/*@}*/
@ -396,23 +415,23 @@ XGetVisualInfo( Display *display, long vinfo_mask,
*/
/*@{*/
extern XVisualInfo*
glXChooseVisual( Display *dpy, int screen, int *attribList );
glXChooseVisual( MINI_Display *dpy, int screen, int *attribList );
extern int
glXGetConfig( Display *dpy, XVisualInfo *vis, int attrib, int *value );
glXGetConfig( MINI_Display *dpy, XVisualInfo *vis, int attrib, int *value );
extern GLXContext
glXCreateContext( Display *dpy, XVisualInfo *vis,
GLXContext shareList, Bool direct );
glXCreateContext( MINI_Display *dpy, XVisualInfo *vis,
GLXContext shareList, MINI_Bool direct );
extern void
glXDestroyContext( Display *dpy, GLXContext ctx );
glXDestroyContext( MINI_Display *dpy, GLXContext ctx );
extern Bool
glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx);
extern MINI_Bool
glXMakeCurrent( MINI_Display *dpy, GLXDrawable drawable, GLXContext ctx);
extern void
glXSwapBuffers( Display *dpy, GLXDrawable drawable );
glXSwapBuffers( MINI_Display *dpy, GLXDrawable drawable );
extern GLXContext
glXGetCurrentContext( void );
@ -423,22 +442,22 @@ glXGetCurrentDrawable( void );
extern void
(*glXGetProcAddress(const GLubyte *procname))( void );
extern Bool
glXQueryVersion( Display *dpy, int *major, int *minor );
extern MINI_Bool
glXQueryVersion( MINI_Display *dpy, int *major, int *minor );
/* Added in MiniGLX 1.1 */
extern GLXPbuffer
glXCreatePbuffer( Display *dpy, GLXFBConfig config, const int *attribList );
glXCreatePbuffer( MINI_Display *dpy, GLXFBConfig config, const int *attribList );
extern void
glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf );
glXDestroyPbuffer( MINI_Display *dpy, GLXPbuffer pbuf );
extern GLXFBConfig *
glXChooseFBConfig( Display *dpy, int screen, const int *attribList,
glXChooseFBConfig( MINI_Display *dpy, int screen, const int *attribList,
int *nitems );
extern XVisualInfo *
glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config );
glXGetVisualFromFBConfig( MINI_Display *dpy, GLXFBConfig config );
extern void *glXAllocateMemoryMESA(Display *dpy, int scrn,
size_t size, float readFreq,

View File

@ -1215,8 +1215,20 @@ CallCreateNewScreen(Display *dpy, int scrn, __DRIscreen *psc)
fd,
(get_ver != NULL) ? (*get_ver)() : 20040602,
(__GLcontextModes **) &dpy->driver_modes);
}
/* fill in dummy visual ids */
{
__GLcontextModes *temp;
temp = (__GLcontextModes *)dpy->driver_modes;
i = 1;
while (temp)
{
temp->visualID = i++;
temp=temp->next;
}
}
}
done:
if ( psp == NULL ) {
if ( pSAREA != MAP_FAILED ) {
@ -1631,50 +1643,102 @@ XGetVisualInfo( Display *dpy, long vinfo_mask, XVisualInfo *vinfo_template, int
const __GLcontextModes *mode;
XVisualInfo *results;
Visual *visResults;
int i, n;
int i, n=0;
ASSERT(vinfo_mask == VisualScreenMask);
// ASSERT(vinfo_mask == VisualScreenMask);
ASSERT(vinfo_template.screen == 0);
n = 0;
for ( mode = dpy->driver_modes ; mode != NULL ; mode = mode->next )
n++;
if (vinfo_mask == VisualIDMask)
{
for ( mode = dpy->driver_modes ; mode != NULL ; mode= mode->next )
if (mode->visualID == vinfo_template->visualid)
n=1;
results = (XVisualInfo *)calloc(1, n * sizeof(XVisualInfo));
if (!results) {
*nitens_return = 0;
return NULL;
}
if (n==0)
return NULL;
results = (XVisualInfo *)calloc(1, n * sizeof(XVisualInfo));
if (!results) {
*nitens_return = 0;
return NULL;
}
visResults = (Visual *)calloc(1, n * sizeof(Visual));
if (!results) {
free(results);
*nitens_return = 0;
return NULL;
}
visResults = (Visual *)calloc(1, n * sizeof(Visual));
if (!results) {
free(results);
*nitens_return = 0;
return NULL;
}
for ( mode = dpy->driver_modes, i = 0 ; mode != NULL ; mode = mode->next, i++ ) {
visResults[i].mode = mode;
visResults[i].visInfo = results + i;
visResults[i].dpy = dpy;
if (dpy->driverContext.bpp == 32)
visResults[i].pixelFormat = PF_B8G8R8A8; /* XXX: FIX ME */
else
visResults[i].pixelFormat = PF_B5G6R5; /* XXX: FIX ME */
results[i].visual = visResults + i;
results[i].visualid = i;
for ( mode = dpy->driver_modes ; mode != NULL ; mode= mode->next )
if (mode->visualID == vinfo_template->visualid)
{
visResults[0].mode=mode;
visResults[0].visInfo = results;
visResults[0].dpy = dpy;
if (dpy->driverContext.bpp == 32)
visResults[0].pixelFormat = PF_B8G8R8A8; /* XXX: FIX ME */
else
visResults[0].pixelFormat = PF_B5G6R5; /* XXX: FIX ME */
results[0].visual = visResults;
results[0].visualid = mode->visualID;
#if defined(__cplusplus) || defined(c_plusplus)
results[i].c_class = TrueColor;
results[0].c_class = TrueColor;
#else
results[i].class = TrueColor;
results[0].class = TrueColor;
#endif
results[i].depth = mode->redBits +
mode->redBits +
mode->redBits +
mode->redBits;
results[i].bits_per_rgb = dpy->driverContext.bpp;
results[0].depth = mode->redBits +
mode->redBits +
mode->redBits +
mode->redBits;
results[0].bits_per_rgb = dpy->driverContext.bpp;
}
}
else // if (vinfo_mask == VisualScreenMask)
{
n = 0;
for ( mode = dpy->driver_modes ; mode != NULL ; mode = mode->next )
n++;
results = (XVisualInfo *)calloc(1, n * sizeof(XVisualInfo));
if (!results) {
*nitens_return = 0;
return NULL;
}
visResults = (Visual *)calloc(1, n * sizeof(Visual));
if (!results) {
free(results);
*nitens_return = 0;
return NULL;
}
for ( mode = dpy->driver_modes, i = 0 ; mode != NULL ; mode = mode->next, i++ ) {
visResults[i].mode = mode;
visResults[i].visInfo = results + i;
visResults[i].dpy = dpy;
if (dpy->driverContext.bpp == 32)
visResults[i].pixelFormat = PF_B8G8R8A8; /* XXX: FIX ME */
else
visResults[i].pixelFormat = PF_B5G6R5; /* XXX: FIX ME */
results[i].visual = visResults + i;
results[i].visualid = mode->visualID;
#if defined(__cplusplus) || defined(c_plusplus)
results[i].c_class = TrueColor;
#else
results[i].class = TrueColor;
#endif
results[i].depth = mode->redBits +
mode->redBits +
mode->redBits +
mode->redBits;
results[i].bits_per_rgb = dpy->driverContext.bpp;
}
}
*nitens_return = n;
return results;