summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2001-01-25 17:34:21 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2001-01-25 17:34:21 +0000
commitc3ccae5f498ee75e5d68f0383aee345544bb6079 (patch)
tree6bd676e57fcc506e5e18a29c5f84195c21c4b5ae
parent18074cf055a53192f63045f95a63cddacf77519e (diff)
improved glReadPixels accuracy for 16bpp color buffers - fixes lots of conformance bugs
-rw-r--r--src/mesa/main/image.c1746
-rw-r--r--src/mesa/main/image.h13
2 files changed, 902 insertions, 857 deletions
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index ca6b55b6af..44eab2d975 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -1,8 +1,8 @@
-/* $Id: image.c,v 1.35.4.4 2000/11/09 23:24:25 brianp Exp $ */
+/* $Id: image.c,v 1.35.4.5 2001/01/25 17:34:21 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.4
+ * Version: 3.4.1
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -591,6 +591,891 @@ _mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest,
+
+void
+_mesa_pack_float_rgba_span( GLcontext *ctx,
+ GLuint n, CONST GLfloat rgbaIn[][4],
+ GLenum dstFormat, GLenum dstType,
+ GLvoid *destination,
+ const struct gl_pixelstore_attrib *dstPacking,
+ GLboolean applyTransferOps )
+{
+ const GLint comps = _mesa_components_in_format(dstFormat);
+ GLfloat luminance[MAX_WIDTH];
+ GLfloat (*rgba)[4];
+ GLuint i;
+
+ /*
+ * Apply scale, bias and lookup-tables if enabled.
+ */
+ if (applyTransferOps) {
+ /* make copy of incoming data */
+ GLfloat rgbaCopy[MAX_WIDTH][4];
+ for (i = 0; i < n; i++) {
+ rgbaCopy[i][0] = rgbaIn[i][0];
+ rgbaCopy[i][1] = rgbaIn[i][1];
+ rgbaCopy[i][2] = rgbaIn[i][2];
+ rgbaCopy[i][3] = rgbaIn[i][3];
+ }
+
+ rgba = (GLfloat (*)[4]) rgbaCopy;
+
+ /* scale & bias */
+ if (ctx->Pixel.ScaleOrBiasRGBA) {
+ _mesa_scale_and_bias_rgba( ctx, n, (GLfloat (*)[4]) rgba );
+ }
+ /* color map lookup */
+ if (ctx->Pixel.MapColorFlag) {
+ _mesa_map_rgba( ctx, n, rgba );
+ }
+ /* GL_COLOR_TABLE lookup */
+ if (ctx->Pixel.ColorTableEnabled) {
+ _mesa_lookup_rgba(&ctx->ColorTable, n, rgba);
+ }
+ /* XXX convolution here */
+ /* GL_POST_CONVOLUTION_COLOR_TABLE lookup */
+ if (ctx->Pixel.PostConvolutionColorTableEnabled) {
+ _mesa_lookup_rgba(&ctx->PostConvolutionColorTable, n, rgba);
+ }
+ /* color matrix transform */
+ if (ctx->ColorMatrix.type != MATRIX_IDENTITY ||
+ ctx->Pixel.ScaleOrBiasRGBApcm) {
+ _mesa_transform_rgba(ctx, n, rgba);
+ }
+ /* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */
+ if (ctx->Pixel.PostColorMatrixColorTableEnabled) {
+ _mesa_lookup_rgba(&ctx->PostColorMatrixColorTable, n, rgba);
+ }
+ /* update histogram count */
+ if (ctx->Pixel.HistogramEnabled) {
+ _mesa_update_histogram(ctx, n, (CONST GLfloat (*)[4]) rgba);
+ }
+ /* XXX min/max here */
+ if (ctx->Pixel.MinMaxEnabled) {
+ _mesa_update_minmax(ctx, n, (CONST GLfloat (*)[4]) rgba);
+ if (ctx->MinMax.Sink)
+ return;
+ }
+ }
+ else {
+ /* use incoming data, not a copy */
+ rgba = (GLfloat (*)[4]) rgbaIn;
+ }
+
+ if (dstFormat == GL_LUMINANCE || dstFormat == GL_LUMINANCE_ALPHA) {
+ for (i=0;i<n;i++) {
+ GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP];
+ luminance[i] = CLAMP( sum, 0.0F, 1.0F );
+ }
+ }
+
+ /*
+ * Pack/store the pixels. Ugh! Lots of cases!!!
+ */
+ switch (dstType) {
+ case GL_UNSIGNED_BYTE:
+ {
+ GLubyte *dst = (GLubyte *) destination;
+ switch (dstFormat) {
+ case GL_RED:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
+ break;
+ case GL_GREEN:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_UBYTE(rgba[i][GCOMP]);
+ break;
+ case GL_BLUE:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_UBYTE(rgba[i][BCOMP]);
+ break;
+ case GL_ALPHA:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_UBYTE(rgba[i][ACOMP]);
+ break;
+ case GL_LUMINANCE:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_UBYTE(luminance[i]);
+ break;
+ case GL_LUMINANCE_ALPHA:
+ for (i=0;i<n;i++) {
+ dst[i*2+0] = FLOAT_TO_UBYTE(luminance[i]);
+ dst[i*2+1] = FLOAT_TO_UBYTE(rgba[i][ACOMP]);
+ }
+ break;
+ case GL_RGB:
+ for (i=0;i<n;i++) {
+ dst[i*3+0] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
+ dst[i*3+1] = FLOAT_TO_UBYTE(rgba[i][GCOMP]);
+ dst[i*3+2] = FLOAT_TO_UBYTE(rgba[i][BCOMP]);
+ }
+ break;
+ case GL_RGBA:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
+ dst[i*4+1] = FLOAT_TO_UBYTE(rgba[i][GCOMP]);
+ dst[i*4+2] = FLOAT_TO_UBYTE(rgba[i][BCOMP]);
+ dst[i*4+3] = FLOAT_TO_UBYTE(rgba[i][ACOMP]);
+ }
+ break;
+ case GL_BGR:
+ for (i=0;i<n;i++) {
+ dst[i*3+0] = FLOAT_TO_UBYTE(rgba[i][BCOMP]);
+ dst[i*3+1] = FLOAT_TO_UBYTE(rgba[i][GCOMP]);
+ dst[i*3+2] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
+ }
+ break;
+ case GL_BGRA:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = FLOAT_TO_UBYTE(rgba[i][BCOMP]);
+ dst[i*4+1] = FLOAT_TO_UBYTE(rgba[i][GCOMP]);
+ dst[i*4+2] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
+ dst[i*4+3] = FLOAT_TO_UBYTE(rgba[i][ACOMP]);
+ }
+ break;
+ case GL_ABGR_EXT:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = FLOAT_TO_UBYTE(rgba[i][ACOMP]);
+ dst[i*4+1] = FLOAT_TO_UBYTE(rgba[i][BCOMP]);
+ dst[i*4+2] = FLOAT_TO_UBYTE(rgba[i][GCOMP]);
+ dst[i*4+3] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
+ }
+ break;
+ default:
+ gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
+ }
+ }
+ break;
+ case GL_BYTE:
+ {
+ GLbyte *dst = (GLbyte *) destination;
+ switch (dstFormat) {
+ case GL_RED:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_BYTE(rgba[i][RCOMP]);
+ break;
+ case GL_GREEN:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_BYTE(rgba[i][GCOMP]);
+ break;
+ case GL_BLUE:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_BYTE(rgba[i][BCOMP]);
+ break;
+ case GL_ALPHA:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_BYTE(rgba[i][ACOMP]);
+ break;
+ case GL_LUMINANCE:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_BYTE(luminance[i]);
+ break;
+ case GL_LUMINANCE_ALPHA:
+ for (i=0;i<n;i++) {
+ dst[i*2+0] = FLOAT_TO_BYTE(luminance[i]);
+ dst[i*2+1] = FLOAT_TO_BYTE(rgba[i][ACOMP]);
+ }
+ break;
+ case GL_RGB:
+ for (i=0;i<n;i++) {
+ dst[i*3+0] = FLOAT_TO_BYTE(rgba[i][RCOMP]);
+ dst[i*3+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]);
+ dst[i*3+2] = FLOAT_TO_BYTE(rgba[i][BCOMP]);
+ }
+ break;
+ case GL_RGBA:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = FLOAT_TO_BYTE(rgba[i][RCOMP]);
+ dst[i*4+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]);
+ dst[i*4+2] = FLOAT_TO_BYTE(rgba[i][BCOMP]);
+ dst[i*4+3] = FLOAT_TO_BYTE(rgba[i][ACOMP]);
+ }
+ break;
+ case GL_BGR:
+ for (i=0;i<n;i++) {
+ dst[i*3+0] = FLOAT_TO_BYTE(rgba[i][BCOMP]);
+ dst[i*3+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]);
+ dst[i*3+2] = FLOAT_TO_BYTE(rgba[i][RCOMP]);
+ }
+ break;
+ case GL_BGRA:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = FLOAT_TO_BYTE(rgba[i][BCOMP]);
+ dst[i*4+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]);
+ dst[i*4+2] = FLOAT_TO_BYTE(rgba[i][RCOMP]);
+ dst[i*4+3] = FLOAT_TO_BYTE(rgba[i][ACOMP]);
+ }
+ case GL_ABGR_EXT:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = FLOAT_TO_BYTE(rgba[i][ACOMP]);
+ dst[i*4+1] = FLOAT_TO_BYTE(rgba[i][BCOMP]);
+ dst[i*4+2] = FLOAT_TO_BYTE(rgba[i][GCOMP]);
+ dst[i*4+3] = FLOAT_TO_BYTE(rgba[i][RCOMP]);
+ }
+ break;
+ default:
+ gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT:
+ {
+ GLushort *dst = (GLushort *) destination;
+ switch (dstFormat) {
+ case GL_RED:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_USHORT(rgba[i][RCOMP]);
+ break;
+ case GL_GREEN:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_USHORT(rgba[i][GCOMP]);
+ break;
+ case GL_BLUE:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_USHORT(rgba[i][BCOMP]);
+ break;
+ case GL_ALPHA:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_USHORT(rgba[i][ACOMP]);
+ break;
+ case GL_LUMINANCE:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_USHORT(luminance[i]);
+ break;
+ case GL_LUMINANCE_ALPHA:
+ for (i=0;i<n;i++) {
+ dst[i*2+0] = FLOAT_TO_USHORT(luminance[i]);
+ dst[i*2+1] = FLOAT_TO_USHORT(rgba[i][ACOMP]);
+ }
+ break;
+ case GL_RGB:
+ for (i=0;i<n;i++) {
+ dst[i*3+0] = FLOAT_TO_USHORT(rgba[i][RCOMP]);
+ dst[i*3+1] = FLOAT_TO_USHORT(rgba[i][GCOMP]);
+ dst[i*3+2] = FLOAT_TO_USHORT(rgba[i][BCOMP]);
+ }
+ break;
+ case GL_RGBA:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = FLOAT_TO_USHORT(rgba[i][RCOMP]);
+ dst[i*4+1] = FLOAT_TO_USHORT(rgba[i][GCOMP]);
+ dst[i*4+2] = FLOAT_TO_USHORT(rgba[i][BCOMP]);
+ dst[i*4+3] = FLOAT_TO_USHORT(rgba[i][ACOMP]);
+ }
+ break;
+ case GL_BGR:
+ for (i=0;i<n;i++) {
+ dst[i*3+0] = FLOAT_TO_USHORT(rgba[i][BCOMP]);
+ dst[i*3+1] = FLOAT_TO_USHORT(rgba[i][GCOMP]);
+ dst[i*3+2] = FLOAT_TO_USHORT(rgba[i][RCOMP]);
+ }
+ break;
+ case GL_BGRA:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = FLOAT_TO_USHORT(rgba[i][BCOMP]);
+ dst[i*4+1] = FLOAT_TO_USHORT(rgba[i][GCOMP]);
+ dst[i*4+2] = FLOAT_TO_USHORT(rgba[i][RCOMP]);
+ dst[i*4+3] = FLOAT_TO_USHORT(rgba[i][ACOMP]);
+ }
+ break;
+ case GL_ABGR_EXT:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = FLOAT_TO_USHORT(rgba[i][ACOMP]);
+ dst[i*4+1] = FLOAT_TO_USHORT(rgba[i][BCOMP]);
+ dst[i*4+2] = FLOAT_TO_USHORT(rgba[i][GCOMP]);
+ dst[i*4+3] = FLOAT_TO_USHORT(rgba[i][RCOMP]);
+ }
+ break;
+ default:
+ gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap2( (GLushort *) dst, n * comps);
+ }
+ }
+ break;
+ case GL_SHORT:
+ {
+ GLshort *dst = (GLshort *) destination;
+ switch (dstFormat) {
+ case GL_RED:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_SHORT(rgba[i][RCOMP]);
+ break;
+ case GL_GREEN:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_SHORT(rgba[i][GCOMP]);
+ break;
+ case GL_BLUE:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_SHORT(rgba[i][BCOMP]);
+ break;
+ case GL_ALPHA:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_SHORT(rgba[i][ACOMP]);
+ break;
+ case GL_LUMINANCE:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_SHORT(luminance[i]);
+ break;
+ case GL_LUMINANCE_ALPHA:
+ for (i=0;i<n;i++) {
+ dst[i*2+0] = FLOAT_TO_SHORT(luminance[i]);
+ dst[i*2+1] = FLOAT_TO_SHORT(rgba[i][ACOMP]);
+ }
+ break;
+ case GL_RGB:
+ for (i=0;i<n;i++) {
+ dst[i*3+0] = FLOAT_TO_SHORT(rgba[i][RCOMP]);
+ dst[i*3+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]);
+ dst[i*3+2] = FLOAT_TO_SHORT(rgba[i][BCOMP]);
+ }
+ break;
+ case GL_RGBA:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = FLOAT_TO_SHORT(rgba[i][RCOMP]);
+ dst[i*4+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]);
+ dst[i*4+2] = FLOAT_TO_SHORT(rgba[i][BCOMP]);
+ dst[i*4+3] = FLOAT_TO_SHORT(rgba[i][ACOMP]);
+ }
+ break;
+ case GL_BGR:
+ for (i=0;i<n;i++) {
+ dst[i*3+0] = FLOAT_TO_SHORT(rgba[i][BCOMP]);
+ dst[i*3+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]);
+ dst[i*3+2] = FLOAT_TO_SHORT(rgba[i][RCOMP]);
+ }
+ break;
+ case GL_BGRA:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = FLOAT_TO_SHORT(rgba[i][BCOMP]);
+ dst[i*4+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]);
+ dst[i*4+2] = FLOAT_TO_SHORT(rgba[i][RCOMP]);
+ dst[i*4+3] = FLOAT_TO_SHORT(rgba[i][ACOMP]);
+ }
+ case GL_ABGR_EXT:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = FLOAT_TO_SHORT(rgba[i][ACOMP]);
+ dst[i*4+1] = FLOAT_TO_SHORT(rgba[i][BCOMP]);
+ dst[i*4+2] = FLOAT_TO_SHORT(rgba[i][GCOMP]);
+ dst[i*4+3] = FLOAT_TO_SHORT(rgba[i][RCOMP]);
+ }
+ break;
+ default:
+ gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap2( (GLushort *) dst, n * comps );
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT:
+ {
+ GLuint *dst = (GLuint *) destination;
+ switch (dstFormat) {
+ case GL_RED:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_UINT(rgba[i][RCOMP]);
+ break;
+ case GL_GREEN:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_UINT(rgba[i][GCOMP]);
+ break;
+ case GL_BLUE:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_UINT(rgba[i][BCOMP]);
+ break;
+ case GL_ALPHA:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_UINT(rgba[i][ACOMP]);
+ break;
+ case GL_LUMINANCE:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_UINT(luminance[i]);
+ break;
+ case GL_LUMINANCE_ALPHA:
+ for (i=0;i<n;i++) {
+ dst[i*2+0] = FLOAT_TO_UINT(luminance[i]);
+ dst[i*2+1] = FLOAT_TO_UINT(rgba[i][ACOMP]);
+ }
+ break;
+ case GL_RGB:
+ for (i=0;i<n;i++) {
+ dst[i*3+0] = FLOAT_TO_UINT(rgba[i][RCOMP]);
+ dst[i*3+1] = FLOAT_TO_UINT(rgba[i][GCOMP]);
+ dst[i*3+2] = FLOAT_TO_UINT(rgba[i][BCOMP]);
+ }
+ break;
+ case GL_RGBA:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = FLOAT_TO_UINT(rgba[i][RCOMP]);
+ dst[i*4+1] = FLOAT_TO_UINT(rgba[i][GCOMP]);
+ dst[i*4+2] = FLOAT_TO_UINT(rgba[i][BCOMP]);
+ dst[i*4+3] = FLOAT_TO_UINT(rgba[i][ACOMP]);
+ }
+ break;
+ case GL_BGR:
+ for (i=0;i<n;i++) {
+ dst[i*3+0] = FLOAT_TO_UINT(rgba[i][BCOMP]);
+ dst[i*3+1] = FLOAT_TO_UINT(rgba[i][GCOMP]);
+ dst[i*3+2] = FLOAT_TO_UINT(rgba[i][RCOMP]);
+ }
+ break;
+ case GL_BGRA:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = FLOAT_TO_UINT(rgba[i][BCOMP]);
+ dst[i*4+1] = FLOAT_TO_UINT(rgba[i][GCOMP]);
+ dst[i*4+2] = FLOAT_TO_UINT(rgba[i][RCOMP]);
+ dst[i*4+3] = FLOAT_TO_UINT(rgba[i][ACOMP]);
+ }
+ break;
+ case GL_ABGR_EXT:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = FLOAT_TO_UINT(rgba[i][ACOMP]);
+ dst[i*4+1] = FLOAT_TO_UINT(rgba[i][BCOMP]);
+ dst[i*4+2] = FLOAT_TO_UINT(rgba[i][GCOMP]);
+ dst[i*4+3] = FLOAT_TO_UINT(rgba[i][RCOMP]);
+ }
+ break;
+ default:
+ gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap4( (GLuint *) dst, n * comps );
+ }
+ }
+ break;
+ case GL_INT:
+ {
+ GLint *dst = (GLint *) destination;
+ switch (dstFormat) {
+ case GL_RED:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_INT(rgba[i][RCOMP]);
+ break;
+ case GL_GREEN:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_INT(rgba[i][GCOMP]);
+ break;
+ case GL_BLUE:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_INT(rgba[i][BCOMP]);
+ break;
+ case GL_ALPHA:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_INT(rgba[i][ACOMP]);
+ break;
+ case GL_LUMINANCE:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_INT(luminance[i]);
+ break;
+ case GL_LUMINANCE_ALPHA:
+ for (i=0;i<n;i++) {
+ dst[i*2+0] = FLOAT_TO_INT(luminance[i]);
+ dst[i*2+1] = FLOAT_TO_INT(rgba[i][ACOMP]);
+ }
+ break;
+ case GL_RGB:
+ for (i=0;i<n;i++) {
+ dst[i*3+0] = FLOAT_TO_INT(rgba[i][RCOMP]);
+ dst[i*3+1] = FLOAT_TO_INT(rgba[i][GCOMP]);
+ dst[i*3+2] = FLOAT_TO_INT(rgba[i][BCOMP]);
+ }
+ break;
+ case GL_RGBA:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = FLOAT_TO_INT(rgba[i][RCOMP]);
+ dst[i*4+1] = FLOAT_TO_INT(rgba[i][GCOMP]);
+ dst[i*4+2] = FLOAT_TO_INT(rgba[i][BCOMP]);
+ dst[i*4+3] = FLOAT_TO_INT(rgba[i][ACOMP]);
+ }
+ break;
+ case GL_BGR:
+ for (i=0;i<n;i++) {
+ dst[i*3+0] = FLOAT_TO_INT(rgba[i][BCOMP]);
+ dst[i*3+1] = FLOAT_TO_INT(rgba[i][GCOMP]);
+ dst[i*3+2] = FLOAT_TO_INT(rgba[i][RCOMP]);
+ }
+ break;
+ case GL_BGRA:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = FLOAT_TO_INT(rgba[i][BCOMP]);
+ dst[i*4+1] = FLOAT_TO_INT(rgba[i][GCOMP]);
+ dst[i*4+2] = FLOAT_TO_INT(rgba[i][RCOMP]);
+ dst[i*4+3] = FLOAT_TO_INT(rgba[i][ACOMP]);
+ }
+ break;
+ case GL_ABGR_EXT:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = FLOAT_TO_INT(rgba[i][ACOMP]);
+ dst[i*4+1] = FLOAT_TO_INT(rgba[i][BCOMP]);
+ dst[i*4+2] = FLOAT_TO_INT(rgba[i][GCOMP]);
+ dst[i*4+3] = FLOAT_TO_INT(rgba[i][RCOMP]);
+ }
+ break;
+ default:
+ gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap4( (GLuint *) dst, n * comps );
+ }
+ }
+ break;
+ case GL_FLOAT:
+ {
+ GLfloat *dst = (GLfloat *) destination;
+ switch (dstFormat) {
+ case GL_RED:
+ for (i=0;i<n;i++)
+ dst[i] = rgba[i][RCOMP];
+ break;
+ case GL_GREEN:
+ for (i=0;i<n;i++)
+ dst[i] = rgba[i][GCOMP];
+ break;
+ case GL_BLUE:
+ for (i=0;i<n;i++)
+ dst[i] = rgba[i][BCOMP];
+ break;
+ case GL_ALPHA:
+ for (i=0;i<n;i++)
+ dst[i] = rgba[i][ACOMP];
+ break;
+ case GL_LUMINANCE:
+ for (i=0;i<n;i++)
+ dst[i] = luminance[i];
+ break;
+ case GL_LUMINANCE_ALPHA:
+ for (i=0;i<n;i++) {
+ dst[i*2+0] = luminance[i];
+ dst[i*2+1] = rgba[i][ACOMP];
+ }
+ break;
+ case GL_RGB:
+ for (i=0;i<n;i++) {
+ dst[i*3+0] = rgba[i][RCOMP];
+ dst[i*3+1] = rgba[i][GCOMP];
+ dst[i*3+2] = rgba[i][BCOMP];
+ }
+ break;
+ case GL_RGBA:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = rgba[i][RCOMP];
+ dst[i*4+1] = rgba[i][GCOMP];
+ dst[i*4+2] = rgba[i][BCOMP];
+ dst[i*4+3] = rgba[i][ACOMP];
+ }
+ break;
+ case GL_BGR:
+ for (i=0;i<n;i++) {
+ dst[i*3+0] = rgba[i][BCOMP];
+ dst[i*3+1] = rgba[i][GCOMP];
+ dst[i*3+2] = rgba[i][RCOMP];
+ }
+ break;
+ case GL_BGRA:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = rgba[i][BCOMP];
+ dst[i*4+1] = rgba[i][GCOMP];
+ dst[i*4+2] = rgba[i][RCOMP];
+ dst[i*4+3] = rgba[i][ACOMP];
+ }
+ break;
+ case GL_ABGR_EXT:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = rgba[i][ACOMP];
+ dst[i*4+1] = rgba[i][BCOMP];
+ dst[i*4+2] = rgba[i][GCOMP];
+ dst[i*4+3] = rgba[i][RCOMP];
+ }
+ break;
+ default:
+ gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap4( (GLuint *) dst, n * comps );
+ }
+ }
+ break;
+ case GL_UNSIGNED_BYTE_3_3_2:
+ if (dstFormat == GL_RGB) {
+ GLubyte *dst = (GLubyte *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][RCOMP] * 7.0F)) << 5)
+ | (((GLint) (rgba[i][GCOMP] * 7.0F)) << 2)
+ | (((GLint) (rgba[i][BCOMP] * 3.0F)) );
+ }
+ }
+ break;
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ if (dstFormat == GL_RGB) {
+ GLubyte *dst = (GLubyte *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][RCOMP] * 7.0F)) )
+ | (((GLint) (rgba[i][GCOMP] * 7.0F)) << 3)
+ | (((GLint) (rgba[i][BCOMP] * 3.0F)) << 5);
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ if (dstFormat == GL_RGB) {
+ GLushort *dst = (GLushort *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) << 11)
+ | (((GLint) (rgba[i][GCOMP] * 63.0F)) << 5)
+ | (((GLint) (rgba[i][BCOMP] * 31.0F)) );
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ if (dstFormat == GL_RGB) {
+ GLushort *dst = (GLushort *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) )
+ | (((GLint) (rgba[i][GCOMP] * 63.0F)) << 5)
+ | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 11);
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ if (dstFormat == GL_RGBA) {
+ GLushort *dst = (GLushort *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][RCOMP] * 15.0F)) << 12)
+ | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 8)
+ | (((GLint) (rgba[i][BCOMP] * 15.0F)) << 4)
+ | (((GLint) (rgba[i][ACOMP] * 15.0F)) );
+ }
+ }
+ else if (dstFormat == GL_BGRA) {
+ GLushort *dst = (GLushort *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][BCOMP] * 15.0F)) << 12)
+ | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 8)
+ | (((GLint) (rgba[i][RCOMP] * 15.0F)) << 4)
+ | (((GLint) (rgba[i][ACOMP] * 15.0F)) );
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLushort *dst = (GLushort *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][ACOMP] * 15.0F)) << 4)
+ | (((GLint) (rgba[i][BCOMP] * 15.0F)) << 8)
+ | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 12)
+ | (((GLint) (rgba[i][RCOMP] * 15.0F)) );
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ if (dstFormat == GL_RGBA) {
+ GLushort *dst = (GLushort *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][RCOMP] * 15.0F)) )
+ | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 4)
+ | (((GLint) (rgba[i][BCOMP] * 15.0F)) << 8)
+ | (((GLint) (rgba[i][ACOMP] * 15.0F)) << 12);
+ }
+ }
+ else if (dstFormat == GL_BGRA) {
+ GLushort *dst = (GLushort *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][BCOMP] * 15.0F)) )
+ | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 4)
+ | (((GLint) (rgba[i][RCOMP] * 15.0F)) << 8)
+ | (((GLint) (rgba[i][ACOMP] * 15.0F)) << 12);
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLushort *dst = (GLushort *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][ACOMP] * 15.0F)) )
+ | (((GLint) (rgba[i][BCOMP] * 15.0F)) << 4)
+ | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 8)
+ | (((GLint) (rgba[i][RCOMP] * 15.0F)) << 12);
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ if (dstFormat == GL_RGBA) {
+ GLushort *dst = (GLushort *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) << 11)
+ | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 6)
+ | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 1)
+ | (((GLint) (rgba[i][ACOMP] * 1.0F)) );
+ }
+ }
+ else if (dstFormat == GL_BGRA) {
+ GLushort *dst = (GLushort *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][BCOMP] * 31.0F)) << 11)
+ | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 6)
+ | (((GLint) (rgba[i][RCOMP] * 31.0F)) << 1)
+ | (((GLint) (rgba[i][ACOMP] * 1.0F)) );
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLushort *dst = (GLushort *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][ACOMP] * 31.0F)) << 11)
+ | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 6)
+ | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 1)
+ | (((GLint) (rgba[i][RCOMP] * 1.0F)) );
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ if (dstFormat == GL_RGBA) {
+ GLushort *dst = (GLushort *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) )
+ | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 5)
+ | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 10)
+ | (((GLint) (rgba[i][ACOMP] * 1.0F)) << 15);
+ }
+ }
+ else if (dstFormat == GL_BGRA) {
+ GLushort *dst = (GLushort *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][BCOMP] * 31.0F)) )
+ | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 5)
+ | (((GLint) (rgba[i][RCOMP] * 31.0F)) << 10)
+ | (((GLint) (rgba[i][ACOMP] * 1.0F)) << 15);
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLushort *dst = (GLushort *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][ACOMP] * 31.0F)) )
+ | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 5)
+ | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 10)
+ | (((GLint) (rgba[i][RCOMP] * 1.0F)) << 15);
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ if (dstFormat == GL_RGBA) {
+ GLuint *dst = (GLuint *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 24)
+ | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 16)
+ | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 8)
+ | (((GLuint) (rgba[i][ACOMP] * 255.0F)) );
+ }
+ }
+ else if (dstFormat == GL_BGRA) {
+ GLuint *dst = (GLuint *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 24)
+ | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 16)
+ | (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 8)
+ | (((GLuint) (rgba[i][ACOMP] * 255.0F)) );
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLuint *dst = (GLuint *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLuint) (rgba[i][ACOMP] * 255.0F)) << 24)
+ | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 16)
+ | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 8)
+ | (((GLuint) (rgba[i][RCOMP] * 255.0F)) );
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ if (dstFormat == GL_RGBA) {
+ GLuint *dst = (GLuint *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLuint) (rgba[i][RCOMP] * 255.0F)) )
+ | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 8)
+ | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 16)
+ | (((GLuint) (rgba[i][ACOMP] * 255.0F)) << 24);
+ }
+ }
+ else if (dstFormat == GL_BGRA) {
+ GLuint *dst = (GLuint *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLuint) (rgba[i][BCOMP] * 255.0F)) )
+ | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 8)
+ | (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 16)
+ | (((GLuint) (rgba[i][ACOMP] * 255.0F)) << 24);
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLuint *dst = (GLuint *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLuint) (rgba[i][ACOMP] * 255.0F)) )
+ | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 8)
+ | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 16)
+ | (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 24);
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT_10_10_10_2:
+ if (dstFormat == GL_RGBA) {
+ GLuint *dst = (GLuint *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLuint) (rgba[i][RCOMP] * 1023.0F)) << 22)
+ | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 12)
+ | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 2)
+ | (((GLuint) (rgba[i][ACOMP] * 3.0F)) );
+ }
+ }
+ else if (dstFormat == GL_BGRA) {
+ GLuint *dst = (GLuint *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 22)
+ | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 12)
+ | (((GLuint) (rgba[i][RCOMP] * 1023.0F)) << 2)
+ | (((GLuint) (rgba[i][ACOMP] * 3.0F)) );
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLuint *dst = (GLuint *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLuint) (rgba[i][ACOMP] * 1023.0F)) << 22)
+ | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 12)
+ | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 2)
+ | (((GLuint) (rgba[i][RCOMP] * 3.0F)) );
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ if (dstFormat == GL_RGBA) {
+ GLuint *dst = (GLuint *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLuint) (rgba[i][RCOMP] * 1023.0F)) )
+ | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 10)
+ | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 20)
+ | (((GLuint) (rgba[i][ACOMP] * 3.0F)) << 30);
+ }
+ }
+ else if (dstFormat == GL_BGRA) {
+ GLuint *dst = (GLuint *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLuint) (rgba[i][BCOMP] * 1023.0F)) )
+ | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 10)
+ | (((GLuint) (rgba[i][RCOMP] * 1023.0F)) << 20)
+ | (((GLuint) (rgba[i][ACOMP] * 3.0F)) << 30);
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLuint *dst = (GLuint *) destination;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLuint) (rgba[i][ACOMP] * 1023.0F)) )
+ | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 10)
+ | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 20)
+ | (((GLuint) (rgba[i][RCOMP] * 3.0F)) << 30);
+ }
+ }
+ break;
+ default:
+ gl_problem( ctx, "bad type in _mesa_pack_rgba_rgba_span" );
+ }
+}
+
+
+
/*
* Pack the given RGBA span into client memory at 'dest' address
* in the given pixel format and type.
@@ -641,12 +1526,11 @@ _mesa_pack_rgba_span( GLcontext *ctx,
}
else {
/* general solution */
- GLfloat rgba[MAX_WIDTH][4], luminance[MAX_WIDTH];
+ GLfloat rgba[MAX_WIDTH][4];
const GLfloat rscale = 1.0F / 255.0F;
const GLfloat gscale = 1.0F / 255.0F;
const GLfloat bscale = 1.0F / 255.0F;
const GLfloat ascale = 1.0F / 255.0F;
- const GLint comps = _mesa_components_in_format(format);
GLuint i;
assert(n <= MAX_WIDTH);
@@ -659,858 +1543,10 @@ _mesa_pack_rgba_span( GLcontext *ctx,
rgba[i][ACOMP] = srcRgba[i][ACOMP] * ascale;
}
- /*
- * Apply scale, bias and lookup-tables if enabled.
- */
- if (applyTransferOps) {
- /* scale & bias */
- if (ctx->Pixel.ScaleOrBiasRGBA) {
- _mesa_scale_and_bias_rgba( ctx, n, rgba );
- }
- /* color map lookup */
- if (ctx->Pixel.MapColorFlag) {
- _mesa_map_rgba( ctx, n, rgba );
- }
- /* GL_COLOR_TABLE lookup */
- if (ctx->Pixel.ColorTableEnabled) {
- _mesa_lookup_rgba(&ctx->ColorTable, n, rgba);
- }
- /* XXX convolution here */
- /* GL_POST_CONVOLUTION_COLOR_TABLE lookup */
- if (ctx->Pixel.PostConvolutionColorTableEnabled) {
- _mesa_lookup_rgba(&ctx->PostConvolutionColorTable, n, rgba);
- }
- /* color matrix transform */
- if (ctx->ColorMatrix.type != MATRIX_IDENTITY ||
- ctx->Pixel.ScaleOrBiasRGBApcm) {
- _mesa_transform_rgba(ctx, n, rgba);
- }
- /* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */
- if (ctx->Pixel.PostColorMatrixColorTableEnabled) {
- _mesa_lookup_rgba(&ctx->PostColorMatrixColorTable, n, rgba);
- }
- /* update histogram count */
- if (ctx->Pixel.HistogramEnabled) {
- _mesa_update_histogram(ctx, n, (CONST GLfloat (*)[4]) rgba);
- }
- /* XXX min/max here */
- if (ctx->Pixel.MinMaxEnabled) {
- _mesa_update_minmax(ctx, n, (CONST GLfloat (*)[4]) rgba);
- if (ctx->MinMax.Sink)
- return;
- }
- }
-
- if (format==GL_LUMINANCE || format==GL_LUMINANCE_ALPHA) {
- for (i=0;i<n;i++) {
- GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP];
- luminance[i] = CLAMP( sum, 0.0F, 1.0F );
- }
- }
+ _mesa_pack_float_rgba_span(ctx, n, (const GLfloat (*)[4]) rgba,
+ format, type, destination,
+ packing, applyTransferOps);
- /*
- * Pack/store the pixels. Ugh! Lots of cases!!!
- */
- switch (type) {
- case GL_UNSIGNED_BYTE:
- {
- GLubyte *dst = (GLubyte *) destination;
- switch (format) {
- case GL_RED:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
- break;
- case GL_GREEN:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_UBYTE(rgba[i][GCOMP]);
- break;
- case GL_BLUE:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_UBYTE(rgba[i][BCOMP]);
- break;
- case GL_ALPHA:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_UBYTE(rgba[i][ACOMP]);
- break;
- case GL_LUMINANCE:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_UBYTE(luminance[i]);
- break;
- case GL_LUMINANCE_ALPHA:
- for (i=0;i<n;i++) {
- dst[i*2+0] = FLOAT_TO_UBYTE(luminance[i]);
- dst[i*2+1] = FLOAT_TO_UBYTE(rgba[i][ACOMP]);
- }
- break;
- case GL_RGB:
- for (i=0;i<n;i++) {
- dst[i*3+0] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
- dst[i*3+1] = FLOAT_TO_UBYTE(rgba[i][GCOMP]);
- dst[i*3+2] = FLOAT_TO_UBYTE(rgba[i][BCOMP]);
- }
- break;
- case GL_RGBA:
- for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
- dst[i*4+1] = FLOAT_TO_UBYTE(rgba[i][GCOMP]);
- dst[i*4+2] = FLOAT_TO_UBYTE(rgba[i][BCOMP]);
- dst[i*4+3] = FLOAT_TO_UBYTE(rgba[i][ACOMP]);
- }
- break;
- case GL_BGR:
- for (i=0;i<n;i++) {
- dst[i*3+0] = FLOAT_TO_UBYTE(rgba[i][BCOMP]);
- dst[i*3+1] = FLOAT_TO_UBYTE(rgba[i][GCOMP]);
- dst[i*3+2] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
- }
- break;
- case GL_BGRA:
- for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_UBYTE(rgba[i][BCOMP]);
- dst[i*4+1] = FLOAT_TO_UBYTE(rgba[i][GCOMP]);
- dst[i*4+2] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
- dst[i*4+3] = FLOAT_TO_UBYTE(rgba[i][ACOMP]);
- }
- break;
- case GL_ABGR_EXT:
- for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_UBYTE(rgba[i][ACOMP]);
- dst[i*4+1] = FLOAT_TO_UBYTE(rgba[i][BCOMP]);
- dst[i*4+2] = FLOAT_TO_UBYTE(rgba[i][GCOMP]);
- dst[i*4+3] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
- }
- break;
- default:
- gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
- }
- }
- break;
- case GL_BYTE:
- {
- GLbyte *dst = (GLbyte *) destination;
- switch (format) {
- case GL_RED:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_BYTE(rgba[i][RCOMP]);
- break;
- case GL_GREEN:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_BYTE(rgba[i][GCOMP]);
- break;
- case GL_BLUE:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_BYTE(rgba[i][BCOMP]);
- break;
- case GL_ALPHA:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_BYTE(rgba[i][ACOMP]);
- break;
- case GL_LUMINANCE:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_BYTE(luminance[i]);
- break;
- case GL_LUMINANCE_ALPHA:
- for (i=0;i<n;i++) {
- dst[i*2+0] = FLOAT_TO_BYTE(luminance[i]);
- dst[i*2+1] = FLOAT_TO_BYTE(rgba[i][ACOMP]);
- }
- break;
- case GL_RGB:
- for (i=0;i<n;i++) {
- dst[i*3+0] = FLOAT_TO_BYTE(rgba[i][RCOMP]);
- dst[i*3+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]);
- dst[i*3+2] = FLOAT_TO_BYTE(rgba[i][BCOMP]);
- }
- break;
- case GL_RGBA:
- for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_BYTE(rgba[i][RCOMP]);
- dst[i*4+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]);
- dst[i*4+2] = FLOAT_TO_BYTE(rgba[i][BCOMP]);
- dst[i*4+3] = FLOAT_TO_BYTE(rgba[i][ACOMP]);
- }
- break;
- case GL_BGR:
- for (i=0;i<n;i++) {
- dst[i*3+0] = FLOAT_TO_BYTE(rgba[i][BCOMP]);
- dst[i*3+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]);
- dst[i*3+2] = FLOAT_TO_BYTE(rgba[i][RCOMP]);
- }
- break;
- case GL_BGRA:
- for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_BYTE(rgba[i][BCOMP]);
- dst[i*4+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]);
- dst[i*4+2] = FLOAT_TO_BYTE(rgba[i][RCOMP]);
- dst[i*4+3] = FLOAT_TO_BYTE(rgba[i][ACOMP]);
- }
- case GL_ABGR_EXT:
- for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_BYTE(rgba[i][ACOMP]);
- dst[i*4+1] = FLOAT_TO_BYTE(rgba[i][BCOMP]);
- dst[i*4+2] = FLOAT_TO_BYTE(rgba[i][GCOMP]);
- dst[i*4+3] = FLOAT_TO_BYTE(rgba[i][RCOMP]);
- }
- break;
- default:
- gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
- }
- }
- break;
- case GL_UNSIGNED_SHORT:
- {
- GLushort *dst = (GLushort *) destination;
- switch (format) {
- case GL_RED:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_USHORT(rgba[i][RCOMP]);
- break;
- case GL_GREEN:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_USHORT(rgba[i][GCOMP]);
- break;
- case GL_BLUE:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_USHORT(rgba[i][BCOMP]);
- break;
- case GL_ALPHA:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_USHORT(rgba[i][ACOMP]);
- break;
- case GL_LUMINANCE:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_USHORT(luminance[i]);
- break;
- case GL_LUMINANCE_ALPHA:
- for (i=0;i<n;i++) {
- dst[i*2+0] = FLOAT_TO_USHORT(luminance[i]);
- dst[i*2+1] = FLOAT_TO_USHORT(rgba[i][ACOMP]);
- }
- break;
- case GL_RGB:
- for (i=0;i<n;i++) {
- dst[i*3+0] = FLOAT_TO_USHORT(rgba[i][RCOMP]);
- dst[i*3+1] = FLOAT_TO_USHORT(rgba[i][GCOMP]);
- dst[i*3+2] = FLOAT_TO_USHORT(rgba[i][BCOMP]);
- }
- break;
- case GL_RGBA:
- for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_USHORT(rgba[i][RCOMP]);
- dst[i*4+1] = FLOAT_TO_USHORT(rgba[i][GCOMP]);
- dst[i*4+2] = FLOAT_TO_USHORT(rgba[i][BCOMP]);
- dst[i*4+3] = FLOAT_TO_USHORT(rgba[i][ACOMP]);
- }
- break;
- case GL_BGR:
- for (i=0;i<n;i++) {
- dst[i*3+0] = FLOAT_TO_USHORT(rgba[i][BCOMP]);
- dst[i*3+1] = FLOAT_TO_USHORT(rgba[i][GCOMP]);
- dst[i*3+2] = FLOAT_TO_USHORT(rgba[i][RCOMP]);
- }
- break;
- case GL_BGRA:
- for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_USHORT(rgba[i][BCOMP]);
- dst[i*4+1] = FLOAT_TO_USHORT(rgba[i][GCOMP]);
- dst[i*4+2] = FLOAT_TO_USHORT(rgba[i][RCOMP]);
- dst[i*4+3] = FLOAT_TO_USHORT(rgba[i][ACOMP]);
- }
- break;
- case GL_ABGR_EXT:
- for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_USHORT(rgba[i][ACOMP]);
- dst[i*4+1] = FLOAT_TO_USHORT(rgba[i][BCOMP]);
- dst[i*4+2] = FLOAT_TO_USHORT(rgba[i][GCOMP]);
- dst[i*4+3] = FLOAT_TO_USHORT(rgba[i][RCOMP]);
- }
- break;
- default:
- gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
- }
- if (packing->SwapBytes) {
- _mesa_swap2( (GLushort *) dst, n * comps);
- }
- }
- break;
- case GL_SHORT:
- {
- GLshort *dst = (GLshort *) destination;
- switch (format) {
- case GL_RED:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_SHORT(rgba[i][RCOMP]);
- break;
- case GL_GREEN:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_SHORT(rgba[i][GCOMP]);
- break;
- case GL_BLUE:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_SHORT(rgba[i][BCOMP]);
- break;
- case GL_ALPHA:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_SHORT(rgba[i][ACOMP]);
- break;
- case GL_LUMINANCE:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_SHORT(luminance[i]);
- break;
- case GL_LUMINANCE_ALPHA:
- for (i=0;i<n;i++) {
- dst[i*2+0] = FLOAT_TO_SHORT(luminance[i]);
- dst[i*2+1] = FLOAT_TO_SHORT(rgba[i][ACOMP]);
- }
- break;
- case GL_RGB:
- for (i=0;i<n;i++) {
- dst[i*3+0] = FLOAT_TO_SHORT(rgba[i][RCOMP]);
- dst[i*3+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]);
- dst[i*3+2] = FLOAT_TO_SHORT(rgba[i][BCOMP]);
- }
- break;
- case GL_RGBA:
- for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_SHORT(rgba[i][RCOMP]);
- dst[i*4+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]);
- dst[i*4+2] = FLOAT_TO_SHORT(rgba[i][BCOMP]);
- dst[i*4+3] = FLOAT_TO_SHORT(rgba[i][ACOMP]);
- }
- break;
- case GL_BGR:
- for (i=0;i<n;i++) {
- dst[i*3+0] = FLOAT_TO_SHORT(rgba[i][BCOMP]);
- dst[i*3+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]);
- dst[i*3+2] = FLOAT_TO_SHORT(rgba[i][RCOMP]);
- }
- break;
- case GL_BGRA:
- for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_SHORT(rgba[i][BCOMP]);
- dst[i*4+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]);
- dst[i*4+2] = FLOAT_TO_SHORT(rgba[i][RCOMP]);
- dst[i*4+3] = FLOAT_TO_SHORT(rgba[i][ACOMP]);
- }
- case GL_ABGR_EXT:
- for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_SHORT(rgba[i][ACOMP]);
- dst[i*4+1] = FLOAT_TO_SHORT(rgba[i][BCOMP]);
- dst[i*4+2] = FLOAT_TO_SHORT(rgba[i][GCOMP]);
- dst[i*4+3] = FLOAT_TO_SHORT(rgba[i][RCOMP]);
- }
- break;
- default:
- gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
- }
- if (packing->SwapBytes) {
- _mesa_swap2( (GLushort *) dst, n * comps );
- }
- }
- break;
- case GL_UNSIGNED_INT:
- {
- GLuint *dst = (GLuint *) destination;
- switch (format) {
- case GL_RED:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_UINT(rgba[i][RCOMP]);
- break;
- case GL_GREEN:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_UINT(rgba[i][GCOMP]);
- break;
- case GL_BLUE:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_UINT(rgba[i][BCOMP]);
- break;
- case GL_ALPHA:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_UINT(rgba[i][ACOMP]);
- break;
- case GL_LUMINANCE:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_UINT(luminance[i]);
- break;
- case GL_LUMINANCE_ALPHA:
- for (i=0;i<n;i++) {
- dst[i*2+0] = FLOAT_TO_UINT(luminance[i]);
- dst[i*2+1] = FLOAT_TO_UINT(rgba[i][ACOMP]);
- }
- break;
- case GL_RGB:
- for (i=0;i<n;i++) {
- dst[i*3+0] = FLOAT_TO_UINT(rgba[i][RCOMP]);
- dst[i*3+1] = FLOAT_TO_UINT(rgba[i][GCOMP]);
- dst[i*3+2] = FLOAT_TO_UINT(rgba[i][BCOMP]);
- }
- break;
- case GL_RGBA:
- for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_UINT(rgba[i][RCOMP]);
- dst[i*4+1] = FLOAT_TO_UINT(rgba[i][GCOMP]);
- dst[i*4+2] = FLOAT_TO_UINT(rgba[i][BCOMP]);
- dst[i*4+3] = FLOAT_TO_UINT(rgba[i][ACOMP]);
- }
- break;
- case GL_BGR:
- for (i=0;i<n;i++) {
- dst[i*3+0] = FLOAT_TO_UINT(rgba[i][BCOMP]);
- dst[i*3+1] = FLOAT_TO_UINT(rgba[i][GCOMP]);
- dst[i*3+2] = FLOAT_TO_UINT(rgba[i][RCOMP]);
- }
- break;
- case GL_BGRA:
- for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_UINT(rgba[i][BCOMP]);
- dst[i*4+1] = FLOAT_TO_UINT(rgba[i][GCOMP]);
- dst[i*4+2] = FLOAT_TO_UINT(rgba[i][RCOMP]);
- dst[i*4+3] = FLOAT_TO_UINT(rgba[i][ACOMP]);
- }
- break;
- case GL_ABGR_EXT:
- for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_UINT(rgba[i][ACOMP]);
- dst[i*4+1] = FLOAT_TO_UINT(rgba[i][BCOMP]);
- dst[i*4+2] = FLOAT_TO_UINT(rgba[i][GCOMP]);
- dst[i*4+3] = FLOAT_TO_UINT(rgba[i][RCOMP]);
- }
- break;
- default:
- gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
- }
- if (packing->SwapBytes) {
- _mesa_swap4( (GLuint *) dst, n * comps );
- }
- }
- break;
- case GL_INT:
- {
- GLint *dst = (GLint *) destination;
- switch (format) {
- case GL_RED:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_INT(rgba[i][RCOMP]);
- break;
- case GL_GREEN:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_INT(rgba[i][GCOMP]);
- break;
- case GL_BLUE:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_INT(rgba[i][BCOMP]);
- break;
- case GL_ALPHA:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_INT(rgba[i][ACOMP]);
- break;
- case GL_LUMINANCE:
- for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_INT(luminance[i]);
- break;
- case GL_LUMINANCE_ALPHA:
- for (i=0;i<n;i++) {
- dst[i*2+0] = FLOAT_TO_INT(luminance[i]);
- dst[i*2+1] = FLOAT_TO_INT(rgba[i][ACOMP]);
- }
- break;
- case GL_RGB:
- for (i=0;i<n;i++) {
- dst[i*3+0] = FLOAT_TO_INT(rgba[i][RCOMP]);
- dst[i*3+1] = FLOAT_TO_INT(rgba[i][GCOMP]);
- dst[i*3+2] = FLOAT_TO_INT(rgba[i][BCOMP]);
- }
- break;
- case GL_RGBA:
- for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_INT(rgba[i][RCOMP]);
- dst[i*4+1] = FLOAT_TO_INT(rgba[i][GCOMP]);
- dst[i*4+2] = FLOAT_TO_INT(rgba[i][BCOMP]);
- dst[i*4+3] = FLOAT_TO_INT(rgba[i][ACOMP]);
- }
- break;
- case GL_BGR:
- for (i=0;i<n;i++) {
- dst[i*3+0] = FLOAT_TO_INT(rgba[i][BCOMP]);
- dst[i*3+1] = FLOAT_TO_INT(rgba[i][GCOMP]);
- dst[i*3+2] = FLOAT_TO_INT(rgba[i][RCOMP]);
- }
- break;
- case GL_BGRA:
- for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_INT(rgba[i][BCOMP]);
- dst[i*4+1] = FLOAT_TO_INT(rgba[i][GCOMP]);
- dst[i*4+2] = FLOAT_TO_INT(rgba[i][RCOMP]);
- dst[i*4+3] = FLOAT_TO_INT(rgba[i][ACOMP]);
- }
- break;
- case GL_ABGR_EXT:
- for (i=0;i<n;i++) {
- dst[i*4+0] = FLOAT_TO_INT(rgba[i][ACOMP]);
- dst[i*4+1] = FLOAT_TO_INT(rgba[i][BCOMP]);
- dst[i*4+2] = FLOAT_TO_INT(rgba[i][GCOMP]);
- dst[i*4+3] = FLOAT_TO_INT(rgba[i][RCOMP]);
- }
- break;
- default:
- gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
- }
- if (packing->SwapBytes) {
- _mesa_swap4( (GLuint *) dst, n * comps );
- }
- }
- break;
- case GL_FLOAT:
- {
- GLfloat *dst = (GLfloat *) destination;
- switch (format) {
- case GL_RED:
- for (i=0;i<n;i++)
- dst[i] = rgba[i][RCOMP];
- break;
- case GL_GREEN:
- for (i=0;i<n;i++)
- dst[i] = rgba[i][GCOMP];
- break;
- case GL_BLUE:
- for (i=0;i<n;i++)
- dst[i] = rgba[i][BCOMP];
- break;
- case GL_ALPHA:
- for (i=0;i<n;i++)
- dst[i] = rgba[i][ACOMP];
- break;
- case GL_LUMINANCE:
- for (i=0;i<n;i++)
- dst[i] = luminance[i];
- break;
- case GL_LUMINANCE_ALPHA:
- for (i=0;i<n;i++) {
- dst[i*2+0] = luminance[i];
- dst[i*2+1] = rgba[i][ACOMP];
- }
- break;
- case GL_RGB:
- for (i=0;i<n;i++) {
- dst[i*3+0] = rgba[i][RCOMP];
- dst[i*3+1] = rgba[i][GCOMP];
- dst[i*3+2] = rgba[i][BCOMP];
- }
- break;
- case GL_RGBA:
- for (i=0;i<n;i++) {
- dst[i*4+0] = rgba[i][RCOMP];
- dst[i*4+1] = rgba[i][GCOMP];
- dst[i*4+2] = rgba[i][BCOMP];
- dst[i*4+3] = rgba[i][ACOMP];
- }
- break;
- case GL_BGR:
- for (i=0;i<n;i++) {
- dst[i*3+0] = rgba[i][BCOMP];
- dst[i*3+1] = rgba[i][GCOMP];
- dst[i*3+2] = rgba[i][RCOMP];
- }
- break;
- case GL_BGRA:
- for (i=0;i<n;i++) {
- dst[i*4+0] = rgba[i][BCOMP];
- dst[i*4+1] = rgba[i][GCOMP];
- dst[i*4+2] = rgba[i][RCOMP];
- dst[i*4+3] = rgba[i][ACOMP];
- }
- break;
- case GL_ABGR_EXT:
- for (i=0;i<n;i++) {
- dst[i*4+0] = rgba[i][ACOMP];
- dst[i*4+1] = rgba[i][BCOMP];
- dst[i*4+2] = rgba[i][GCOMP];
- dst[i*4+3] = rgba[i][RCOMP];
- }
- break;
- default:
- gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
- }
- if (packing->SwapBytes) {
- _mesa_swap4( (GLuint *) dst, n * comps );
- }
- }
- break;
- case GL_UNSIGNED_BYTE_3_3_2:
- if (format == GL_RGB) {
- GLubyte *dst = (GLubyte *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][RCOMP] * 7.0F)) << 5)
- | (((GLint) (rgba[i][GCOMP] * 7.0F)) << 2)
- | (((GLint) (rgba[i][BCOMP] * 3.0F)) );
- }
- }
- break;
- case GL_UNSIGNED_BYTE_2_3_3_REV:
- if (format == GL_RGB) {
- GLubyte *dst = (GLubyte *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][RCOMP] * 7.0F)) )
- | (((GLint) (rgba[i][GCOMP] * 7.0F)) << 3)
- | (((GLint) (rgba[i][BCOMP] * 3.0F)) << 5);
- }
- }
- break;
- case GL_UNSIGNED_SHORT_5_6_5:
- if (format == GL_RGB) {
- GLushort *dst = (GLushort *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) << 11)
- | (((GLint) (rgba[i][GCOMP] * 63.0F)) << 5)
- | (((GLint) (rgba[i][BCOMP] * 31.0F)) );
- }
- }
- break;
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- if (format == GL_RGB) {
- GLushort *dst = (GLushort *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) )
- | (((GLint) (rgba[i][GCOMP] * 63.0F)) << 5)
- | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 11);
- }
- }
- break;
- case GL_UNSIGNED_SHORT_4_4_4_4:
- if (format == GL_RGBA) {
- GLushort *dst = (GLushort *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][RCOMP] * 15.0F)) << 12)
- | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 8)
- | (((GLint) (rgba[i][BCOMP] * 15.0F)) << 4)
- | (((GLint) (rgba[i][ACOMP] * 15.0F)) );
- }
- }
- else if (format == GL_BGRA) {
- GLushort *dst = (GLushort *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][BCOMP] * 15.0F)) << 12)
- | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 8)
- | (((GLint) (rgba[i][RCOMP] * 15.0F)) << 4)
- | (((GLint) (rgba[i][ACOMP] * 15.0F)) );
- }
- }
- else if (format == GL_ABGR_EXT) {
- GLushort *dst = (GLushort *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][ACOMP] * 15.0F)) << 4)
- | (((GLint) (rgba[i][BCOMP] * 15.0F)) << 8)
- | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 12)
- | (((GLint) (rgba[i][RCOMP] * 15.0F)) );
- }
- }
- break;
- case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- if (format == GL_RGBA) {
- GLushort *dst = (GLushort *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][RCOMP] * 15.0F)) )
- | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 4)
- | (((GLint) (rgba[i][BCOMP] * 15.0F)) << 8)
- | (((GLint) (rgba[i][ACOMP] * 15.0F)) << 12);
- }
- }
- else if (format == GL_BGRA) {
- GLushort *dst = (GLushort *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][BCOMP] * 15.0F)) )
- | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 4)
- | (((GLint) (rgba[i][RCOMP] * 15.0F)) << 8)
- | (((GLint) (rgba[i][ACOMP] * 15.0F)) << 12);
- }
- }
- else if (format == GL_ABGR_EXT) {
- GLushort *dst = (GLushort *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][ACOMP] * 15.0F)) )
- | (((GLint) (rgba[i][BCOMP] * 15.0F)) << 4)
- | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 8)
- | (((GLint) (rgba[i][RCOMP] * 15.0F)) << 12);
- }
- }
- break;
- case GL_UNSIGNED_SHORT_5_5_5_1:
- if (format == GL_RGBA) {
- GLushort *dst = (GLushort *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) << 11)
- | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 6)
- | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 1)
- | (((GLint) (rgba[i][ACOMP] * 1.0F)) );
- }
- }
- else if (format == GL_BGRA) {
- GLushort *dst = (GLushort *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][BCOMP] * 31.0F)) << 11)
- | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 6)
- | (((GLint) (rgba[i][RCOMP] * 31.0F)) << 1)
- | (((GLint) (rgba[i][ACOMP] * 1.0F)) );
- }
- }
- else if (format == GL_ABGR_EXT) {
- GLushort *dst = (GLushort *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][ACOMP] * 31.0F)) << 11)
- | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 6)
- | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 1)
- | (((GLint) (rgba[i][RCOMP] * 1.0F)) );
- }
- }
- break;
- case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- if (format == GL_RGBA) {
- GLushort *dst = (GLushort *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) )
- | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 5)
- | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 10)
- | (((GLint) (rgba[i][ACOMP] * 1.0F)) << 15);
- }
- }
- else if (format == GL_BGRA) {
- GLushort *dst = (GLushort *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][BCOMP] * 31.0F)) )
- | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 5)
- | (((GLint) (rgba[i][RCOMP] * 31.0F)) << 10)
- | (((GLint) (rgba[i][ACOMP] * 1.0F)) << 15);
- }
- }
- else if (format == GL_ABGR_EXT) {
- GLushort *dst = (GLushort *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLint) (rgba[i][ACOMP] * 31.0F)) )
- | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 5)
- | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 10)
- | (((GLint) (rgba[i][RCOMP] * 1.0F)) << 15);
- }
- }
- break;
- case GL_UNSIGNED_INT_8_8_8_8:
- if (format == GL_RGBA) {
- GLuint *dst = (GLuint *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 24)
- | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 16)
- | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 8)
- | (((GLuint) (rgba[i][ACOMP] * 255.0F)) );
- }
- }
- else if (format == GL_BGRA) {
- GLuint *dst = (GLuint *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 24)
- | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 16)
- | (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 8)
- | (((GLuint) (rgba[i][ACOMP] * 255.0F)) );
- }
- }
- else if (format == GL_ABGR_EXT) {
- GLuint *dst = (GLuint *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (rgba[i][ACOMP] * 255.0F)) << 24)
- | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 16)
- | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 8)
- | (((GLuint) (rgba[i][RCOMP] * 255.0F)) );
- }
- }
- break;
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- if (format == GL_RGBA) {
- GLuint *dst = (GLuint *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (rgba[i][RCOMP] * 255.0F)) )
- | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 8)
- | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 16)
- | (((GLuint) (rgba[i][ACOMP] * 255.0F)) << 24);
- }
- }
- else if (format == GL_BGRA) {
- GLuint *dst = (GLuint *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (rgba[i][BCOMP] * 255.0F)) )
- | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 8)
- | (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 16)
- | (((GLuint) (rgba[i][ACOMP] * 255.0F)) << 24);
- }
- }
- else if (format == GL_ABGR_EXT) {
- GLuint *dst = (GLuint *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (rgba[i][ACOMP] * 255.0F)) )
- | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 8)
- | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 16)
- | (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 24);
- }
- }
- break;
- case GL_UNSIGNED_INT_10_10_10_2:
- if (format == GL_RGBA) {
- GLuint *dst = (GLuint *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (rgba[i][RCOMP] * 1023.0F)) << 22)
- | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 12)
- | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 2)
- | (((GLuint) (rgba[i][ACOMP] * 3.0F)) );
- }
- }
- else if (format == GL_BGRA) {
- GLuint *dst = (GLuint *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 22)
- | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 12)
- | (((GLuint) (rgba[i][RCOMP] * 1023.0F)) << 2)
- | (((GLuint) (rgba[i][ACOMP] * 3.0F)) );
- }
- }
- else if (format == GL_ABGR_EXT) {
- GLuint *dst = (GLuint *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (rgba[i][ACOMP] * 1023.0F)) << 22)
- | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 12)
- | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 2)
- | (((GLuint) (rgba[i][RCOMP] * 3.0F)) );
- }
- }
- break;
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- if (format == GL_RGBA) {
- GLuint *dst = (GLuint *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (rgba[i][RCOMP] * 1023.0F)) )
- | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 10)
- | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 20)
- | (((GLuint) (rgba[i][ACOMP] * 3.0F)) << 30);
- }
- }
- else if (format == GL_BGRA) {
- GLuint *dst = (GLuint *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (rgba[i][BCOMP] * 1023.0F)) )
- | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 10)
- | (((GLuint) (rgba[i][RCOMP] * 1023.0F)) << 20)
- | (((GLuint) (rgba[i][ACOMP] * 3.0F)) << 30);
- }
- }
- else if (format == GL_ABGR_EXT) {
- GLuint *dst = (GLuint *) destination;
- for (i=0;i<n;i++) {
- dst[i] = (((GLuint) (rgba[i][ACOMP] * 1023.0F)) )
- | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 10)
- | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 20)
- | (((GLuint) (rgba[i][RCOMP] * 3.0F)) << 30);
- }
- }
- break;
- default:
- gl_problem( ctx, "bad type in _mesa_pack_rgba_span" );
- }
}
}
diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h
index 1526491b81..063a24bb2b 100644
--- a/src/mesa/main/image.h
+++ b/src/mesa/main/image.h
@@ -1,8 +1,8 @@
-/* $Id: image.h,v 1.9 2000/05/10 14:39:53 brianp Exp $ */
+/* $Id: image.h,v 1.9.4.1 2001/01/25 17:34:22 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 3.4.1
*
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
*
@@ -80,6 +80,15 @@ _mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest,
extern void
+_mesa_pack_float_rgba_span( GLcontext *ctx,
+ GLuint n, CONST GLfloat rgba[][4],
+ GLenum dstFormat, GLenum dstType,
+ GLvoid *dstAddr,
+ const struct gl_pixelstore_attrib *dstPacking,
+ GLboolean applyTransferOps );
+
+
+extern void
_mesa_pack_rgba_span( GLcontext *ctx,
GLuint n, CONST GLubyte rgba[][4],
GLenum format, GLenum type, GLvoid *dest,