summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2000-08-30 18:21:37 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2000-08-30 18:21:37 +0000
commit116970154dc3bb148178e1a9fe38554fbbd133c8 (patch)
treed76f09c11d91ec1a40485d662515f730fe55f581 /src/mesa/main
parent8e053916c8052b47c191f68991c126f47c72c3f3 (diff)
added _mesa_pack_float_rgba_span()
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/image.c1546
-rw-r--r--src/mesa/main/image.h10
2 files changed, 795 insertions, 761 deletions
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index 4f8faf8366e..0d4b2ef525c 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -1,4 +1,4 @@
-/* $Id: image.c,v 1.37 2000/08/29 14:25:30 brianp Exp $ */
+/* $Id: image.c,v 1.38 2000/08/30 18:21:37 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -633,16 +633,13 @@ _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);
-
/* convert color components to floating point */
for (i=0;i<n;i++) {
rgba[i][RCOMP] = srcRgba[i][RCOMP] * rscale;
@@ -650,792 +647,821 @@ _mesa_pack_rgba_span( GLcontext *ctx,
rgba[i][BCOMP] = srcRgba[i][BCOMP] * bscale;
rgba[i][ACOMP] = srcRgba[i][ACOMP] * ascale;
}
+ _mesa_pack_float_rgba_span(ctx, n, (const GLfloat (*)[4]) rgba,
+ format, type, destination,
+ packing, transferOps);
+ }
+}
- /*
- * Apply scale, bias and lookup-tables if enabled.
- */
- if (transferOps) {
- /* scale & bias */
- if (transferOps & IMAGE_SCALE_BIAS_BIT) {
- _mesa_scale_and_bias_rgba( ctx, n, rgba );
- }
- /* color map lookup */
- if (transferOps & IMAGE_MAP_COLOR_BIT) {
- _mesa_map_rgba( ctx, n, rgba );
- }
- /* GL_COLOR_TABLE lookup */
- if (transferOps & IMAGE_COLOR_TABLE_BIT) {
- _mesa_lookup_rgba(&ctx->ColorTable, n, rgba);
- }
- /* convolution */
- if (transferOps & IMAGE_CONVOLUTION_BIT) {
- /* this has to be done in the calling code */
- }
- /* GL_POST_CONVOLUTION_COLOR_TABLE lookup */
- if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) {
- _mesa_lookup_rgba(&ctx->PostConvolutionColorTable, n, rgba);
- }
- /* color matrix transform */
- if (transferOps & IMAGE_COLOR_MATRIX_BIT) {
- _mesa_transform_rgba(ctx, n, rgba);
- }
- /* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */
- if (transferOps & IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT) {
- _mesa_lookup_rgba(&ctx->PostColorMatrixColorTable, n, rgba);
- }
- /* update histogram count */
- if (transferOps & IMAGE_HISTOGRAM_BIT) {
- _mesa_update_histogram(ctx, n, (CONST GLfloat (*)[4]) rgba);
- }
- /* min/max here */
- if (transferOps & IMAGE_MIN_MAX_BIT) {
- _mesa_update_minmax(ctx, n, (CONST GLfloat (*)[4]) rgba);
- if (ctx->MinMax.Sink)
- return;
- }
+
+void
+_mesa_pack_float_rgba_span( GLcontext *ctx,
+ GLuint n, CONST GLfloat rgbaIn[][4],
+ GLenum format, GLenum type, GLvoid *destination,
+ const struct gl_pixelstore_attrib *packing,
+ GLuint transferOps )
+{
+ const GLint comps = _mesa_components_in_format(format);
+ GLfloat luminance[MAX_WIDTH];
+ GLfloat (*rgba)[4];
+ GLuint i;
+
+ if (transferOps) {
+ /* 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];
}
- /* XXX clamp rgba to [0,1]? */
+ rgba = (GLfloat (*)[4]) rgbaCopy;
+ /* scale & bias */
+ if (transferOps & IMAGE_SCALE_BIAS_BIT) {
+ _mesa_scale_and_bias_rgba( ctx, n, rgba );
+ }
+ /* color map lookup */
+ if (transferOps & IMAGE_MAP_COLOR_BIT) {
+ _mesa_map_rgba( ctx, n, rgba );
+ }
+ /* GL_COLOR_TABLE lookup */
+ if (transferOps & IMAGE_COLOR_TABLE_BIT) {
+ _mesa_lookup_rgba(&ctx->ColorTable, n, rgba);
+ }
+ /* convolution */
+ if (transferOps & IMAGE_CONVOLUTION_BIT) {
+ /* this has to be done in the calling code */
+ }
+ /* GL_POST_CONVOLUTION_COLOR_TABLE lookup */
+ if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) {
+ _mesa_lookup_rgba(&ctx->PostConvolutionColorTable, n, rgba);
+ }
+ /* color matrix transform */
+ if (transferOps & IMAGE_COLOR_MATRIX_BIT) {
+ _mesa_transform_rgba(ctx, n, rgba);
+ }
+ /* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */
+ if (transferOps & IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT) {
+ _mesa_lookup_rgba(&ctx->PostColorMatrixColorTable, n, rgba);
+ }
+ /* update histogram count */
+ if (transferOps & IMAGE_HISTOGRAM_BIT) {
+ _mesa_update_histogram(ctx, n, (CONST GLfloat (*)[4]) rgba);
+ }
+ /* min/max here */
+ if (transferOps & IMAGE_MIN_MAX_BIT) {
+ _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 (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);
- }
+ /* XXX clamp rgba to [0,1]? */
+
+
+ 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);
}
+ }
- /*
- * 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");
- }
+ /*
+ * 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_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_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_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_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");
}
- 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 );
- }
+ if (packing->SwapBytes) {
+ _mesa_swap2( (GLushort *) 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_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");
}
- 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);
- }
+ if (packing->SwapBytes) {
+ _mesa_swap2( (GLushort *) dst, n * comps );
}
- 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_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");
}
- 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);
- }
+ if (packing->SwapBytes) {
+ _mesa_swap4( (GLuint *) dst, n * comps );
}
- break;
- case GL_UNSIGNED_SHORT_4_4_4_4:
- if (format == GL_RGB) {
- 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)) );
- }
+ }
+ 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");
}
- break;
- case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- if (format == GL_RGB) {
- 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);
- }
+ if (packing->SwapBytes) {
+ _mesa_swap4( (GLuint *) dst, n * comps );
}
- break;
- case GL_UNSIGNED_SHORT_5_5_5_1:
- 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] * 31.0F)) << 6)
- | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 1)
- | (((GLint) (rgba[i][ACOMP] * 1.0F)) );
- }
+ }
+ 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");
}
- break;
- case GL_UNSIGNED_SHORT_1_5_5_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] * 31.0F)) << 5)
- | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 10)
- | (((GLint) (rgba[i][ACOMP] * 1.0F)) << 15);
- }
+ if (packing->SwapBytes) {
+ _mesa_swap4( (GLuint *) dst, n * comps );
}
- 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)) );
- }
+ }
+ 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)) );
}
- 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)) );
- }
+ }
+ 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);
}
- 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_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_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);
- }
+ }
+ 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);
}
- 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);
- }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ if (format == GL_RGB) {
+ 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_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_SHORT_4_4_4_4_REV:
+ if (format == GL_RGB) {
+ 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);
}
- 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)) );
- }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ 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] * 31.0F)) << 6)
+ | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 1)
+ | (((GLint) (rgba[i][ACOMP] * 1.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)) );
- }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_1_5_5_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] * 31.0F)) << 5)
+ | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 10)
+ | (((GLint) (rgba[i][ACOMP] * 1.0F)) << 15);
}
- 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_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)) );
}
- 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] * 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_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] * 255.0F)) << 24)
+ | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 16)
+ | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 8)
+ | (((GLuint) (rgba[i][RCOMP] * 255.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)) )
- | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 10)
- | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 20)
- | (((GLuint) (rgba[i][RCOMP] * 3.0F)) << 30);
- }
+ }
+ 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);
}
- break;
- default:
- gl_problem( ctx, "bad type in _mesa_pack_rgba_span" );
- }
+ }
+ 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_float_rgba_span");
}
}
diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h
index c9a3aab662c..4a18e1937c3 100644
--- a/src/mesa/main/image.h
+++ b/src/mesa/main/image.h
@@ -1,4 +1,4 @@
-/* $Id: image.h,v 1.10 2000/08/21 14:22:24 brianp Exp $ */
+/* $Id: image.h,v 1.11 2000/08/30 18:21:37 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -80,6 +80,14 @@ _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 format, GLenum type, GLvoid *dest,
+ const struct gl_pixelstore_attrib *packing,
+ GLuint transferOps );
+
+
+extern void
_mesa_pack_rgba_span( GLcontext *ctx,
GLuint n, CONST GLubyte rgba[][4],
GLenum format, GLenum type, GLvoid *dest,