From 116970154dc3bb148178e1a9fe38554fbbd133c8 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 30 Aug 2000 18:21:37 +0000 Subject: [PATCH] added _mesa_pack_float_rgba_span() --- src/mesa/main/image.c | 1546 +++++++++++++++++++++-------------------- src/mesa/main/image.h | 10 +- 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;iColorTable, 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;iSwapBytes) { - _mesa_swap2( (GLushort *) dst, n * comps); - } + } + break; + case GL_BYTE: + { + GLbyte *dst = (GLbyte *) destination; + switch (format) { + case GL_RED: + for (i=0;iSwapBytes) { - _mesa_swap2( (GLushort *) dst, n * comps ); - } + } + break; + case GL_UNSIGNED_SHORT: + { + GLushort *dst = (GLushort *) destination; + switch (format) { + case GL_RED: + for (i=0;iSwapBytes) { - _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;iSwapBytes) { - _mesa_swap4( (GLuint *) dst, n * comps ); - } - } - break; - case GL_FLOAT: - { - GLfloat *dst = (GLfloat *) destination; - switch (format) { - case GL_RED: - for (i=0;iSwapBytes) { - _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;iSwapBytes) { + _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;iSwapBytes) { + _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;iSwapBytes) { + _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;iSwapBytes) { + _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