summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2012-01-16 11:24:18 -0700
committerBrian Paul <[email protected]>2012-01-24 14:12:18 -0700
commit2e80c7e5bf822e3b9efd145d33badcf4f14504ff (patch)
tree1952cb779806865147f0a66d9914729b738bce01 /src
parent0d2f0c8bb86b8dfcb6f0be7bf027fe725007bc5f (diff)
xlib: remove obsolete GetRow/PutRow code
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/x11/xm_span.c1597
1 files changed, 3 insertions, 1594 deletions
diff --git a/src/mesa/drivers/x11/xm_span.c b/src/mesa/drivers/x11/xm_span.c
index 37e88154f49..be4e54563f3 100644
--- a/src/mesa/drivers/x11/xm_span.c
+++ b/src/mesa/drivers/x11/xm_span.c
@@ -146,1082 +146,6 @@ static unsigned long read_pixel( XMesaDisplay *dpy,
-/**********************************************************************/
-/*** Write COLOR SPAN functions ***/
-/**********************************************************************/
-
-
-#define PUT_ROW_ARGS \
- struct gl_context *ctx, \
- struct gl_renderbuffer *rb, \
- GLuint n, GLint x, GLint y, \
- const void *values, const GLubyte mask[]
-
-#define RGB_SPAN_ARGS \
- struct gl_context *ctx, \
- struct gl_renderbuffer *rb, \
- GLuint n, GLint x, GLint y, \
- const void *values, const GLubyte mask[]
-
-
-#define GET_XRB(XRB) \
- struct xmesa_renderbuffer *XRB = xmesa_renderbuffer(rb)
-
-
-/*
- * Write a span of PF_TRUECOLOR pixels to a pixmap.
- */
-static void put_row_TRUECOLOR_pixmap( PUT_ROW_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
- XMesaDisplay *dpy = XMESA_BUFFER(ctx->DrawBuffer)->display;
- XMesaDrawable buffer = xrb->drawable;
- XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
- register GLuint i;
-
- y = YFLIP(xrb, y);
- if (mask) {
- for (i=0;i<n;i++,x++) {
- if (mask[i]) {
- 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, (int) y );
- }
- }
- }
- else {
- /* draw all pixels */
- XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
- for (i=0;i<n;i++) {
- unsigned long p;
- PACK_TRUECOLOR( p, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
- XMesaPutPixel( rowimg, i, 0, p );
- }
- XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
- }
-}
-
-
-/*
- * Write a span of PF_TRUEDITHER pixels to a pixmap.
- */
-static void put_row_TRUEDITHER_pixmap( PUT_ROW_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
- XMesaDisplay *dpy = xmesa->xm_visual->display;
- XMesaDrawable buffer = xrb->drawable;
- XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
- register GLuint i;
- y = YFLIP(xrb, y);
- if (mask) {
- for (i=0;i<n;i++,x++) {
- if (mask[i]) {
- unsigned long p;
- PACK_TRUEDITHER(p, x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
- XMesaSetForeground( dpy, gc, p );
- XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
- }
- }
- }
- else {
- XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
- for (i=0;i<n;i++) {
- unsigned long p;
- PACK_TRUEDITHER(p, x+i, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
- XMesaPutPixel( rowimg, i, 0, p );
- }
- XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
- }
-}
-
-
-/*
- * Write a span of PF_8A8B8G8R pixels to a pixmap.
- */
-static void put_row_8A8B8G8R_pixmap( PUT_ROW_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
- XMesaDisplay *dpy = xmesa->xm_visual->display;
- XMesaDrawable buffer = xrb->drawable;
- XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
- register GLuint i;
- y = YFLIP(xrb, y);
- if (mask) {
- for (i=0;i<n;i++,x++) {
- 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, (int) y );
- }
- }
- }
- else {
- /* draw all pixels */
- XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
- register GLuint *ptr4 = (GLuint *) rowimg->data;
- for (i=0;i<n;i++) {
- *ptr4++ = PACK_8A8B8G8R( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] );
- }
- XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
- }
-}
-
-
-/*
- * Write a span of PF_8A8R8G8B pixels to a pixmap.
- */
-static void put_row_8A8R8G8B_pixmap( PUT_ROW_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
- XMesaDisplay *dpy = xmesa->xm_visual->display;
- XMesaDrawable buffer = xrb->drawable;
- XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
- register GLuint i;
- y = YFLIP(xrb, y);
- if (mask) {
- for (i=0;i<n;i++,x++) {
- 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, (int) y );
- }
- }
- }
- else {
- /* draw all pixels */
- XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
- register GLuint *ptr4 = (GLuint *) rowimg->data;
- for (i=0;i<n;i++) {
- *ptr4++ = PACK_8A8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] );
- }
- XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
- }
-}
-
-
-
-/*
- * Write a span of PF_8R8G8B pixels to a pixmap.
- */
-static void put_row_8R8G8B_pixmap( PUT_ROW_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
- XMesaDisplay *dpy = xmesa->xm_visual->display;
- XMesaDrawable buffer = xrb->drawable;
- XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
- register GLuint i;
- y = YFLIP(xrb, y);
- if (mask) {
- for (i=0;i<n;i++,x++) {
- if (mask[i]) {
-#if 1
- /*
- * XXX Something funny is going on here.
- * If we're drawing into a window that uses a depth 32 TrueColor
- * visual, we see the right pixels on screen, but when we read
- * them back with XGetImage() we get random colors.
- * The alternative code below which uses XPutImage() instead
- * seems to mostly fix the problem, but not always.
- * We don't normally create windows with this visual, but glean
- * does and we're seeing some failures there.
- */
- XMesaSetForeground( dpy, gc, PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));
- XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
-#else
- /* This code works more often, but not always */
- XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
- GLuint *ptr4 = (GLuint *) rowimg->data;
- *ptr4 = PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
- XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, 1, 1 );
-#endif
- }
- }
- }
- else {
- /* draw all pixels */
- XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
- register GLuint *ptr4 = (GLuint *) rowimg->data;
- for (i=0;i<n;i++) {
- *ptr4++ = PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
- }
- XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
- }
-}
-
-
-/*
- * Write a span of PF_8R8G8B24 pixels to a pixmap.
- */
-static void put_row_8R8G8B24_pixmap( PUT_ROW_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
- XMesaDisplay *dpy = xmesa->xm_visual->display;
- XMesaDrawable buffer = xrb->drawable;
- XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
- y = YFLIP(xrb, y);
- if (mask) {
- register GLuint i;
- for (i=0;i<n;i++,x++) {
- if (mask[i]) {
- XMesaSetForeground( dpy, gc,
- PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));
- XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
- }
- }
- }
- else {
- /* draw all pixels */
- XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
- register GLuint *ptr4 = (GLuint *) rowimg->data;
- register GLuint pixel;
- static const GLuint shift[4] = {0, 8, 16, 24};
- register GLuint i = 0;
- int w = n;
- while (w > 3) {
- pixel = rgba[i][BCOMP] /* << shift[0]*/;
- pixel |= rgba[i][GCOMP] << shift[1];
- pixel |= rgba[i++][RCOMP] << shift[2];
- pixel |= rgba[i][BCOMP] << shift[3];
- *ptr4++ = pixel;
-
- pixel = rgba[i][GCOMP] /* << shift[0]*/;
- pixel |= rgba[i++][RCOMP] << shift[1];
- pixel |= rgba[i][BCOMP] << shift[2];
- pixel |= rgba[i][GCOMP] << shift[3];
- *ptr4++ = pixel;
-
- pixel = rgba[i++][RCOMP]/* << shift[0]*/;
- pixel |= rgba[i][BCOMP] << shift[1];
- pixel |= rgba[i][GCOMP] << shift[2];
- pixel |= rgba[i++][RCOMP] << shift[3];
- *ptr4++ = pixel;
-
- w -= 4;
- }
- switch (w) {
- case 3:
- pixel = 0;
- pixel |= rgba[i][BCOMP] /*<< shift[0]*/;
- pixel |= rgba[i][GCOMP] << shift[1];
- pixel |= rgba[i++][RCOMP] << shift[2];
- pixel |= rgba[i][BCOMP] << shift[3];
- *ptr4++ = pixel;
- pixel = 0;
- pixel |= rgba[i][GCOMP] /*<< shift[0]*/;
- pixel |= rgba[i++][RCOMP] << shift[1];
- pixel |= rgba[i][BCOMP] << shift[2];
- pixel |= rgba[i][GCOMP] << shift[3];
- *ptr4++ = pixel;
- pixel = 0xffffff00 & *ptr4;
- pixel |= rgba[i][RCOMP] /*<< shift[0]*/;
- *ptr4 = pixel;
- break;
- case 2:
- pixel = 0;
- pixel |= rgba[i][BCOMP] /*<< shift[0]*/;
- pixel |= rgba[i][GCOMP] << shift[1];
- pixel |= rgba[i++][RCOMP] << shift[2];
- pixel |= rgba[i][BCOMP] << shift[3];
- *ptr4++ = pixel;
- pixel = 0xffff0000 & *ptr4;
- pixel |= rgba[i][GCOMP] /*<< shift[0]*/;
- pixel |= rgba[i][RCOMP] << shift[1];
- *ptr4 = pixel;
- break;
- case 1:
- pixel = 0xff000000 & *ptr4;
- pixel |= rgba[i][BCOMP] /*<< shift[0]*/;
- pixel |= rgba[i][GCOMP] << shift[1];
- pixel |= rgba[i][RCOMP] << shift[2];
- *ptr4 = pixel;
- break;
- case 0:
- break;
- }
- XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
- }
-}
-
-
-
-/*
- * Write a span of PF_5R6G5B pixels to a pixmap.
- */
-static void put_row_5R6G5B_pixmap( PUT_ROW_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
- XMesaDisplay *dpy = xmesa->xm_visual->display;
- XMesaDrawable buffer = xrb->drawable;
- XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
- register GLuint i;
- y = YFLIP(xrb, y);
- if (mask) {
- for (i=0;i<n;i++,x++) {
- if (mask[i]) {
- XMesaSetForeground( dpy, gc, PACK_5R6G5B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));
- XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
- }
- }
- }
- else {
- /* draw all pixels */
- XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
- register GLushort *ptr2 = (GLushort *) rowimg->data;
- for (i=0;i<n;i++) {
- ptr2[i] = PACK_5R6G5B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
- }
- XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
- }
-}
-
-
-/*
- * Write a span of PF_DITHER_5R6G5B pixels to a pixmap.
- */
-static void put_row_DITHER_5R6G5B_pixmap( PUT_ROW_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
- XMesaDisplay *dpy = xmesa->xm_visual->display;
- XMesaDrawable buffer = xrb->drawable;
- XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
- register GLuint i;
- y = YFLIP(xrb, y);
- if (mask) {
- for (i=0;i<n;i++,x++) {
- if (mask[i]) {
- unsigned long p;
- PACK_TRUEDITHER(p, x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
- XMesaSetForeground( dpy, gc, p );
- XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
- }
- }
- }
- else {
- /* draw all pixels */
- XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
- register GLushort *ptr2 = (GLushort *) rowimg->data;
- for (i=0;i<n;i++) {
- PACK_TRUEDITHER( ptr2[i], x+i, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
- }
- XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
- }
-}
-
-
-/*
- * Write a span of PF_TRUECOLOR pixels to an XImage.
- */
-static void put_row_TRUECOLOR_ximage( PUT_ROW_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
- XMesaImage *img = xrb->ximage;
- register GLuint i;
- y = YFLIP(xrb, y);
- if (mask) {
- for (i=0;i<n;i++,x++) {
- if (mask[i]) {
- unsigned long p;
- PACK_TRUECOLOR( p, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
- XMesaPutPixel( img, x, y, p );
- }
- }
- }
- else {
- /* draw all pixels */
- for (i=0;i<n;i++,x++) {
- unsigned long p;
- PACK_TRUECOLOR( p, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
- XMesaPutPixel( img, x, y, p );
- }
- }
-}
-
-
-/*
- * Write a span of PF_TRUEDITHER pixels to an XImage.
- */
-static void put_row_TRUEDITHER_ximage( PUT_ROW_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
- XMesaImage *img = xrb->ximage;
- register GLuint i;
- y = YFLIP(xrb, y);
- if (mask) {
- for (i=0;i<n;i++,x++) {
- if (mask[i]) {
- unsigned long p;
- PACK_TRUEDITHER(p, x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
- XMesaPutPixel( img, x, y, p );
- }
- }
- }
- else {
- /* draw all pixels */
- for (i=0;i<n;i++,x++) {
- unsigned long p;
- PACK_TRUEDITHER(p, x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
- XMesaPutPixel( img, x, y, p );
- }
- }
-}
-
-
-/*
- * Write a span of PF_8A8B8G8R-format pixels to an ximage.
- */
-static void put_row_8A8B8G8R_ximage( PUT_ROW_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- GET_XRB(xrb);
- register GLuint i;
- register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);
- (void) ctx;
- if (mask) {
- for (i=0;i<n;i++) {
- if (mask[i]) {
- ptr[i] = PACK_8A8B8G8R( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] );
- }
- }
- }
- else {
- /* draw all pixels */
- for (i=0;i<n;i++) {
- ptr[i] = PACK_8A8B8G8R( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] );
- }
- }
-}
-
-
-/*
- * Write a span of PF_8A8R8G8B-format pixels to an ximage.
- */
-static void put_row_8A8R8G8B_ximage( PUT_ROW_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- GET_XRB(xrb);
- register GLuint i;
- register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);
- if (mask) {
- for (i=0;i<n;i++) {
- if (mask[i]) {
- ptr[i] = PACK_8A8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] );
- }
- }
- }
- else {
- /* draw all pixels */
- for (i=0;i<n;i++) {
- ptr[i] = PACK_8A8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] );
- }
- }
-}
-
-
-/*
- * Write a span of PF_8R8G8B-format pixels to an ximage.
- */
-static void put_row_8R8G8B_ximage( PUT_ROW_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- GET_XRB(xrb);
- register GLuint i;
- register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);
- if (mask) {
- for (i=0;i<n;i++) {
- if (mask[i]) {
- ptr[i] = PACK_8R8G8B(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
- }
- }
- }
- else {
- for (i=0;i<n;i++) {
- ptr[i] = PACK_8R8G8B(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
- }
- }
-}
-
-
-/*
- * Write a span of PF_8R8G8B24-format pixels to an ximage.
- */
-static void put_row_8R8G8B24_ximage( PUT_ROW_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- GET_XRB(xrb);
- register GLuint i;
- register GLubyte *ptr = (GLubyte *) PIXEL_ADDR3(xrb, x, y );
- if (mask) {
- for (i=0;i<n;i++) {
- if (mask[i]) {
- GLuint *ptr4 = (GLuint *) ptr;
- register GLuint pixel = *ptr4;
- switch (3 & (int)(ptr - (GLubyte*)ptr4)) {
- case 0:
- pixel &= 0xff000000;
- pixel |= rgba[i][BCOMP];
- pixel |= rgba[i][GCOMP] << 8;
- pixel |= rgba[i][RCOMP] << 16;
- *ptr4 = pixel;
- break;
- case 3:
- pixel &= 0x00ffffff;
- pixel |= rgba[i][BCOMP] << 24;
- *ptr4++ = pixel;
- pixel = *ptr4 & 0xffff0000;
- pixel |= rgba[i][GCOMP];
- pixel |= rgba[i][RCOMP] << 8;
- *ptr4 = pixel;
- break;
- case 2:
- pixel &= 0x0000ffff;
- pixel |= rgba[i][BCOMP] << 16;
- pixel |= rgba[i][GCOMP] << 24;
- *ptr4++ = pixel;
- pixel = *ptr4 & 0xffffff00;
- pixel |= rgba[i][RCOMP];
- *ptr4 = pixel;
- break;
- case 1:
- pixel &= 0x000000ff;
- pixel |= rgba[i][BCOMP] << 8;
- pixel |= rgba[i][GCOMP] << 16;
- pixel |= rgba[i][RCOMP] << 24;
- *ptr4 = pixel;
- break;
- }
- }
- ptr += 3;
- }
- }
- else {
- /* write all pixels */
- int w = n;
- GLuint *ptr4 = (GLuint *) ptr;
- register GLuint pixel = *ptr4;
- int index = (int)(ptr - (GLubyte *)ptr4);
- register GLuint i = 0;
- switch (index) {
- case 0:
- break;
- case 1:
- pixel &= 0x00ffffff;
- pixel |= rgba[i][BCOMP] << 24;
- *ptr4++ = pixel;
- pixel = *ptr4 & 0xffff0000;
- pixel |= rgba[i][GCOMP];
- pixel |= rgba[i++][RCOMP] << 8;
- *ptr4 = pixel;
- if (0 == --w)
- break;
- case 2:
- pixel &= 0x0000ffff;
- pixel |= rgba[i][BCOMP] << 16;
- pixel |= rgba[i][GCOMP] << 24;
- *ptr4++ = pixel;
- pixel = *ptr4 & 0xffffff00;
- pixel |= rgba[i++][RCOMP];
- *ptr4 = pixel;
- if (0 == --w)
- break;
- case 3:
- pixel &= 0x000000ff;
- pixel |= rgba[i][BCOMP] << 8;
- pixel |= rgba[i][GCOMP] << 16;
- pixel |= rgba[i++][RCOMP] << 24;
- *ptr4++ = pixel;
- if (0 == --w)
- break;
- break;
- }
- while (w > 3) {
- pixel = rgba[i][BCOMP];
- pixel |= rgba[i][GCOMP] << 8;
- pixel |= rgba[i++][RCOMP] << 16;
- pixel |= rgba[i][BCOMP] << 24;
- *ptr4++ = pixel;
- pixel = rgba[i][GCOMP];
- pixel |= rgba[i++][RCOMP] << 8;
- pixel |= rgba[i][BCOMP] << 16;
- pixel |= rgba[i][GCOMP] << 24;
- *ptr4++ = pixel;
- pixel = rgba[i++][RCOMP];
- pixel |= rgba[i][BCOMP] << 8;
- pixel |= rgba[i][GCOMP] << 16;
- pixel |= rgba[i++][RCOMP] << 24;
- *ptr4++ = pixel;
- w -= 4;
- }
- switch (w) {
- case 0:
- break;
- case 1:
- pixel = *ptr4 & 0xff000000;
- pixel |= rgba[i][BCOMP];
- pixel |= rgba[i][GCOMP] << 8;
- pixel |= rgba[i][RCOMP] << 16;
- *ptr4 = pixel;
- break;
- case 2:
- pixel = rgba[i][BCOMP];
- pixel |= rgba[i][GCOMP] << 8;
- pixel |= rgba[i++][RCOMP] << 16;
- pixel |= rgba[i][BCOMP] << 24;
- *ptr4++ = pixel;
- pixel = *ptr4 & 0xffff0000;
- pixel |= rgba[i][GCOMP];
- pixel |= rgba[i][RCOMP] << 8;
- *ptr4 = pixel;
- break;
- case 3:
- pixel = rgba[i][BCOMP];
- pixel |= rgba[i][GCOMP] << 8;
- pixel |= rgba[i++][RCOMP] << 16;
- pixel |= rgba[i][BCOMP] << 24;
- *ptr4++ = pixel;
- pixel = rgba[i][GCOMP];
- pixel |= rgba[i++][RCOMP] << 8;
- pixel |= rgba[i][BCOMP] << 16;
- pixel |= rgba[i][GCOMP] << 24;
- *ptr4++ = pixel;
- pixel = *ptr4 & 0xffffff00;
- pixel |= rgba[i][RCOMP];
- *ptr4 = pixel;
- break;
- }
- }
-}
-
-
-/*
- * Write a span of PF_5R6G5B-format pixels to an ximage.
- */
-static void put_row_5R6G5B_ximage( PUT_ROW_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- GET_XRB(xrb);
- register GLuint i;
- register GLushort *ptr = PIXEL_ADDR2(xrb, x, y);
- if (mask) {
- for (i=0;i<n;i++) {
- if (mask[i]) {
- ptr[i] = PACK_5R6G5B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
- }
- }
- }
- else {
- /* draw all pixels */
-#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
- GLuint *ptr32 = (GLuint *) ptr;
- GLuint extraPixel = (n & 1);
- n -= extraPixel;
- for (i = 0; i < n; i += 2) {
- GLuint p0, p1;
- p0 = PACK_5R6G5B(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
- p1 = PACK_5R6G5B(rgba[i+1][RCOMP], rgba[i+1][GCOMP], rgba[i+1][BCOMP]);
- *ptr32++ = (p1 << 16) | p0;
- }
- if (extraPixel) {
- ptr[n] = PACK_5R6G5B(rgba[n][RCOMP], rgba[n][GCOMP], rgba[n][BCOMP]);
- }
-#else
- for (i = 0; i < n; i++) {
- ptr[i] = PACK_5R6G5B(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
- }
-#endif
- }
-}
-
-
-/*
- * Write a span of PF_DITHER_5R6G5B-format pixels to an ximage.
- */
-static void put_row_DITHER_5R6G5B_ximage( PUT_ROW_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- GET_XRB(xrb);
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- register GLuint i;
- register GLushort *ptr = PIXEL_ADDR2(xrb, x, y);
- const GLint y2 = YFLIP(xrb, y);
- if (mask) {
- for (i=0;i<n;i++,x++) {
- if (mask[i]) {
- PACK_TRUEDITHER( ptr[i], x, y2, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
- }
- }
- }
- else {
- /* draw all pixels */
-#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
- GLuint *ptr32 = (GLuint *) ptr;
- GLuint extraPixel = (n & 1);
- n -= extraPixel;
- for (i = 0; i < n; i += 2, x += 2) {
- GLuint p0, p1;
- PACK_TRUEDITHER( p0, x, y2, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
- PACK_TRUEDITHER( p1, x+1, y2, rgba[i+1][RCOMP], rgba[i+1][GCOMP], rgba[i+1][BCOMP] );
- *ptr32++ = (p1 << 16) | p0;
- }
- if (extraPixel) {
- PACK_TRUEDITHER( ptr[n], x+n, y2, rgba[n][RCOMP], rgba[n][GCOMP], rgba[n][BCOMP]);
- }
-#else
- for (i = 0; i < n; i++, x++) {
- PACK_TRUEDITHER( ptr[i], x, y2, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
- }
-#endif
- }
-}
-
-
-/**********************************************************************/
-/*** Write COLOR PIXEL functions ***/
-/**********************************************************************/
-
-
-#define PUT_VALUES_ARGS \
- struct gl_context *ctx, struct gl_renderbuffer *rb, \
- GLuint n, const GLint x[], const GLint y[], \
- const void *values, const GLubyte mask[]
-
-
-/*
- * Write an array of PF_TRUECOLOR pixels to a pixmap.
- */
-static void put_values_TRUECOLOR_pixmap( PUT_VALUES_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
- XMesaDisplay *dpy = xmesa->xm_visual->display;
- XMesaDrawable buffer = xrb->drawable;
- XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
- 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] );
- XMesaSetForeground( dpy, gc, p );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
- }
- }
-}
-
-
-/*
- * Write an array of PF_TRUEDITHER pixels to a pixmap.
- */
-static void put_values_TRUEDITHER_pixmap( PUT_VALUES_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
- XMesaDisplay *dpy = xmesa->xm_visual->display;
- XMesaDrawable buffer = xrb->drawable;
- XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
- 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]);
- XMesaSetForeground( dpy, gc, p );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
- }
- }
-}
-
-
-/*
- * Write an array of PF_8A8B8G8R pixels to a pixmap.
- */
-static void put_values_8A8B8G8R_pixmap( PUT_VALUES_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
- XMesaDisplay *dpy = xmesa->xm_visual->display;
- XMesaDrawable buffer = xrb->drawable;
- XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
- register GLuint i;
- for (i=0;i<n;i++) {
- 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) YFLIP(xrb, y[i]) );
- }
- }
-}
-
-/*
- * Write an array of PF_8A8R8G8B pixels to a pixmap.
- */
-static void put_values_8A8R8G8B_pixmap( PUT_VALUES_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
- XMesaDisplay *dpy = xmesa->xm_visual->display;
- XMesaDrawable buffer = xrb->drawable;
- XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
- register GLuint i;
- for (i=0;i<n;i++) {
- 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) YFLIP(xrb, y[i]) );
- }
- }
-}
-
-/*
- * Write an array of PF_8R8G8B pixels to a pixmap.
- */
-static void put_values_8R8G8B_pixmap( PUT_VALUES_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
- XMesaDisplay *dpy = xmesa->xm_visual->display;
- XMesaDrawable buffer = xrb->drawable;
- XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
- register GLuint i;
- 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) YFLIP(xrb, y[i]) );
- }
- }
-}
-
-
-/*
- * Write an array of PF_8R8G8B24 pixels to a pixmap.
- */
-static void put_values_8R8G8B24_pixmap( PUT_VALUES_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
- XMesaDisplay *dpy = xmesa->xm_visual->display;
- XMesaDrawable buffer = xrb->drawable;
- XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
- register GLuint i;
- 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) YFLIP(xrb, y[i]) );
- }
- }
-}
-
-
-/*
- * Write an array of PF_5R6G5B pixels to a pixmap.
- */
-static void put_values_5R6G5B_pixmap( PUT_VALUES_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
- XMesaDisplay *dpy = xmesa->xm_visual->display;
- XMesaDrawable buffer = xrb->drawable;
- XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
- register GLuint i;
- 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) YFLIP(xrb, y[i]) );
- }
- }
-}
-
-
-/*
- * Write an array of PF_DITHER_5R6G5B pixels to a pixmap.
- */
-static void put_values_DITHER_5R6G5B_pixmap( PUT_VALUES_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
- XMesaDisplay *dpy = xmesa->xm_visual->display;
- XMesaDrawable buffer = xrb->drawable;
- XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
- 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] );
- XMesaSetForeground( dpy, gc, p );
- XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
- }
- }
-}
-
-
-/*
- * Write an array of PF_TRUECOLOR pixels to an ximage.
- */
-static void put_values_TRUECOLOR_ximage( PUT_VALUES_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
- XMesaImage *img = xrb->ximage;
- 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], YFLIP(xrb, y[i]), p );
- }
- }
-}
-
-
-/*
- * Write an array of PF_TRUEDITHER pixels to an XImage.
- */
-static void put_values_TRUEDITHER_ximage( PUT_VALUES_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
- XMesaImage *img = xrb->ximage;
- 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], YFLIP(xrb, y[i]), p );
- }
- }
-}
-
-
-/*
- * Write an array of PF_8A8B8G8R pixels to an ximage.
- */
-static void put_values_8A8B8G8R_ximage( PUT_VALUES_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- GET_XRB(xrb);
- register GLuint i;
- for (i=0;i<n;i++) {
- if (mask[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] );
- }
- }
-}
-
-/*
- * Write an array of PF_8A8R8G8B pixels to an ximage.
- */
-static void put_values_8A8R8G8B_ximage( PUT_VALUES_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- GET_XRB(xrb);
- register GLuint i;
- for (i=0;i<n;i++) {
- if (mask[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] );
- }
- }
-}
-
-
-/*
- * Write an array of PF_8R8G8B pixels to an ximage.
- */
-static void put_values_8R8G8B_ximage( PUT_VALUES_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- GET_XRB(xrb);
- register GLuint i;
- for (i=0;i<n;i++) {
- if (mask[i]) {
- GLuint *ptr = PIXEL_ADDR4(xrb, x[i], y[i]);
- *ptr = PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
- }
- }
-}
-
-
-/*
- * Write an array of PF_8R8G8B24 pixels to an ximage.
- */
-static void put_values_8R8G8B24_ximage( PUT_VALUES_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- GET_XRB(xrb);
- register GLuint i;
- for (i=0;i<n;i++) {
- if (mask[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];
- }
- }
-}
-
-
-/*
- * Write an array of PF_5R6G5B pixels to an ximage.
- */
-static void put_values_5R6G5B_ximage( PUT_VALUES_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- GET_XRB(xrb);
- register GLuint i;
- for (i=0;i<n;i++) {
- if (mask[i]) {
- GLushort *ptr = PIXEL_ADDR2(xrb, x[i], y[i] );
- *ptr = PACK_5R6G5B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
- }
- }
-}
-
-
-/*
- * Write an array of PF_DITHER_5R6G5B pixels to an ximage.
- */
-static void put_values_DITHER_5R6G5B_ximage( PUT_VALUES_ARGS )
-{
- const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
- GET_XRB(xrb);
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- register GLuint i;
- for (i=0;i<n;i++) {
- if (mask[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] );
- }
- }
-}
@@ -1273,435 +197,11 @@ clip_for_xgetimage(struct gl_context *ctx, XMesaPixmap pixmap, GLuint *n, GLint
}
-/*
- * Read a horizontal span of color pixels.
- */
-static void
-get_row_rgba(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint n, GLint x, GLint y, void *values)
-{
- GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
-
- if (xrb->pixmap) {
- /* Read from Pixmap or Window */
- XMesaImage *span = NULL;
- int error;
- int k;
- y = YFLIP(xrb, y);
- k = clip_for_xgetimage(ctx, xrb->pixmap, &n, &x, &y);
- if (k < 0)
- return;
- rgba += k;
- catch_xgetimage_errors( xmesa->display );
- span = XGetImage( xmesa->display, xrb->pixmap,
- x, y, n, 1, AllPlanes, ZPixmap );
- error = check_xgetimage_errors();
- if (span && !error) {
- switch (xmesa->pixelformat) {
- case PF_Truecolor:
- case PF_Dither_True:
- {
- const GLubyte *pixelToR = xmesa->xm_visual->PixelToR;
- const GLubyte *pixelToG = xmesa->xm_visual->PixelToG;
- const GLubyte *pixelToB = xmesa->xm_visual->PixelToB;
- unsigned long rMask = GET_REDMASK(xmesa->xm_visual);
- unsigned long gMask = GET_GREENMASK(xmesa->xm_visual);
- unsigned long bMask = GET_BLUEMASK(xmesa->xm_visual);
- GLint rShift = xmesa->xm_visual->rshift;
- GLint gShift = xmesa->xm_visual->gshift;
- GLint bShift = xmesa->xm_visual->bshift;
- GLuint i;
- for (i=0;i<n;i++) {
- unsigned long p;
- p = XMesaGetPixel( span, i, 0 );
- rgba[i][RCOMP] = pixelToR[(p & rMask) >> rShift];
- rgba[i][GCOMP] = pixelToG[(p & gMask) >> gShift];
- rgba[i][BCOMP] = pixelToB[(p & bMask) >> bShift];
- rgba[i][ACOMP] = 255;
- }
- }
- break;
- case PF_5R6G5B:
- case PF_Dither_5R6G5B:
- {
- const GLubyte *pixelToR = xmesa->xm_visual->PixelToR;
- const GLubyte *pixelToG = xmesa->xm_visual->PixelToG;
- const GLubyte *pixelToB = xmesa->xm_visual->PixelToB;
- GLuint i;
- for (i=0;i<n;i++) {
- unsigned long p = XMesaGetPixel( span, i, 0 );
- /* fast, but not quite accurate
- rgba[i][RCOMP] = ((p >> 8) & 0xf8);
- rgba[i][GCOMP] = ((p >> 3) & 0xfc);
- rgba[i][BCOMP] = ((p << 3) & 0xff);
- */
- rgba[i][RCOMP] = pixelToR[p >> 11];
- rgba[i][GCOMP] = pixelToG[(p >> 5) & 0x3f];
- rgba[i][BCOMP] = pixelToB[p & 0x1f];
- rgba[i][ACOMP] = 255;
- }
- }
- break;
- case PF_8A8B8G8R:
- {
- const GLuint *ptr4 = (GLuint *) span->data;
- GLuint i;
- for (i=0;i<n;i++) {
- GLuint p4 = *ptr4++;
- rgba[i][RCOMP] = (GLubyte) ( p4 & 0xff);
- rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
- rgba[i][BCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
- rgba[i][ACOMP] = (GLubyte) ((p4 >> 24) & 0xff);
- }
- }
- break;
- case PF_8A8R8G8B:
- {
- const GLuint *ptr4 = (GLuint *) span->data;
- GLuint i;
- for (i=0;i<n;i++) {
- GLuint p4 = *ptr4++;
- rgba[i][RCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
- rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
- rgba[i][BCOMP] = (GLubyte) ( p4 & 0xff);
- rgba[i][ACOMP] = (GLubyte) ((p4 >> 24) & 0xff);
- }
- }
- break;
- case PF_8R8G8B:
- {
- const GLuint *ptr4 = (GLuint *) span->data;
- GLuint i;
- for (i=0;i<n;i++) {
- GLuint p4 = *ptr4++;
- rgba[i][RCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
- rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
- rgba[i][BCOMP] = (GLubyte) ( p4 & 0xff);
- rgba[i][ACOMP] = 255;
- }
- }
- break;
- case PF_8R8G8B24:
- {
- const bgr_t *ptr3 = (bgr_t *) span->data;
- GLuint i;
- for (i=0;i<n;i++) {
- rgba[i][RCOMP] = ptr3[i].r;
- rgba[i][GCOMP] = ptr3[i].g;
- rgba[i][BCOMP] = ptr3[i].b;
- rgba[i][ACOMP] = 255;
- }
- }
- break;
- default:
- _mesa_problem(NULL,"Problem in DD.read_color_span (1)");
- return;
- }
- }
- else {
- /* return black pixels */
- GLuint i;
- for (i=0;i<n;i++) {
- rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = rgba[i][ACOMP] = 0;
- }
- }
- if (span) {
- XMesaDestroyImage( span );
- }
- }
- else if (xrb->ximage) {
- /* Read from XImage back buffer */
- switch (xmesa->pixelformat) {
- case PF_Truecolor:
- case PF_Dither_True:
- {
- const GLubyte *pixelToR = xmesa->xm_visual->PixelToR;
- const GLubyte *pixelToG = xmesa->xm_visual->PixelToG;
- const GLubyte *pixelToB = xmesa->xm_visual->PixelToB;
- unsigned long rMask = GET_REDMASK(xmesa->xm_visual);
- unsigned long gMask = GET_GREENMASK(xmesa->xm_visual);
- unsigned long bMask = GET_BLUEMASK(xmesa->xm_visual);
- GLint rShift = xmesa->xm_visual->rshift;
- GLint gShift = xmesa->xm_visual->gshift;
- GLint bShift = xmesa->xm_visual->bshift;
- XMesaImage *img = xrb->ximage;
- GLuint i;
- y = YFLIP(xrb, y);
- for (i=0;i<n;i++) {
- unsigned long p;
- p = XMesaGetPixel( img, x+i, y );
- rgba[i][RCOMP] = pixelToR[(p & rMask) >> rShift];
- rgba[i][GCOMP] = pixelToG[(p & gMask) >> gShift];
- rgba[i][BCOMP] = pixelToB[(p & bMask) >> bShift];
- rgba[i][ACOMP] = 255;
- }
- }
- break;
- case PF_5R6G5B:
- case PF_Dither_5R6G5B:
- {
- const GLubyte *pixelToR = xmesa->xm_visual->PixelToR;
- const GLubyte *pixelToG = xmesa->xm_visual->PixelToG;
- const GLubyte *pixelToB = xmesa->xm_visual->PixelToB;
- 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;
- GLuint extraPixel = (n & 1);
- n -= extraPixel;
- for (i = 0; i < n; i += 2) {
- const GLuint p = *ptr4++;
- const GLuint p0 = p & 0xffff;
- const GLuint p1 = p >> 16;
- /* fast, but not quite accurate
- rgba[i][RCOMP] = ((p >> 8) & 0xf8);
- rgba[i][GCOMP] = ((p >> 3) & 0xfc);
- rgba[i][BCOMP] = ((p << 3) & 0xff);
- */
- rgba[i][RCOMP] = pixelToR[p0 >> 11];
- rgba[i][GCOMP] = pixelToG[(p0 >> 5) & 0x3f];
- rgba[i][BCOMP] = pixelToB[p0 & 0x1f];
- rgba[i][ACOMP] = 255;
- rgba[i+1][RCOMP] = pixelToR[p1 >> 11];
- rgba[i+1][GCOMP] = pixelToG[(p1 >> 5) & 0x3f];
- rgba[i+1][BCOMP] = pixelToB[p1 & 0x1f];
- rgba[i+1][ACOMP] = 255;
- }
- if (extraPixel) {
- GLushort p = ptr2[n];
- rgba[n][RCOMP] = pixelToR[p >> 11];
- rgba[n][GCOMP] = pixelToG[(p >> 5) & 0x3f];
- rgba[n][BCOMP] = pixelToB[p & 0x1f];
- rgba[n][ACOMP] = 255;
- }
-#else
- for (i = 0; i < n; i++) {
- const GLushort p = ptr2[i];
- rgba[i][RCOMP] = pixelToR[p >> 11];
- rgba[i][GCOMP] = pixelToG[(p >> 5) & 0x3f];
- rgba[i][BCOMP] = pixelToB[p & 0x1f];
- rgba[i][ACOMP] = 255;
- }
-#endif
- }
- break;
- case PF_8A8B8G8R:
- {
- const GLuint *ptr4 = PIXEL_ADDR4(xrb, x, y);
- GLuint i;
- for (i=0;i<n;i++) {
- GLuint p4 = *ptr4++;
- rgba[i][RCOMP] = (GLubyte) ( p4 & 0xff);
- rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
- rgba[i][BCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
- rgba[i][ACOMP] = (GLint) ((p4 >> 24) & 0xff);
- }
- }
- break;
- case PF_8A8R8G8B:
- {
- const GLuint *ptr4 = PIXEL_ADDR4(xrb, x, y);
- GLuint i;
- for (i=0;i<n;i++) {
- GLuint p4 = *ptr4++;
- rgba[i][RCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
- rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
- rgba[i][BCOMP] = (GLubyte) ( p4 & 0xff);
- rgba[i][ACOMP] = (GLint) ((p4 >> 24) & 0xff);
- }
- }
- break;
- case PF_8R8G8B:
- {
- const GLuint *ptr4 = PIXEL_ADDR4(xrb, x, y);
- GLuint i;
- for (i=0;i<n;i++) {
- GLuint p4 = *ptr4++;
- rgba[i][RCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
- rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
- rgba[i][BCOMP] = (GLubyte) ( p4 & 0xff);
- rgba[i][ACOMP] = 255;
- }
- }
- break;
- case PF_8R8G8B24:
- {
- const bgr_t *ptr3 = PIXEL_ADDR3(xrb, x, y);
- GLuint i;
- for (i=0;i<n;i++) {
- rgba[i][RCOMP] = ptr3[i].r;
- rgba[i][GCOMP] = ptr3[i].g;
- rgba[i][BCOMP] = ptr3[i].b;
- rgba[i][ACOMP] = 255;
- }
- }
- break;
- default:
- _mesa_problem(NULL,"Problem in DD.read_color_span (2)");
- return;
- }
- }
-}
-
+#define GET_XRB(XRB) \
+ struct xmesa_renderbuffer *XRB = xmesa_renderbuffer(rb)
-static void
-get_values_rgba(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint n, const GLint x[], const GLint y[], void *values)
-{
- GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
- GET_XRB(xrb);
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- XMesaDisplay *dpy = xmesa->xm_visual->display;
- register GLuint i;
- if (xrb->pixmap) {
- XMesaDrawable buffer = xrb->drawable;
- switch (xmesa->pixelformat) {
- case PF_Truecolor:
- case PF_Dither_True:
- case PF_5R6G5B:
- case PF_Dither_5R6G5B:
- {
- unsigned long rMask = GET_REDMASK(xmesa->xm_visual);
- unsigned long gMask = GET_GREENMASK(xmesa->xm_visual);
- unsigned long bMask = GET_BLUEMASK(xmesa->xm_visual);
- GLubyte *pixelToR = xmesa->xm_visual->PixelToR;
- GLubyte *pixelToG = xmesa->xm_visual->PixelToG;
- GLubyte *pixelToB = xmesa->xm_visual->PixelToB;
- GLint rShift = xmesa->xm_visual->rshift;
- GLint gShift = xmesa->xm_visual->gshift;
- GLint bShift = xmesa->xm_visual->bshift;
- for (i=0;i<n;i++) {
- unsigned long p = read_pixel( dpy, buffer,
- 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];
- rgba[i][ACOMP] = 255;
- }
- }
- break;
- case PF_8A8B8G8R:
- for (i=0;i<n;i++) {
- unsigned long p = read_pixel( dpy, buffer,
- 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);
- rgba[i][ACOMP] = (GLubyte) ((p >> 24) & 0xff);
- }
- break;
- case PF_8A8R8G8B:
- for (i=0;i<n;i++) {
- unsigned long p = read_pixel( dpy, buffer,
- 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);
- rgba[i][ACOMP] = (GLubyte) ((p >> 24) & 0xff);
- }
- break;
- case PF_8R8G8B:
- for (i=0;i<n;i++) {
- unsigned long p = read_pixel( dpy, buffer,
- 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);
- rgba[i][ACOMP] = 255;
- }
- break;
- case PF_8R8G8B24:
- for (i=0;i<n;i++) {
- unsigned long p = read_pixel( dpy, buffer,
- 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);
- rgba[i][ACOMP] = 255;
- }
- break;
- default:
- _mesa_problem(NULL,"Problem in DD.read_color_pixels (1)");
- return;
- }
- }
- else if (xrb->ximage) {
- /* Read from XImage back buffer */
- switch (xmesa->pixelformat) {
- case PF_Truecolor:
- case PF_Dither_True:
- case PF_5R6G5B:
- case PF_Dither_5R6G5B:
- {
- unsigned long rMask = GET_REDMASK(xmesa->xm_visual);
- unsigned long gMask = GET_GREENMASK(xmesa->xm_visual);
- unsigned long bMask = GET_BLUEMASK(xmesa->xm_visual);
- GLubyte *pixelToR = xmesa->xm_visual->PixelToR;
- GLubyte *pixelToG = xmesa->xm_visual->PixelToG;
- GLubyte *pixelToB = xmesa->xm_visual->PixelToB;
- GLint rShift = xmesa->xm_visual->rshift;
- GLint gShift = xmesa->xm_visual->gshift;
- GLint bShift = xmesa->xm_visual->bshift;
- XMesaImage *img = xrb->ximage;
- for (i=0;i<n;i++) {
- unsigned long p;
- 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];
- rgba[i][ACOMP] = 255;
- }
- }
- break;
- case PF_8A8B8G8R:
- for (i=0;i<n;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);
- rgba[i][BCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
- rgba[i][ACOMP] = (GLubyte) ((p4 >> 24) & 0xff);
- }
- break;
- case PF_8A8R8G8B:
- for (i=0;i<n;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);
- rgba[i][BCOMP] = (GLubyte) ( p4 & 0xff);
- rgba[i][ACOMP] = (GLubyte) ((p4 >> 24) & 0xff);
- }
- break;
- case PF_8R8G8B:
- for (i=0;i<n;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);
- rgba[i][BCOMP] = (GLubyte) ( p4 & 0xff);
- rgba[i][ACOMP] = 255;
- }
- break;
- case PF_8R8G8B24:
- for (i=0;i<n;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;
- rgba[i][ACOMP] = 255;
- }
- break;
- default:
- _mesa_problem(NULL,"Problem in DD.read_color_pixels (1)");
- return;
- }
- }
-}
/**
@@ -1714,97 +214,6 @@ void
xmesa_set_renderbuffer_funcs(struct xmesa_renderbuffer *xrb,
enum pixel_format pixelformat, GLint depth)
{
- const GLboolean pixmap = xrb->pixmap ? GL_TRUE : GL_FALSE;
-
- switch (pixelformat) {
- case PF_Truecolor:
- if (pixmap) {
- xrb->Base.PutRow = put_row_TRUECOLOR_pixmap;
- xrb->Base.PutValues = put_values_TRUECOLOR_pixmap;
- }
- else {
- xrb->Base.PutRow = put_row_TRUECOLOR_ximage;
- xrb->Base.PutValues = put_values_TRUECOLOR_ximage;
- }
- break;
- case PF_Dither_True:
- if (pixmap) {
- xrb->Base.PutRow = put_row_TRUEDITHER_pixmap;
- xrb->Base.PutValues = put_values_TRUEDITHER_pixmap;
- }
- else {
- xrb->Base.PutRow = put_row_TRUEDITHER_ximage;
- xrb->Base.PutValues = put_values_TRUEDITHER_ximage;
- }
- break;
- case PF_8A8B8G8R:
- if (pixmap) {
- xrb->Base.PutRow = put_row_8A8B8G8R_pixmap;
- xrb->Base.PutValues = put_values_8A8B8G8R_pixmap;
- }
- else {
- xrb->Base.PutRow = put_row_8A8B8G8R_ximage;
- xrb->Base.PutValues = put_values_8A8B8G8R_ximage;
- }
- break;
- case PF_8A8R8G8B:
- if (pixmap) {
- xrb->Base.PutRow = put_row_8A8R8G8B_pixmap;
- xrb->Base.PutValues = put_values_8A8R8G8B_pixmap;
- }
- else {
- xrb->Base.PutRow = put_row_8A8R8G8B_ximage;
- xrb->Base.PutValues = put_values_8A8R8G8B_ximage;
- }
- break;
- case PF_8R8G8B:
- if (pixmap) {
- xrb->Base.PutRow = put_row_8R8G8B_pixmap;
- xrb->Base.PutValues = put_values_8R8G8B_pixmap;
- }
- else {
- xrb->Base.PutRow = put_row_8R8G8B_ximage;
- xrb->Base.PutValues = put_values_8R8G8B_ximage;
- }
- break;
- case PF_8R8G8B24:
- if (pixmap) {
- xrb->Base.PutRow = put_row_8R8G8B24_pixmap;
- xrb->Base.PutValues = put_values_8R8G8B24_pixmap;
- }
- else {
- xrb->Base.PutRow = put_row_8R8G8B24_ximage;
- xrb->Base.PutValues = put_values_8R8G8B24_ximage;
- }
- break;
- case PF_5R6G5B:
- if (pixmap) {
- xrb->Base.PutRow = put_row_5R6G5B_pixmap;
- xrb->Base.PutValues = put_values_5R6G5B_pixmap;
- }
- else {
- xrb->Base.PutRow = put_row_5R6G5B_ximage;
- xrb->Base.PutValues = put_values_5R6G5B_ximage;
- }
- break;
- case PF_Dither_5R6G5B:
- if (pixmap) {
- xrb->Base.PutRow = put_row_DITHER_5R6G5B_pixmap;
- xrb->Base.PutValues = put_values_DITHER_5R6G5B_pixmap;
- }
- else {
- xrb->Base.PutRow = put_row_DITHER_5R6G5B_ximage;
- xrb->Base.PutValues = put_values_DITHER_5R6G5B_ximage;
- }
- break;
- default:
- _mesa_problem(NULL, "Bad pixel format in xmesa_update_state (1)");
- return;
- }
-
-
- /* Get functions */
- xrb->Base.GetRow = get_row_rgba;
- xrb->Base.GetValues = get_values_rgba;
+ /* XXX remove this */
}