summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/x11
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/x11')
-rw-r--r--src/mesa/drivers/x11/fakeglx.c32
-rw-r--r--src/mesa/drivers/x11/glxheader.h1
-rw-r--r--src/mesa/drivers/x11/xm_api.c378
-rw-r--r--src/mesa/drivers/x11/xm_buffer.c111
-rw-r--r--src/mesa/drivers/x11/xm_dd.c745
-rw-r--r--src/mesa/drivers/x11/xm_line.c129
-rw-r--r--src/mesa/drivers/x11/xm_span.c966
-rw-r--r--src/mesa/drivers/x11/xm_tri.c337
-rw-r--r--src/mesa/drivers/x11/xmesaP.h117
9 files changed, 1736 insertions, 1080 deletions
diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c
index b0cb52846a..e4dbc5acd9 100644
--- a/src/mesa/drivers/x11/fakeglx.c
+++ b/src/mesa/drivers/x11/fakeglx.c
@@ -417,11 +417,8 @@ create_glx_visual( Display *dpy, XVisualInfo *visinfo )
GL_TRUE, /* double */
GL_FALSE, /* stereo */
zBits,
- 8 * sizeof(GLstencil),
- 0 * sizeof(GLaccum), /* r */
- 0 * sizeof(GLaccum), /* g */
- 0 * sizeof(GLaccum), /* b */
- 0 * sizeof(GLaccum), /* a */
+ STENCIL_BITS,
+ 0, 0, 0, 0, /* accum bits */
0, /* level */
0 /* numAux */
);
@@ -436,11 +433,11 @@ create_glx_visual( Display *dpy, XVisualInfo *visinfo )
GL_TRUE, /* double */
GL_FALSE, /* stereo */
zBits,
- 8 * sizeof(GLstencil),
- 8 * sizeof(GLaccum), /* r */
- 8 * sizeof(GLaccum), /* g */
- 8 * sizeof(GLaccum), /* b */
- 8 * sizeof(GLaccum), /* a */
+ STENCIL_BITS,
+ ACCUM_BITS, /* r */
+ ACCUM_BITS, /* g */
+ ACCUM_BITS, /* b */
+ ACCUM_BITS, /* a */
0, /* level */
0 /* numAux */
);
@@ -1231,6 +1228,11 @@ static XVisualInfo *
Fake_glXChooseVisual( Display *dpy, int screen, int *list )
{
XMesaVisual xmvis = choose_visual(dpy, screen, list, GL_FALSE);
+ {
+ int x;
+ glXGetConfig(dpy, xmvis->vishandle, GLX_RED_SIZE, &x);
+ }
+
if (xmvis) {
#if 0
return xmvis->vishandle;
@@ -1418,7 +1420,7 @@ Fake_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo, Pixmap pixmap )
if (!b) {
return 0;
}
- return b->frontbuffer;
+ return b->frontxrb->pixmap;
}
@@ -1444,7 +1446,7 @@ Fake_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo,
if (!b) {
return 0;
}
- return b->frontbuffer;
+ return b->frontxrb->pixmap;
}
@@ -2096,7 +2098,7 @@ Fake_glXCreatePbuffer( Display *dpy, GLXFBConfig config,
/* A GLXPbuffer handle must be an X Drawable because that's what
* glXMakeCurrent takes.
*/
- return (GLXPbuffer) xmbuf->frontbuffer;
+ return (GLXPbuffer) xmbuf->frontxrb->pixmap;
}
@@ -2357,7 +2359,7 @@ Fake_glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixm
{
XMesaVisual xmvis = (XMesaVisual) config;
XMesaBuffer xmbuf = XMesaCreatePixmapBuffer(xmvis, pixmap, 0);
- return xmbuf->frontbuffer; /* need to return an X ID */
+ return xmbuf->frontxrb->pixmap; /* need to return an X ID */
}
@@ -2451,7 +2453,7 @@ Fake_glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config,
/* A GLXPbuffer handle must be an X Drawable because that's what
* glXMakeCurrent takes.
*/
- return (GLXPbuffer) xmbuf->frontbuffer;
+ return (GLXPbuffer) xmbuf->frontxrb->pixmap;
}
diff --git a/src/mesa/drivers/x11/glxheader.h b/src/mesa/drivers/x11/glxheader.h
index b583400389..42637f4c14 100644
--- a/src/mesa/drivers/x11/glxheader.h
+++ b/src/mesa/drivers/x11/glxheader.h
@@ -67,5 +67,4 @@ struct timespec;
struct itimerspec;
-
#endif /*GLX_HEADER*/
diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c
index 0e1f5c58ed..99beb5c501 100644
--- a/src/mesa/drivers/x11/xm_api.c
+++ b/src/mesa/drivers/x11/xm_api.c
@@ -65,11 +65,13 @@
#include "xmesaP.h"
#include "context.h"
#include "extensions.h"
+#include "framebuffer.h"
#include "glthread.h"
#include "imports.h"
#include "matrix.h"
#include "mtypes.h"
#include "macros.h"
+#include "renderbuffer.h"
#include "texformat.h"
#include "texobj.h"
#include "texstore.h"
@@ -278,7 +280,7 @@ static int bits_per_pixel( XMesaVisual xmv )
/* grab the bits/pixel value */
bitsPerPixel = img->bits_per_pixel;
/* free the XImage */
- FREE( img->data );
+ _mesa_free( img->data );
img->data = NULL;
XMesaDestroyImage( img );
return bitsPerPixel;
@@ -343,18 +345,7 @@ alloc_xmesa_buffer(XMesaVisual vis, BufferType type, XMesaColormap cmap)
b->type = type;
b->cmap = cmap;
- _mesa_initialize_framebuffer(&b->mesa_buffer,
- &vis->mesa_visual,
- vis->mesa_visual.depthBits > 0,
- vis->mesa_visual.stencilBits > 0,
- vis->mesa_visual.accumRedBits +
- vis->mesa_visual.accumGreenBits +
- vis->mesa_visual.accumBlueBits > 0,
- vis->mesa_visual.alphaBits > 0
- /*v->mesa_visual.numAuxBuffers > 0*/ );
- /* XXX hack */
- if (vis->mesa_visual.numAuxBuffers > 0)
- b->mesa_buffer.UseSoftwareAuxBuffers = GL_TRUE;
+ _mesa_initialize_framebuffer(&b->mesa_buffer, &vis->mesa_visual);
/* determine back buffer implementation */
if (vis->mesa_visual.doubleBufferMode) {
@@ -369,6 +360,30 @@ alloc_xmesa_buffer(XMesaVisual vis, BufferType type, XMesaColormap cmap)
b->db_state = 0;
}
+ /* Allocate the framebuffer's renderbuffers */
+ assert(!b->mesa_buffer.Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
+ assert(!b->mesa_buffer.Attachment[BUFFER_BACK_LEFT].Renderbuffer);
+
+ /* front renderbuffer */
+ b->frontxrb = xmesa_new_renderbuffer(NULL, 0, vis->mesa_visual.rgbMode);
+ _mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_FRONT_LEFT,
+ &b->frontxrb->Base);
+
+ /* back renderbuffer */
+ if (vis->mesa_visual.doubleBufferMode) {
+ b->backxrb =xmesa_new_renderbuffer(NULL, 0, vis->mesa_visual.rgbMode);
+ _mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_BACK_LEFT,
+ &b->backxrb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(&b->mesa_buffer,
+ GL_FALSE, /* color */
+ vis->mesa_visual.haveDepthBuffer,
+ vis->mesa_visual.haveStencilBuffer,
+ vis->mesa_visual.haveAccumBuffer,
+ vis->mesa_visual.alphaBits > 0,
+ vis->mesa_visual.numAuxBuffers > 0 );
+
/* insert into linked list */
b->Next = XMesaBufferList;
XMesaBufferList = b;
@@ -426,7 +441,11 @@ static void free_xmesa_buffer(int client, XMesaBuffer buffer)
}
_mesa_free_framebuffer_data(&buffer->mesa_buffer);
- FREE(buffer);
+ /* delete front/back renderbuffers */
+ buffer->frontxrb->Base.Delete(&(buffer->frontxrb->Base));
+ if (buffer->backxrb)
+ buffer->backxrb->Base.Delete(&(buffer->backxrb->Base));
+ _mesa_free(buffer);
return;
}
@@ -473,12 +492,13 @@ static int bitcount( unsigned long n )
-/*
+/**
* Allocate a shared memory XImage back buffer for the given XMesaBuffer.
* Return: GL_TRUE if success, GL_FALSE if error
*/
#ifndef XFree86Server
-static GLboolean alloc_shm_back_buffer( XMesaBuffer b )
+static GLboolean
+alloc_shm_back_buffer(XMesaBuffer b, GLuint width, GLuint height)
{
#ifdef USE_XSHM
/*
@@ -490,40 +510,40 @@ static GLboolean alloc_shm_back_buffer( XMesaBuffer b )
GC gc;
int (*old_handler)( XMesaDisplay *, XErrorEvent * );
- if (b->mesa_buffer.Width == 0 || b->mesa_buffer.Height == 0) {
+ if (width == 0 || 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) {
+ b->backxrb->ximage = XShmCreateImage(b->xm_visual->display,
+ b->xm_visual->visinfo->visual,
+ b->xm_visual->visinfo->depth,
+ ZPixmap, NULL, &b->shminfo,
+ width, height);
+ if (b->backxrb->ximage == NULL) {
_mesa_warning(NULL, "alloc_back_buffer: Shared memory error (XShmCreateImage), disabling.");
b->shm = 0;
return GL_FALSE;
}
- b->shminfo.shmid = shmget( IPC_PRIVATE, b->backimage->bytes_per_line
- * b->backimage->height, IPC_CREAT|0777 );
+ b->shminfo.shmid = shmget( IPC_PRIVATE, b->backxrb->ximage->bytes_per_line
+ * b->backxrb->ximage->height, IPC_CREAT|0777 );
if (b->shminfo.shmid < 0) {
_mesa_warning(NULL, "shmget failed while allocating back buffer");
- XDestroyImage( b->backimage );
- b->backimage = NULL;
+ XDestroyImage( b->backxrb->ximage );
+ b->backxrb->ximage = NULL;
_mesa_warning(NULL, "alloc_back_buffer: Shared memory error (shmget), disabling.");
b->shm = 0;
return GL_FALSE;
}
- b->shminfo.shmaddr = b->backimage->data
+ b->shminfo.shmaddr = b->backxrb->ximage->data
= (char*)shmat( b->shminfo.shmid, 0, 0 );
if (b->shminfo.shmaddr == (char *) -1) {
_mesa_warning(NULL, "shmat() failed while allocating back buffer");
- XDestroyImage( b->backimage );
+ XDestroyImage( b->backxrb->ximage );
shmctl( b->shminfo.shmid, IPC_RMID, 0 );
- b->backimage = NULL;
+ b->backxrb->ximage = NULL;
_mesa_warning(NULL, "alloc_back_buffer: Shared memory error (shmat), disabling.");
b->shm = 0;
return GL_FALSE;
@@ -540,10 +560,10 @@ static GLboolean alloc_shm_back_buffer( XMesaBuffer b )
/* we are on a remote display, this error is normal, don't print it */
XFlush( b->xm_visual->display );
mesaXErrorFlag = 0;
- XDestroyImage( b->backimage );
+ XDestroyImage( b->backxrb->ximage );
shmdt( b->shminfo.shmaddr );
shmctl( b->shminfo.shmid, IPC_RMID, 0 );
- b->backimage = NULL;
+ b->backxrb->ximage = NULL;
b->shm = 0;
(void) XSetErrorHandler( old_handler );
return GL_FALSE;
@@ -552,43 +572,23 @@ static GLboolean alloc_shm_back_buffer( XMesaBuffer b )
shmctl( b->shminfo.shmid, IPC_RMID, 0 ); /* nobody else needs it */
/* Finally, try an XShmPutImage to be really sure the extension works */
- gc = XCreateGC( b->xm_visual->display, b->frontbuffer, 0, NULL );
- XShmPutImage( b->xm_visual->display, b->frontbuffer, gc,
- b->backimage, 0, 0, 0, 0, 1, 1 /*one pixel*/, False );
+ gc = XCreateGC( b->xm_visual->display, b->frontxrb->pixmap, 0, NULL );
+ XShmPutImage( b->xm_visual->display, b->frontxrb->pixmap, gc,
+ b->backxrb->ximage, 0, 0, 0, 0, 1, 1 /*one pixel*/, False );
XSync( b->xm_visual->display, False );
XFreeGC( b->xm_visual->display, gc );
(void) XSetErrorHandler( old_handler );
if (mesaXErrorFlag) {
XFlush( b->xm_visual->display );
mesaXErrorFlag = 0;
- XDestroyImage( b->backimage );
+ XDestroyImage( b->backxrb->ximage );
shmdt( b->shminfo.shmaddr );
shmctl( b->shminfo.shmid, IPC_RMID, 0 );
- b->backimage = NULL;
+ b->backxrb->ximage = NULL;
b->shm = 0;
return GL_FALSE;
}
- if (b->backimage) {
- int height = b->backimage->height;
- /* Needed by PIXELADDR1 macro */
- b->ximage_width1 = b->backimage->bytes_per_line;
- b->ximage_origin1 = (GLubyte *) b->backimage->data
- + b->ximage_width1 * (height-1);
- /* Needed by PIXELADDR2 macro */
- b->ximage_width2 = b->backimage->bytes_per_line / 2;
- b->ximage_origin2 = (GLushort *) b->backimage->data
- + b->ximage_width2 * (height-1);
- /* Needed by PIXELADDR3 macro */
- b->ximage_width3 = b->backimage->bytes_per_line;
- b->ximage_origin3 = (GLubyte *) b->backimage->data
- + b->ximage_width3 * (height-1);
- /* Needed by PIXELADDR4 macro */
- b->ximage_width4 = b->backimage->width;
- b->ximage_origin4 = (GLuint *) b->backimage->data
- + b->ximage_width4 * (height-1);
- }
-
return GL_TRUE;
#else
/* Can't compile XSHM support */
@@ -603,77 +603,73 @@ static GLboolean alloc_shm_back_buffer( XMesaBuffer b )
* Setup an off-screen pixmap or Ximage to use as the back buffer.
* Input: b - the X/Mesa buffer
*/
-void xmesa_alloc_back_buffer( XMesaBuffer b )
+void
+xmesa_alloc_back_buffer( XMesaBuffer b, GLuint width, GLuint height )
{
- if (b->db_state==BACK_XIMAGE) {
- /* Deallocate the old backimage, if any */
- if (b->backimage) {
+ if (width == 0 || height == 0)
+ return;
+
+ if (b->db_state == BACK_XIMAGE) {
+ /* Deallocate the old backxrb->ximage, if any */
+ if (b->backxrb->ximage) {
#if defined(USE_XSHM) && !defined(XFree86Server)
if (b->shm) {
XShmDetach( b->xm_visual->display, &b->shminfo );
- XDestroyImage( b->backimage );
+ XDestroyImage( b->backxrb->ximage );
shmdt( b->shminfo.shmaddr );
}
else
#endif
- XMesaDestroyImage( b->backimage );
- b->backimage = NULL;
+ XMesaDestroyImage( b->backxrb->ximage );
+ b->backxrb->ximage = NULL;
}
/* Allocate new back buffer */
#ifdef XFree86Server
{
/* Allocate a regular XImage for the back buffer. */
- b->backimage = XMesaCreateImage(b->xm_visual->BitsPerPixel,
- b->mesa_buffer.Width,
- b->mesa_buffer.Height, NULL);
+ b->backxrb->ximage = XMesaCreateImage(b->xm_visual->BitsPerPixel,
+ width, height, NULL);
#else
- if (b->shm==0 || alloc_shm_back_buffer(b)==GL_FALSE) {
+ if (b->shm == 0 || !alloc_shm_back_buffer(b, width, height)) {
/* Allocate a regular XImage for the back buffer. */
- b->backimage = XCreateImage( b->xm_visual->display,
+ b->backxrb->ximage = XCreateImage( b->xm_visual->display,
b->xm_visual->visinfo->visual,
GET_VISUAL_DEPTH(b->xm_visual),
ZPixmap, 0, /* format, offset */
NULL,
- b->mesa_buffer.Width,
- b->mesa_buffer.Height,
+ width, height,
8, 0 ); /* pad, bytes_per_line */
#endif
- if (!b->backimage) {
+ if (!b->backxrb->ximage) {
_mesa_warning(NULL, "alloc_back_buffer: XCreateImage failed.");
}
- b->backimage->data = (char *) MALLOC( b->backimage->height
- * b->backimage->bytes_per_line );
- if (!b->backimage->data) {
+ b->backxrb->ximage->data = (char *) MALLOC( b->backxrb->ximage->height
+ * b->backxrb->ximage->bytes_per_line );
+ if (!b->backxrb->ximage->data) {
_mesa_warning(NULL, "alloc_back_buffer: MALLOC failed.");
- XMesaDestroyImage( b->backimage );
- b->backimage = NULL;
+ XMesaDestroyImage( b->backxrb->ximage );
+ b->backxrb->ximage = NULL;
}
}
- b->backpixmap = None;
+ b->backxrb->pixmap = None;
+ b->backxrb->ximage = b->backxrb->ximage;
}
else if (b->db_state==BACK_PIXMAP) {
- XMesaPixmap old_pixmap = b->backpixmap;
- int width = b->mesa_buffer.Width, height = b->mesa_buffer.Height;
-
if (!width)
width = 1;
if (!height)
height = 1;
/* Free the old back pixmap */
- if (b->backpixmap) {
- XMesaFreePixmap( b->xm_visual->display, b->backpixmap );
+ if (b->backxrb->pixmap) {
+ XMesaFreePixmap( b->xm_visual->display, b->backxrb->pixmap );
}
/* Allocate new back pixmap */
- b->backpixmap = XMesaCreatePixmap( b->xm_visual->display, b->frontbuffer,
+ b->backxrb->pixmap = XMesaCreatePixmap( b->xm_visual->display, b->frontxrb->pixmap,
width, height,
GET_VISUAL_DEPTH(b->xm_visual) );
- b->backimage = NULL;
- /* update other references to backpixmap */
- if (b->buffer==(XMesaDrawable)old_pixmap) {
- b->buffer = (XMesaDrawable)b->backpixmap;
- }
+ b->backxrb->ximage = NULL;
}
}
@@ -747,7 +743,7 @@ noFaultXAllocColor( int client,
|| prevCmapSize != cmapSize || !ctable) {
/* free previously cached color table */
if (ctable)
- FREE(ctable);
+ _mesa_free(ctable);
/* Get the color table from X */
ctable = (XMesaColor *) MALLOC(cmapSize * sizeof(XMesaColor));
assert(ctable);
@@ -803,8 +799,8 @@ noFaultXAllocColor( int client,
*alloced = 0;
}
#ifdef XFree86Server
- FREE(ppixIn);
- FREE(ctable);
+ _mesa_free(ppixIn);
+ _mesa_free(ctable);
#else
/* don't free table, save it for next time */
#endif
@@ -1208,6 +1204,9 @@ static GLboolean initialize_visual_and_buffer( int client,
XMesaDrawable window,
XMesaColormap cmap )
{
+#if NEW_RENDERBUFFER
+ struct xmesa_renderbuffer *front_xrb, *back_xrb;
+#endif
#ifndef XFree86Server
XGCValues gcvalues;
#endif
@@ -1216,6 +1215,16 @@ static GLboolean initialize_visual_and_buffer( int client,
assert(b->xm_visual == v);
}
+#if NEW_RENDERBUFFER
+ if (b) {
+ front_xrb = b->frontxrb;
+ back_xrb = b->backxrb;
+ }
+ else {
+ front_xrb = back_xrb = NULL;
+ }
+#endif
+
/* Save true bits/pixel */
v->BitsPerPixel = bits_per_pixel(v);
assert(v->BitsPerPixel > 0);
@@ -1280,7 +1289,7 @@ static GLboolean initialize_visual_and_buffer( int client,
if (b && window) {
/* Do window-specific initializations */
- b->frontbuffer = window;
+ b->frontxrb->pixmap = window;
/* Setup for single/double buffering */
if (v->mesa_visual.doubleBufferMode) {
@@ -1288,17 +1297,7 @@ static GLboolean initialize_visual_and_buffer( int client,
#ifndef XFree86Server
b->shm = check_for_xshm( v->display );
#endif
- xmesa_alloc_back_buffer( b );
- if (b->db_state==BACK_PIXMAP) {
- b->buffer = (XMesaDrawable)b->backpixmap;
- }
- else {
- b->buffer = XIMAGE;
- }
- }
- else {
- /* Single Buffered */
- b->buffer = b->frontbuffer;
+ xmesa_alloc_back_buffer(b, b->mesa_buffer.Width, b->mesa_buffer.Height);
}
/* X11 graphics contexts */
@@ -1340,7 +1339,7 @@ static GLboolean initialize_visual_and_buffer( int client,
* Initialize whole stuff
* Patch contributed by Jacques Leroy March 8, 1998.
*/
- if (v->hpcr_clear_flag && b->buffer!=XIMAGE) {
+ if (v->hpcr_clear_flag && back_xrb->pixmap) {
int i;
for (i=0; i<16; i++)
{
@@ -1380,9 +1379,11 @@ static GLboolean initialize_visual_and_buffer( int client,
* Convert an RGBA color to a pixel value.
*/
unsigned long
-xmesa_color_to_pixel( XMesaContext xmesa, GLubyte r, GLubyte g, GLubyte b, GLubyte a,
- GLuint pixelFormat)
+xmesa_color_to_pixel(GLcontext *ctx,
+ GLubyte r, GLubyte g, GLubyte b, GLubyte a,
+ GLuint pixelFormat)
{
+ XMesaContext xmesa = XMESA_CONTEXT(ctx);
switch (pixelFormat) {
case PF_Index:
return 0;
@@ -1428,7 +1429,7 @@ xmesa_color_to_pixel( XMesaContext xmesa, GLubyte r, GLubyte g, GLubyte b, GLuby
return p;
}
default:
- _mesa_problem(NULL, "Bad pixel format in xmesa_color_to_pixel");
+ _mesa_problem(ctx, "Bad pixel format in xmesa_color_to_pixel");
}
return 0;
}
@@ -1536,14 +1537,14 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
*/
v->display = display;
- /* Save a copy of the XVisualInfo struct because the user may XFREE()
+ /* Save a copy of the XVisualInfo struct because the user may X_mesa_free()
* the struct but we may need some of the information contained in it
* at a later time.
*/
#ifndef XFree86Server
v->visinfo = (XVisualInfo *) MALLOC(sizeof(*visinfo));
if(!v->visinfo) {
- FREE(v);
+ _mesa_free(v);
return NULL;
}
MEMCPY(v->visinfo, visinfo, sizeof(*visinfo));
@@ -1647,9 +1648,9 @@ void XMesaSetVisualDisplay( XMesaDisplay *dpy, XMesaVisual v )
void XMesaDestroyVisual( XMesaVisual v )
{
#ifndef XFree86Server
- FREE(v->visinfo);
+ _mesa_free(v->visinfo);
#endif
- FREE(v);
+ _mesa_free(v);
}
@@ -1687,7 +1688,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
if (!_mesa_initialize_context(mesaCtx, &v->mesa_visual,
share_list ? &(share_list->mesa) : (GLcontext *) NULL,
&functions, (void *) c)) {
- FREE(c);
+ _mesa_free(c);
return NULL;
}
@@ -1707,8 +1708,6 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
/* finish up xmesa context initializations */
c->swapbytes = CHECK_BYTE_ORDER(v) ? GL_FALSE : GL_TRUE;
c->xm_visual = v;
- c->xm_draw_buffer = NULL; /* set later by XMesaMakeCurrent */
- c->xm_read_buffer = NULL; /* set later by XMesaMakeCurrent */
c->xm_buffer = NULL; /* set later by XMesaMakeCurrent */
c->display = v->display;
c->pixelformat = v->dithered_pf; /* Dithering is enabled by default */
@@ -1740,8 +1739,10 @@ void XMesaDestroyContext( XMesaContext c )
{
GLcontext *mesaCtx = &c->mesa;
#ifdef FX
- if (c->xm_draw_buffer && c->xm_buffer->FXctx)
- fxMesaDestroyContext(c->xm_draw_buffer->FXctx);
+ XMesaBuffer xmbuf = XMESA_BUFFER(mesaCtx->DrawBuffer);
+
+ if (xmbuf && xmbuf->FXctx)
+ fxMesaDestroyContext(xmbuf->FXctx);
#endif
_swsetup_DestroyContext( mesaCtx );
_swrast_DestroyContext( mesaCtx );
@@ -1864,7 +1865,7 @@ XMesaCreateWindowBuffer2(XMesaVisual v, XMesaWindow w, XMesaContext c)
if ((hw == GR_SSTTYPE_VOODOO) || (hw == GR_SSTTYPE_Voodoo2)) {
b->FXctx = fxMesaCreateBestContext(0, b->mesa_buffer.Width,
b->mesa_buffer.Height, attribs);
- if ((v->undithered_pf!=PF_Index) && (b->backimage)) {
+ if ((v->undithered_pf!=PF_Index) && (b->backxrb->ximage)) {
b->FXisHackUsable = b->FXctx ? GL_TRUE : GL_FALSE;
if (b->FXctx && (fxEnvVar[0]=='w' || fxEnvVar[0]=='W')) {
b->FXwindowHack = GL_TRUE;
@@ -1989,27 +1990,27 @@ void XMesaDestroyBuffer( XMesaBuffer b )
int client = 0;
#ifdef XFree86Server
- if (b->frontbuffer)
- client = CLIENT_ID(b->frontbuffer->id);
+ if (b->frontxrb->pixmap)
+ client = CLIENT_ID(b->frontxrb->pixmap->id);
#endif
if (b->gc) XMesaFreeGC( b->xm_visual->display, b->gc );
if (b->cleargc) XMesaFreeGC( b->xm_visual->display, b->cleargc );
if (b->swapgc) XMesaFreeGC( b->xm_visual->display, b->swapgc );
- if (b->backimage) {
+ if (b->backxrb->ximage) {
#if defined(USE_XSHM) && !defined(XFree86Server)
if (b->shm) {
XShmDetach( b->xm_visual->display, &b->shminfo );
- XDestroyImage( b->backimage );
+ XDestroyImage( b->backxrb->ximage );
shmdt( b->shminfo.shmaddr );
}
else
#endif
- XMesaDestroyImage( b->backimage );
+ XMesaDestroyImage( b->backxrb->ximage );
}
- if (b->backpixmap) {
- XMesaFreePixmap( b->xm_visual->display, b->backpixmap );
+ if (b->backxrb->pixmap) {
+ XMesaFreePixmap( b->xm_visual->display, b->backxrb->pixmap );
if (b->xm_visual->hpcr_clear_flag) {
XMesaFreePixmap( b->xm_visual->display,
b->xm_visual->hpcr_clear_pixmap );
@@ -2017,7 +2018,7 @@ void XMesaDestroyBuffer( XMesaBuffer b )
}
}
if (b->rowimage) {
- FREE( b->rowimage->data );
+ _mesa_free( b->rowimage->data );
b->rowimage->data = NULL;
XMesaDestroyImage( b->rowimage );
}
@@ -2050,49 +2051,45 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
if (drawBuffer->FXctx) {
fxMesaMakeCurrent(drawBuffer->FXctx);
- c->xm_draw_buffer = drawBuffer;
- c->xm_read_buffer = readBuffer;
c->xm_buffer = drawBuffer;
return GL_TRUE;
}
#endif
if (&(c->mesa) == _mesa_get_current_context()
- && c->xm_draw_buffer == drawBuffer
- && c->xm_read_buffer == readBuffer
- && c->xm_draw_buffer->wasCurrent) {
+ && c->mesa.DrawBuffer == &drawBuffer->mesa_buffer
+ && c->mesa.ReadBuffer == &readBuffer->mesa_buffer
+ && ((XMesaBuffer) c->mesa.DrawBuffer)->wasCurrent) {
/* same context and buffer, do nothing */
return GL_TRUE;
}
- c->xm_draw_buffer = drawBuffer;
- c->xm_read_buffer = readBuffer;
c->xm_buffer = drawBuffer;
- _mesa_make_current2(&(c->mesa),
- &drawBuffer->mesa_buffer,
- &readBuffer->mesa_buffer);
+ _mesa_make_current(&(c->mesa),
+ &drawBuffer->mesa_buffer,
+ &readBuffer->mesa_buffer);
if (c->xm_visual->mesa_visual.rgbMode) {
/*
* Must recompute and set these pixel values because colormap
* can be different for different windows.
*/
- c->clearpixel = xmesa_color_to_pixel( c,
+ c->clearpixel = xmesa_color_to_pixel( &c->mesa,
c->clearcolor[0],
c->clearcolor[1],
c->clearcolor[2],
c->clearcolor[3],
c->xm_visual->undithered_pf);
- XMesaSetForeground(c->display, c->xm_draw_buffer->cleargc, c->clearpixel);
+ XMesaSetForeground(c->display, drawBuffer->cleargc, c->clearpixel);
}
/* Solution to Stephane Rehel's problem with glXReleaseBuffersMESA(): */
- c->xm_draw_buffer->wasCurrent = GL_TRUE;
+ drawBuffer->wasCurrent = GL_TRUE;
}
else {
/* Detach */
- _mesa_make_current2( NULL, NULL, NULL );
+ _mesa_make_current( NULL, NULL, NULL );
}
return GL_TRUE;
}
@@ -2125,8 +2122,8 @@ XMesaBuffer XMesaGetCurrentBuffer( void )
{
GET_CURRENT_CONTEXT(ctx);
if (ctx) {
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
- return xmesa->xm_draw_buffer;
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+ return xmbuf;
}
else {
return 0;
@@ -2139,8 +2136,7 @@ XMesaBuffer XMesaGetCurrentReadBuffer( void )
{
GET_CURRENT_CONTEXT(ctx);
if (ctx) {
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
- return xmesa->xm_read_buffer;
+ return (XMesaBuffer) (ctx->ReadBuffer);
}
else {
return 0;
@@ -2152,11 +2148,11 @@ GLboolean XMesaForceCurrent(XMesaContext c)
{
if (c) {
if (&(c->mesa) != _mesa_get_current_context()) {
- _mesa_make_current(&(c->mesa), &c->xm_draw_buffer->mesa_buffer);
+ _mesa_make_current(&c->mesa, c->mesa.DrawBuffer, c->mesa.ReadBuffer);
}
}
else {
- _mesa_make_current(NULL, NULL);
+ _mesa_make_current(NULL, NULL, NULL);
}
return GL_TRUE;
}
@@ -2165,7 +2161,7 @@ GLboolean XMesaForceCurrent(XMesaContext c)
GLboolean XMesaLoseCurrent(XMesaContext c)
{
(void) c;
- _mesa_make_current(NULL, NULL);
+ _mesa_make_current(NULL, NULL, NULL);
return GL_TRUE;
}
@@ -2193,17 +2189,17 @@ GLboolean XMesaSetFXmode( GLint mode )
* oh, this is sooo wrong: ctx above is
* really an fxMesaContext, not an XMesaContext
*/
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
if (mode == XMESA_FX_WINDOW) {
- if (xmesa->xm_draw_buffer->FXisHackUsable) {
+ if (xmbuf->FXisHackUsable) {
FX_grSstControl(GR_CONTROL_DEACTIVATE);
- xmesa->xm_draw_buffer->FXwindowHack = GL_TRUE;
+ xmbuf->FXwindowHack = GL_TRUE;
return GL_TRUE;
}
}
else if (mode == XMESA_FX_FULLSCREEN) {
FX_grSstControl(GR_CONTROL_ACTIVATE);
- xmesa->xm_draw_buffer->FXwindowHack = GL_FALSE;
+ xmbuf->FXwindowHack = GL_FALSE;
return GL_TRUE;
}
else {
@@ -2235,13 +2231,13 @@ static void FXgetImage( XMesaBuffer b )
XMesaContext xmesa = XMESA_CONTEXT(ctx);
#ifdef XFree86Server
- x = b->frontbuffer->x;
- y = b->frontbuffer->y;
- width = b->frontbuffer->width;
- height = b->frontbuffer->height;
- depth = b->frontbuffer->depth;
+ x = b->frontxrb->pixmap->x;
+ y = b->frontxrb->pixmap->y;
+ width = b->frontxrb->pixmap->width;
+ height = b->frontxrb->pixmap->height;
+ depth = b->frontxrb->pixmap->depth;
#else
- XGetGeometry( b->xm_visual->display, b->frontbuffer,
+ XGetGeometry( b->xm_visual->display, b->frontxrb->pixmap,
&root, &xpos, &ypos, &width, &height, &bw, &depth);
#endif
if (b->mesa_buffer.Width != width || b->mesa_buffer.Height != height) {
@@ -2249,29 +2245,29 @@ static void FXgetImage( XMesaBuffer b )
b->mesa_buffer.Height = MIN2((int)height, b->FXctx->height);
if (b->mesa_buffer.Width & 1)
b->mesa_buffer.Width--; /* prevent odd width */
- xmesa_alloc_back_buffer( b );
+ xmesa_alloc_back_buffer(b, b->mesa_buffer.Width, b->mesa_buffer.Height);
}
/* [dBorca] we're always in the right GR_COLORFORMAT... aren't we? */
/* grLfbWriteColorFormat(GR_COLORFORMAT_ARGB); */
if (b->xm_visual->undithered_pf==PF_5R6G5B) {
/* Special case: 16bpp RGB */
- grLfbReadRegion( GR_BUFFER_FRONTBUFFER, /* src buffer */
+ grLfbReadRegion( GR_BUFFER_FRONTXRB->PIXMAP, /* src buffer */
0, b->FXctx->height - b->mesa_buffer.Height, /*pos*/
b->mesa_buffer.Width, b->mesa_buffer.Height, /* size */
b->mesa_buffer.Width * sizeof(GLushort), /* stride */
- b->backimage->data); /* dest buffer */
+ b->backxrb->ximage->data); /* dest buffer */
}
else if (b->xm_visual->dithered_pf==PF_Dither
&& GET_VISUAL_DEPTH(b->xm_visual)==8) {
/* Special case: 8bpp RGB */
for (y=0;y<b->mesa_buffer.Height;y++) {
- GLubyte *ptr = (GLubyte*) b->backimage->data
- + b->backimage->bytes_per_line * y;
+ GLubyte *ptr = (GLubyte*) b->backxrb->ximage->data
+ + b->backxrb->ximage->bytes_per_line * y;
XDITHER_SETUP(y);
/* read row from 3Dfx frame buffer */
- grLfbReadRegion( GR_BUFFER_FRONTBUFFER,
+ grLfbReadRegion( GR_BUFFER_FRONTXRB->PIXMAP,
0, b->FXctx->height-(b->mesa_buffer.Height-y),
b->mesa_buffer.Width, 1,
0,
@@ -2290,7 +2286,7 @@ static void FXgetImage( XMesaBuffer b )
/* General case: slow! */
for (y=0;y<b->mesa_buffer.Height;y++) {
/* read row from 3Dfx frame buffer */
- grLfbReadRegion( GR_BUFFER_FRONTBUFFER,
+ grLfbReadRegion( GR_BUFFER_FRONTXRB->PIXMAP,
0, b->FXctx->height-(b->mesa_buffer.Height-y),
b->mesa_buffer.Width, 1,
0,
@@ -2298,8 +2294,8 @@ static void FXgetImage( XMesaBuffer b )
/* write to XImage back buffer */
for (x=0;x<b->mesa_buffer.Width;x++) {
- XMesaPutPixel(b->backimage,x,y,
- xmesa_color_to_pixel(xmesa,
+ XMesaPutPixel(b->backxrb->ximage,x,y,
+ xmesa_color_to_pixel(&c->mesa,
(pixbuf[x] & 0xf800) >> 8,
(pixbuf[x] & 0x07e0) >> 3,
(pixbuf[x] & 0x001f) << 3,
@@ -2338,14 +2334,14 @@ void XMesaSwapBuffers( XMesaBuffer b )
return;
}
#endif
- if (b->backimage) {
+ if (b->backxrb->ximage) {
/* Copy Ximage from host's memory to server's window */
#if defined(USE_XSHM) && !defined(XFree86Server)
if (b->shm) {
/*_glthread_LOCK_MUTEX(_xmesa_lock);*/
- XShmPutImage( b->xm_visual->display, b->frontbuffer,
+ XShmPutImage( b->xm_visual->display, b->frontxrb->pixmap,
b->swapgc,
- b->backimage, 0, 0,
+ b->backxrb->ximage, 0, 0,
0, 0, b->mesa_buffer.Width, b->mesa_buffer.Height,
False );
/*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
@@ -2354,9 +2350,9 @@ void XMesaSwapBuffers( XMesaBuffer b )
#endif
{
/*_glthread_LOCK_MUTEX(_xmesa_lock);*/
- XMesaPutImage( b->xm_visual->display, b->frontbuffer,
+ XMesaPutImage( b->xm_visual->display, b->frontxrb->pixmap,
b->swapgc,
- b->backimage, 0, 0,
+ b->backxrb->ximage, 0, 0,
0, 0, b->mesa_buffer.Width, b->mesa_buffer.Height );
/*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
}
@@ -2365,8 +2361,8 @@ void XMesaSwapBuffers( XMesaBuffer b )
/* Copy pixmap to window on server */
/*_glthread_LOCK_MUTEX(_xmesa_lock);*/
XMesaCopyArea( b->xm_visual->display,
- b->backpixmap, /* source drawable */
- b->frontbuffer, /* dest. drawable */
+ b->backxrb->pixmap, /* source drawable */
+ b->frontxrb->pixmap, /* dest. drawable */
b->swapgc,
0, 0, b->mesa_buffer.Width, b->mesa_buffer.Height,
0, 0 /* dest region */
@@ -2405,14 +2401,14 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
return;
}
#endif
- if (b->backimage) {
+ if (b->backxrb->ximage) {
/* Copy Ximage from host's memory to server's window */
#if defined(USE_XSHM) && !defined(XFree86Server)
if (b->shm) {
/* XXX assuming width and height aren't too large! */
- XShmPutImage( b->xm_visual->display, b->frontbuffer,
+ XShmPutImage( b->xm_visual->display, b->frontxrb->pixmap,
b->swapgc,
- b->backimage, x, yTop,
+ b->backxrb->ximage, x, yTop,
x, yTop, width, height, False );
/* wait for finished event??? */
}
@@ -2420,17 +2416,17 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
#endif
{
/* XXX assuming width and height aren't too large! */
- XMesaPutImage( b->xm_visual->display, b->frontbuffer,
+ XMesaPutImage( b->xm_visual->display, b->frontxrb->pixmap,
b->swapgc,
- b->backimage, x, yTop,
+ b->backxrb->ximage, x, yTop,
x, yTop, width, height );
}
}
else {
/* Copy pixmap to window on server */
XMesaCopyArea( b->xm_visual->display,
- b->backpixmap, /* source drawable */
- b->frontbuffer, /* dest. drawable */
+ b->backxrb->pixmap, /* source drawable */
+ b->frontxrb->pixmap, /* dest. drawable */
b->swapgc,
x, yTop, width, height, /* source region */
x, yTop /* dest region */
@@ -2454,8 +2450,8 @@ GLboolean XMesaGetBackBuffer( XMesaBuffer b,
XMesaImage **ximage )
{
if (b->db_state) {
- if (pixmap) *pixmap = b->backpixmap;
- if (ximage) *ximage = b->backimage;
+ if (pixmap) *pixmap = b->backxrb->pixmap;
+ if (ximage) *ximage = b->backxrb->ximage;
return GL_TRUE;
}
else {
@@ -2477,7 +2473,9 @@ GLboolean XMesaGetBackBuffer( XMesaBuffer b,
GLboolean XMesaGetDepthBuffer( XMesaBuffer b, GLint *width, GLint *height,
GLint *bytesPerValue, void **buffer )
{
- if (!b->mesa_buffer.DepthBuffer) {
+ struct gl_renderbuffer *rb
+ = b->mesa_buffer.Attachment[BUFFER_DEPTH].Renderbuffer;
+ if (!rb || !rb->Data) {
*width = 0;
*height = 0;
*bytesPerValue = 0;
@@ -2489,7 +2487,7 @@ GLboolean XMesaGetDepthBuffer( XMesaBuffer b, GLint *width, GLint *height,
*height = b->mesa_buffer.Height;
*bytesPerValue = b->mesa_buffer.Visual.depthBits <= 16
? sizeof(GLushort) : sizeof(GLuint);
- *buffer = b->mesa_buffer.DepthBuffer;
+ *buffer = rb->Data;
return GL_TRUE;
}
}
@@ -2528,7 +2526,7 @@ XMesaBuffer XMesaFindBuffer( XMesaDisplay *dpy, XMesaDrawable d )
{
XMesaBuffer b;
for (b=XMesaBufferList; b; b=b->Next) {
- if (b->frontbuffer==d && b->display==dpy) {
+ if (b->frontxrb->pixmap==d && b->display==dpy) {
return b;
}
}
@@ -2546,12 +2544,12 @@ void XMesaGarbageCollect( void )
XMesaBuffer b, next;
for (b=XMesaBufferList; b; b=next) {
next = b->Next;
- if (b->display && b->frontbuffer && b->type == WINDOW) {
+ if (b->display && b->frontxrb->pixmap && b->type == WINDOW) {
#ifdef XFree86Server
/* NOT_NEEDED */
#else
XSync(b->display, False);
- if (!window_exists( b->display, b->frontbuffer )) {
+ if (!window_exists( b->display, b->frontxrb->pixmap )) {
/* found a dead window, free the ancillary info */
XMesaDestroyBuffer( b );
}
@@ -2574,6 +2572,7 @@ unsigned long XMesaDitherColor( XMesaContext xmesa, GLint x, GLint y,
GLfloat red, GLfloat green,
GLfloat blue, GLfloat alpha )
{
+ GLcontext *ctx = &xmesa->mesa;
GLint r = (GLint) (red * 255.0F);
GLint g = (GLint) (green * 255.0F);
GLint b = (GLint) (blue * 255.0F);
@@ -2634,7 +2633,8 @@ unsigned long XMesaDitherColor( XMesaContext xmesa, GLint x, GLint y,
*/
void XMesaResizeBuffers( XMesaBuffer b )
{
- xmesa_resize_buffers( &(b->mesa_buffer) );
-
+#if OLD_RENDERBUFFER && 0
+ xmesa_resize_buffers(ctx, &(b->mesa_buffer), 0, 0 );
+#endif
}
diff --git a/src/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c
new file mode 100644
index 0000000000..9f481aaba1
--- /dev/null
+++ b/src/mesa/drivers/x11/xm_buffer.c
@@ -0,0 +1,111 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul 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 and this permission notice 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
+ * BRIAN PAUL 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.
+ */
+
+
+#include "glxheader.h"
+#include "GL/xmesa.h"
+#include "xmesaP.h"
+#include "imports.h"
+#include "renderbuffer.h"
+
+
+static void
+xmesa_delete_renderbuffer(struct gl_renderbuffer *rb)
+{
+ /* XXX this routine should really delete the attached ximage, etc. */
+}
+
+
+/**
+ * Reallocate renderbuffer storage.
+ * This is called when the window's resized. It'll get called once for
+ * the front color renderbuffer and again for the back color renderbuffer.
+ */
+static GLboolean
+xmesa_alloc_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat, GLuint width, GLuint height)
+{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+
+ if (xrb->ximage) {
+ /* Needed by PIXELADDR1 macro */
+ xrb->width1 = xrb->ximage->bytes_per_line;
+ xrb->origin1 = (GLubyte *) xrb->ximage->data + xrb->width1 * (height - 1);
+
+ /* Needed by PIXELADDR2 macro */
+ xrb->width2 = xrb->ximage->bytes_per_line / 2;
+ xrb->origin2 = (GLushort *) xrb->ximage->data + xrb->width2 * (height - 1);
+
+ /* Needed by PIXELADDR3 macro */
+ xrb->width3 = xrb->ximage->bytes_per_line;
+ xrb->origin3 = (GLubyte *) xrb->ximage->data + xrb->width3 * (height - 1);
+
+ /* Needed by PIXELADDR4 macro */
+ xrb->width4 = xrb->ximage->width;
+ xrb->origin4 = (GLuint *) xrb->ximage->data + xrb->width4 * (height - 1);
+ }
+ else {
+ assert(xrb->pixmap);
+ }
+
+ /* for the FLIP macro: */
+ xrb->bottom = height - 1;
+
+ rb->Width = width;
+ rb->Height = height;
+ rb->InternalFormat = internalFormat;
+
+ return GL_TRUE;
+}
+
+
+struct xmesa_renderbuffer *
+xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, GLboolean rgbMode)
+{
+ struct xmesa_renderbuffer *xrb = CALLOC_STRUCT(xmesa_renderbuffer);
+ if (xrb) {
+ GLuint name = 0;
+ _mesa_init_renderbuffer(&xrb->Base, name);
+
+ xrb->Base.Delete = xmesa_delete_renderbuffer;
+ xrb->Base.AllocStorage = xmesa_alloc_storage;
+
+ if (rgbMode) {
+ xrb->Base.InternalFormat = GL_RGBA;
+ xrb->Base._BaseFormat = GL_RGBA;
+ xrb->Base.DataType = GL_UNSIGNED_BYTE;
+ }
+ else {
+ xrb->Base.InternalFormat = GL_COLOR_INDEX;
+ xrb->Base._BaseFormat = GL_COLOR_INDEX;
+ xrb->Base.DataType = GL_UNSIGNED_INT;
+ }
+ xrb->Base.ComponentSizes[0] = 0; /* XXX fix? */
+ }
+ return xrb;
+}
+
+
+
+
diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c
index 0588694ace..f9eb877db9 100644
--- a/src/mesa/drivers/x11/xm_dd.c
+++ b/src/mesa/drivers/x11/xm_dd.c
@@ -31,6 +31,7 @@
#include "depth.h"
#include "drawpix.h"
#include "extensions.h"
+#include "framebuffer.h"
#include "macros.h"
#include "image.h"
#include "imports.h"
@@ -43,9 +44,7 @@
#include "xmesaP.h"
#include "array_cache/acache.h"
#include "swrast/swrast.h"
-#include "swrast/s_auxbuffer.h"
#include "swrast/s_context.h"
-#include "swrast/s_alphabuf.h"
#include "swrast_setup/swrast_setup.h"
#include "tnl/tnl.h"
#include "tnl/t_context.h"
@@ -106,8 +105,8 @@ get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
unsigned int winwidth, winheight;
#ifdef XFree86Server
/* XFree86 GLX renderer */
- winwidth = MIN2(xmBuffer->frontbuffer->width, MAX_WIDTH);
- winheight = MIN2(xmBuffer->frontbuffer->height, MAX_HEIGHT);
+ winwidth = MIN2(xmBuffer->frontxrb->pixmap->width, MAX_WIDTH);
+ winheight = MIN2(xmBuffer->frontxrb->pixmap->height, MAX_HEIGHT);
#else
Window root;
int winx, winy;
@@ -115,7 +114,7 @@ get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
_glthread_LOCK_MUTEX(_xmesa_lock);
XSync(xmBuffer->xm_visual->display, 0); /* added for Chromium */
- XGetGeometry( xmBuffer->xm_visual->display, xmBuffer->frontbuffer, &root,
+ XGetGeometry( xmBuffer->xm_visual->display, xmBuffer->frontxrb->pixmap, &root,
&winx, &winy, &winwidth, &winheight, &bw, &d );
_glthread_UNLOCK_MUTEX(_xmesa_lock);
#endif
@@ -152,29 +151,36 @@ finish_or_flush( GLcontext *ctx )
void
xmesa_set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
{
+#if 000
/* We can make this cast since the XMesaBuffer wraps GLframebuffer.
* GLframebuffer is the first member in a XMesaBuffer struct.
*/
XMesaBuffer target = (XMesaBuffer) buffer;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+#if NEW_RENDERBUFFER
+ if (buffer->Name != 0)
+ return;
+#endif
+
/* This assignment tells the span/point/line/triangle functions
* which XMesaBuffer to use.
*/
- xmesa->xm_buffer = target;
+ /* xmesa->xm_buffer = target;*/
/*
* Now determine front vs back color buffer.
*/
- if (bufferBit == DD_FRONT_LEFT_BIT) {
- target->buffer = target->frontbuffer;
+ if (bufferBit == BUFFER_BIT_FRONT_LEFT) {
+ target->buffer = target->frontxrb->pixmap;
+ printf("set get/put!\n");
xmesa_update_span_funcs(ctx);
}
- else if (bufferBit == DD_BACK_LEFT_BIT) {
+ else if (bufferBit == BUFFER_BIT_BACK_LEFT) {
ASSERT(target->db_state);
- if (target->backpixmap) {
+ if (target->backxrb->pixmap) {
/* back buffer is a pixmap */
- target->buffer = (XMesaDrawable) target->backpixmap;
+ target->buffer = (XMesaDrawable) target->backxrb->pixmap;
}
else if (target->backimage) {
/* back buffer is an XImage */
@@ -182,17 +188,19 @@ xmesa_set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
}
else {
/* No back buffer!!!! Must be out of memory, use front buffer */
- target->buffer = target->frontbuffer;
+ target->buffer = target->frontxrb->pixmap;
}
+ printf("set get/put!\n");
xmesa_update_span_funcs(ctx);
}
- else if (bufferBit & (DD_AUX0_BIT | DD_AUX1_BIT | DD_AUX2_BIT | DD_AUX3_BIT)) {
- _swrast_use_aux_buffer(ctx, buffer, bufferBit);
+ else if (bufferBit & (BUFFER_BIT_AUX0 | BUFFER_BIT_AUX1 | BUFFER_BIT_AUX2 | BUFFER_BIT_AUX3)) {
+ /*_swrast_use_aux_buffer(ctx, buffer, bufferBit);*/
}
else {
_mesa_problem(ctx, "invalid buffer 0x%x in set_buffer() in xm_dd.c");
return;
}
+#endif
}
@@ -200,31 +208,37 @@ xmesa_set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
static void
clear_index( GLcontext *ctx, GLuint index )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- xmesa->clearpixel = (unsigned long) index;
- XMesaSetForeground( xmesa->display, xmesa->xm_draw_buffer->cleargc,
- (unsigned long) index );
+ if (ctx->DrawBuffer->Name == 0) {
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+ xmesa->clearpixel = (unsigned long) index;
+ XMesaSetForeground( xmesa->display, xmbuf->cleargc, (unsigned long) index );
+ }
}
static void
clear_color( GLcontext *ctx, const GLfloat color[4] )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[0], color[0]);
- CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[1], color[1]);
- CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[2], color[2]);
- CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[3], color[3]);
- xmesa->clearpixel = xmesa_color_to_pixel( xmesa,
- xmesa->clearcolor[0],
- xmesa->clearcolor[1],
- xmesa->clearcolor[2],
- xmesa->clearcolor[3],
- xmesa->xm_visual->undithered_pf );
- _glthread_LOCK_MUTEX(_xmesa_lock);
- XMesaSetForeground( xmesa->display, xmesa->xm_draw_buffer->cleargc,
- xmesa->clearpixel );
- _glthread_UNLOCK_MUTEX(_xmesa_lock);
+ if (ctx->DrawBuffer->Name == 0) {
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[3], color[3]);
+ xmesa->clearpixel = xmesa_color_to_pixel( ctx,
+ xmesa->clearcolor[0],
+ xmesa->clearcolor[1],
+ xmesa->clearcolor[2],
+ xmesa->clearcolor[3],
+ xmesa->xm_visual->undithered_pf );
+ _glthread_LOCK_MUTEX(_xmesa_lock);
+ XMesaSetForeground( xmesa->display, xmbuf->cleargc,
+ xmesa->clearpixel );
+ _glthread_UNLOCK_MUTEX(_xmesa_lock);
+ }
}
@@ -234,7 +248,9 @@ static void
index_mask( GLcontext *ctx, GLuint mask )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- if (xmesa->xm_draw_buffer->buffer != XIMAGE) {
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+ /* not sure this conditional is really needed */
+ if (xmbuf->backxrb && xmbuf->backxrb->pixmap) {
unsigned long m;
if (mask==0xffffffff) {
m = ((unsigned long)~0L);
@@ -242,8 +258,8 @@ index_mask( GLcontext *ctx, GLuint mask )
else {
m = (unsigned long) mask;
}
- XMesaSetPlaneMask( xmesa->display, xmesa->xm_draw_buffer->cleargc, m );
- XMesaSetPlaneMask( xmesa->display, xmesa->xm_draw_buffer->gc, m );
+ XMesaSetPlaneMask( xmesa->display, xmbuf->cleargc, m );
+ XMesaSetPlaneMask( xmesa->display, xmbuf->gc, m );
}
}
@@ -254,6 +270,7 @@ color_mask(GLcontext *ctx,
GLboolean rmask, GLboolean gmask, GLboolean bmask, GLboolean amask)
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
const int xclass = xmesa->xm_visual->mesa_visual.visualType;
(void) amask;
@@ -268,8 +285,8 @@ color_mask(GLcontext *ctx,
if (gmask) m |= GET_GREENMASK(xmesa->xm_visual);
if (bmask) m |= GET_BLUEMASK(xmesa->xm_visual);
}
- XMesaSetPlaneMask( xmesa->display, xmesa->xm_draw_buffer->cleargc, m );
- XMesaSetPlaneMask( xmesa->display, xmesa->xm_draw_buffer->gc, m );
+ XMesaSetPlaneMask( xmesa->display, xmbuf->cleargc, m );
+ XMesaSetPlaneMask( xmesa->display, xmbuf->gc, m );
}
}
@@ -280,62 +297,45 @@ color_mask(GLcontext *ctx,
/**********************************************************************/
+/**
+ * Clear the front or back color buffer, if it's implemented with a pixmap.
+ */
static void
-clear_front_pixmap( GLcontext *ctx, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
+clear_pixmap(GLcontext *ctx, struct xmesa_renderbuffer *xrb, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height)
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- if (all) {
- XMesaFillRectangle( xmesa->display, xmesa->xm_draw_buffer->frontbuffer,
- xmesa->xm_draw_buffer->cleargc,
- 0, 0,
- 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->mesa_buffer.Height - y - height,
- width, height );
- }
-}
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+ assert(xrb->pixmap == xmbuf->backxrb->pixmap ||
+ xrb->pixmap == xmbuf->frontxrb->pixmap);
-static void
-clear_back_pixmap( GLcontext *ctx, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
-{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
if (all) {
- XMesaFillRectangle( xmesa->display, xmesa->xm_draw_buffer->backpixmap,
- xmesa->xm_draw_buffer->cleargc,
- 0, 0,
- xmesa->xm_draw_buffer->mesa_buffer.Width + 1,
- xmesa->xm_draw_buffer->mesa_buffer.Height + 1 );
+ XMesaFillRectangle( xmesa->display, xrb->pixmap, xmbuf->cleargc,
+ 0, 0, xrb->Base.Width + 1, xrb->Base.Height + 1 );
}
else {
- XMesaFillRectangle( xmesa->display, xmesa->xm_draw_buffer->backpixmap,
- xmesa->xm_draw_buffer->cleargc,
- x, xmesa->xm_draw_buffer->mesa_buffer.Height - y - height,
+ XMesaFillRectangle( xmesa->display, xrb->pixmap, xmbuf->cleargc,
+ x, xrb->Base.Height - y - height,
width, height );
}
}
static void
-clear_8bit_ximage( GLcontext *ctx, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
+clear_8bit_ximage( GLcontext *ctx, struct xmesa_renderbuffer *xrb,
+ GLboolean all, GLint x, GLint y, GLint width, GLint height )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+
if (all) {
- size_t n = xmesa->xm_draw_buffer->backimage->bytes_per_line
- * xmesa->xm_draw_buffer->backimage->height;
- MEMSET( xmesa->xm_draw_buffer->backimage->data, xmesa->clearpixel, n );
+ const size_t n = xrb->ximage->bytes_per_line * xrb->Base.Height;
+ MEMSET( xrb->ximage->data, xmesa->clearpixel, n );
}
else {
GLint i;
for (i=0;i<height;i++) {
- GLubyte *ptr = PIXELADDR1( xmesa->xm_draw_buffer, x, y+i );
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x, y + i);
MEMSET( ptr, xmesa->clearpixel, width );
}
}
@@ -343,14 +343,15 @@ clear_8bit_ximage( GLcontext *ctx, GLboolean all,
static void
-clear_HPCR_ximage( GLcontext *ctx, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
+clear_HPCR_ximage( GLcontext *ctx, struct xmesa_renderbuffer *xrb,
+ GLboolean all, GLint x, GLint y, GLint width, GLint height )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+
if (all) {
- GLint i, c16 = (xmesa->xm_draw_buffer->backimage->bytes_per_line>>4)<<4;
- GLubyte *ptr = (GLubyte *)xmesa->xm_draw_buffer->backimage->data;
- for (i=0; i<xmesa->xm_draw_buffer->backimage->height; i++) {
+ GLint i, c16 = (xrb->ximage->bytes_per_line>>4)<<4;
+ GLubyte *ptr = (GLubyte *) xrb->ximage->data;
+ for (i = 0; i < xrb->Base.Height; i++) {
GLint j;
GLubyte *sptr = xmesa->xm_visual->hpcr_clear_ximage_pattern[0];
if (i&1) {
@@ -375,7 +376,7 @@ clear_HPCR_ximage( GLcontext *ctx, GLboolean all,
ptr[15] = sptr[15];
ptr += 16;
}
- for (; j<xmesa->xm_draw_buffer->backimage->bytes_per_line; j++) {
+ for (; j < xrb->ximage->bytes_per_line; j++) {
*ptr = sptr[j&15];
ptr++;
}
@@ -384,9 +385,9 @@ clear_HPCR_ximage( GLcontext *ctx, GLboolean all,
else {
GLint i;
for (i=y; i<y+height; i++) {
- GLubyte *ptr = PIXELADDR1( xmesa->xm_draw_buffer, x, i );
+ GLubyte *ptr = PIXEL_ADDR1( xrb, x, i );
int j;
- GLubyte *sptr = xmesa->xm_visual->hpcr_clear_ximage_pattern[0];
+ const GLubyte *sptr = xmesa->xm_visual->hpcr_clear_ximage_pattern[0];
if (i&1) {
sptr += 16;
}
@@ -400,41 +401,40 @@ clear_HPCR_ximage( GLcontext *ctx, GLboolean all,
static void
-clear_16bit_ximage( GLcontext *ctx, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
+clear_16bit_ximage( GLcontext *ctx, struct xmesa_renderbuffer *xrb,
+ GLboolean all, GLint x, GLint y, GLint width, GLint height)
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint pixel = (GLuint) xmesa->clearpixel;
+
if (xmesa->swapbytes) {
pixel = ((pixel >> 8) & 0x00ff) | ((pixel << 8) & 0xff00);
}
+
if (all) {
- register GLuint n;
- register GLuint *ptr4 = (GLuint *) xmesa->xm_draw_buffer->backimage->data;
+ GLuint *ptr4 = (GLuint *) xrb->ximage->data;
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->mesa_buffer.Height;
+ const GLuint n = xrb->ximage->bytes_per_line * xrb->Base.Height;
MEMSET( ptr4, pixel & 0xff, n );
}
else {
+ const GLuint n = xrb->ximage->bytes_per_line * xrb->Base.Height / 4;
+ GLuint i;
pixel = pixel | (pixel<<16);
- n = xmesa->xm_draw_buffer->backimage->bytes_per_line
- * 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->mesa_buffer.Height) & 0x2)
+ for (i = 0; i < n; i++) {
+ ptr4[i] = pixel;
+ }
+ ptr4 += n;
+ /* might be one last GLushort to set */
+ if ((xrb->ximage->bytes_per_line * xrb->Base.Height) & 0x2)
*(GLushort *)ptr4 = pixel & 0xffff;
}
}
else {
- register int i, j;
+ GLint i, j;
for (j=0;j<height;j++) {
- register GLushort *ptr2 = PIXELADDR2( xmesa->xm_draw_buffer, x, y+j );
+ GLushort *ptr2 = PIXEL_ADDR2(xrb, x, y + j);
for (i=0;i<width;i++) {
*ptr2++ = pixel;
}
@@ -445,41 +445,32 @@ clear_16bit_ximage( GLcontext *ctx, GLboolean all,
/* Optimized code provided by Nozomi Ytow <noz@xfree86.org> */
static void
-clear_24bit_ximage( GLcontext *ctx, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
+clear_24bit_ximage(GLcontext *ctx, struct xmesa_renderbuffer *xrb,
+ GLboolean all, GLint x, GLint y, GLint width, GLint height)
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
const GLubyte r = xmesa->clearcolor[0];
const GLubyte g = xmesa->clearcolor[1];
const GLubyte b = xmesa->clearcolor[2];
-#if 0 /* See below */
- register GLuint clearPixel;
- if (xmesa->swapbytes) {
- clearPixel = (b << 16) | (g << 8) | r;
- }
- else {
- clearPixel = (r << 16) | (g << 8) | b;
- }
-#endif
if (all) {
- if (r==g && g==b) {
+ if (r == g && g == b) {
/* same value for all three components (gray) */
- const GLint w3 = xmesa->xm_draw_buffer->mesa_buffer.Width * 3;
- const GLint h = xmesa->xm_draw_buffer->mesa_buffer.Height;
+ const GLint w3 = xrb->Base.Width * 3;
+ const GLint h = xrb->Base.Height;
GLint i;
for (i = 0; i < h; i++) {
- bgr_t *ptr3 = PIXELADDR3(xmesa->xm_draw_buffer, 0, i);
+ bgr_t *ptr3 = PIXEL_ADDR3(xrb, 0, i);
MEMSET(ptr3, r, w3);
}
}
else {
/* the usual case */
- const GLint w = xmesa->xm_draw_buffer->mesa_buffer.Width;
- const GLint h = xmesa->xm_draw_buffer->mesa_buffer.Height;
+ const GLint w = xrb->Base.Width;
+ const GLint h = xrb->Base.Height;
GLint i, j;
for (i = 0; i < h; i++) {
- bgr_t *ptr3 = PIXELADDR3(xmesa->xm_draw_buffer, 0, i);
+ bgr_t *ptr3 = PIXEL_ADDR3(xrb, 0, i);
for (j = 0; j < w; j++) {
ptr3->r = r;
ptr3->g = g;
@@ -487,83 +478,15 @@ clear_24bit_ximage( GLcontext *ctx, GLboolean all,
ptr3++;
}
}
-#if 0 /* this code doesn't work for all window widths */
- register GLuint *ptr4 = (GLuint *) ptr3;
- register GLuint px;
- GLuint pixel4[3];
- register GLuint *p = pixel4;
- pixel4[0] = clearPixel | (clearPixel << 24);
- pixel4[1] = (clearPixel << 16) | (clearPixel >> 8);
- pixel4[2] = (clearPixel << 8) | (clearPixel >> 16);
- switch (3 & (int)(ptr3 - (bgr_t*) ptr4)){
- case 0:
- break;
- case 1:
- px = *ptr4 & 0x00ffffff;
- px |= pixel4[0] & 0xff000000;
- *ptr4++ = px;
- px = *ptr4 & 0xffff0000;
- px |= pixel4[2] & 0x0000ffff;
- *ptr4 = px;
- if (0 == --n)
- break;
- case 2:
- px = *ptr4 & 0x0000fffff;
- px |= pixel4[1] & 0xffff0000;
- *ptr4++ = px;
- px = *ptr4 & 0xffffff00;
- px |= pixel4[2] & 0x000000ff;
- *ptr4 = px;
- if (0 == --n)
- break;
- case 3:
- px = *ptr4 & 0x000000ff;
- px |= pixel4[2] & 0xffffff00;
- *ptr4++ = px;
- --n;
- break;
- }
- while (n > 3) {
- p = pixel4;
- *ptr4++ = *p++;
- *ptr4++ = *p++;
- *ptr4++ = *p++;
- n -= 4;
- }
- switch (n) {
- case 3:
- p = pixel4;
- *ptr4++ = *p++;
- *ptr4++ = *p++;
- px = *ptr4 & 0xffffff00;
- px |= clearPixel & 0xff;
- *ptr4 = px;
- break;
- case 2:
- p = pixel4;
- *ptr4++ = *p++;
- px = *ptr4 & 0xffff0000;
- px |= *p & 0xffff;
- *ptr4 = px;
- break;
- case 1:
- px = *ptr4 & 0xff000000;
- px |= *p & 0xffffff;
- *ptr4 = px;
- break;
- case 0:
- break;
- }
-#endif
}
}
else {
/* only clear subrect of color buffer */
- if (r==g && g==b) {
+ if (r == g && g == b) {
/* same value for all three components (gray) */
GLint j;
for (j=0;j<height;j++) {
- bgr_t *ptr3 = PIXELADDR3( xmesa->xm_draw_buffer, x, y+j );
+ bgr_t *ptr3 = PIXEL_ADDR3(xrb, x, y + j);
MEMSET(ptr3, r, 3 * width);
}
}
@@ -571,7 +494,7 @@ clear_24bit_ximage( GLcontext *ctx, GLboolean all,
/* non-gray clear color */
GLint i, j;
for (j = 0; j < height; j++) {
- bgr_t *ptr3 = PIXELADDR3( xmesa->xm_draw_buffer, x, y+j );
+ bgr_t *ptr3 = PIXEL_ADDR3(xrb, x, y + j);
for (i = 0; i < width; i++) {
ptr3->r = r;
ptr3->g = g;
@@ -579,115 +502,43 @@ clear_24bit_ximage( GLcontext *ctx, GLboolean all,
ptr3++;
}
}
-#if 0 /* this code might not always (seems ptr3 always == ptr4) */
- GLint j;
- GLuint pixel4[3];
- pixel4[0] = clearPixel | (clearPixel << 24);
- pixel4[1] = (clearPixel << 16) | (clearPixel >> 8);
- pixel4[2] = (clearPixel << 8) | (clearPixel >> 16);
- for (j=0;j<height;j++) {
- bgr_t *ptr3 = PIXELADDR3( xmesa->xm_draw_buffer, x, y+j );
- register GLuint *ptr4 = (GLuint *)ptr3;
- register GLuint *p, px;
- GLuint w = width;
- switch (3 & (int)(ptr3 - (bgr_t*) ptr4)){
- case 0:
- break;
- case 1:
- px = *ptr4 & 0x00ffffff;
- px |= pixel4[0] & 0xff000000;
- *ptr4++ = px;
- px = *ptr4 & 0xffff0000;
- px |= pixel4[2] & 0x0000ffff;
- *ptr4 = px;
- if (0 == --w)
- break;
- case 2:
- px = *ptr4 & 0x0000fffff;
- px |= pixel4[1] & 0xffff0000;
- *ptr4++ = px;
- px = *ptr4 & 0xffffff00;
- px |= pixel4[2] & 0x000000ff;
- *ptr4 = px;
- if (0 == --w)
- break;
- case 3:
- px = *ptr4 & 0x000000ff;
- px |= pixel4[2] & 0xffffff00;
- *ptr4++ = px;
- --w;
- break;
- }
- while (w > 3){
- p = pixel4;
- *ptr4++ = *p++;
- *ptr4++ = *p++;
- *ptr4++ = *p++;
- w -= 4;
- }
- switch (w) {
- case 3:
- p = pixel4;
- *ptr4++ = *p++;
- *ptr4++ = *p++;
- px = *ptr4 & 0xffffff00;
- px |= *p & 0xff;
- *ptr4 = px;
- break;
- case 2:
- p = pixel4;
- *ptr4++ = *p++;
- px = *ptr4 & 0xffff0000;
- px |= *p & 0xffff;
- *ptr4 = px;
- break;
- case 1:
- px = *ptr4 & 0xff000000;
- px |= pixel4[0] & 0xffffff;
- *ptr4 = px;
- break;
- case 0:
- break;
- }
- }
-#endif
}
}
}
static void
-clear_32bit_ximage( GLcontext *ctx, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
+clear_32bit_ximage(GLcontext *ctx, struct xmesa_renderbuffer *xrb,
+ GLboolean all, GLint x, GLint y, GLint width, GLint height)
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint pixel = (GLuint) xmesa->clearpixel;
+
if (xmesa->swapbytes) {
pixel = ((pixel >> 24) & 0x000000ff)
| ((pixel >> 8) & 0x0000ff00)
| ((pixel << 8) & 0x00ff0000)
| ((pixel << 24) & 0xff000000);
}
+
if (all) {
- 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 GLuint n = xrb->Base.Width * xrb->Base.Height;
+ GLuint *ptr4 = (GLuint *) xrb->ximage->data;
+ if (pixel == 0) {
+ _mesa_memset(ptr4, pixel, 4 * n);
}
else {
- do {
- *ptr4++ = pixel;
- n--;
- } while (n!=0);
+ GLuint i;
+ for (i = 0; i < n; i++)
+ ptr4[i] = pixel;
}
}
else {
- register int i, j;
- for (j=0;j<height;j++) {
- register GLuint *ptr4 = PIXELADDR4( xmesa->xm_draw_buffer, x, y+j );
- for (i=0;i<width;i++) {
- *ptr4++ = pixel;
+ GLint i, j;
+ for (j = 0; j < height; j++) {
+ GLuint *ptr4 = PIXEL_ADDR4(xrb, x, y + j);
+ for (i = 0; i < width; i++) {
+ ptr4[i] = pixel;
}
}
}
@@ -695,18 +546,18 @@ clear_32bit_ximage( GLcontext *ctx, GLboolean all,
static void
-clear_nbit_ximage( GLcontext *ctx, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
+clear_nbit_ximage(GLcontext *ctx, struct xmesa_renderbuffer *xrb,
+ GLboolean all, GLint x, GLint y, GLint width, GLint height)
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- XMesaImage *img = xmesa->xm_draw_buffer->backimage;
- register int i, j;
+ XMesaImage *img = xrb->ximage;
+ GLint 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);
+ y = YFLIP(xrb, y);
for (j = 0; j < height; j++) {
for (i = 0; i < width; i++) {
XMesaPutPixel(img, x+i, y-j, xmesa->clearpixel);
@@ -720,78 +571,62 @@ static void
clear_buffers( GLcontext *ctx, GLbitfield mask,
GLboolean all, GLint x, GLint y, GLint width, GLint height )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask;
-
- if ((mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) &&
- xmesa->xm_draw_buffer->mesa_buffer.UseSoftwareAlphaBuffers &&
- ctx->Color.ColorMask[ACOMP]) {
- _swrast_clear_alpha_buffers(ctx);
- }
-
- /* we can't handle color or index masking */
- if (*colorMask == 0xffffffff && ctx->Color.IndexMask == 0xffffffff) {
- if (mask & DD_FRONT_LEFT_BIT) {
- ASSERT(xmesa->xm_draw_buffer->front_clear_func);
- (*xmesa->xm_draw_buffer->front_clear_func)( ctx, all, x, y, width, height );
- mask &= ~DD_FRONT_LEFT_BIT;
- }
- if (mask & DD_BACK_LEFT_BIT) {
- ASSERT(xmesa->xm_draw_buffer->back_clear_func);
- (*xmesa->xm_draw_buffer->back_clear_func)( ctx, all, x, y, width, height );
- mask &= ~DD_BACK_LEFT_BIT;
+ if (ctx->DrawBuffer->Name == 0) {
+ /* this is a window system framebuffer */
+ const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask;
+ XMesaBuffer b = (XMesaBuffer) ctx->DrawBuffer;
+
+ /* we can't handle color or index masking */
+ if (*colorMask == 0xffffffff && ctx->Color.IndexMask == 0xffffffff) {
+ if (mask & BUFFER_BIT_FRONT_LEFT) {
+ /* clear front color buffer */
+ if (b->frontxrb == (struct xmesa_renderbuffer *)
+ ctx->DrawBuffer->Attachment[BUFFER_FRONT_LEFT].Renderbuffer) {
+ /* renderbuffer is not wrapped - great! */
+ b->frontxrb->clearFunc(ctx, b->frontxrb, all, x, y,
+ width, height);
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
+ }
+ else {
+ /* we can't directly clear an alpha-wrapped color buffer */
+ }
+ }
+ if (mask & BUFFER_BIT_BACK_LEFT) {
+ /* clear back color buffer */
+ if (b->backxrb == (struct xmesa_renderbuffer *)
+ ctx->DrawBuffer->Attachment[BUFFER_BACK_LEFT].Renderbuffer) {
+ /* renderbuffer is not wrapped - great! */
+ b->backxrb->clearFunc(ctx, b->backxrb, all, x, y,
+ width, height);
+ mask &= ~BUFFER_BIT_BACK_LEFT;
+ }
+ }
}
}
-
if (mask)
_swrast_Clear( ctx, mask, all, x, y, width, height );
}
-/*
- * 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.
+/**
+ * Called by ctx->Driver.ResizeBuffers()
+ * Resize the front/back colorbuffers to match the latest window size.
*/
void
-xmesa_resize_buffers( GLframebuffer *buffer )
+xmesa_resize_buffers(GLcontext *ctx, GLframebuffer *buffer,
+ GLuint width, GLuint height)
{
- int height = (int) buffer->Height;
/* We can do this cast because the first field in the XMesaBuffer
* struct is a GLframebuffer struct. If this weren't true, we'd
* need a pointer from the GLframebuffer to the XMesaBuffer.
*/
XMesaBuffer xmBuffer = (XMesaBuffer) buffer;
- xmesa_alloc_back_buffer( xmBuffer );
-
- /* Needed by FLIP macro */
- xmBuffer->bottom = height - 1;
+ xmesa_alloc_back_buffer(xmBuffer, width, height);
- if (xmBuffer->backimage) {
- /* Needed by PIXELADDR1 macro */
- xmBuffer->ximage_width1 = xmBuffer->backimage->bytes_per_line;
- xmBuffer->ximage_origin1 = (GLubyte *) xmBuffer->backimage->data
- + xmBuffer->ximage_width1 * (height-1);
-
- /* Needed by PIXELADDR2 macro */
- xmBuffer->ximage_width2 = xmBuffer->backimage->bytes_per_line / 2;
- xmBuffer->ximage_origin2 = (GLushort *) xmBuffer->backimage->data
- + xmBuffer->ximage_width2 * (height-1);
-
- /* Needed by PIXELADDR3 macro */
- xmBuffer->ximage_width3 = xmBuffer->backimage->bytes_per_line;
- xmBuffer->ximage_origin3 = (GLubyte *) xmBuffer->backimage->data
- + xmBuffer->ximage_width3 * (height-1);
-
- /* Needed by PIXELADDR4 macro */
- xmBuffer->ximage_width4 = xmBuffer->backimage->width;
- xmBuffer->ximage_origin4 = (GLuint *) xmBuffer->backimage->data
- + xmBuffer->ximage_width4 * (height-1);
- }
-
- _swrast_alloc_buffers( buffer );
+#if NEW_RENDERBUFFER
+ _mesa_resize_framebuffer(ctx, buffer, width, height);
+#endif
}
@@ -810,11 +645,14 @@ xmesa_DrawPixels_8R8G8B( GLcontext *ctx,
const struct gl_pixelstore_attrib *unpack,
const GLvoid *pixels )
{
+ struct xmesa_renderbuffer *xrb
+ = (struct xmesa_renderbuffer *) ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
const SWcontext *swrast = SWRAST_CONTEXT( ctx );
XMesaDisplay *dpy = xmesa->xm_visual->display;
- const XMesaDrawable buffer = xmesa->xm_draw_buffer->buffer;
- const XMesaGC gc = xmesa->xm_draw_buffer->gc;
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+ const XMesaGC gc = xmbuf->gc;
ASSERT(dpy);
ASSERT(gc);
@@ -824,7 +662,7 @@ xmesa_DrawPixels_8R8G8B( GLcontext *ctx,
if (swrast->NewState)
_swrast_validate_derived( ctx );
- if (buffer && /* buffer != 0 means it's a Window or Pixmap */
+ if (xrb->pixmap &&
format == GL_BGRA &&
type == GL_UNSIGNED_BYTE &&
(swrast->_RasterMask & ~CLIP_BIT) == 0 && /* no blend, z-test, etc */
@@ -882,8 +720,8 @@ xmesa_DrawPixels_8R8G8B( GLcontext *ctx,
ximage.bits_per_pixel = 32;
/* it seems we don't need to set the ximage.red/green/blue_mask fields */
/* flip Y axis for dest position */
- dstY = FLIP(xmesa->xm_draw_buffer, dstY) - h + 1;
- XPutImage(dpy, buffer, gc, &ximage, 0, 0, dstX, dstY, w, h);
+ dstY = YFLIP(xrb, dstY) - h + 1;
+ XPutImage(dpy, xrb->pixmap, gc, &ximage, 0, 0, dstX, dstY, w, h);
}
if (unpack->BufferObj->Name) {
@@ -913,11 +751,13 @@ xmesa_DrawPixels_5R6G5B( GLcontext *ctx,
const struct gl_pixelstore_attrib *unpack,
const GLvoid *pixels )
{
+ struct xmesa_renderbuffer *xrb
+ = (struct xmesa_renderbuffer *) ctx->DrawBuffer->_ColorDrawBuffers[0][0];
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
const SWcontext *swrast = SWRAST_CONTEXT( ctx );
XMesaDisplay *dpy = xmesa->xm_visual->display;
- const XMesaDrawable buffer = xmesa->xm_draw_buffer->buffer;
- const XMesaGC gc = xmesa->xm_draw_buffer->gc;
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+ const XMesaGC gc = xmbuf->gc;
ASSERT(dpy);
ASSERT(gc);
@@ -926,7 +766,7 @@ xmesa_DrawPixels_5R6G5B( GLcontext *ctx,
if (swrast->NewState)
_swrast_validate_derived( ctx );
- if (buffer && /* buffer != 0 means it's a Window or Pixmap */
+ if (xrb->pixmap &&
format == GL_RGB &&
type == GL_UNSIGNED_SHORT_5_6_5 &&
!ctx->Color.DitherFlag && /* no dithering */
@@ -985,8 +825,8 @@ xmesa_DrawPixels_5R6G5B( GLcontext *ctx,
ximage.bits_per_pixel = 16;
/* it seems we don't need to set the ximage.red/green/blue_mask fields */
/* flip Y axis for dest position */
- dstY = FLIP(xmesa->xm_draw_buffer, dstY) - h + 1;
- XPutImage(dpy, buffer, gc, &ximage, 0, 0, dstX, dstY, w, h);
+ dstY = YFLIP(xrb, dstY) - h + 1;
+ XPutImage(dpy, xrb->pixmap, gc, &ximage, 0, 0, dstX, dstY, w, h);
}
if (unpack->BufferObj->Name) {
@@ -1016,9 +856,11 @@ xmesa_CopyPixels( GLcontext *ctx,
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
const SWcontext *swrast = SWRAST_CONTEXT( ctx );
XMesaDisplay *dpy = xmesa->xm_visual->display;
- const XMesaDrawable drawBuffer = xmesa->xm_draw_buffer->buffer;
- const XMesaDrawable readBuffer = xmesa->xm_read_buffer->buffer;
- const XMesaGC gc = xmesa->xm_draw_buffer->gc;
+ const XMesaGC gc = ((XMesaBuffer) ctx->DrawBuffer)->gc;
+ struct xmesa_renderbuffer *srcXrb = (struct xmesa_renderbuffer *)
+ ctx->ReadBuffer->_ColorReadBuffer;
+ struct xmesa_renderbuffer *dstXrb = (struct xmesa_renderbuffer *)
+ ctx->DrawBuffer->_ColorDrawBuffers[0][0];
ASSERT(dpy);
ASSERT(gc);
@@ -1028,8 +870,8 @@ xmesa_CopyPixels( GLcontext *ctx,
if (ctx->Color.DrawBuffer[0] == GL_FRONT &&
ctx->Pixel.ReadBuffer == GL_FRONT &&
- drawBuffer && /* buffer != 0 means it's a Window or Pixmap */
- readBuffer &&
+ srcXrb->pixmap &&
+ dstXrb->pixmap &&
type == GL_COLOR &&
(swrast->_RasterMask & ~CLIP_BIT) == 0 && /* no blend, z-test, etc */
ctx->_ImageTransferState == 0 && /* no color tables, scale/bias, etc */
@@ -1038,9 +880,9 @@ xmesa_CopyPixels( GLcontext *ctx,
/* Note: we don't do any special clipping work here. We could,
* but X will do it for us.
*/
- srcy = FLIP(xmesa->xm_read_buffer, srcy) - height + 1;
- desty = FLIP(xmesa->xm_draw_buffer, desty) - height + 1;
- XCopyArea(dpy, readBuffer, drawBuffer, gc,
+ srcy = YFLIP(srcXrb, srcy) - height + 1;
+ desty = YFLIP(dstXrb, desty) - height + 1;
+ XCopyArea(dpy, srcXrb->pixmap, dstXrb->pixmap, gc,
srcx, srcy, width, height, destx, desty);
}
else {
@@ -1100,9 +942,89 @@ enable( GLcontext *ctx, GLenum pname, GLboolean state )
}
-void xmesa_update_state( GLcontext *ctx, GLuint new_state )
+static void
+clear_color_HPCR_ximage( GLcontext *ctx, const GLfloat color[4] )
+{
+ int i;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[3], color[3]);
+
+ if (color[0] == 0.0 && color[1] == 0.0 && color[2] == 0.0) {
+ /* black is black */
+ MEMSET( xmesa->xm_visual->hpcr_clear_ximage_pattern, 0x0 ,
+ sizeof(xmesa->xm_visual->hpcr_clear_ximage_pattern));
+ }
+ else {
+ /* build clear pattern */
+ for (i=0; i<16; i++) {
+ xmesa->xm_visual->hpcr_clear_ximage_pattern[0][i] =
+ DITHER_HPCR(i, 0,
+ xmesa->clearcolor[0],
+ xmesa->clearcolor[1],
+ xmesa->clearcolor[2]);
+ xmesa->xm_visual->hpcr_clear_ximage_pattern[1][i] =
+ DITHER_HPCR(i, 1,
+ xmesa->clearcolor[0],
+ xmesa->clearcolor[1],
+ xmesa->clearcolor[2]);
+ }
+ }
+}
+
+
+static void
+clear_color_HPCR_pixmap( GLcontext *ctx, const GLfloat color[4] )
+{
+ int i;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[3], color[3]);
+
+ if (color[0] == 0.0 && color[1] == 0.0 && color[2] == 0.0) {
+ /* black is black */
+ for (i=0; i<16; i++) {
+ XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 0, 0);
+ XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 1, 0);
+ }
+ }
+ else {
+ for (i=0; i<16; i++) {
+ XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 0,
+ DITHER_HPCR(i, 0,
+ xmesa->clearcolor[0],
+ xmesa->clearcolor[1],
+ xmesa->clearcolor[2]));
+ XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 1,
+ DITHER_HPCR(i, 1,
+ xmesa->clearcolor[0],
+ xmesa->clearcolor[1],
+ xmesa->clearcolor[2]));
+ }
+ }
+ /* change tile pixmap content */
+ XMesaPutImage(xmesa->display,
+ (XMesaDrawable)xmesa->xm_visual->hpcr_clear_pixmap,
+ XMESA_BUFFER(ctx->DrawBuffer)->cleargc,
+ xmesa->xm_visual->hpcr_clear_ximage, 0, 0, 0, 0, 16, 2);
+}
+
+
+/**
+ * Called when the driver should update it's state, based on the new_state
+ * flags.
+ */
+void
+xmesa_update_state( GLcontext *ctx, GLuint new_state )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *front_xrb, *back_xrb;
/* Propagate statechange information to swrast and swrast_setup
* modules. The X11 driver has no internal GL-dependent state.
@@ -1112,40 +1034,76 @@ void xmesa_update_state( GLcontext *ctx, GLuint new_state )
_tnl_InvalidateState( ctx, new_state );
_swsetup_InvalidateState( ctx, new_state );
+ if (ctx->DrawBuffer->Name != 0)
+ return;
- /* setup pointers to front and back buffer clear functions */
- xmesa->xm_draw_buffer->front_clear_func = clear_front_pixmap;
- if (xmesa->xm_draw_buffer->backpixmap != XIMAGE) {
- xmesa->xm_draw_buffer->back_clear_func = clear_back_pixmap;
+ front_xrb = XMESA_BUFFER(ctx->DrawBuffer)->frontxrb;
+ if (front_xrb) {
+ /* XXX check for relevant new_state flags */
+ xmesa_set_renderbuffer_funcs(front_xrb, xmesa->pixelformat,
+ xmesa->xm_visual->BitsPerPixel);
+ /* setup pointers to front and back buffer clear functions */
+ front_xrb->clearFunc = clear_pixmap;
}
- else {
- switch (xmesa->xm_visual->BitsPerPixel) {
- case 8:
- if (xmesa->xm_visual->hpcr_clear_flag) {
- xmesa->xm_draw_buffer->back_clear_func = clear_HPCR_ximage;
- }
- else {
- xmesa->xm_draw_buffer->back_clear_func = clear_8bit_ximage;
+
+ back_xrb = XMESA_BUFFER(ctx->DrawBuffer)->backxrb;
+ if (back_xrb) {
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+
+ /* XXX check for relevant new_state flags */
+ xmesa_set_renderbuffer_funcs(back_xrb, xmesa->pixelformat,
+ xmesa->xm_visual->BitsPerPixel);
+
+ if (xmbuf->backxrb->pixmap) {
+ back_xrb->clearFunc = clear_pixmap;
+ }
+ else {
+ switch (xmesa->xm_visual->BitsPerPixel) {
+ case 8:
+ if (xmesa->xm_visual->hpcr_clear_flag) {
+ back_xrb->clearFunc = clear_HPCR_ximage;
+ }
+ else {
+ back_xrb->clearFunc = clear_8bit_ximage;
+ }
+ break;
+ case 16:
+ back_xrb->clearFunc = clear_16bit_ximage;
+ break;
+ case 24:
+ back_xrb->clearFunc = clear_24bit_ximage;
+ break;
+ case 32:
+ back_xrb->clearFunc = clear_32bit_ximage;
+ break;
+ default:
+ back_xrb->clearFunc = clear_nbit_ximage;
+ break;
}
- break;
- case 16:
- xmesa->xm_draw_buffer->back_clear_func = clear_16bit_ximage;
- break;
- case 24:
- xmesa->xm_draw_buffer->back_clear_func = clear_24bit_ximage;
- break;
- case 32:
- xmesa->xm_draw_buffer->back_clear_func = clear_32bit_ximage;
- break;
- default:
- xmesa->xm_draw_buffer->back_clear_func = clear_nbit_ximage;
- break;
}
}
- if (ctx->Color._DrawDestMask[0] & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) {
+#if OLD_RENDERBUFFER && 0
+ if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) {
xmesa_update_span_funcs(ctx);
}
+#endif
+
+ if (xmesa->xm_visual->hpcr_clear_flag) {
+ /* this depends on whether we're drawing to the front or back buffer */
+ /* XXX FIX THIS! */
+#if 0
+ if (pixmap) {
+ ctx->Driver.ClearColor = clear_color_HPCR_pixmap;
+ }
+ else {
+ ctx->Driver.ClearColor = clear_color_HPCR_ximage;
+ }
+#else
+ (void) clear_color_HPCR_pixmap;
+ (void) clear_color_HPCR_ximage;
+#endif
+ }
}
@@ -1208,17 +1166,36 @@ choose_tex_format( GLcontext *ctx, GLint internalFormat,
/**
* Called by glViewport.
* This is a good time for us to poll the current X window size and adjust
- * our ancillary (back color, depth, stencil, etc) buffers to match the
- * current window size. Remember, we have no opportunity to respond to
- * conventional X Resize/StructureNotify events since the X driver has no
- * event loop. Thus, we poll.
+ * our renderbuffers to match the current window size.
+ * Remember, we have no opportunity to respond to conventional
+ * X Resize/StructureNotify events since the X driver has no event loop.
+ * Thus, we poll.
* Note that this trick isn't fool-proof. If the application never calls
* glViewport, our notion of the current window size may be incorrect.
*/
static void
xmesa_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
{
+#if 1
+ struct gl_framebuffer *fb = ctx->WinSysDrawBuffer;
+ GLuint newWidth, newHeight;
+
+ /*
+ printf("%s before %d x %d\n", __FUNCTION__, fb->Width, fb->Height);
+ */
+
+ get_buffer_size(fb, &newWidth, &newHeight);
+ if (newWidth != fb->Width || newHeight != fb->Height) {
+ xmesa_resize_buffers(ctx, fb, newWidth, newHeight);
+ ctx->NewState |= _NEW_BUFFERS; /* to update scissor / window bounds */
+ }
+ /*
+ printf("%s after %d x %d\n", __FUNCTION__, fb->Width, fb->Height);
+ */
+#else
+ /* This also works: */
_mesa_ResizeBuffersMESA();
+#endif
}
diff --git a/src/mesa/drivers/x11/xm_line.c b/src/mesa/drivers/x11/xm_line.c
index 24e09ce344..43de9a98ab 100644
--- a/src/mesa/drivers/x11/xm_line.c
+++ b/src/mesa/drivers/x11/xm_line.c
@@ -70,7 +70,7 @@ static void draw_points_ANY_pixmap( GLcontext *ctx, const SWvertex *vert )
xmesa->pixelformat);
XMesaSetForeground( dpy, gc, pixel );
x = (GLint) vert->win[0];
- y = FLIP( xmesa->xm_buffer, (GLint) vert->win[1] );
+ y = YFLIP( xrb, (GLint) vert->win[1] );
XMesaDrawPoint( dpy, buffer, gc, x, y);
}
else {
@@ -78,7 +78,7 @@ static void draw_points_ANY_pixmap( GLcontext *ctx, const SWvertex *vert )
register int x, y;
XMesaSetForeground( dpy, gc, vert->index );
x = (GLint) vert->win[0];
- y = FLIP( xmesa->xm_buffer, (GLint) vert->win[1] );
+ y = YFLIP( xrb, (GLint) vert->win[1] );
XMesaDrawPoint( dpy, buffer, gc, x, y);
}
}
@@ -117,18 +117,22 @@ void xmesa_choose_point( GLcontext *ctx )
/**********************************************************************/
+#define GET_XRB(XRB) struct xmesa_renderbuffer *XRB = \
+ (struct xmesa_renderbuffer *) ctx->DrawBuffer->_ColorDrawBuffers[0][0]
+
+
/*
* Draw a flat-shaded, PF_TRUECOLOR line into an XImage.
*/
#define NAME flat_TRUECOLOR_line
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
- XMesaImage *img = xmesa->xm_buffer->backimage; \
unsigned long pixel; \
PACK_TRUECOLOR( pixel, color[0], color[1], color[2] );
#define CLIP_HACK 1
-#define PLOT(X,Y) XMesaPutPixel( img, X, FLIP(xmesa->xm_buffer, Y), pixel );
+#define PLOT(X,Y) XMesaPutPixel(xrb->ximage, X, YFLIP(xrb, Y), pixel );
#include "swrast/s_linetemp.h"
@@ -138,12 +142,12 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_8A8B8G8R_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLuint pixel = PACK_8B8G8R( color[0], color[1], color[2] );
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = pixel;
#include "swrast/s_linetemp.h"
@@ -155,12 +159,12 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_8A8R8G8B_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] );
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = pixel;
#include "swrast/s_linetemp.h"
@@ -172,12 +176,12 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_8R8G8B_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] );
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = pixel;
#include "swrast/s_linetemp.h"
@@ -189,11 +193,11 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_8R8G8B24_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color;
#define PIXEL_TYPE bgr_t
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR3(xrb, X, Y)
#define CLIP_HACK 1
#define PLOT(X,Y) { \
pixelPtr->r = color[RCOMP]; \
@@ -209,12 +213,12 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_5R6G5B_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLushort pixel = PACK_5R6G5B( color[0], color[1], color[2] );
#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = pixel;
#include "swrast/s_linetemp.h"
@@ -226,11 +230,12 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_DITHER_5R6G5B_line
#define SETUP_CODE \
+ GET_XRB(xrb); \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
const GLubyte *color = vert1->color;
#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
#define CLIP_HACK 1
#define PLOT(X,Y) PACK_TRUEDITHER( *pixelPtr, X, Y, color[0], color[1], color[2] );
#include "swrast/s_linetemp.h"
@@ -243,13 +248,13 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_DITHER8_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLint r = color[0], g = color[1], b = color[2]; \
DITHER_SETUP;
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = DITHER(X,Y,r,g,b);
#include "swrast/s_linetemp.h"
@@ -261,14 +266,14 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_LOOKUP8_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLubyte pixel; \
LOOKUP_SETUP; \
pixel = (GLubyte) LOOKUP( color[0], color[1], color[2] );
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = pixel;
#include "swrast/s_linetemp.h"
@@ -280,12 +285,13 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_HPCR_line
#define SETUP_CODE \
+ GET_XRB(xrb); \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
const GLubyte *color = vert1->color; \
GLint r = color[0], g = color[1], b = color[2];
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) *pixelPtr = (GLubyte) DITHER_HPCR(X,Y,r,g,b);
#include "swrast/s_linetemp.h"
@@ -298,9 +304,9 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_TRUECOLOR_z_line
#define SETUP_CODE \
+ GET_XRB(xrb); \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
const GLubyte *color = vert1->color; \
- XMesaImage *img = xmesa->xm_buffer->backimage; \
unsigned long pixel; \
PACK_TRUECOLOR( pixel, color[0], color[1], color[2] );
#define INTERP_Z 1
@@ -309,7 +315,7 @@ void xmesa_choose_point( GLcontext *ctx )
#define PLOT(X,Y) \
if (Z < *zPtr) { \
*zPtr = Z; \
- XMesaPutPixel( img, X, FLIP(xmesa->xm_buffer, Y), pixel ); \
+ XMesaPutPixel(xrb->ximage, X, YFLIP(xrb, Y), pixel); \
}
#include "swrast/s_linetemp.h"
@@ -320,14 +326,14 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_8A8B8G8R_z_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLuint pixel = PACK_8B8G8R( color[0], color[1], color[2] );
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
@@ -343,14 +349,14 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_8A8R8G8B_z_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] );
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
@@ -366,14 +372,14 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_8R8G8B_z_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] );
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
@@ -389,13 +395,13 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_8R8G8B24_z_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color;
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE bgr_t
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR3(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
@@ -413,14 +419,14 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_5R6G5B_z_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLushort pixel = PACK_5R6G5B( color[0], color[1], color[2] );
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
@@ -436,13 +442,14 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_DITHER_5R6G5B_z_line
#define SETUP_CODE \
+ GET_XRB(xrb); \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
const GLubyte *color = vert1->color;
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
@@ -458,15 +465,15 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_DITHER8_z_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLint r = color[0], g = color[1], b = color[2]; \
DITHER_SETUP;
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
@@ -482,7 +489,7 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_LOOKUP8_z_line
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = vert1->color; \
GLubyte pixel; \
LOOKUP_SETUP; \
@@ -490,8 +497,8 @@ void xmesa_choose_point( GLcontext *ctx )
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
@@ -507,14 +514,15 @@ void xmesa_choose_point( GLcontext *ctx )
*/
#define NAME flat_HPCR_z_line
#define SETUP_CODE \
+ GET_XRB(xrb); \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
const GLubyte *color = vert1->color; \
GLint r = color[0], g = color[1], b = color[2];
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X,Y)
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
@@ -530,8 +538,11 @@ static swrast_line_func get_line_func( GLcontext *ctx )
XMesaContext xmesa = XMESA_CONTEXT(ctx);
SWcontext *swrast = SWRAST_CONTEXT(ctx);
int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *)
+ ctx->DrawBuffer->_ColorDrawBuffers[0][0];
- if ((ctx->Color._DrawDestMask[0] & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) ==0)
+ if ((ctx->DrawBuffer->_ColorDrawBufferMask[0]
+ & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) == 0)
return (swrast_line_func) NULL;
if (ctx->RenderMode != GL_RENDER) return (swrast_line_func) NULL;
if (ctx->Line.SmoothFlag) return (swrast_line_func) NULL;
@@ -540,7 +551,7 @@ static swrast_line_func get_line_func( GLcontext *ctx )
if (ctx->Line.StippleFlag) return (swrast_line_func) NULL;
if (swrast->_RasterMask & MULTI_DRAW_BIT) return (swrast_line_func) NULL;
- if (xmesa->xm_buffer->buffer==XIMAGE
+ if (xrb->ximage
&& swrast->_RasterMask==DEPTH_BIT
&& ctx->Depth.Func==GL_LESS
&& ctx->Depth.Mask==GL_TRUE
@@ -571,7 +582,7 @@ static swrast_line_func get_line_func( GLcontext *ctx )
return (swrast_line_func)NULL;
}
}
- if (xmesa->xm_buffer->buffer==XIMAGE
+ if (xrb->ximage
&& swrast->_RasterMask==0
&& ctx->Line.Width==1.0F) {
switch (xmesa->pixelformat) {
diff --git a/src/mesa/drivers/x11/xm_span.c b/src/mesa/drivers/x11/xm_span.c
index b3b5970bdf..88dbb0d0b3 100644
--- a/src/mesa/drivers/x11/xm_span.c
+++ b/src/mesa/drivers/x11/xm_span.c
@@ -164,10 +164,12 @@ static unsigned long read_pixel( XMesaDisplay *dpy,
#define RGBA_SPAN_ARGS const GLcontext *ctx, \
+ struct gl_renderbuffer *rb, \
GLuint n, GLint x, GLint y, \
CONST GLubyte rgba[][4], const GLubyte mask[]
#define RGB_SPAN_ARGS const GLcontext *ctx, \
+ struct gl_renderbuffer *rb, \
GLuint n, GLint x, GLint y, \
CONST GLubyte rgb[][3], const GLubyte mask[]
@@ -181,12 +183,13 @@ static unsigned long read_pixel( XMesaDisplay *dpy,
static void write_span_TRUECOLOR_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -216,11 +219,12 @@ static void write_span_TRUECOLOR_pixmap( RGBA_SPAN_ARGS )
static void write_span_rgb_TRUECOLOR_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -250,11 +254,12 @@ static void write_span_rgb_TRUECOLOR_pixmap( RGB_SPAN_ARGS )
static void write_span_TRUEDITHER_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -283,11 +288,12 @@ static void write_span_TRUEDITHER_pixmap( RGBA_SPAN_ARGS )
static void write_span_rgb_TRUEDITHER_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -317,11 +323,12 @@ static void write_span_rgb_TRUEDITHER_pixmap( RGB_SPAN_ARGS )
static void write_span_8A8B8G8R_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -349,11 +356,12 @@ static void write_span_8A8B8G8R_pixmap( RGBA_SPAN_ARGS )
static void write_span_rgb_8A8B8G8R_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -380,11 +388,12 @@ static void write_span_rgb_8A8B8G8R_pixmap( RGB_SPAN_ARGS )
static void write_span_8A8R8G8B_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -412,11 +421,12 @@ static void write_span_8A8R8G8B_pixmap( RGBA_SPAN_ARGS )
static void write_span_rgb_8A8R8G8B_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -444,11 +454,12 @@ static void write_span_rgb_8A8R8G8B_pixmap( RGB_SPAN_ARGS )
static void write_span_8R8G8B_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -475,10 +486,11 @@ static void write_span_8R8G8B_pixmap( RGBA_SPAN_ARGS )
static void write_span_8R8G8B24_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
register GLuint i;
for (i=0;i<n;i++,x++) {
@@ -569,11 +581,12 @@ static void write_span_8R8G8B24_pixmap( RGBA_SPAN_ARGS )
static void write_span_rgb_8R8G8B_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -600,10 +613,11 @@ static void write_span_rgb_8R8G8B_pixmap( RGB_SPAN_ARGS )
static void write_span_rgb_8R8G8B24_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
register GLuint i;
for (i=0;i<n;i++,x++) {
@@ -699,11 +713,12 @@ static void write_span_rgb_8R8G8B24_pixmap( RGB_SPAN_ARGS )
static void write_span_5R6G5B_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -730,11 +745,12 @@ static void write_span_5R6G5B_pixmap( RGBA_SPAN_ARGS )
static void write_span_DITHER_5R6G5B_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -763,11 +779,12 @@ static void write_span_DITHER_5R6G5B_pixmap( RGBA_SPAN_ARGS )
static void write_span_rgb_5R6G5B_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -794,11 +811,12 @@ static void write_span_rgb_5R6G5B_pixmap( RGB_SPAN_ARGS )
static void write_span_rgb_DITHER_5R6G5B_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -828,12 +846,13 @@ static void write_span_rgb_DITHER_5R6G5B_pixmap( RGB_SPAN_ARGS )
static void write_span_DITHER_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
XDITHER_SETUP(y);
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -859,12 +878,13 @@ static void write_span_DITHER_pixmap( RGBA_SPAN_ARGS )
static void write_span_rgb_DITHER_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
XDITHER_SETUP(y);
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -890,12 +910,13 @@ static void write_span_rgb_DITHER_pixmap( RGB_SPAN_ARGS )
static void write_span_1BIT_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
SETUP_1BIT;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -923,12 +944,13 @@ static void write_span_1BIT_pixmap( RGBA_SPAN_ARGS )
static void write_span_rgb_1BIT_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
SETUP_1BIT;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -956,11 +978,12 @@ static void write_span_rgb_1BIT_pixmap( RGB_SPAN_ARGS )
static void write_span_HPCR_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -987,11 +1010,12 @@ static void write_span_HPCR_pixmap( RGBA_SPAN_ARGS )
static void write_span_rgb_HPCR_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1018,12 +1042,13 @@ static void write_span_rgb_HPCR_pixmap( RGB_SPAN_ARGS )
static void write_span_LOOKUP_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
LOOKUP_SETUP;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1048,12 +1073,13 @@ static void write_span_LOOKUP_pixmap( RGBA_SPAN_ARGS )
static void write_span_rgb_LOOKUP_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
LOOKUP_SETUP;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1079,11 +1105,12 @@ static void write_span_rgb_LOOKUP_pixmap( RGB_SPAN_ARGS )
static void write_span_GRAYSCALE_pixmap( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1108,11 +1135,12 @@ static void write_span_GRAYSCALE_pixmap( RGBA_SPAN_ARGS )
static void write_span_rgb_GRAYSCALE_pixmap( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1137,9 +1165,10 @@ static void write_span_rgb_GRAYSCALE_pixmap( RGB_SPAN_ARGS )
static void write_span_TRUECOLOR_ximage( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1166,9 +1195,10 @@ static void write_span_TRUECOLOR_ximage( RGBA_SPAN_ARGS )
static void write_span_rgb_TRUECOLOR_ximage( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1195,9 +1225,10 @@ static void write_span_rgb_TRUECOLOR_ximage( RGB_SPAN_ARGS )
static void write_span_TRUEDITHER_ximage( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1224,9 +1255,10 @@ static void write_span_TRUEDITHER_ximage( RGBA_SPAN_ARGS )
static void write_span_rgb_TRUEDITHER_ximage( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1252,9 +1284,9 @@ static void write_span_rgb_TRUEDITHER_ximage( RGB_SPAN_ARGS )
*/
static void write_span_8A8B8G8R_ximage( RGBA_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
- register GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
+ register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -1276,9 +1308,9 @@ static void write_span_8A8B8G8R_ximage( RGBA_SPAN_ARGS )
*/
static void write_span_rgb_8A8B8G8R_ximage( RGB_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
- register GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
+ register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -1299,9 +1331,9 @@ static void write_span_rgb_8A8B8G8R_ximage( RGB_SPAN_ARGS )
*/
static void write_span_8A8R8G8B_ximage( RGBA_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
- register GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
+ register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -1323,9 +1355,9 @@ static void write_span_8A8R8G8B_ximage( RGBA_SPAN_ARGS )
*/
static void write_span_rgb_8A8R8G8B_ximage( RGB_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
- register GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
+ register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -1347,9 +1379,9 @@ static void write_span_rgb_8A8R8G8B_ximage( RGB_SPAN_ARGS )
*/
static void write_span_8R8G8B_ximage( RGBA_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
- register GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
+ register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -1370,9 +1402,9 @@ static void write_span_8R8G8B_ximage( RGBA_SPAN_ARGS )
*/
static void write_span_8R8G8B24_ximage( RGBA_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
- register GLubyte *ptr = (GLubyte *) PIXELADDR3( xmesa->xm_buffer, x, y );
+ register GLubyte *ptr = (GLubyte *) PIXEL_ADDR3(xrb, x, y );
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -1520,9 +1552,9 @@ static void write_span_8R8G8B24_ximage( RGBA_SPAN_ARGS )
*/
static void write_span_rgb_8R8G8B_ximage( RGB_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
- register GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
+ register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -1544,9 +1576,9 @@ static void write_span_rgb_8R8G8B_ximage( RGB_SPAN_ARGS )
*/
static void write_span_rgb_8R8G8B24_ximage( RGB_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
- register GLubyte *ptr = (GLubyte *) PIXELADDR3( xmesa->xm_buffer, x, y );
+ register GLubyte *ptr = (GLubyte *) PIXEL_ADDR3(xrb, x, y);
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -1575,9 +1607,9 @@ static void write_span_rgb_8R8G8B24_ximage( RGB_SPAN_ARGS )
*/
static void write_span_5R6G5B_ximage( RGBA_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
- register GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x, y );
+ register GLushort *ptr = PIXEL_ADDR2(xrb, x, y);
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -1614,10 +1646,12 @@ static void write_span_5R6G5B_ximage( RGBA_SPAN_ARGS )
*/
static void write_span_DITHER_5R6G5B_ximage( RGBA_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
- register GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x, y );
- const GLint y2 = FLIP(xmesa->xm_buffer, y);
+ register GLushort *ptr = PIXEL_ADDR2(xrb, x, y);
+ const GLint y2 = YFLIP(xrb, y);
+ ASSERT(xrb->ximage);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1654,9 +1688,9 @@ static void write_span_DITHER_5R6G5B_ximage( RGBA_SPAN_ARGS )
*/
static void write_span_rgb_5R6G5B_ximage( RGB_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
- register GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x, y );
+ register GLushort *ptr = PIXEL_ADDR2(xrb, x, y);
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -1693,9 +1727,10 @@ static void write_span_rgb_5R6G5B_ximage( RGB_SPAN_ARGS )
*/
static void write_span_rgb_DITHER_5R6G5B_ximage( RGB_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
- register GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x, y );
+ register GLushort *ptr = PIXEL_ADDR2(xrb, x, y );
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1733,9 +1768,10 @@ static void write_span_rgb_DITHER_5R6G5B_ximage( RGB_SPAN_ARGS )
static void write_span_DITHER_ximage( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- int yy = FLIP(xmesa->xm_buffer, y);
+ int yy = YFLIP(xrb, y);
XDITHER_SETUP(yy);
if (mask) {
for (i=0;i<n;i++,x++) {
@@ -1759,9 +1795,10 @@ static void write_span_DITHER_ximage( RGBA_SPAN_ARGS )
static void write_span_rgb_DITHER_ximage( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- int yy = FLIP(xmesa->xm_buffer, y);
+ int yy = YFLIP(xrb, y);
XDITHER_SETUP(yy);
if (mask) {
for (i=0;i<n;i++,x++) {
@@ -1786,8 +1823,9 @@ static void write_span_rgb_DITHER_ximage( RGB_SPAN_ARGS )
static void write_span_DITHER8_ximage( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
- register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y );
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
XDITHER_SETUP(y);
if (mask) {
for (i=0;i<n;i++,x++) {
@@ -1807,8 +1845,9 @@ static void write_span_DITHER8_ximage( RGBA_SPAN_ARGS )
static void write_span_rgb_DITHER8_ximage( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
- register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y );
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
XDITHER_SETUP(y);
if (mask) {
for (i=0;i<n;i++,x++) {
@@ -1834,10 +1873,11 @@ static void write_span_rgb_DITHER8_ximage( RGB_SPAN_ARGS )
static void write_span_1BIT_ximage( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
SETUP_1BIT;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1859,10 +1899,11 @@ static void write_span_1BIT_ximage( RGBA_SPAN_ARGS )
static void write_span_rgb_1BIT_ximage( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
SETUP_1BIT;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1883,9 +1924,10 @@ static void write_span_rgb_1BIT_ximage( RGB_SPAN_ARGS )
*/
static void write_span_HPCR_ximage( RGBA_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
- register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y );
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1907,9 +1949,10 @@ static void write_span_HPCR_ximage( RGBA_SPAN_ARGS )
*/
static void write_span_rgb_HPCR_ximage( RGB_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
- register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y );
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1932,10 +1975,11 @@ static void write_span_rgb_HPCR_ximage( RGB_SPAN_ARGS )
static void write_span_LOOKUP_ximage( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
LOOKUP_SETUP;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1958,10 +2002,11 @@ static void write_span_LOOKUP_ximage( RGBA_SPAN_ARGS )
static void write_span_rgb_LOOKUP_ximage( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
LOOKUP_SETUP;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -1983,9 +2028,10 @@ static void write_span_rgb_LOOKUP_ximage( RGB_SPAN_ARGS )
*/
static void write_span_LOOKUP8_ximage( RGBA_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
- register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y );
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
LOOKUP_SETUP;
if (mask) {
for (i=0;i<n;i++,x++) {
@@ -2003,14 +2049,12 @@ static void write_span_LOOKUP8_ximage( RGBA_SPAN_ARGS )
}
-static void write_rgb_LOOKUP8_ximage( const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- CONST GLubyte rgb[][3],
- const GLubyte mask[] )
+static void write_rgb_LOOKUP8_ximage( RGB_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
- register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y );
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
LOOKUP_SETUP;
if (mask) {
for (i=0;i<n;i++,x++) {
@@ -2036,9 +2080,10 @@ static void write_rgb_LOOKUP8_ximage( const GLcontext *ctx,
static void write_span_GRAYSCALE_ximage( RGBA_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -2061,9 +2106,10 @@ static void write_span_GRAYSCALE_ximage( RGBA_SPAN_ARGS )
static void write_span_rgb_GRAYSCALE_ximage( RGB_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -2085,9 +2131,10 @@ static void write_span_rgb_GRAYSCALE_ximage( RGB_SPAN_ARGS )
*/
static void write_span_GRAYSCALE8_ximage( RGBA_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
- register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y );
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -2109,9 +2156,10 @@ static void write_span_GRAYSCALE8_ximage( RGBA_SPAN_ARGS )
*/
static void write_span_rgb_GRAYSCALE8_ximage( RGB_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
- register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y );
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -2136,6 +2184,7 @@ static void write_span_rgb_GRAYSCALE8_ximage( RGB_SPAN_ARGS )
#define RGBA_PIXEL_ARGS const GLcontext *ctx, \
+ struct gl_renderbuffer *rb, \
GLuint n, const GLint x[], const GLint y[], \
CONST GLubyte rgba[][4], const GLubyte mask[]
@@ -2146,6 +2195,7 @@ static void write_span_rgb_GRAYSCALE8_ximage( RGB_SPAN_ARGS )
static void write_pixels_TRUECOLOR_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2155,7 +2205,7 @@ static void write_pixels_TRUECOLOR_pixmap( RGBA_PIXEL_ARGS )
unsigned long p;
PACK_TRUECOLOR( p, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
XMesaSetForeground( dpy, gc, p );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2167,6 +2217,7 @@ static void write_pixels_TRUECOLOR_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_TRUEDITHER_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2176,7 +2227,7 @@ static void write_pixels_TRUEDITHER_pixmap( RGBA_PIXEL_ARGS )
unsigned long p;
PACK_TRUEDITHER(p, x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
XMesaSetForeground( dpy, gc, p );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2188,6 +2239,7 @@ static void write_pixels_TRUEDITHER_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_8A8B8G8R_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2196,7 +2248,7 @@ static void write_pixels_8A8B8G8R_pixmap( RGBA_PIXEL_ARGS )
if (mask[i]) {
XMesaSetForeground( dpy, gc,
PACK_8A8B8G8R( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] ));
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2207,6 +2259,7 @@ static void write_pixels_8A8B8G8R_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_8A8R8G8B_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2215,7 +2268,7 @@ static void write_pixels_8A8R8G8B_pixmap( RGBA_PIXEL_ARGS )
if (mask[i]) {
XMesaSetForeground( dpy, gc,
PACK_8A8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] ));
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2226,6 +2279,7 @@ static void write_pixels_8A8R8G8B_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_8R8G8B_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2233,7 +2287,7 @@ static void write_pixels_8R8G8B_pixmap( RGBA_PIXEL_ARGS )
for (i=0;i<n;i++) {
if (mask[i]) {
XMesaSetForeground( dpy, gc, PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2245,6 +2299,7 @@ static void write_pixels_8R8G8B_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_8R8G8B24_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2252,7 +2307,7 @@ static void write_pixels_8R8G8B24_pixmap( RGBA_PIXEL_ARGS )
for (i=0;i<n;i++) {
if (mask[i]) {
XMesaSetForeground( dpy, gc, PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2264,6 +2319,7 @@ static void write_pixels_8R8G8B24_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_5R6G5B_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2271,7 +2327,7 @@ static void write_pixels_5R6G5B_pixmap( RGBA_PIXEL_ARGS )
for (i=0;i<n;i++) {
if (mask[i]) {
XMesaSetForeground( dpy, gc, PACK_5R6G5B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2283,6 +2339,7 @@ static void write_pixels_5R6G5B_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_DITHER_5R6G5B_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2292,7 +2349,7 @@ static void write_pixels_DITHER_5R6G5B_pixmap( RGBA_PIXEL_ARGS )
unsigned long p;
PACK_TRUEDITHER(p, x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
XMesaSetForeground( dpy, gc, p );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2304,6 +2361,7 @@ static void write_pixels_DITHER_5R6G5B_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_DITHER_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2313,7 +2371,7 @@ static void write_pixels_DITHER_pixmap( RGBA_PIXEL_ARGS )
if (mask[i]) {
XMesaSetForeground( dpy, gc,
DITHER(x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]) );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2325,6 +2383,7 @@ static void write_pixels_DITHER_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_1BIT_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2334,7 +2393,7 @@ static void write_pixels_1BIT_pixmap( RGBA_PIXEL_ARGS )
if (mask[i]) {
XMesaSetForeground( dpy, gc,
DITHER_1BIT( x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2346,6 +2405,7 @@ static void write_pixels_1BIT_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_HPCR_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2354,7 +2414,7 @@ static void write_pixels_HPCR_pixmap( RGBA_PIXEL_ARGS )
if (mask[i]) {
XMesaSetForeground( dpy, gc,
DITHER_HPCR( x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2366,6 +2426,7 @@ static void write_pixels_HPCR_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_LOOKUP_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2374,7 +2435,7 @@ static void write_pixels_LOOKUP_pixmap( RGBA_PIXEL_ARGS )
for (i=0;i<n;i++) {
if (mask[i]) {
XMesaSetForeground( dpy, gc, LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2386,6 +2447,7 @@ static void write_pixels_LOOKUP_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_GRAYSCALE_pixmap( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2393,7 +2455,7 @@ static void write_pixels_GRAYSCALE_pixmap( RGBA_PIXEL_ARGS )
for (i=0;i<n;i++) {
if (mask[i]) {
XMesaSetForeground( dpy, gc, GRAY_RGB( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -2405,13 +2467,14 @@ static void write_pixels_GRAYSCALE_pixmap( RGBA_PIXEL_ARGS )
static void write_pixels_TRUECOLOR_ximage( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p;
PACK_TRUECOLOR( p, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), p );
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), p );
}
}
}
@@ -2423,13 +2486,14 @@ static void write_pixels_TRUECOLOR_ximage( RGBA_PIXEL_ARGS )
static void write_pixels_TRUEDITHER_ximage( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p;
PACK_TRUEDITHER(p, x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), p );
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), p );
}
}
}
@@ -2440,11 +2504,11 @@ static void write_pixels_TRUEDITHER_ximage( RGBA_PIXEL_ARGS )
*/
static void write_pixels_8A8B8G8R_ximage( RGBA_PIXEL_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x[i], y[i] );
+ GLuint *ptr = PIXEL_ADDR4(xrb, x[i], y[i] );
*ptr = PACK_8A8B8G8R( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] );
}
}
@@ -2455,11 +2519,11 @@ static void write_pixels_8A8B8G8R_ximage( RGBA_PIXEL_ARGS )
*/
static void write_pixels_8A8R8G8B_ximage( RGBA_PIXEL_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x[i], y[i] );
+ GLuint *ptr = PIXEL_ADDR4(xrb, x[i], y[i]);
*ptr = PACK_8A8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] );
}
}
@@ -2471,11 +2535,11 @@ static void write_pixels_8A8R8G8B_ximage( RGBA_PIXEL_ARGS )
*/
static void write_pixels_8R8G8B_ximage( RGBA_PIXEL_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x[i], y[i] );
+ GLuint *ptr = PIXEL_ADDR4(xrb, x[i], y[i]);
*ptr = PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
}
}
@@ -2487,11 +2551,11 @@ static void write_pixels_8R8G8B_ximage( RGBA_PIXEL_ARGS )
*/
static void write_pixels_8R8G8B24_ximage( RGBA_PIXEL_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- bgr_t *ptr = PIXELADDR3( xmesa->xm_buffer, x[i], y[i] );
+ bgr_t *ptr = PIXEL_ADDR3(xrb, x[i], y[i] );
ptr->r = rgba[i][RCOMP];
ptr->g = rgba[i][GCOMP];
ptr->b = rgba[i][BCOMP];
@@ -2505,11 +2569,11 @@ static void write_pixels_8R8G8B24_ximage( RGBA_PIXEL_ARGS )
*/
static void write_pixels_5R6G5B_ximage( RGBA_PIXEL_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x[i], y[i] );
+ GLushort *ptr = PIXEL_ADDR2(xrb, x[i], y[i] );
*ptr = PACK_5R6G5B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
}
}
@@ -2521,11 +2585,12 @@ static void write_pixels_5R6G5B_ximage( RGBA_PIXEL_ARGS )
*/
static void write_pixels_DITHER_5R6G5B_ximage( RGBA_PIXEL_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x[i], y[i] );
+ GLushort *ptr = PIXEL_ADDR2(xrb, x[i], y[i] );
PACK_TRUEDITHER( *ptr, x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
}
}
@@ -2538,12 +2603,13 @@ static void write_pixels_DITHER_5R6G5B_ximage( RGBA_PIXEL_ARGS )
static void write_pixels_DITHER_ximage( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
DITHER_SETUP;
for (i=0;i<n;i++) {
if (mask[i]) {
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]),
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]),
DITHER( x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
}
}
@@ -2555,12 +2621,13 @@ static void write_pixels_DITHER_ximage( RGBA_PIXEL_ARGS )
*/
static void write_pixels_DITHER8_ximage( RGBA_PIXEL_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
DITHER_SETUP;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x[i], y[i]);
*ptr = (GLubyte) DITHER( x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
}
}
@@ -2573,12 +2640,13 @@ static void write_pixels_DITHER8_ximage( RGBA_PIXEL_ARGS )
static void write_pixels_1BIT_ximage( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
SETUP_1BIT;
for (i=0;i<n;i++) {
if (mask[i]) {
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]),
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]),
DITHER_1BIT( x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));
}
}
@@ -2590,11 +2658,12 @@ static void write_pixels_1BIT_ximage( RGBA_PIXEL_ARGS )
*/
static void write_pixels_HPCR_ximage( RGBA_PIXEL_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x[i], y[i]);
*ptr = (GLubyte) DITHER_HPCR( x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
}
}
@@ -2607,12 +2676,13 @@ static void write_pixels_HPCR_ximage( RGBA_PIXEL_ARGS )
static void write_pixels_LOOKUP_ximage( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
LOOKUP_SETUP;
for (i=0;i<n;i++) {
if (mask[i]) {
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), LOOKUP(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]) );
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), LOOKUP(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]) );
}
}
}
@@ -2623,12 +2693,13 @@ static void write_pixels_LOOKUP_ximage( RGBA_PIXEL_ARGS )
*/
static void write_pixels_LOOKUP8_ximage( RGBA_PIXEL_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
LOOKUP_SETUP;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x[i], y[i]);
*ptr = (GLubyte) LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
}
}
@@ -2641,11 +2712,12 @@ static void write_pixels_LOOKUP8_ximage( RGBA_PIXEL_ARGS )
static void write_pixels_GRAYSCALE_ximage( RGBA_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]),
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]),
GRAY_RGB( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
}
}
@@ -2657,11 +2729,12 @@ static void write_pixels_GRAYSCALE_ximage( RGBA_PIXEL_ARGS )
*/
static void write_pixels_GRAYSCALE8_ximage( RGBA_PIXEL_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x[i], y[i] );
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x[i], y[i] );
*ptr = (GLubyte) GRAY_RGB( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
}
}
@@ -2675,6 +2748,7 @@ static void write_pixels_GRAYSCALE8_ximage( RGBA_PIXEL_ARGS )
/**********************************************************************/
#define MONO_SPAN_ARGS const GLcontext *ctx, \
+ struct gl_renderbuffer *rb, \
GLuint n, GLint x, GLint y, const GLchan color[4], \
const GLubyte mask[]
@@ -2685,6 +2759,7 @@ static void write_pixels_GRAYSCALE8_ximage( RGBA_PIXEL_ARGS )
static void write_span_mono_pixmap( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -2692,7 +2767,7 @@ static void write_span_mono_pixmap( MONO_SPAN_ARGS )
color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
register GLuint i;
XMesaSetForeground( xmesa->display, gc, pixel );
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
/* New code contributed by Jeff Epler and cleaned up by Keith
* Whitwell.
@@ -2719,17 +2794,19 @@ static void write_span_mono_pixmap( MONO_SPAN_ARGS )
-static void write_span_mono_index_pixmap( const GLcontext *ctx, GLuint n,
- GLint x, GLint y, GLuint colorIndex,
- const GLubyte mask[] )
+static void
+write_span_mono_index_pixmap( const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLuint colorIndex,
+ const GLubyte mask[] )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
XMesaSetForeground( xmesa->display, gc, colorIndex );
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
for (i = 0 ; i < n ;) {
GLuint start = i;
@@ -2759,12 +2836,13 @@ static void write_span_mono_index_pixmap( const GLcontext *ctx, GLuint n,
static void write_span_mono_TRUEDITHER_pixmap( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
register GLuint i;
- int yy = FLIP(xmesa->xm_buffer, y);
+ int yy = YFLIP(xrb, y);
for (i=0;i<n;i++,x++) {
if (mask[i]) {
unsigned long p;
@@ -2782,12 +2860,13 @@ static void write_span_mono_TRUEDITHER_pixmap( MONO_SPAN_ARGS )
static void write_span_mono_DITHER_pixmap( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
register GLuint i;
- int yy = FLIP(xmesa->xm_buffer, y);
+ int yy = YFLIP(xrb, y);
XDITHER_SETUP(yy);
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -2804,13 +2883,14 @@ static void write_span_mono_DITHER_pixmap( MONO_SPAN_ARGS )
static void write_span_mono_1BIT_pixmap( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
register GLuint i;
SETUP_1BIT;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
for (i=0;i<n;i++,x++) {
if (mask[i]) {
XMesaSetForeground( dpy, gc, DITHER_1BIT( x, y, r, g, b ) );
@@ -2826,11 +2906,12 @@ static void write_span_mono_1BIT_pixmap( MONO_SPAN_ARGS )
static void write_span_mono_ximage( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
const unsigned long pixel = xmesa_color_to_pixel(xmesa, color[RCOMP],
color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
for (i=0;i<n;i++,x++) {
if (mask[i]) {
XMesaPutPixel( img, x, y, pixel );
@@ -2839,15 +2920,16 @@ static void write_span_mono_ximage( MONO_SPAN_ARGS )
}
-static void write_span_mono_index_ximage( const GLcontext *ctx, GLuint n,
- GLint x, GLint y,
- GLuint colorIndex,
- const GLubyte mask[] )
+static void
+write_span_mono_index_ximage( const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLuint colorIndex,
+ const GLubyte mask[] )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
for (i=0;i<n;i++,x++) {
if (mask[i]) {
XMesaPutPixel( img, x, y, colorIndex );
@@ -2862,10 +2944,11 @@ static void write_span_mono_index_ximage( const GLcontext *ctx, GLuint n,
static void write_span_mono_TRUEDITHER_ximage( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
const GLint r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p;
@@ -2881,11 +2964,12 @@ static void write_span_mono_TRUEDITHER_ximage( MONO_SPAN_ARGS )
*/
static void write_span_mono_8A8B8G8R_ximage( MONO_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
GLuint i, *ptr;
const unsigned long pixel = xmesa_color_to_pixel(xmesa, color[RCOMP],
color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
- ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
+ ptr = PIXEL_ADDR4(xrb, x, y );
for (i=0;i<n;i++) {
if (mask[i]) {
ptr[i] = pixel;
@@ -2898,11 +2982,12 @@ static void write_span_mono_8A8B8G8R_ximage( MONO_SPAN_ARGS )
*/
static void write_span_mono_8A8R8G8B_ximage( MONO_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
GLuint i, *ptr;
const unsigned long pixel = xmesa_color_to_pixel(xmesa, color[RCOMP],
color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
- ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
+ ptr = PIXEL_ADDR4(xrb, x, y );
for (i=0;i<n;i++) {
if (mask[i]) {
ptr[i] = pixel;
@@ -2916,9 +3001,9 @@ static void write_span_mono_8A8R8G8B_ximage( MONO_SPAN_ARGS )
*/
static void write_span_mono_8R8G8B_ximage( MONO_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const GLuint pixel = PACK_8R8G8B(color[RCOMP], color[GCOMP], color[BCOMP]);
- GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x, y );
+ GLuint *ptr = PIXEL_ADDR4(xrb, x, y );
GLuint i;
for (i=0;i<n;i++) {
if (!mask || mask[i]) {
@@ -2933,12 +3018,12 @@ static void write_span_mono_8R8G8B_ximage( MONO_SPAN_ARGS )
*/
static void write_span_mono_8R8G8B24_ximage( MONO_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const GLubyte r = color[RCOMP];
const GLubyte g = color[GCOMP];
const GLubyte b = color[BCOMP];
GLuint i;
- bgr_t *ptr = PIXELADDR3( xmesa->xm_buffer, x, y );
+ bgr_t *ptr = PIXEL_ADDR3(xrb, x, y );
for (i=0;i<n;i++) {
if (mask[i]) {
ptr[i].r = r;
@@ -2955,9 +3040,10 @@ static void write_span_mono_8R8G8B24_ximage( MONO_SPAN_ARGS )
static void write_span_mono_DITHER_ximage( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
XMesaImage *img = xmesa->xm_buffer->backimage;
- int yy = FLIP(xmesa->xm_buffer, y);
+ int yy = YFLIP(xrb, y);
register GLuint i;
XDITHER_SETUP(yy);
for (i=0;i<n;i++,x++) {
@@ -2973,9 +3059,10 @@ static void write_span_mono_DITHER_ximage( MONO_SPAN_ARGS )
*/
static void write_span_mono_DITHER8_ximage( MONO_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
- register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x,y);
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
register GLuint i;
XDITHER_SETUP(y);
for (i=0;i<n;i++,x++) {
@@ -2991,9 +3078,10 @@ static void write_span_mono_DITHER8_ximage( MONO_SPAN_ARGS )
*/
static void write_span_mono_LOOKUP8_ximage( MONO_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
- register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x,y);
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
GLubyte pixel;
LOOKUP_SETUP;
pixel = LOOKUP(color[RCOMP], color[GCOMP], color[BCOMP]);
@@ -3011,11 +3099,12 @@ static void write_span_mono_LOOKUP8_ximage( MONO_SPAN_ARGS )
static void write_span_mono_1BIT_ximage( MONO_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
SETUP_1BIT;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
for (i=0;i<n;i++,x++) {
if (mask[i]) {
XMesaPutPixel( img, x, y, DITHER_1BIT( x, y, r, g, b ) );
@@ -3029,9 +3118,10 @@ static void write_span_mono_1BIT_ximage( MONO_SPAN_ARGS )
*/
static void write_span_mono_HPCR_ximage( MONO_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
- register GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x,y);
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
register GLuint i;
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -3046,9 +3136,10 @@ static void write_span_mono_HPCR_ximage( MONO_SPAN_ARGS )
*/
static void write_span_mono_GRAYSCALE8_ximage( MONO_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
const GLubyte p = GRAY_RGB(color[RCOMP], color[GCOMP], color[BCOMP]);
- GLubyte *ptr = (GLubyte *) PIXELADDR1( xmesa->xm_buffer,x,y);
+ GLubyte *ptr = (GLubyte *) PIXEL_ADDR1(xrb, x, y);
GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
@@ -3064,11 +3155,12 @@ static void write_span_mono_GRAYSCALE8_ximage( MONO_SPAN_ARGS )
*/
static void write_span_mono_DITHER_5R6G5B_ximage( MONO_SPAN_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- register GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x, y );
+ register GLushort *ptr = PIXEL_ADDR2(xrb, x, y );
const GLint r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
for (i=0;i<n;i++) {
if (mask[i]) {
PACK_TRUEDITHER(ptr[i], x+i, y, r, g, b);
@@ -3083,6 +3175,7 @@ static void write_span_mono_DITHER_5R6G5B_ximage( MONO_SPAN_ARGS )
/**********************************************************************/
#define MONO_PIXEL_ARGS const GLcontext *ctx, \
+ struct gl_renderbuffer *rb, \
GLuint n, const GLint x[], const GLint y[], \
const GLchan color[4], const GLubyte mask[]
@@ -3092,6 +3185,7 @@ static void write_span_mono_DITHER_5R6G5B_ximage( MONO_SPAN_ARGS )
static void write_pixels_mono_pixmap( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -3102,19 +3196,19 @@ static void write_pixels_mono_pixmap( MONO_PIXEL_ARGS )
for (i=0;i<n;i++) {
if (mask[i]) {
XMesaDrawPoint( dpy, buffer, gc,
- (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
-static void write_pixels_mono_index_pixmap(const GLcontext *ctx,
- GLuint n,
- const GLint x[], const GLint y[],
- GLuint colorIndex,
- const GLubyte mask[] )
+static void
+write_pixels_mono_index_pixmap(const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ GLuint colorIndex, const GLubyte mask[] )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -3123,7 +3217,7 @@ static void write_pixels_mono_index_pixmap(const GLcontext *ctx,
for (i=0;i<n;i++) {
if (mask[i]) {
XMesaDrawPoint( dpy, buffer, gc,
- (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -3135,6 +3229,7 @@ static void write_pixels_mono_index_pixmap(const GLcontext *ctx,
static void write_pixels_mono_TRUEDITHER_pixmap( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -3146,7 +3241,7 @@ static void write_pixels_mono_TRUEDITHER_pixmap( MONO_PIXEL_ARGS )
PACK_TRUEDITHER(p, x[i], y[i], r, g, b);
XMesaSetForeground( dpy, gc, p );
XMesaDrawPoint( dpy, buffer, gc,
- (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -3158,6 +3253,7 @@ static void write_pixels_mono_TRUEDITHER_pixmap( MONO_PIXEL_ARGS )
static void write_pixels_mono_DITHER_pixmap( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -3167,7 +3263,7 @@ static void write_pixels_mono_DITHER_pixmap( MONO_PIXEL_ARGS )
for (i=0;i<n;i++) {
if (mask[i]) {
XMesaSetForeground( dpy, gc, DITHER( x[i], y[i], r, g, b ) );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -3179,6 +3275,7 @@ static void write_pixels_mono_DITHER_pixmap( MONO_PIXEL_ARGS )
static void write_pixels_mono_1BIT_pixmap( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -3188,7 +3285,7 @@ static void write_pixels_mono_1BIT_pixmap( MONO_PIXEL_ARGS )
for (i=0;i<n;i++) {
if (mask[i]) {
XMesaSetForeground( dpy, gc, DITHER_1BIT( x[i], y[i], r, g, b ) );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -3200,29 +3297,32 @@ static void write_pixels_mono_1BIT_pixmap( MONO_PIXEL_ARGS )
static void write_pixels_mono_ximage( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
const unsigned long pixel = xmesa_color_to_pixel(xmesa, color[RCOMP],
color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
for (i=0;i<n;i++) {
if (mask[i]) {
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), pixel );
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), pixel );
}
}
}
-static void write_pixels_mono_index_ximage( const GLcontext *ctx, GLuint n,
- const GLint x[], const GLint y[],
- GLuint colorIndex,
- const GLubyte mask[] )
+static void
+write_pixels_mono_index_ximage(const GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ GLuint colorIndex, const GLubyte mask[] )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), colorIndex );
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), colorIndex );
}
}
}
@@ -3234,14 +3334,15 @@ static void write_pixels_mono_index_ximage( const GLcontext *ctx, GLuint n,
static void write_pixels_mono_TRUEDITHER_ximage( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
const int r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p;
- PACK_TRUEDITHER(p, x[i], FLIP(xmesa->xm_buffer, y[i]), r, g, b);
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), p );
+ PACK_TRUEDITHER(p, x[i], YFLIP(xrb, y[i]), r, g, b);
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), p );
}
}
}
@@ -3253,13 +3354,13 @@ static void write_pixels_mono_TRUEDITHER_ximage( MONO_PIXEL_ARGS )
*/
static void write_pixels_mono_8A8B8G8R_ximage( MONO_PIXEL_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const GLuint p = PACK_8A8B8G8R(color[RCOMP], color[GCOMP],
color[BCOMP], color[ACOMP]);
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x[i], y[i] );
+ GLuint *ptr = PIXEL_ADDR4(xrb, x[i], y[i] );
*ptr = p;
}
}
@@ -3270,13 +3371,13 @@ static void write_pixels_mono_8A8B8G8R_ximage( MONO_PIXEL_ARGS )
*/
static void write_pixels_mono_8A8R8G8B_ximage( MONO_PIXEL_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const GLuint p = PACK_8A8R8G8B(color[RCOMP], color[GCOMP],
color[BCOMP], color[ACOMP]);
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x[i], y[i] );
+ GLuint *ptr = PIXEL_ADDR4(xrb, x[i], y[i] );
*ptr = p;
}
}
@@ -3287,12 +3388,12 @@ static void write_pixels_mono_8A8R8G8B_ximage( MONO_PIXEL_ARGS )
*/
static void write_pixels_mono_8R8G8B_ximage( MONO_PIXEL_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
const GLuint p = PACK_8R8G8B(color[RCOMP], color[GCOMP], color[BCOMP]);
for (i=0;i<n;i++) {
if (mask[i]) {
- GLuint *ptr = PIXELADDR4( xmesa->xm_buffer, x[i], y[i] );
+ GLuint *ptr = PIXEL_ADDR4(xrb, x[i], y[i] );
*ptr = p;
}
}
@@ -3304,12 +3405,12 @@ static void write_pixels_mono_8R8G8B_ximage( MONO_PIXEL_ARGS )
*/
static void write_pixels_mono_8R8G8B24_ximage( MONO_PIXEL_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- bgr_t *ptr = PIXELADDR3( xmesa->xm_buffer, x[i], y[i] );
+ bgr_t *ptr = PIXEL_ADDR3(xrb, x[i], y[i] );
ptr->r = r;
ptr->g = g;
ptr->b = b;
@@ -3324,13 +3425,14 @@ static void write_pixels_mono_8R8G8B24_ximage( MONO_PIXEL_ARGS )
static void write_pixels_mono_DITHER_ximage( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
DITHER_SETUP;
for (i=0;i<n;i++) {
if (mask[i]) {
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), DITHER( x[i], y[i], r, g, b ) );
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), DITHER( x[i], y[i], r, g, b ) );
}
}
}
@@ -3341,13 +3443,14 @@ static void write_pixels_mono_DITHER_ximage( MONO_PIXEL_ARGS )
*/
static void write_pixels_mono_DITHER8_ximage( MONO_PIXEL_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
register GLuint i;
DITHER_SETUP;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x[i], y[i]);
*ptr = (GLubyte) DITHER( x[i], y[i], r, g, b );
}
}
@@ -3359,6 +3462,7 @@ static void write_pixels_mono_DITHER8_ximage( MONO_PIXEL_ARGS )
*/
static void write_pixels_mono_LOOKUP8_ximage( MONO_PIXEL_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
GLubyte pixel;
@@ -3366,7 +3470,7 @@ static void write_pixels_mono_LOOKUP8_ximage( MONO_PIXEL_ARGS )
pixel = LOOKUP(color[RCOMP], color[GCOMP], color[BCOMP]);
for (i=0;i<n;i++) {
if (mask[i]) {
- GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x[i], y[i]);
*ptr = pixel;
}
}
@@ -3380,13 +3484,14 @@ static void write_pixels_mono_LOOKUP8_ximage( MONO_PIXEL_ARGS )
static void write_pixels_mono_1BIT_ximage( MONO_PIXEL_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
SETUP_1BIT;
for (i=0;i<n;i++) {
if (mask[i]) {
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]),
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]),
DITHER_1BIT( x[i], y[i], r, g, b ));
}
}
@@ -3398,12 +3503,13 @@ static void write_pixels_mono_1BIT_ximage( MONO_PIXEL_ARGS )
*/
static void write_pixels_mono_HPCR_ximage( MONO_PIXEL_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x[i], y[i]);
*ptr = DITHER_HPCR( x[i], y[i], r, g, b );
}
}
@@ -3415,12 +3521,13 @@ static void write_pixels_mono_HPCR_ximage( MONO_PIXEL_ARGS )
*/
static void write_pixels_mono_GRAYSCALE8_ximage( MONO_PIXEL_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
register GLuint i;
register GLubyte p = GRAY_RGB(color[RCOMP], color[GCOMP], color[BCOMP]);
for (i=0;i<n;i++) {
if (mask[i]) {
- GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer,x[i],y[i]);
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x[i], y[i]);
*ptr = p;
}
}
@@ -3432,12 +3539,13 @@ static void write_pixels_mono_GRAYSCALE8_ximage( MONO_PIXEL_ARGS )
*/
static void write_pixels_mono_DITHER_5R6G5B_ximage( MONO_PIXEL_ARGS )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
const int r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- GLushort *ptr = PIXELADDR2( xmesa->xm_buffer, x[i], y[i] );
+ GLushort *ptr = PIXEL_ADDR2(xrb, x[i], y[i] );
PACK_TRUEDITHER(*ptr, x[i], y[i], r, g, b);
}
}
@@ -3449,11 +3557,11 @@ static void write_pixels_mono_DITHER_5R6G5B_ximage( MONO_PIXEL_ARGS )
/*** Write INDEX SPAN functions ***/
/**********************************************************************/
-#define INDEX_SPAN_ARGS const GLcontext *ctx, \
+#define INDEX_SPAN_ARGS const GLcontext *ctx, struct gl_renderbuffer *rb, \
GLuint n, GLint x, GLint y, const GLuint index[], \
const GLubyte mask[]
-#define INDEX8_SPAN_ARGS const GLcontext *ctx, \
+#define INDEX8_SPAN_ARGS const GLcontext *ctx, struct gl_renderbuffer *rb, \
GLuint n, GLint x, GLint y, const GLubyte index[], \
const GLubyte mask[]
@@ -3464,11 +3572,12 @@ static void write_pixels_mono_DITHER_5R6G5B_ximage( MONO_PIXEL_ARGS )
static void write_span_index_pixmap( INDEX_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -3492,11 +3601,12 @@ static void write_span_index_pixmap( INDEX_SPAN_ARGS )
static void write_span_index8_pixmap( INDEX8_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -3520,9 +3630,10 @@ static void write_span_index8_pixmap( INDEX8_SPAN_ARGS )
static void write_span_index_ximage( INDEX_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
- y = FLIP(xmesa->xm_buffer, y);
+ y = YFLIP(xrb, y);
if (mask) {
for (i=0;i<n;i++,x++) {
if (mask[i]) {
@@ -3544,6 +3655,8 @@ static void write_span_index_ximage( INDEX_SPAN_ARGS )
static void write_span_index8_ximage( INDEX8_SPAN_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ y = YFLIP(xrb, y);
if (mask) {
GLuint i;
for (i=0;i<n;i++) {
@@ -3565,8 +3678,8 @@ static void write_span_index8_ximage( INDEX8_SPAN_ARGS )
*/
static void write_span_index8_ximage8( INDEX8_SPAN_ARGS )
{
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GLubyte *dst = PIXELADDR1( xmesa->xm_buffer,x,y);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ GLubyte *dst = PIXEL_ADDR1(xrb, x, y);
if (mask) {
GLuint i;
for (i=0;i<n;i++) {
@@ -3587,6 +3700,7 @@ static void write_span_index8_ximage8( INDEX8_SPAN_ARGS )
/**********************************************************************/
#define INDEX_PIXELS_ARGS const GLcontext *ctx, \
+ struct gl_renderbuffer *rb, \
GLuint n, const GLint x[], const GLint y[], \
const GLuint index[], const GLubyte mask[]
@@ -3597,6 +3711,7 @@ static void write_span_index8_ximage8( INDEX8_SPAN_ARGS )
static void write_pixels_index_pixmap( INDEX_PIXELS_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaDisplay *dpy = xmesa->xm_visual->display;
XMesaDrawable buffer = xmesa->xm_buffer->buffer;
XMesaGC gc = xmesa->xm_buffer->gc;
@@ -3604,7 +3719,7 @@ static void write_pixels_index_pixmap( INDEX_PIXELS_ARGS )
for (i=0;i<n;i++) {
if (mask[i]) {
XMesaSetForeground( dpy, gc, (unsigned long) index[i] );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) FLIP(xmesa->xm_buffer, y[i]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
}
}
}
@@ -3616,11 +3731,12 @@ static void write_pixels_index_pixmap( INDEX_PIXELS_ARGS )
static void write_pixels_index_ximage( INDEX_PIXELS_ARGS )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaImage *img = xmesa->xm_buffer->backimage;
register GLuint i;
for (i=0;i<n;i++) {
if (mask[i]) {
- XMesaPutPixel( img, x[i], FLIP(xmesa->xm_buffer, y[i]), (unsigned long) index[i] );
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), (unsigned long) index[i] );
}
}
}
@@ -3651,7 +3767,7 @@ clip_for_xgetimage(XMesaContext xmesa, GLuint *n, GLint *x, GLint *y)
GLint dx, dy;
if (source->type == PBUFFER || source->type == PIXMAP)
return 0;
- XTranslateCoordinates(xmesa->display, source->buffer, rootWin,
+ XTranslateCoordinates(xmesa->display, source->frontbuffer, rootWin,
*x, *y, &dx, &dy, &child);
if (dx >= screenWidth) {
/* totally clipped on right */
@@ -3680,14 +3796,16 @@ clip_for_xgetimage(XMesaContext xmesa, GLuint *n, GLint *x, GLint *y)
/*
* Read a horizontal span of color-index pixels.
*/
-static void read_index_span( const GLcontext *ctx,
- GLuint n, GLint x, GLint y, GLuint index[] )
+static void
+read_index_span(const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLuint index[])
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaBuffer source = xmesa->xm_buffer;
GLuint i;
- y = FLIP(source, y);
+ y = YFLIP(xrb, y);
if (source->buffer) {
#ifndef XFree86Server
@@ -3735,11 +3853,12 @@ static void read_index_span( const GLcontext *ctx,
/*
* Read a horizontal span of color pixels.
*/
-static void read_color_span( const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
- GLubyte rgba[][4] )
+static void
+read_color_span( const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLubyte rgba[][4] )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
XMesaBuffer source = xmesa->xm_buffer;
if (source->buffer) {
@@ -3751,11 +3870,11 @@ static void read_color_span( const GLcontext *ctx,
span->data = (char *)MALLOC(span->height * span->bytes_per_line);
error = (!span->data);
(*xmesa->display->GetImage)(source->buffer,
- x, FLIP(source, y), n, 1, ZPixmap,
+ x, YFLIP(xrb, y), n, 1, ZPixmap,
~0L, (pointer)span->data);
#else
int k;
- y = FLIP(source, y);
+ y = YFLIP(xrb, y);
k = clip_for_xgetimage(xmesa, &n, &x, &y);
if (k < 0)
return;
@@ -3952,7 +4071,7 @@ static void read_color_span( const GLcontext *ctx,
GLint bShift = xmesa->xm_visual->bshift;
XMesaImage *img = source->backimage;
GLuint i;
- y = FLIP(source, y);
+ y = YFLIP(xrb, y);
for (i=0;i<n;i++) {
unsigned long p;
p = XMesaGetPixel( img, x+i, y );
@@ -3969,7 +4088,7 @@ static void read_color_span( const GLcontext *ctx,
const GLubyte *pixelToR = xmesa->xm_visual->PixelToR;
const GLubyte *pixelToG = xmesa->xm_visual->PixelToG;
const GLubyte *pixelToB = xmesa->xm_visual->PixelToB;
- const GLushort *ptr2 = PIXELADDR2( source, x, y );
+ const GLushort *ptr2 = PIXEL_ADDR2(xrb, x, y);
GLuint i;
#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
const GLuint *ptr4 = (const GLuint *) ptr2;
@@ -4013,7 +4132,7 @@ static void read_color_span( const GLcontext *ctx,
break;
case PF_8A8B8G8R:
{
- const GLuint *ptr4 = PIXELADDR4( source, x, y );
+ const GLuint *ptr4 = PIXEL_ADDR4(xrb, x, y);
GLuint i;
for (i=0;i<n;i++) {
GLuint p4 = *ptr4++;
@@ -4026,7 +4145,7 @@ static void read_color_span( const GLcontext *ctx,
break;
case PF_8A8R8G8B:
{
- const GLuint *ptr4 = PIXELADDR4( source, x, y );
+ const GLuint *ptr4 = PIXEL_ADDR4(xrb, x, y);
GLuint i;
for (i=0;i<n;i++) {
GLuint p4 = *ptr4++;
@@ -4039,7 +4158,7 @@ static void read_color_span( const GLcontext *ctx,
break;
case PF_8R8G8B:
{
- const GLuint *ptr4 = PIXELADDR4( source, x, y );
+ const GLuint *ptr4 = PIXEL_ADDR4(xrb, x, y);
GLuint i;
for (i=0;i<n;i++) {
GLuint p4 = *ptr4++;
@@ -4052,7 +4171,7 @@ static void read_color_span( const GLcontext *ctx,
break;
case PF_8R8G8B24:
{
- const bgr_t *ptr3 = PIXELADDR3( source, x, y );
+ const bgr_t *ptr3 = PIXEL_ADDR3(xrb, x, y);
GLuint i;
for (i=0;i<n;i++) {
rgba[i][RCOMP] = ptr3[i].r;
@@ -4064,7 +4183,7 @@ static void read_color_span( const GLcontext *ctx,
break;
case PF_HPCR:
{
- const GLubyte *ptr1 = PIXELADDR1( source, x, y );
+ const GLubyte *ptr1 = PIXEL_ADDR1(xrb, x, y);
GLuint i;
for (i=0;i<n;i++) {
GLubyte p = *ptr1++;
@@ -4083,7 +4202,7 @@ static void read_color_span( const GLcontext *ctx,
const GLubyte *gTable = source->pixel_to_g;
const GLubyte *bTable = source->pixel_to_b;
if (GET_VISUAL_DEPTH(xmesa->xm_visual)==8) {
- GLubyte *ptr1 = PIXELADDR1( source, x, y );
+ GLubyte *ptr1 = PIXEL_ADDR1(xrb, x, y);
GLuint i;
for (i=0;i<n;i++) {
unsigned long p = *ptr1++;
@@ -4096,7 +4215,7 @@ static void read_color_span( const GLcontext *ctx,
else {
XMesaImage *img = source->backimage;
GLuint i;
- y = FLIP(source, y);
+ y = YFLIP(xrb, y);
for (i=0;i<n;i++,x++) {
unsigned long p = XMesaGetPixel( img, x, y );
rgba[i][RCOMP] = rTable[p];
@@ -4112,7 +4231,7 @@ static void read_color_span( const GLcontext *ctx,
XMesaImage *img = source->backimage;
int bitFlip = xmesa->xm_visual->bitFlip;
GLuint i;
- y = FLIP(source, y);
+ y = YFLIP(xrb, y);
for (i=0;i<n;i++,x++) {
unsigned long p;
p = XMesaGetPixel( img, x, y ) ^ bitFlip;
@@ -4135,11 +4254,13 @@ static void read_color_span( const GLcontext *ctx,
/*
* Read an array of color index pixels.
*/
-static void read_index_pixels( const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- GLuint indx[], const GLubyte mask[] )
+static void
+read_index_pixels( const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ GLuint indx[], const GLubyte mask[] )
{
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
register GLuint i;
XMesaBuffer source = xmesa->xm_buffer;
@@ -4148,7 +4269,7 @@ static void read_index_pixels( const GLcontext *ctx,
if (mask[i]) {
indx[i] = (GLuint) read_pixel( xmesa->display,
source->buffer,
- x[i], FLIP(source, y[i]) );
+ x[i], YFLIP(xrb, y[i]) );
}
}
}
@@ -4156,7 +4277,7 @@ static void read_index_pixels( const GLcontext *ctx,
XMesaImage *img = source->backimage;
for (i=0;i<n;i++) {
if (mask[i]) {
- indx[i] = (GLuint) XMesaGetPixel( img, x[i], FLIP(source, y[i]) );
+ indx[i] = (GLuint) XMesaGetPixel( img, x[i], YFLIP(xrb, y[i]) );
}
}
}
@@ -4164,10 +4285,12 @@ static void read_index_pixels( const GLcontext *ctx,
-static void read_color_pixels( const GLcontext *ctx,
- GLuint n, const GLint x[], const GLint y[],
- GLubyte rgba[][4], const GLubyte mask[] )
+static void
+read_color_pixels( const GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ GLubyte rgba[][4], const GLubyte mask[] )
{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
XMesaDisplay *dpy = xmesa->xm_visual->display;
register GLuint i;
@@ -4193,7 +4316,7 @@ static void read_color_pixels( const GLcontext *ctx,
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p = read_pixel( dpy, buffer,
- x[i], FLIP(source, y[i]) );
+ x[i], YFLIP(xrb, y[i]) );
rgba[i][RCOMP] = pixelToR[(p & rMask) >> rShift];
rgba[i][GCOMP] = pixelToG[(p & gMask) >> gShift];
rgba[i][BCOMP] = pixelToB[(p & bMask) >> bShift];
@@ -4206,7 +4329,7 @@ static void read_color_pixels( const GLcontext *ctx,
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p = read_pixel( dpy, buffer,
- x[i], FLIP(source, y[i]) );
+ x[i], YFLIP(xrb, y[i]) );
rgba[i][RCOMP] = (GLubyte) ( p & 0xff);
rgba[i][GCOMP] = (GLubyte) ((p >> 8) & 0xff);
rgba[i][BCOMP] = (GLubyte) ((p >> 16) & 0xff);
@@ -4218,7 +4341,7 @@ static void read_color_pixels( const GLcontext *ctx,
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p = read_pixel( dpy, buffer,
- x[i], FLIP(source, y[i]) );
+ x[i], YFLIP(xrb, y[i]) );
rgba[i][RCOMP] = (GLubyte) ((p >> 16) & 0xff);
rgba[i][GCOMP] = (GLubyte) ((p >> 8) & 0xff);
rgba[i][BCOMP] = (GLubyte) ( p & 0xff);
@@ -4230,7 +4353,7 @@ static void read_color_pixels( const GLcontext *ctx,
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p = read_pixel( dpy, buffer,
- x[i], FLIP(source, y[i]) );
+ x[i], YFLIP(xrb, y[i]) );
rgba[i][RCOMP] = (GLubyte) ((p >> 16) & 0xff);
rgba[i][GCOMP] = (GLubyte) ((p >> 8) & 0xff);
rgba[i][BCOMP] = (GLubyte) ( p & 0xff);
@@ -4242,7 +4365,7 @@ static void read_color_pixels( const GLcontext *ctx,
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p = read_pixel( dpy, buffer,
- x[i], FLIP(source, y[i]) );
+ x[i], YFLIP(xrb, y[i]) );
rgba[i][RCOMP] = (GLubyte) ((p >> 16) & 0xff);
rgba[i][GCOMP] = (GLubyte) ((p >> 8) & 0xff);
rgba[i][BCOMP] = (GLubyte) ( p & 0xff);
@@ -4255,7 +4378,7 @@ static void read_color_pixels( const GLcontext *ctx,
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p = read_pixel( dpy, buffer,
- x[i], FLIP(source, y[i]) );
+ x[i], YFLIP(xrb, y[i]) );
rgba[i][RCOMP] = (GLubyte) ( p & 0xE0 );
rgba[i][GCOMP] = (GLubyte) ((p & 0x1C) << 3);
rgba[i][BCOMP] = (GLubyte) ((p & 0x03) << 6);
@@ -4274,7 +4397,7 @@ static void read_color_pixels( const GLcontext *ctx,
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p = read_pixel( dpy, buffer,
- x[i], FLIP(source, y[i]) );
+ x[i], YFLIP(xrb, y[i]) );
rgba[i][RCOMP] = rTable[p];
rgba[i][GCOMP] = gTable[p];
rgba[i][BCOMP] = bTable[p];
@@ -4289,7 +4412,7 @@ static void read_color_pixels( const GLcontext *ctx,
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p = read_pixel( dpy, buffer,
- x[i], FLIP(source, y[i])) ^ bitFlip;
+ x[i], YFLIP(xrb, y[i])) ^ bitFlip;
rgba[i][RCOMP] = (GLubyte) (p * 255);
rgba[i][GCOMP] = (GLubyte) (p * 255);
rgba[i][BCOMP] = (GLubyte) (p * 255);
@@ -4304,6 +4427,7 @@ static void read_color_pixels( const GLcontext *ctx,
}
}
else if (source->backimage) {
+ /* Read from XImage back buffer */
switch (xmesa->pixelformat) {
case PF_Truecolor:
case PF_Dither_True:
@@ -4323,7 +4447,7 @@ static void read_color_pixels( const GLcontext *ctx,
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p;
- p = XMesaGetPixel( img, x[i], FLIP(source, y[i]) );
+ p = XMesaGetPixel( img, x[i], YFLIP(xrb, y[i]) );
rgba[i][RCOMP] = pixelToR[(p & rMask) >> rShift];
rgba[i][GCOMP] = pixelToG[(p & gMask) >> gShift];
rgba[i][BCOMP] = pixelToB[(p & bMask) >> bShift];
@@ -4335,7 +4459,7 @@ static void read_color_pixels( const GLcontext *ctx,
case PF_8A8B8G8R:
for (i=0;i<n;i++) {
if (mask[i]) {
- GLuint *ptr4 = PIXELADDR4( source, x[i], y[i] );
+ GLuint *ptr4 = PIXEL_ADDR4(xrb, x[i], y[i]);
GLuint p4 = *ptr4;
rgba[i][RCOMP] = (GLubyte) ( p4 & 0xff);
rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
@@ -4347,7 +4471,7 @@ static void read_color_pixels( const GLcontext *ctx,
case PF_8A8R8G8B:
for (i=0;i<n;i++) {
if (mask[i]) {
- GLuint *ptr4 = PIXELADDR4( source, x[i], y[i] );
+ GLuint *ptr4 = PIXEL_ADDR4(xrb, x[i], y[i]);
GLuint p4 = *ptr4;
rgba[i][RCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
@@ -4359,7 +4483,7 @@ static void read_color_pixels( const GLcontext *ctx,
case PF_8R8G8B:
for (i=0;i<n;i++) {
if (mask[i]) {
- GLuint *ptr4 = PIXELADDR4( source, x[i], y[i] );
+ GLuint *ptr4 = PIXEL_ADDR4(xrb, x[i], y[i]);
GLuint p4 = *ptr4;
rgba[i][RCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
@@ -4371,7 +4495,7 @@ static void read_color_pixels( const GLcontext *ctx,
case PF_8R8G8B24:
for (i=0;i<n;i++) {
if (mask[i]) {
- bgr_t *ptr3 = PIXELADDR3( source, x[i], y[i] );
+ bgr_t *ptr3 = PIXEL_ADDR3(xrb, x[i], y[i]);
rgba[i][RCOMP] = ptr3->r;
rgba[i][GCOMP] = ptr3->g;
rgba[i][BCOMP] = ptr3->b;
@@ -4382,7 +4506,7 @@ static void read_color_pixels( const GLcontext *ctx,
case PF_HPCR:
for (i=0;i<n;i++) {
if (mask[i]) {
- GLubyte *ptr1 = PIXELADDR1( source, x[i], y[i] );
+ GLubyte *ptr1 = PIXEL_ADDR1(xrb, x[i], y[i]);
GLubyte p = *ptr1;
rgba[i][RCOMP] = p & 0xE0;
rgba[i][GCOMP] = (p & 0x1C) << 3;
@@ -4402,7 +4526,7 @@ static void read_color_pixels( const GLcontext *ctx,
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p;
- p = XMesaGetPixel( img, x[i], FLIP(source, y[i]) );
+ p = XMesaGetPixel( img, x[i], YFLIP(xrb, y[i]) );
rgba[i][RCOMP] = rTable[p];
rgba[i][GCOMP] = gTable[p];
rgba[i][BCOMP] = bTable[p];
@@ -4418,7 +4542,7 @@ static void read_color_pixels( const GLcontext *ctx,
for (i=0;i<n;i++) {
if (mask[i]) {
unsigned long p;
- p = XMesaGetPixel( img, x[i], FLIP(source, y[i]) ) ^ bitFlip;
+ p = XMesaGetPixel( img, x[i], YFLIP(xrb, y[i]) ) ^ bitFlip;
rgba[i][RCOMP] = (GLubyte) (p * 255);
rgba[i][GCOMP] = (GLubyte) (p * 255);
rgba[i][BCOMP] = (GLubyte) (p * 255);
@@ -4516,6 +4640,25 @@ void xmesa_update_span_funcs( GLcontext *ctx )
int depth=GET_VISUAL_DEPTH(xmesa->xm_visual);
struct swrast_device_driver *dd = _swrast_GetDeviceDriverReference( ctx );
+ if (ctx->DrawBuffer->Name != 0) {
+ /* drawing to user framebuffer */
+ dd->WriteCI32Span = NULL;
+ dd->WriteCI8Span = NULL;
+ dd->WriteMonoCISpan = NULL;
+ dd->WriteCI32Pixels = NULL;
+ dd->WriteMonoCIPixels = NULL;
+ dd->WriteRGBASpan = NULL;
+ dd->WriteRGBSpan = NULL;
+ dd->WriteMonoRGBASpan = NULL;
+ dd->WriteRGBAPixels = NULL;
+ dd->WriteMonoRGBAPixels = NULL;
+ dd->ReadCI32Span = NULL;
+ dd->ReadRGBASpan = NULL;
+ dd->ReadCI32Pixels = NULL;
+ dd->ReadRGBAPixels = NULL;
+ return;
+ }
+
/*
* These drawing functions depend on color buffer config:
*/
@@ -4624,7 +4767,7 @@ void xmesa_update_span_funcs( GLcontext *ctx )
dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
break;
default:
- _mesa_problem(NULL,"Bad pixel format in xmesa_update_state (1)");
+ _mesa_problem(ctx, "Bad pixel format in xmesa_update_state (1)");
return;
}
}
@@ -4764,7 +4907,7 @@ void xmesa_update_span_funcs( GLcontext *ctx )
}
break;
default:
- _mesa_problem(NULL,"Bad pixel format in xmesa_update_state (2)");
+ _mesa_problem(ctx, "Bad pixel format in xmesa_update_state (2)");
return;
}
}
@@ -4775,3 +4918,380 @@ void xmesa_update_span_funcs( GLcontext *ctx )
dd->ReadCI32Pixels = read_index_pixels;
dd->ReadRGBAPixels = read_color_pixels;
}
+
+
+#if 000
+/**
+ * Initialize the renderbuffer's PutRow, GetRow, etc. functions
+ */
+static void
+xmesa_set_renderbuffer_funcs(GLcontext *ctx, struct xmesa_renderbuffer *xrb,
+ GLboolean pixmap, enum pixel_format pixelformat)
+{
+#if 0
+ XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
+
+#endif
+
+ switch (pixelformat) {
+ case PF_Index:
+ if (pixmap) {
+ /*
+ dd->WriteCI32Span = write_span_index_pixmap;
+ dd->WriteCI8Span = write_span_index8_pixmap;
+ dd->WriteMonoCISpan = write_span_mono_index_pixmap;
+ dd->WriteCI32Pixels = write_pixels_index_pixmap;
+ dd->WriteMonoCIPixels = write_pixels_mono_index_pixmap;
+ */
+ }
+ else {
+ }
+ break;
+ case PF_Truecolor:
+ if (pixmap) {
+ /*
+ dd->WriteRGBASpan = write_span_TRUECOLOR_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_TRUECOLOR_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_pixmap;
+ dd->WriteRGBAPixels = write_pixels_TRUECOLOR_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ */
+ }
+ else {
+ }
+ break;
+ case PF_Dither_True:
+ if (pixmap) {
+ /*
+ dd->WriteRGBASpan = write_span_TRUEDITHER_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_TRUEDITHER_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_TRUEDITHER_pixmap;
+ dd->WriteRGBAPixels = write_pixels_TRUEDITHER_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_TRUEDITHER_pixmap;
+ */
+ }
+ else {
+ }
+ break;
+ case PF_8A8B8G8R:
+ if (pixmap) {
+ /*
+ dd->WriteRGBASpan = write_span_8A8B8G8R_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_8A8B8G8R_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_pixmap;
+ dd->WriteRGBAPixels = write_pixels_8A8B8G8R_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ */
+ }
+ else {
+ }
+ break;
+ case PF_8A8R8G8B:
+ if (pixmap) {
+ /*
+ dd->WriteRGBASpan = write_span_8A8R8G8B_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_8A8R8G8B_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_pixmap;
+ dd->WriteRGBAPixels = write_pixels_8A8R8G8B_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ */
+ }
+ else {
+ }
+ break;
+ case PF_8R8G8B:
+ /*
+ dd->WriteRGBASpan = write_span_8R8G8B_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_8R8G8B_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_pixmap;
+ dd->WriteRGBAPixels = write_pixels_8R8G8B_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ */
+ if (pixmap) {
+ xrb->Base.PutRow = put_row_8R8G8B_pixmap;
+ xrb->Base.PutMonoRow = put_mono_row_pixmap;
+ xrb->Base.PutValues = put_values_8R8G8B_pixmap;
+ xrb->Base.PutMonoValues = put_mono_values_pixmap;
+ }
+ break;
+ case PF_8R8G8B24:
+ if (pixmap) {
+ /*
+ dd->WriteRGBASpan = write_span_8R8G8B24_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_8R8G8B24_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_pixmap;
+ dd->WriteRGBAPixels = write_pixels_8R8G8B24_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ */
+ }
+ else {
+ }
+ break;
+ case PF_5R6G5B:
+ if (pixmap) {
+ /*
+ dd->WriteRGBASpan = write_span_5R6G5B_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_5R6G5B_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_pixmap;
+ dd->WriteRGBAPixels = write_pixels_5R6G5B_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ */
+ }
+ else {
+ }
+ break;
+ case PF_Dither_5R6G5B:
+ if (pixmap) {
+ /*
+ dd->WriteRGBASpan = write_span_DITHER_5R6G5B_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_DITHER_5R6G5B_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_TRUEDITHER_pixmap;
+ dd->WriteRGBAPixels = write_pixels_DITHER_5R6G5B_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_TRUEDITHER_pixmap;
+ */
+ }
+ else {
+ }
+ break;
+ case PF_Dither:
+ if (pixmap) {
+ /*
+ dd->WriteRGBASpan = write_span_DITHER_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_DITHER_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_DITHER_pixmap;
+ dd->WriteRGBAPixels = write_pixels_DITHER_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_DITHER_pixmap;
+ */
+ }
+ else {
+ }
+ break;
+ case PF_1Bit:
+ if (pixmap) {
+ /*
+ dd->WriteRGBASpan = write_span_1BIT_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_1BIT_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_1BIT_pixmap;
+ dd->WriteRGBAPixels = write_pixels_1BIT_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_1BIT_pixmap;
+ */
+ }
+ else {
+ }
+ break;
+ case PF_HPCR:
+ if (pixmap) {
+ /*
+ dd->WriteRGBASpan = write_span_HPCR_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_HPCR_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_pixmap;
+ dd->WriteRGBAPixels = write_pixels_HPCR_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ */
+ }
+ else {
+ }
+ ctx->Driver.ClearColor = clear_color_HPCR_pixmap;
+ }
+ break;
+ case PF_Lookup:
+ if (pixmap) {
+ /*
+ dd->WriteRGBASpan = write_span_LOOKUP_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_LOOKUP_pixmap;
+ dd->WriteRGBAPixels = write_pixels_LOOKUP_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ */
+ }
+ else {
+ }
+ break;
+ case PF_Grayscale:
+ if (pixmap) {
+ /*
+ dd->WriteRGBASpan = write_span_GRAYSCALE_pixmap;
+ dd->WriteRGBSpan = write_span_rgb_GRAYSCALE_pixmap;
+ dd->WriteMonoRGBASpan = write_span_mono_pixmap;
+ dd->WriteRGBAPixels = write_pixels_GRAYSCALE_pixmap;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_pixmap;
+ */
+ }
+ else {
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "Bad pixel format in xmesa_update_state (1)");
+ return;
+ }
+
+#if 0000
+#if 0
+ /* Generic RGB */
+ dd->WriteRGBASpan = write_span_TRUECOLOR_ximage;
+ dd->WriteRGBSpan = write_span_rgb_TRUECOLOR_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_ximage;
+ dd->WriteRGBAPixels = write_pixels_TRUECOLOR_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_ximage;
+#endif
+ break;
+ case PF_Dither_True:
+#if 0
+ dd->WriteRGBASpan = write_span_TRUEDITHER_ximage;
+ dd->WriteRGBSpan = write_span_rgb_TRUEDITHER_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_TRUEDITHER_ximage;
+ dd->WriteRGBAPixels = write_pixels_TRUEDITHER_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_TRUEDITHER_ximage;
+#endif
+ break;
+ case PF_8A8B8G8R:
+#if 0
+ dd->WriteRGBASpan = write_span_8A8B8G8R_ximage;
+ dd->WriteRGBSpan = write_span_rgb_8A8B8G8R_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_8A8B8G8R_ximage;
+ dd->WriteRGBAPixels = write_pixels_8A8B8G8R_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_8A8B8G8R_ximage;
+#endif
+ break;
+ case PF_8A8R8G8B:
+#if 0
+ dd->WriteRGBASpan = write_span_8A8R8G8B_ximage;
+ dd->WriteRGBSpan = write_span_rgb_8A8R8G8B_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_8A8R8G8B_ximage;
+ dd->WriteRGBAPixels = write_pixels_8A8R8G8B_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_8A8R8G8B_ximage;
+#endif
+ break;
+ case PF_8R8G8B:
+#if 0
+ dd->WriteRGBASpan = write_span_8R8G8B_ximage;
+ dd->WriteRGBSpan = write_span_rgb_8R8G8B_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_8R8G8B_ximage;
+ dd->WriteRGBAPixels = write_pixels_8R8G8B_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_8R8G8B_ximage;
+#endif
+ break;
+ case PF_8R8G8B24:
+#if 0
+ dd->WriteRGBASpan = write_span_8R8G8B24_ximage;
+ dd->WriteRGBSpan = write_span_rgb_8R8G8B24_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_8R8G8B24_ximage;
+ dd->WriteRGBAPixels = write_pixels_8R8G8B24_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_8R8G8B24_ximage;
+#endif
+ break;
+ case PF_5R6G5B:
+#if 0
+ dd->WriteRGBASpan = write_span_5R6G5B_ximage;
+ dd->WriteRGBSpan = write_span_rgb_5R6G5B_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_ximage;
+ dd->WriteRGBAPixels = write_pixels_5R6G5B_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_ximage;
+#endif
+ break;
+ case PF_Dither_5R6G5B:
+#if 0
+ dd->WriteRGBASpan = write_span_DITHER_5R6G5B_ximage;
+ dd->WriteRGBSpan = write_span_rgb_DITHER_5R6G5B_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_DITHER_5R6G5B_ximage;
+ dd->WriteRGBAPixels = write_pixels_DITHER_5R6G5B_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_DITHER_5R6G5B_ximage;
+#endif
+ break;
+ case PF_Dither:
+#if 0
+ if (depth==8) {
+ dd->WriteRGBASpan = write_span_DITHER8_ximage;
+ dd->WriteRGBSpan = write_span_rgb_DITHER8_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_DITHER8_ximage;
+ dd->WriteRGBAPixels = write_pixels_DITHER8_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_DITHER8_ximage;
+ }
+ else {
+ dd->WriteRGBASpan = write_span_DITHER_ximage;
+ dd->WriteRGBSpan = write_span_rgb_DITHER_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_DITHER_ximage;
+ dd->WriteRGBAPixels = write_pixels_DITHER_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_DITHER_ximage;
+ }
+#endif
+ break;
+ case PF_1Bit:
+#if 0
+ dd->WriteRGBASpan = write_span_1BIT_ximage;
+ dd->WriteRGBSpan = write_span_rgb_1BIT_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_1BIT_ximage;
+ dd->WriteRGBAPixels = write_pixels_1BIT_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_1BIT_ximage;
+#endif
+ break;
+ case PF_HPCR:
+#if 0
+ dd->WriteRGBASpan = write_span_HPCR_ximage;
+ dd->WriteRGBSpan = write_span_rgb_HPCR_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_HPCR_ximage;
+ dd->WriteRGBAPixels = write_pixels_HPCR_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_HPCR_ximage;
+ if (xmesa->xm_visual->hpcr_clear_flag) {
+ ctx->Driver.ClearColor = clear_color_HPCR_ximage;
+ }
+#endif
+ break;
+ case PF_Lookup:
+#if 0
+ if (depth==8) {
+ dd->WriteRGBASpan = write_span_LOOKUP8_ximage;
+ dd->WriteRGBSpan = write_rgb_LOOKUP8_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_LOOKUP8_ximage;
+ dd->WriteRGBAPixels = write_pixels_LOOKUP8_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_LOOKUP8_ximage;
+ }
+ else {
+ dd->WriteRGBASpan = write_span_LOOKUP_ximage;
+ dd->WriteRGBSpan = write_span_rgb_LOOKUP_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_ximage;
+ dd->WriteRGBAPixels = write_pixels_LOOKUP_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_ximage;
+ }
+#endif
+ break;
+ case PF_Grayscale:
+#if 0
+ if (depth==8) {
+ dd->WriteRGBASpan = write_span_GRAYSCALE8_ximage;
+ dd->WriteRGBSpan = write_span_rgb_GRAYSCALE8_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_GRAYSCALE8_ximage;
+ dd->WriteRGBAPixels = write_pixels_GRAYSCALE8_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_GRAYSCALE8_ximage;
+ }
+ else {
+ dd->WriteRGBASpan = write_span_GRAYSCALE_ximage;
+ dd->WriteRGBSpan = write_span_rgb_GRAYSCALE_ximage;
+ dd->WriteMonoRGBASpan = write_span_mono_ximage;
+ dd->WriteRGBAPixels = write_pixels_GRAYSCALE_ximage;
+ dd->WriteMonoRGBAPixels = write_pixels_mono_ximage;
+ }
+#endif
+ break;
+ default:
+ _mesa_problem(ctx, "Bad pixel format in xmesa_update_state (2)");
+ return;
+ }
+ }
+#endif
+
+
+ /* Pixel/span reading functions: */
+#if 0
+ rb->ReadCI32Span = read_index_span;
+ dd->ReadRGBASpan = read_color_span;
+ dd->ReadCI32Pixels = read_index_pixels;
+ dd->ReadRGBAPixels = read_color_pixels;
+#else
+ rb->GetRow = get_row_color;
+ rb->GetValues = get_values_color;
+#endif
+}
+
+#endif
+
diff --git a/src/mesa/drivers/x11/xm_tri.c b/src/mesa/drivers/x11/xm_tri.c
index 8fd22ccf4e..8b5c39392a 100644
--- a/src/mesa/drivers/x11/xm_tri.c
+++ b/src/mesa/drivers/x11/xm_tri.c
@@ -44,6 +44,9 @@
#include "swrast/s_triangle.h"
+#define GET_XRB(XRB) struct xmesa_renderbuffer *XRB = \
+ (struct xmesa_renderbuffer *) ctx->DrawBuffer->_ColorDrawBuffers[0][0]
+
/**********************************************************************/
/*** Triangle rendering ***/
@@ -59,10 +62,10 @@
#define INTERP_RGB 1
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- XMesaImage *img = xmesa->xm_buffer->backimage;
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
GLuint i; \
for (i = 0; i < span.end; i++, x++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
@@ -70,7 +73,7 @@
unsigned long p; \
PACK_TRUECOLOR(p, FixedToInt(span.red), \
FixedToInt(span.green), FixedToInt(span.blue)); \
- XMesaPutPixel(img, x, y, p); \
+ XMesaPutPixel(xrb->ximage, x, y, p); \
zRow[i] = z; \
} \
span.red += span.redStep; \
@@ -91,12 +94,11 @@
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
-
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
@@ -123,11 +125,11 @@
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
@@ -155,11 +157,11 @@
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
@@ -187,11 +189,11 @@
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR3(xrb, X, Y)
#define PIXEL_TYPE bgr_t
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
@@ -221,17 +223,17 @@
#define INTERP_RGB 1
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- XMesaImage *img = xmesa->xm_buffer->backimage;
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
unsigned long p; \
PACK_TRUEDITHER(p, x, y, FixedToInt(span.red), \
FixedToInt(span.green), FixedToInt(span.blue)); \
- XMesaPutPixel(img, x, y, p); \
+ XMesaPutPixel(xrb->ximage, x, y, p); \
zRow[i] = z; \
} \
span.red += span.redStep; \
@@ -250,11 +252,11 @@
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
@@ -280,14 +282,15 @@
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
@@ -311,14 +314,14 @@
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
XDITHER_SETUP(y); \
for (i = 0; i < span.end; i++, x++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
@@ -344,11 +347,11 @@
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- XMesaImage *img = xmesa->xm_buffer->backimage;
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage;
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
XDITHER_SETUP(y); \
for (i = 0; i < span.end; i++, x++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
@@ -374,11 +377,11 @@
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
LOOKUP_SETUP; \
@@ -405,14 +408,15 @@
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
@@ -437,12 +441,13 @@
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- XMesaImage *img = xmesa->xm_buffer->backimage; \
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage; \
unsigned long pixel; \
PACK_TRUECOLOR(pixel, v2->color[0], v2->color[1], v2->color[2]);
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
@@ -461,13 +466,12 @@
#define NAME flat_8A8B8G8R_z_triangle
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- unsigned long p = PACK_8B8G8R( v2->color[0], \
- v2->color[1], v2->color[2] );
+ GET_XRB(xrb); \
+ GLuint p = PACK_8B8G8R( v2->color[0], v2->color[1], v2->color[2] );
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
@@ -488,13 +492,12 @@
#define NAME flat_8A8R8G8B_z_triangle
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- unsigned long p = PACK_8R8G8B( v2->color[0], \
- v2->color[1], v2->color[2] );
+ GET_XRB(xrb); \
+ GLuint p = PACK_8R8G8B( v2->color[0], v2->color[1], v2->color[2] );
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
@@ -515,13 +518,12 @@
#define NAME flat_8R8G8B_z_triangle
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- unsigned long p = PACK_8R8G8B( v2->color[0], \
- v2->color[1], v2->color[2] );
+ GET_XRB(xrb); \
+ GLuint p = PACK_8R8G8B( v2->color[0], v2->color[1], v2->color[2] );
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
@@ -529,9 +531,12 @@
if (z < zRow[i]) { \
pRow[i] = (PIXEL_TYPE) p; \
zRow[i] = z; \
+ if (span.y == 100) printf("pass\n");\
} \
+ else if (span.y == 100) printf("fail\n");\
span.z += span.zStep; \
}
+
#include "swrast/s_tritemp.h"
@@ -542,11 +547,11 @@
#define NAME flat_8R8G8B24_z_triangle
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR3(xrb, X, Y)
#define PIXEL_TYPE bgr_t
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = v2->color;
#define RENDER_SPAN( span ) \
GLuint i; \
@@ -573,10 +578,11 @@
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- XMesaImage *img = xmesa->xm_buffer->backimage;
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage;
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
@@ -598,13 +604,12 @@
#define NAME flat_5R6G5B_z_triangle
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- unsigned long p = PACK_5R6G5B( v2->color[0], \
- v2->color[1], v2->color[2] );
+ GET_XRB(xrb); \
+ GLushort p = PACK_5R6G5B( v2->color[0], v2->color[1], v2->color[2] );
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
@@ -625,15 +630,16 @@
#define NAME flat_DITHER_5R6G5B_z_triangle
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = v2->color;
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
@@ -653,16 +659,16 @@
#define NAME flat_DITHER8_z_triangle
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
- FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, y)); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ FLAT_DITHER_ROW_SETUP(YFLIP(xrb, y)); \
for (i = 0; i < span.end; i++, x++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
@@ -682,12 +688,12 @@
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- XMesaImage *img = xmesa->xm_buffer->backimage; \
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage; \
FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
FLAT_DITHER_ROW_SETUP(y); \
for (i = 0; i < span.end; i++, x++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
@@ -708,17 +714,18 @@
#define NAME flat_HPCR_z_triangle
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
GLubyte r = v2->color[0]; \
GLubyte g = v2->color[1]; \
GLubyte b = v2->color[2];
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
const DEPTH_TYPE z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
@@ -737,11 +744,11 @@
#define NAME flat_LOOKUP8_z_triangle
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
LOOKUP_SETUP; \
GLubyte r = v2->color[0]; \
GLubyte g = v2->color[1]; \
@@ -768,10 +775,11 @@
#define INTERP_RGB 1
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- XMesaImage *img = xmesa->xm_buffer->backimage;
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage;
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
unsigned long p; \
PACK_TRUECOLOR(p, FixedToInt(span.red), \
@@ -790,11 +798,11 @@
*/
#define NAME smooth_8A8B8G8R_triangle
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
@@ -813,11 +821,11 @@
*/
#define NAME smooth_8A8R8G8B_triangle
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
@@ -836,11 +844,11 @@
*/
#define NAME smooth_8R8G8B_triangle
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
@@ -859,11 +867,11 @@
*/
#define NAME smooth_8R8G8B24_triangle
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR3(xrb, X, Y)
#define PIXEL_TYPE bgr_t
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
PIXEL_TYPE *pixel = pRow; \
@@ -886,10 +894,11 @@
#define INTERP_RGB 1
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- XMesaImage *img = xmesa->xm_buffer->backimage;
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage;
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
unsigned long p; \
PACK_TRUEDITHER(p, x, y, FixedToInt(span.red), \
@@ -908,11 +917,11 @@
*/
#define NAME smooth_5R6G5B_triangle
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span.end; i++) { \
@@ -931,14 +940,15 @@
*/
#define NAME smooth_DITHER_5R6G5B_triangle
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
PACK_TRUEDITHER(pRow[i], x, y, FixedToInt(span.red), \
FixedToInt(span.green), FixedToInt(span.blue)); \
@@ -955,14 +965,14 @@
*/
#define NAME smooth_DITHER8_triangle
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
XDITHER_SETUP(y); \
for (i = 0; i < span.end; i++, x++) { \
pRow[i] = (PIXEL_TYPE) XDITHER(x, FixedToInt(span.red), \
@@ -981,11 +991,11 @@
#define NAME smooth_DITHER_triangle
#define INTERP_RGB 1
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- XMesaImage *img = xmesa->xm_buffer->backimage;
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage;
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
XDITHER_SETUP(y); \
for (i = 0; i < span.end; i++, x++) { \
unsigned long p = XDITHER(x, FixedToInt(span.red), \
@@ -1004,11 +1014,11 @@
*/
#define NAME smooth_LOOKUP8_triangle
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
LOOKUP_SETUP; \
@@ -1028,14 +1038,15 @@
*/
#define NAME smooth_HPCR_triangle
#define INTERP_RGB 1
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb);
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
pRow[i] = DITHER_HPCR(x, y, FixedToInt(span.red), \
FixedToInt(span.green), FixedToInt(span.blue)); \
@@ -1053,12 +1064,13 @@
#define NAME flat_TRUECOLOR_triangle
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- XMesaImage *img = xmesa->xm_buffer->backimage; \
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage; \
unsigned long pixel; \
PACK_TRUECOLOR(pixel, v2->color[0], v2->color[1], v2->color[2]);
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
XMesaPutPixel(img, x, y, pixel); \
}
@@ -1070,11 +1082,11 @@
* XImage, flat, NON-depth-buffered, PF_8A8B8G8R triangle.
*/
#define NAME flat_8A8B8G8R_triangle
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
unsigned long p = PACK_8B8G8R( v2->color[0], \
v2->color[1], v2->color[2] );
#define RENDER_SPAN( span ) \
@@ -1090,11 +1102,11 @@
* XImage, flat, NON-depth-buffered, PF_8A8R8G8B triangle.
*/
#define NAME flat_8A8R8G8B_triangle
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
unsigned long p = PACK_8R8G8B( v2->color[0], \
v2->color[1], v2->color[2] );
#define RENDER_SPAN( span ) \
@@ -1110,11 +1122,11 @@
* XImage, flat, NON-depth-buffered, PF_8R8G8B triangle.
*/
#define NAME flat_8R8G8B_triangle
-#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
#define PIXEL_TYPE GLuint
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
unsigned long p = PACK_8R8G8B( v2->color[0], \
v2->color[1], v2->color[2] );
#define RENDER_SPAN( span ) \
@@ -1130,11 +1142,11 @@
* XImage, flat, NON-depth-buffered, PF_8R8G8B24 triangle.
*/
#define NAME flat_8R8G8B24_triangle
-#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR3(xrb, X, Y)
#define PIXEL_TYPE bgr_t
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = v2->color;
#define RENDER_SPAN( span ) \
GLuint i; \
@@ -1154,10 +1166,11 @@
#define NAME flat_TRUEDITHER_triangle
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- XMesaImage *img = xmesa->xm_buffer->backimage;
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage;
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
unsigned long p; \
PACK_TRUEDITHER(p, x, y, v2->color[0], \
@@ -1172,11 +1185,11 @@
* XImage, flat, NON-depth-buffered, PF_5R6G5B triangle.
*/
#define NAME flat_5R6G5B_triangle
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
unsigned long p = PACK_5R6G5B( v2->color[0], \
v2->color[1], v2->color[2] );
#define RENDER_SPAN( span ) \
@@ -1192,15 +1205,16 @@
* XImage, flat, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
*/
#define NAME flat_DITHER_5R6G5B_triangle
-#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
#define PIXEL_TYPE GLushort
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
const GLubyte *color = v2->color;
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
PACK_TRUEDITHER(pRow[i], x, y, color[RCOMP], \
color[GCOMP], color[BCOMP]); \
@@ -1213,16 +1227,16 @@
* XImage, flat, NON-depth-buffered, 8-bit PF_DITHER triangle.
*/
#define NAME flat_DITHER8_triangle
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
- FLAT_DITHER_ROW_SETUP(FLIP(xmesa->xm_buffer, y)); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ FLAT_DITHER_ROW_SETUP(YFLIP(xrb, y)); \
for (i = 0; i < span.end; i++, x++) { \
pRow[i] = (PIXEL_TYPE) FLAT_DITHER(x); \
}
@@ -1235,12 +1249,12 @@
*/
#define NAME flat_DITHER_triangle
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
- XMesaImage *img = xmesa->xm_buffer->backimage; \
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage; \
FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
FLAT_DITHER_ROW_SETUP(y); \
for (i = 0; i < span.end; i++, x++) { \
unsigned long p = FLAT_DITHER(x); \
@@ -1254,17 +1268,18 @@
* XImage, flat, NON-depth-buffered, 8-bit PF_HPCR triangle.
*/
#define NAME flat_HPCR_triangle
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
GLubyte r = v2->color[0]; \
GLubyte g = v2->color[1]; \
GLubyte b = v2->color[2];
#define RENDER_SPAN( span ) \
GLuint i; \
- GLint x = span.x, y = FLIP(xmesa->xm_buffer, span.y); \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
for (i = 0; i < span.end; i++, x++) { \
pRow[i] = (PIXEL_TYPE) DITHER_HPCR(x, y, r, g, b); \
}
@@ -1276,11 +1291,11 @@
* XImage, flat, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
*/
#define NAME flat_LOOKUP8_triangle
-#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
#define PIXEL_TYPE GLubyte
-#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
#define SETUP_CODE \
- XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
LOOKUP_SETUP; \
GLubyte r = v2->color[0]; \
GLubyte g = v2->color[1]; \
@@ -1417,12 +1432,16 @@ static swrast_tri_func get_triangle_func( GLcontext *ctx )
SWcontext *swrast = SWRAST_CONTEXT(ctx);
XMesaContext xmesa = XMESA_CONTEXT(ctx);
int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *)
+ ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+ return NULL;
#ifdef DEBUG
triFuncName = NULL;
#endif
- if ((ctx->Color._DrawDestMask[0] & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) ==0)
+ if ((ctx->DrawBuffer->_ColorDrawBufferMask[0]
+ & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) == 0)
return (swrast_tri_func) NULL;
if (ctx->RenderMode != GL_RENDER) return (swrast_tri_func) NULL;
if (ctx->Polygon.SmoothFlag) return (swrast_tri_func) NULL;
@@ -1432,7 +1451,7 @@ static swrast_tri_func get_triangle_func( GLcontext *ctx )
ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)
return (swrast_tri_func) NULL;
- if (xmesa->xm_buffer->buffer==XIMAGE) {
+ if (xrb->ximage) {
if ( ctx->Light.ShadeModel==GL_SMOOTH
&& swrast->_RasterMask==DEPTH_BIT
&& ctx->Depth.Func==GL_LESS
diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h
index 43712ff21f..8e6c9dd48a 100644
--- a/src/mesa/drivers/x11/xmesaP.h
+++ b/src/mesa/drivers/x11/xmesaP.h
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.1
+ * Version: 6.3
*
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2005 Brian Paul 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"),
@@ -52,8 +52,11 @@ typedef struct {
} bgr_t;
+struct xmesa_renderbuffer;
+
+
/* Function pointer for clearing color buffers */
-typedef void (*clear_func)( GLcontext *ctx,
+typedef void (*ClearFunc)( GLcontext *ctx, struct xmesa_renderbuffer *xrb,
GLboolean all, GLint x, GLint y,
GLint width, GLint height );
@@ -131,8 +134,6 @@ struct xmesa_visual {
struct xmesa_context {
GLcontext mesa; /* the core library context (containment) */
XMesaVisual xm_visual; /* Describes the buffers */
- XMesaBuffer xm_draw_buffer; /* current draw framebuffer */
- XMesaBuffer xm_read_buffer; /* current read framebuffer */
XMesaBuffer xm_buffer; /* current span/point/line/triangle buffer */
XMesaDisplay *display; /* == xm_visual->display */
@@ -155,6 +156,30 @@ typedef enum {
} BufferType;
+struct xmesa_renderbuffer
+{
+ struct gl_renderbuffer Base; /* Base class */
+
+ XMesaDrawable pixmap; /* Either an X Window ID (front color buf) */
+ /* or X Pixmap ID (back color buf) */
+
+ XMesaImage *ximage; /* The back buffer, if not using a Pixmap */
+
+ GLubyte *origin1; /* used for PIXEL_ADDR1 macro */
+ GLint width1;
+ GLushort *origin2; /* used for PIXEL_ADDR2 macro */
+ GLint width2;
+ GLubyte *origin3; /* used for PIXEL_ADDR3 macro */
+ GLint width3;
+ GLuint *origin4; /* used for PIXEL_ADDR4 macro */
+ GLint width4;
+
+ GLint bottom; /* used for FLIP macro */
+
+ ClearFunc clearFunc;
+};
+
+
/*
* "Derived" from GLframebuffer. Basically corresponds to a GLXDrawable.
*/
@@ -166,12 +191,9 @@ struct xmesa_buffer {
XMesaDisplay *display;
BufferType type; /* window, pixmap, pbuffer or glxwindow */
- XMesaDrawable frontbuffer; /* either a window or pixmap */
- XMesaPixmap backpixmap; /* back buffer Pixmap */
- XMesaImage *backimage; /* back buffer simulated XImage */
- XMesaDrawable buffer; /* the current buffer, either equal to */
- /* frontbuffer, backpixmap or XIMAGE (None) */
+ struct xmesa_renderbuffer *frontxrb; /* front color renderbuffer */
+ struct xmesa_renderbuffer *backxrb; /* back color renderbuffer */
XMesaColormap cmap; /* the X colormap */
@@ -192,17 +214,6 @@ struct xmesa_buffer {
#endif
XMesaImage *rowimage; /* Used for optimized span writing */
-
- GLint bottom; /* used for FLIP macro below */
- GLubyte *ximage_origin1; /* used for PIXELADDR1 macro */
- GLint ximage_width1;
- GLushort *ximage_origin2; /* used for PIXELADDR2 macro */
- GLint ximage_width2;
- GLubyte *ximage_origin3; /* used for PIXELADDR3 macro */
- GLint ximage_width3;
- GLuint *ximage_origin4; /* used for PIXELADDR4 macro */
- GLint ximage_width4;
-
XMesaPixmap stipple_pixmap; /* For polygon stippling */
XMesaGC stipple_gc; /* For polygon stippling */
@@ -237,23 +248,15 @@ struct xmesa_buffer {
fxMesaContext FXctx;
#endif
- /* functions for clearing the front and back color buffers */
- clear_func front_clear_func;
- clear_func back_clear_func;
-
struct xmesa_buffer *Next; /* Linked list pointer: */
};
-
-/* Values for xmesa->dest: */
+/* Values for xmesa->db_state: */
#define FRONT_PIXMAP 1
#define BACK_PIXMAP 2
#define BACK_XIMAGE 4
-/* Special value for X Drawable variables to indicate use of XImage instead */
-#define XIMAGE None
-
/*
* If pixelformat==PF_TRUECOLOR:
@@ -341,7 +344,7 @@ extern const int xmesa_kernel8[DITH_DY * DITH_DX];
/* Dither for random X,Y */
#define DITHER_SETUP \
int __d; \
- unsigned long *ctable = xmesa->xm_buffer->color_table;
+ unsigned long *ctable = XMESA_BUFFER(ctx->DrawBuffer)->color_table;
#define DITHER( X, Y, R, G, B ) \
(__d = xmesa_kernel8[(((Y)&3)<<2) | ((X)&3)], \
@@ -352,7 +355,7 @@ extern const int xmesa_kernel8[DITH_DY * DITH_DX];
/* Dither for random X, fixed Y */
#define XDITHER_SETUP(Y) \
int __d; \
- unsigned long *ctable = xmesa->xm_buffer->color_table; \
+ unsigned long *ctable = XMESA_BUFFER(ctx->DrawBuffer)->color_table; \
const int *kernel = &xmesa_kernel8[ ((Y)&3) << 2 ];
#define XDITHER( X, R, G, B ) \
@@ -370,7 +373,7 @@ extern const int xmesa_kernel8[DITH_DY * DITH_DX];
#define FLAT_DITHER_SETUP( R, G, B ) \
GLushort ditherValues[16]; \
{ \
- unsigned long *ctable = xmesa->xm_buffer->color_table; \
+ unsigned long *ctable = XMESA_BUFFER(ctx->DrawBuffer)->color_table; \
int msdr = (DITH_N*((DITH_R)-1)+1) * (R); \
int msdg = (DITH_N*((DITH_G)-1)+1) * (G); \
int msdb = (DITH_N*((DITH_B)-1)+1) * (B); \
@@ -395,7 +398,7 @@ extern const int xmesa_kernel8[DITH_DY * DITH_DX];
#define _dither_lookup(C, c) (((unsigned)((DITH_N * (C - 1) + 1) * c)) >> 12)
#define LOOKUP_SETUP \
- unsigned long *ctable = xmesa->xm_buffer->color_table
+ unsigned long *ctable = XMESA_BUFFER(ctx->DrawBuffer)->color_table
#define LOOKUP( R, G, B ) \
ctable[DITH_MIX(_dither_lookup(DITH_R, (R)), \
@@ -438,31 +441,31 @@ extern const int xmesa_kernel1[16];
/*
* If pixelformat==PF_GRAYSCALE:
*/
-#define GRAY_RGB( R, G, B ) xmesa->xm_buffer->color_table[((R) + (G) + (B))/3]
+#define GRAY_RGB( R, G, B ) XMESA_BUFFER(ctx->DrawBuffer)->color_table[((R) + (G) + (B))/3]
/*
* Converts a GL window Y coord to an X window Y coord:
*/
-#define FLIP(BUFFER, Y) ((BUFFER)->bottom-(Y))
+#define YFLIP(XRB, Y) ((XRB)->bottom - (Y))
/*
- * Return the address of a 1, 2 or 4-byte pixel in the back XImage:
+ * Return the address of a 1, 2 or 4-byte pixel in the buffer's XImage:
* X==0 is left, Y==0 is bottom.
*/
-#define PIXELADDR1( BUFFER, X, Y ) \
- ( (BUFFER)->ximage_origin1 - (Y) * (BUFFER)->ximage_width1 + (X) )
+#define PIXEL_ADDR1(XRB, X, Y) \
+ ( (XRB)->origin1 - (Y) * (XRB)->width1 + (X) )
-#define PIXELADDR2( BUFFER, X, Y ) \
- ( (BUFFER)->ximage_origin2 - (Y) * (BUFFER)->ximage_width2 + (X) )
+#define PIXEL_ADDR2(XRB, X, Y) \
+ ( (XRB)->origin2 - (Y) * (XRB)->width2 + (X) )
-#define PIXELADDR3( BUFFER, X, Y ) \
- ( (bgr_t *) ( (BUFFER)->ximage_origin3 - (Y) * (BUFFER)->ximage_width3 + 3 * (X) ))
+#define PIXEL_ADDR3(XRB, X, Y) \
+ ( (bgr_t *) ( (XRB)->origin3 - (Y) * (XRB)->width3 + 3 * (X) ))
-#define PIXELADDR4( BUFFER, X, Y ) \
- ( (BUFFER)->ximage_origin4 - (Y) * (BUFFER)->ximage_width4 + (X) )
+#define PIXEL_ADDR4(XRB, X, Y) \
+ ( (XRB)->origin4 - (Y) * (XRB)->width4 + (X) )
@@ -471,7 +474,13 @@ extern const int xmesa_kernel1[16];
* Return pointer to XMesaContext corresponding to a Mesa GLcontext.
* Since we're using structure containment, it's just a cast!.
*/
-#define XMESA_CONTEXT(MESACTX) (XMesaContext) (MESACTX)
+#define XMESA_CONTEXT(MESACTX) ((XMesaContext) (MESACTX))
+
+/*
+ * Return pointer to XMesaBuffer corresponding to a Mesa GLframebuffer.
+ * Since we're using structure containment, it's just a cast!.
+ */
+#define XMESA_BUFFER(MESABUFF) ((XMesaBuffer) (MESABUFF))
@@ -479,21 +488,29 @@ extern const int xmesa_kernel1[16];
* External functions:
*/
+extern struct xmesa_renderbuffer *
+xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, GLboolean rgbMode);
+
extern unsigned long
-xmesa_color_to_pixel( XMesaContext xmesa,
+xmesa_color_to_pixel( GLcontext *ctx,
GLubyte r, GLubyte g, GLubyte b, GLubyte a,
GLuint pixelFormat );
-extern void xmesa_alloc_back_buffer( XMesaBuffer b );
+extern void
+xmesa_alloc_back_buffer(XMesaBuffer b, GLuint width, GLuint height);
-extern void xmesa_resize_buffers( GLframebuffer *buffer );
+extern void xmesa_resize_buffers(GLcontext *ctx, GLframebuffer *buffer,
+ GLuint width, GLuint height);
extern void xmesa_init_driver_functions( XMesaVisual xmvisual,
struct dd_function_table *driver );
extern void xmesa_update_state( GLcontext *ctx, GLuint new_state );
-extern void xmesa_update_span_funcs( GLcontext *ctx );
+extern void
+xmesa_set_renderbuffer_funcs(struct xmesa_renderbuffer *xrb,
+ enum pixel_format pixelformat, GLint depth);
+
extern void xmesa_set_buffer( GLcontext *ctx, GLframebuffer *buffer,
GLuint bufferBit );