summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/x11/fakeglx.c12
-rw-r--r--src/mesa/drivers/x11/xm_api.c77
-rw-r--r--src/mesa/drivers/x11/xm_dd.c67
-rw-r--r--src/mesa/drivers/x11/xmesaP.h2
4 files changed, 65 insertions, 93 deletions
diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c
index cd953c26fd..1ad62d9e0d 100644
--- a/src/mesa/drivers/x11/fakeglx.c
+++ b/src/mesa/drivers/x11/fakeglx.c
@@ -2079,16 +2079,16 @@ Fake_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
switch (attribute) {
case GLX_WIDTH:
- *value = xmbuf->width;
+ *value = xmbuf->mesa_buffer.Width;
break;
case GLX_HEIGHT:
- *value = xmbuf->height;
+ *value = xmbuf->mesa_buffer.Height;
break;
case GLX_PRESERVED_CONTENTS:
*value = True;
break;
case GLX_LARGEST_PBUFFER:
- *value = xmbuf->width * xmbuf->height;
+ *value = xmbuf->mesa_buffer.Width * xmbuf->mesa_buffer.Height;
break;
case GLX_FBCONFIG_ID:
*value = xmbuf->xm_visual->visinfo->visualid;
@@ -2439,13 +2439,13 @@ Fake_glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, un
*value = True;
break;
case GLX_LARGEST_PBUFFER_SGIX:
- *value = xmbuf->width * xmbuf->height;
+ *value = xmbuf->mesa_buffer.Width * xmbuf->mesa_buffer.Height;
break;
case GLX_WIDTH_SGIX:
- *value = xmbuf->width;
+ *value = xmbuf->mesa_buffer.Width;
break;
case GLX_HEIGHT_SGIX:
- *value = xmbuf->height;
+ *value = xmbuf->mesa_buffer.Height;
break;
case GLX_EVENT_MASK_SGIX:
*value = 0; /* XXX might be wrong */
diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c
index 6255c3b794..f58562ace9 100644
--- a/src/mesa/drivers/x11/xm_api.c
+++ b/src/mesa/drivers/x11/xm_api.c
@@ -221,28 +221,6 @@ static int check_for_xshm( XMesaDisplay *display )
/*
- * Return the width and height of the given drawable.
- */
-static void get_drawable_size( XMesaDisplay *dpy, XMesaDrawable d,
- unsigned int *width, unsigned int *height)
-{
-#ifdef XFree86Server
- (void) dpy;
- *width = d->width;
- *height = d->height;
-#else
- Window root;
- int x, y;
- unsigned int bw, depth;
-
- _glthread_LOCK_MUTEX(_xmesa_lock);
- XGetGeometry( dpy, d, &root, &x, &y, width, height, &bw, &depth );
- _glthread_UNLOCK_MUTEX(_xmesa_lock);
-#endif
-}
-
-
-/*
* Apply gamma correction to an intensity value in [0..max]. Return the
* new intensity value.
*/
@@ -476,11 +454,16 @@ static GLboolean alloc_shm_back_buffer( XMesaBuffer b )
GC gc;
int (*old_handler)( XMesaDisplay *, XErrorEvent * );
- b->backimage = XShmCreateImage( b->xm_visual->display,
- b->xm_visual->visinfo->visual,
- b->xm_visual->visinfo->depth,
- ZPixmap, NULL, &b->shminfo,
- b->width, b->height );
+ if (b->mesa_buffer.Width == 0 || b->mesa_buffer.Height == 0) {
+ /* this will be true the first time we're called on 'b' */
+ return GL_FALSE;
+ }
+
+ b->backimage = XShmCreateImage(b->xm_visual->display,
+ b->xm_visual->visinfo->visual,
+ b->xm_visual->visinfo->depth,
+ ZPixmap, NULL, &b->shminfo,
+ b->mesa_buffer.Width, b->mesa_buffer.Height);
if (b->backimage == NULL) {
_mesa_warning(NULL, "alloc_back_buffer: Shared memory error (XShmCreateImage), disabling.");
b->shm = 0;
@@ -614,7 +597,9 @@ void xmesa_alloc_back_buffer( XMesaBuffer b )
b->xm_visual->visinfo->visual,
GET_VISUAL_DEPTH(b->xm_visual),
ZPixmap, 0, /* format, offset */
- NULL, b->width, b->height,
+ NULL,
+ b->mesa_buffer.Width,
+ b->mesa_buffer.Height,
8, 0 ); /* pad, bytes_per_line */
#endif
if (!b->backimage) {
@@ -638,7 +623,8 @@ void xmesa_alloc_back_buffer( XMesaBuffer b )
}
/* Allocate new back pixmap */
b->backpixmap = XMesaCreatePixmap( b->xm_visual->display, b->frontbuffer,
- b->width, b->height,
+ b->mesa_buffer.Width,
+ b->mesa_buffer.Height,
GET_VISUAL_DEPTH(b->xm_visual) );
b->backimage = NULL;
/* update other references to backpixmap */
@@ -1248,12 +1234,6 @@ static GLboolean initialize_visual_and_buffer( int client,
if (b && window) {
/* Do window-specific initializations */
- /* Window dimensions */
- unsigned int w, h;
- get_drawable_size( v->display, window, &w, &h );
- b->width = w;
- b->height = h;
-
b->frontbuffer = window;
/* Setup for single/double buffering */
@@ -1847,8 +1827,14 @@ XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, XMesaWindow w,
/* [dBorca] we should take an envvar for `fxMesaSelectCurrentBoard'!!! */
hw = fxMesaSelectCurrentBoard(0);
+
+ /* if these fail, there's a new bug somewhere */
+ ASSERT(b->mesa_buffer.Width > 0);
+ ASSERT(b->mesa_buffer.Height > 0);
+
if ((hw == GR_SSTTYPE_VOODOO) || (hw == GR_SSTTYPE_Voodoo2)) {
- b->FXctx = fxMesaCreateBestContext(0, b->width, b->height, attribs);
+ b->FXctx = fxMesaCreateBestContext(0, b->mesa_buffer.Width,
+ b->mesa_buffer.Height, attribs);
if ((v->undithered_pf!=PF_Index) && (b->backimage)) {
b->FXisHackUsable = b->FXctx ? GL_TRUE : GL_FALSE;
if (b->FXctx && (fxEnvVar[0]=='w' || fxEnvVar[0]=='W')) {
@@ -1865,7 +1851,8 @@ XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, XMesaWindow w,
b->FXctx = fxMesaCreateContext(w, GR_RESOLUTION_NONE,
GR_REFRESH_75Hz, attribs);
else
- b->FXctx = fxMesaCreateBestContext(0, b->width, b->height, attribs);
+ b->FXctx = fxMesaCreateBestContext(0, b->mesa_buffer.Width,
+ b->mesa_buffer.Height, attribs);
b->FXisHackUsable = GL_FALSE;
b->FXwindowHack = GL_FALSE;
}
@@ -2106,13 +2093,6 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
&drawBuffer->mesa_buffer,
&readBuffer->mesa_buffer);
- if (c->mesa.Viewport.Width == 0) {
- /* initialize viewport to window size */
- _mesa_Viewport( 0, 0, drawBuffer->width, drawBuffer->height );
- c->mesa.Scissor.Width = drawBuffer->width;
- c->mesa.Scissor.Height = drawBuffer->height;
- }
-
if (c->xm_visual->mesa_visual.rgbMode) {
/*
* Must recompute and set these pixel values because colormap
@@ -2386,7 +2366,8 @@ void XMesaSwapBuffers( XMesaBuffer b )
XShmPutImage( b->xm_visual->display, b->frontbuffer,
b->swapgc,
b->backimage, 0, 0,
- 0, 0, b->width, b->height, False );
+ 0, 0, b->mesa_buffer.Width, b->mesa_buffer.Height,
+ False );
/*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
}
else
@@ -2396,7 +2377,7 @@ void XMesaSwapBuffers( XMesaBuffer b )
XMesaPutImage( b->xm_visual->display, b->frontbuffer,
b->swapgc,
b->backimage, 0, 0,
- 0, 0, b->width, b->height );
+ 0, 0, b->mesa_buffer.Width, b->mesa_buffer.Height );
/*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
}
}
@@ -2407,7 +2388,7 @@ void XMesaSwapBuffers( XMesaBuffer b )
b->backpixmap, /* source drawable */
b->frontbuffer, /* dest. drawable */
b->swapgc,
- 0, 0, b->width, b->height, /* source region */
+ 0, 0, b->mesa_buffer.Width, b->mesa_buffer.Height,
0, 0 /* dest region */
);
/*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
@@ -2434,7 +2415,7 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
_mesa_notifySwapBuffers(ctx);
if (b->db_state) {
- int yTop = b->height - y - height;
+ int yTop = b->mesa_buffer.Height - y - height;
#ifdef FX
if (b->FXctx) {
fxMesaSwapBuffers();
diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c
index f787da2a17..d8f3e22cfc 100644
--- a/src/mesa/drivers/x11/xm_dd.c
+++ b/src/mesa/drivers/x11/xm_dd.c
@@ -285,13 +285,13 @@ clear_front_pixmap( GLcontext *ctx, GLboolean all,
XMesaFillRectangle( xmesa->display, xmesa->xm_draw_buffer->frontbuffer,
xmesa->xm_draw_buffer->cleargc,
0, 0,
- xmesa->xm_draw_buffer->width+1,
- xmesa->xm_draw_buffer->height+1 );
+ xmesa->xm_draw_buffer->mesa_buffer.Width + 1,
+ xmesa->xm_draw_buffer->mesa_buffer.Height + 1 );
}
else {
XMesaFillRectangle( xmesa->display, xmesa->xm_draw_buffer->frontbuffer,
xmesa->xm_draw_buffer->cleargc,
- x, xmesa->xm_draw_buffer->height - y - height,
+ x, xmesa->xm_draw_buffer->mesa_buffer.Height - y - height,
width, height );
}
}
@@ -306,13 +306,13 @@ clear_back_pixmap( GLcontext *ctx, GLboolean all,
XMesaFillRectangle( xmesa->display, xmesa->xm_draw_buffer->backpixmap,
xmesa->xm_draw_buffer->cleargc,
0, 0,
- xmesa->xm_draw_buffer->width+1,
- xmesa->xm_draw_buffer->height+1 );
+ xmesa->xm_draw_buffer->mesa_buffer.Width + 1,
+ xmesa->xm_draw_buffer->mesa_buffer.Height + 1 );
}
else {
XMesaFillRectangle( xmesa->display, xmesa->xm_draw_buffer->backpixmap,
xmesa->xm_draw_buffer->cleargc,
- x, xmesa->xm_draw_buffer->height - y - height,
+ x, xmesa->xm_draw_buffer->mesa_buffer.Height - y - height,
width, height );
}
}
@@ -410,20 +410,20 @@ clear_16bit_ximage( GLcontext *ctx, GLboolean all,
if ((pixel & 0xff) == ((pixel >> 8) & 0xff)) {
/* low and high bytes are equal so use memset() */
n = xmesa->xm_draw_buffer->backimage->bytes_per_line
- * xmesa->xm_draw_buffer->height;
+ * xmesa->xm_draw_buffer->mesa_buffer.Height;
MEMSET( ptr4, pixel & 0xff, n );
}
else {
pixel = pixel | (pixel<<16);
n = xmesa->xm_draw_buffer->backimage->bytes_per_line
- * xmesa->xm_draw_buffer->height / 4;
+ * xmesa->xm_draw_buffer->mesa_buffer.Height / 4;
do {
*ptr4++ = pixel;
n--;
} while (n!=0);
if ((xmesa->xm_draw_buffer->backimage->bytes_per_line *
- xmesa->xm_draw_buffer->height) & 0x2)
+ xmesa->xm_draw_buffer->mesa_buffer.Height) & 0x2)
*(GLushort *)ptr4 = pixel & 0xffff;
}
}
@@ -461,8 +461,8 @@ clear_24bit_ximage( GLcontext *ctx, GLboolean all,
if (all) {
if (r==g && g==b) {
/* same value for all three components (gray) */
- const GLint w3 = xmesa->xm_draw_buffer->width * 3;
- const GLint h = xmesa->xm_draw_buffer->height;
+ const GLint w3 = xmesa->xm_draw_buffer->mesa_buffer.Width * 3;
+ const GLint h = xmesa->xm_draw_buffer->mesa_buffer.Height;
GLint i;
for (i = 0; i < h; i++) {
bgr_t *ptr3 = PIXELADDR3(xmesa->xm_draw_buffer, 0, i);
@@ -471,8 +471,8 @@ clear_24bit_ximage( GLcontext *ctx, GLboolean all,
}
else {
/* the usual case */
- const GLint w = xmesa->xm_draw_buffer->width;
- const GLint h = xmesa->xm_draw_buffer->height;
+ const GLint w = xmesa->xm_draw_buffer->mesa_buffer.Width;
+ const GLint h = xmesa->xm_draw_buffer->mesa_buffer.Height;
GLint i, j;
for (i = 0; i < h; i++) {
bgr_t *ptr3 = PIXELADDR3(xmesa->xm_draw_buffer, 0, i);
@@ -665,7 +665,8 @@ clear_32bit_ximage( GLcontext *ctx, GLboolean all,
| ((pixel << 24) & 0xff000000);
}
if (all) {
- register GLint n = xmesa->xm_draw_buffer->width * xmesa->xm_draw_buffer->height;
+ register GLint n = xmesa->xm_draw_buffer->mesa_buffer.Width
+ * xmesa->xm_draw_buffer->mesa_buffer.Height;
register GLuint *ptr4 = (GLuint *) xmesa->xm_draw_buffer->backimage->data;
if (pixel==0) {
MEMSET( ptr4, pixel, 4*n );
@@ -695,24 +696,16 @@ clear_nbit_ximage( GLcontext *ctx, GLboolean all,
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
XMesaImage *img = xmesa->xm_draw_buffer->backimage;
- if (all) {
- register int i, j;
- width = xmesa->xm_draw_buffer->width;
- height = xmesa->xm_draw_buffer->height;
- for (j=0;j<height;j++) {
- for (i=0;i<width;i++) {
- XMesaPutPixel( img, i, j, xmesa->clearpixel );
- }
- }
- }
- else {
- /* TODO: optimize this */
- register int i, j;
- y = FLIP(xmesa->xm_draw_buffer, y);
- for (j=0;j<height;j++) {
- for (i=0;i<width;i++) {
- XMesaPutPixel( img, x+i, y-j, xmesa->clearpixel );
- }
+ register int i, j;
+
+ /* We can ignore 'all' here - x, y, width, height are always right */
+ (void) all;
+
+ /* TODO: optimize this */
+ y = FLIP(xmesa->xm_draw_buffer, y);
+ for (j = 0; j < height; j++) {
+ for (i = 0; i < width; i++) {
+ XMesaPutPixel(img, x+i, y-j, xmesa->clearpixel);
}
}
}
@@ -755,6 +748,7 @@ clear_buffers( GLcontext *ctx, GLbitfield mask,
* When we detect that the user has resized the window this function will
* get called. Here we'll reallocate the back buffer, depth buffer,
* stencil buffer etc. to match the new window size.
+ * The buffer->Width and buffer->Height values will indicate the new size.
*/
void
xmesa_resize_buffers( GLframebuffer *buffer )
@@ -766,8 +760,6 @@ xmesa_resize_buffers( GLframebuffer *buffer )
*/
XMesaBuffer xmBuffer = (XMesaBuffer) buffer;
- xmBuffer->width = buffer->Width;
- xmBuffer->height = buffer->Height;
xmesa_alloc_back_buffer( xmBuffer );
/* Needed by FLIP macro */
@@ -1214,8 +1206,9 @@ choose_tex_format( GLcontext *ctx, GLint internalFormat,
* Initialize the device driver function table with the functions
* we implement in this driver.
*/
-void xmesa_init_driver_functions( XMesaVisual xmvisual,
- struct dd_function_table *driver )
+void
+xmesa_init_driver_functions( XMesaVisual xmvisual,
+ struct dd_function_table *driver )
{
driver->GetString = get_string;
driver->UpdateState = xmesa_update_state;
@@ -1230,7 +1223,7 @@ void xmesa_init_driver_functions( XMesaVisual xmvisual,
driver->Clear = clear_buffers;
driver->ResizeBuffers = xmesa_resize_buffers;
#ifndef XFree86Server
- driver->CopyPixels = /*_swrast_CopyPixels;*/xmesa_CopyPixels;
+ driver->CopyPixels = xmesa_CopyPixels;
if (xmvisual->undithered_pf == PF_8R8G8B &&
xmvisual->dithered_pf == PF_8R8G8B) {
driver->DrawPixels = xmesa_DrawPixels_8R8G8B;
diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h
index 085b43401c..de989260ae 100644
--- a/src/mesa/drivers/x11/xmesaP.h
+++ b/src/mesa/drivers/x11/xmesaP.h
@@ -192,8 +192,6 @@ struct xmesa_buffer {
XMesaImage *rowimage; /* Used for optimized span writing */
- GLuint width, height; /* size of buffer */
-
GLint bottom; /* used for FLIP macro below */
GLubyte *ximage_origin1; /* used for PIXELADDR1 macro */
GLint ximage_width1;