summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/glx
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2010-03-08 16:20:09 +0000
committerKeith Whitwell <[email protected]>2010-03-08 16:35:49 +0000
commit1675d05f911fbd569efb5248674aa71cb755c75b (patch)
treeff36474f80ec6c34ffebfd035a3befcd9775a659 /src/gallium/state_trackers/glx
parent7f9a3959b0a69f6f4b520a87e3ea87918cf89f11 (diff)
winsys/xlib: remove dependency on glx/x11 state tracker
Introduce xlib_drawable struct, pass this down to winsys instead of having it use the internal data structures from glx/x11
Diffstat (limited to 'src/gallium/state_trackers/glx')
-rw-r--r--src/gallium/state_trackers/glx/xlib/glx_api.c2
-rw-r--r--src/gallium/state_trackers/glx/xlib/xm_api.c91
-rw-r--r--src/gallium/state_trackers/glx/xlib/xm_api.h18
-rw-r--r--src/gallium/state_trackers/glx/xlib/xm_winsys.h7
4 files changed, 25 insertions, 93 deletions
diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c
index 08bf624b5c1..24545858500 100644
--- a/src/gallium/state_trackers/glx/xlib/glx_api.c
+++ b/src/gallium/state_trackers/glx/xlib/glx_api.c
@@ -689,7 +689,7 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig )
int desiredVisualID = -1;
int numAux = 0;
- xmesa_init();
+ xmesa_init( dpy );
parselist = list;
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c
index 217bdeff75e..d878740ab12 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
@@ -35,10 +35,6 @@
* corner of the window. Therefore, most drawing functions in this
* file have to flip Y coordinates.
*
- * Define USE_XSHM in the Makefile with -DUSE_XSHM if you want to compile
- * in support for the MIT Shared Memory extension. If enabled, when you
- * use an Ximage for the back buffer in double buffered mode, the "swap"
- * operation will be faster. You must also link with -lXext.
*
* Byte swapping: If the Mesa host and the X display use a different
* byte order then there's some trickiness to be aware of when using
@@ -111,41 +107,6 @@ static int host_byte_order( void )
}
-/**
- * Check if the X Shared Memory extension is available.
- * Return: 0 = not available
- * 1 = shared XImage support available
- * 2 = shared Pixmap support available also
- */
-int xmesa_check_for_xshm( Display *display )
-{
-#if defined(USE_XSHM)
- int major, minor, ignore;
- Bool pixmaps;
-
- if (getenv("SP_NO_RAST"))
- return 0;
-
- if (getenv("MESA_NOSHM")) {
- return 0;
- }
-
- if (XQueryExtension( display, "MIT-SHM", &ignore, &ignore, &ignore )) {
- if (XShmQueryVersion( display, &major, &minor, &pixmaps )==True) {
- return (pixmaps==True) ? 2 : 1;
- }
- else {
- return 0;
- }
- }
- else {
- return 0;
- }
-#else
- /* No XSHM support */
- return 0;
-#endif
-}
/**
@@ -242,7 +203,7 @@ xmesa_get_window_size(Display *dpy, XMesaBuffer b,
pipe_mutex_lock(_xmesa_lock);
XSync(b->xm_visual->display, 0); /* added for Chromium */
- stat = get_drawable_size(dpy, b->drawable, width, height);
+ stat = get_drawable_size(dpy, b->ws.drawable, width, height);
pipe_mutex_unlock(_xmesa_lock);
if (!stat) {
@@ -397,7 +358,9 @@ create_xmesa_buffer(Drawable d, BufferType type,
if (!b)
return NULL;
- b->drawable = d;
+ b->ws.drawable = d;
+ b->ws.visual = vis->visinfo->visual;
+ b->ws.depth = vis->visinfo->depth;
b->xm_visual = vis;
b->type = type;
@@ -422,18 +385,6 @@ create_xmesa_buffer(Drawable d, BufferType type,
(void *) b);
fb = &b->stfb->Base;
- /*
- * Create scratch XImage for xmesa_display_surface()
- */
- b->tempImage = XCreateImage(vis->display,
- vis->visinfo->visual,
- vis->visinfo->depth,
- ZPixmap, 0, /* format, offset */
- NULL, /* data */
- 0, 0, /* size */
- 32, /* bitmap_pad */
- 0); /* bytes_per_line */
-
/* GLX_EXT_texture_from_pixmap */
b->TextureTarget = 0;
b->TextureFormat = GLX_TEXTURE_FORMAT_NONE_EXT;
@@ -490,15 +441,12 @@ xmesa_free_buffer(XMesaBuffer buffer)
/* Since the X window for the XMesaBuffer is going away, we don't
* want to dereference this pointer in the future.
*/
- b->drawable = 0;
-
- buffer->tempImage->data = NULL;
- XDestroyImage(buffer->tempImage);
+ b->ws.drawable = 0;
/* Unreference. If count = zero we'll really delete the buffer */
_mesa_reference_framebuffer(&fb, NULL);
- XFreeGC(b->xm_visual->display, b->gc);
+ XFreeGC(b->xm_visual->display, b->ws.gc);
free(buffer);
@@ -578,17 +526,12 @@ initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b,
if (b && window) {
/* these should have been set in create_xmesa_buffer */
- ASSERT(b->drawable == window);
+ ASSERT(b->ws.drawable == window);
- /* Setup for single/double buffering */
- if (v->mesa_visual.doubleBufferMode) {
- /* Double buffered */
- b->shm = xmesa_check_for_xshm( v->display );
- }
/* X11 graphics context */
- b->gc = XCreateGC( v->display, window, 0, NULL );
- XSetFunction( v->display, b->gc, GXcopy );
+ b->ws.gc = XCreateGC( v->display, window, 0, NULL );
+ XSetFunction( v->display, b->ws.gc, GXcopy );
}
return GL_TRUE;
@@ -673,7 +616,7 @@ XMesaVisual XMesaCreateVisual( Display *display,
XMesaVisual v;
GLint red_bits, green_bits, blue_bits, alpha_bits;
- xmesa_init();
+ xmesa_init( display );
/* For debugging only */
if (_mesa_getenv("MESA_XSYNC")) {
@@ -773,12 +716,12 @@ void XMesaDestroyVisual( XMesaVisual v )
* Do one-time initializations.
*/
void
-xmesa_init(void)
+xmesa_init( Display *display )
{
static GLboolean firstTime = GL_TRUE;
if (firstTime) {
pipe_mutex_init(_xmesa_lock);
- _screen = driver.create_pipe_screen();
+ _screen = driver.create_pipe_screen( display );
screen = trace_screen_create( _screen );
firstTime = GL_FALSE;
}
@@ -800,7 +743,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
GLcontext *mesaCtx;
uint pf;
- xmesa_init();
+ xmesa_init( v->display );
/* Note: the XMesaContext contains a Mesa GLcontext struct (inheritance) */
c = (XMesaContext) CALLOC_STRUCT(xmesa_context);
@@ -1155,7 +1098,7 @@ void XMesaSwapBuffers( XMesaBuffer b )
frontLeftSurf = surf;
}
- driver.display_surface(b, frontLeftSurf);
+ driver.display_surface(&b->ws, frontLeftSurf);
}
xmesa_check_and_update_buffer_size(NULL, b);
@@ -1203,7 +1146,7 @@ XMesaBuffer XMesaFindBuffer( Display *dpy, Drawable d )
{
XMesaBuffer b;
for (b = XMesaBufferList; b; b = b->Next) {
- if (b->drawable == d && b->xm_visual->display == dpy) {
+ if (b->ws.drawable == d && b->xm_visual->display == dpy) {
return b;
}
}
@@ -1237,10 +1180,10 @@ void XMesaGarbageCollect( void )
next = b->Next;
if (b->xm_visual &&
b->xm_visual->display &&
- b->drawable &&
+ b->ws.drawable &&
b->type == WINDOW) {
XSync(b->xm_visual->display, False);
- if (!window_exists( b->xm_visual->display, b->drawable )) {
+ if (!window_exists( b->xm_visual->display, b->ws.drawable )) {
/* found a dead window, free the ancillary info */
XMesaDestroyBuffer( b );
}
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.h b/src/gallium/state_trackers/glx/xlib/xm_api.h
index 004cb260dcd..de47064b410 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.h
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.h
@@ -62,15 +62,11 @@ and create a window, you must do the following to use the X/Mesa interface:
#include "state_tracker/st_public.h"
#include "os/os_thread.h"
+#include "state_tracker/xlib_sw_winsys.h"
# include <X11/Xlib.h>
# include <X11/Xlibint.h>
# include <X11/Xutil.h>
-# ifdef USE_XSHM /* was SHM */
-# include <sys/ipc.h>
-# include <sys/shm.h>
-# include <X11/extensions/XShm.h>
-# endif
typedef struct xmesa_buffer *XMesaBuffer;
typedef struct xmesa_context *XMesaContext;
@@ -316,6 +312,7 @@ typedef enum {
*/
struct xmesa_buffer {
struct st_framebuffer *stfb;
+ struct xlib_drawable ws;
GLboolean wasCurrent; /* was ever the current buffer? */
XMesaVisual xm_visual; /* the X/Mesa visual */
@@ -329,13 +326,6 @@ struct xmesa_buffer {
XImage *tempImage;
unsigned long selectedEvents;/* for pbuffers only */
- GLuint shm; /* X Shared Memory extension status: */
- /* 0 = not available */
- /* 1 = XImage support available */
- /* 2 = Pixmap support available too */
-#if defined(USE_XSHM)
- XShmSegmentInfo shminfo;
-#endif
GC gc; /* scratch GC for span, line, tri drawing */
@@ -367,7 +357,7 @@ xmesa_buffer(GLframebuffer *fb)
extern void
-xmesa_init(void);
+xmesa_init(Display *dpy);
extern void
xmesa_delete_framebuffer(struct gl_framebuffer *fb);
@@ -397,8 +387,6 @@ xmesa_buffer_height(XMesaBuffer b)
return b->stfb->Base.Height;
}
-extern int
-xmesa_check_for_xshm(Display *display);
#endif
diff --git a/src/gallium/state_trackers/glx/xlib/xm_winsys.h b/src/gallium/state_trackers/glx/xlib/xm_winsys.h
index 4bd5b5c8d3b..fc4444bee0e 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_winsys.h
+++ b/src/gallium/state_trackers/glx/xlib/xm_winsys.h
@@ -32,14 +32,15 @@
struct pipe_context;
struct pipe_screen;
struct pipe_surface;
-struct xmesa_buffer;
+struct xlib_drawable;
+#include <X11/Xlib.h>
struct xm_driver {
- struct pipe_screen *(*create_pipe_screen)( void );
+ struct pipe_screen *(*create_pipe_screen)( Display *display );
- void (*display_surface)( struct xmesa_buffer *,
+ void (*display_surface)( struct xlib_drawable *,
struct pipe_surface * );
};