the values in the contained GLframebuffer.
Removed some other unneeded code.
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;
*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 */
#endif
-/*
- * 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.
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;
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) {
}
/* 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 */
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 */
/* [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')) {
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;
}
&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
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
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);*/
}
}
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);*/
_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();
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 );
}
}
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 );
}
}
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;
}
}
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);
}
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);
| ((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 );
{
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);
}
}
}
* 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 )
*/
XMesaBuffer xmBuffer = (XMesaBuffer) buffer;
- xmBuffer->width = buffer->Width;
- xmBuffer->height = buffer->Height;
xmesa_alloc_back_buffer( xmBuffer );
/* Needed by FLIP macro */
* 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;
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;
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;