From 179870a5b806a3ee84cb56fa20c3a003f9fc5b97 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 12 Apr 2000 18:54:48 +0000 Subject: more work on GL_SGI_color_table, pixel transfer code clean-up --- src/mesa/main/image.c | 563 +++++++++++++++++++++++++------------------------- 1 file changed, 285 insertions(+), 278 deletions(-) (limited to 'src/mesa/main/image.c') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 28720be9f65..f2de78440b0 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1,4 +1,4 @@ -/* $Id: image.c,v 1.25 2000/04/08 18:57:45 brianp Exp $ */ +/* $Id: image.c,v 1.26 2000/04/12 18:54:48 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -603,33 +603,36 @@ _mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest, */ void _mesa_pack_rgba_span( const GLcontext *ctx, - GLuint n, CONST GLubyte rgba[][4], + GLuint n, CONST GLubyte srcRgba[][4], GLenum format, GLenum type, GLvoid *destination, const struct gl_pixelstore_attrib *packing, GLboolean applyTransferOps ) { - applyTransferOps &= (ctx->Pixel.ScaleOrBiasRGBA || ctx->Pixel.MapColorFlag); + applyTransferOps &= (ctx->Pixel.ScaleOrBiasRGBA || + ctx->Pixel.MapColorFlag || + ctx->ColorMatrix.type != MATRIX_IDENTITY || + ctx->Pixel.ScaleOrBiasRGBApcm || + ctx->Pixel.ColorTableEnabled); /* Test for optimized case first */ if (!applyTransferOps && format == GL_RGBA && type == GL_UNSIGNED_BYTE) { /* common simple case */ - MEMCPY( destination, rgba, n * 4 * sizeof(GLubyte) ); + MEMCPY( destination, srcRgba, n * 4 * sizeof(GLubyte) ); } else if (!applyTransferOps && format == GL_RGB && type == GL_UNSIGNED_BYTE) { /* common simple case */ GLint i; GLubyte *dest = (GLubyte *) destination; for (i = 0; i < n; i++) { - dest[0] = rgba[i][RCOMP]; - dest[1] = rgba[i][GCOMP]; - dest[2] = rgba[i][BCOMP]; + dest[0] = srcRgba[i][RCOMP]; + dest[1] = srcRgba[i][GCOMP]; + dest[2] = srcRgba[i][BCOMP]; dest += 3; } } else { /* general solution */ - GLfloat red[MAX_WIDTH], green[MAX_WIDTH], blue[MAX_WIDTH]; - GLfloat alpha[MAX_WIDTH], luminance[MAX_WIDTH]; + GLfloat rgba[MAX_WIDTH][4], luminance[MAX_WIDTH]; const GLfloat rscale = 1.0F / 255.0F; const GLfloat gscale = 1.0F / 255.0F; const GLfloat bscale = 1.0F / 255.0F; @@ -641,27 +644,38 @@ _mesa_pack_rgba_span( const GLcontext *ctx, /* convert color components to floating point */ for (i=0;iPixel.ScaleOrBiasRGBA) { - gl_scale_and_bias_color( ctx, n, red, green, blue, alpha ); + _mesa_scale_and_bias_rgba( ctx, n, rgba ); } + /* color table lookup */ if (ctx->Pixel.MapColorFlag) { - gl_map_color( ctx, n, red, green, blue, alpha ); + _mesa_map_rgba( ctx, n, rgba ); + } + /* color matrix */ + if (ctx->ColorMatrix.type != MATRIX_IDENTITY || + ctx->Pixel.ScaleOrBiasRGBApcm) { + _mesa_transform_rgba(ctx, n, rgba); + } + /* GL_SGI_color_table lookup */ + if (ctx->Pixel.ColorTableEnabled) { + _mesa_lookup_rgba(&ctx->ColorTable, n, rgba); } } if (format==GL_LUMINANCE || format==GL_LUMINANCE_ALPHA) { for (i=0;iPixel.ScaleOrBiasRGBA || ctx->Pixel.MapColorFlag || ctx->ColorMatrix.type != MATRIX_IDENTITY || - ctx->Pixel.ScaleOrBiasRGBApcm); + ctx->Pixel.ScaleOrBiasRGBApcm || + ctx->Pixel.ColorTableEnabled); /* Try simple cases first */ if (!applyTransferOps && srcType == GL_UNSIGNED_BYTE) { @@ -2212,8 +2228,8 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx, } + /* general solution begins here */ { - /* general solution */ GLfloat rgba[MAX_WIDTH][4]; GLint dstComponents; GLint dstRedIndex, dstGreenIndex, dstBlueIndex, dstAlphaIndex; @@ -2233,20 +2249,18 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx, unpacking); /* shift and offset indexes */ - gl_shift_and_offset_ci(ctx, n, indexes); + _mesa_shift_and_offset_ci(ctx, n, indexes); if (dstFormat == GL_COLOR_INDEX) { if (applyTransferOps) { if (ctx->Pixel.MapColorFlag) { /* Apply lookup table */ - gl_map_ci(ctx, n, indexes); + _mesa_map_ci(ctx, n, indexes); } - if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) { - + _mesa_shift_and_offset_ci(ctx, n, indexes); } } - /* convert to GLubyte and return */ { GLuint i; @@ -2257,7 +2271,7 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx, } else { /* Convert indexes to RGBA */ - gl_map_ci_to_rgba_float(ctx, n, indexes, rgba); + _mesa_map_ci_to_rgba(ctx, n, indexes, rgba); } } else { @@ -2266,29 +2280,23 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx, if (applyTransferOps) { /* scale and bias colors */ - _mesa_scale_and_bias_rgba_float(ctx, n, rgba); - + _mesa_scale_and_bias_rgba(ctx, n, rgba); /* color table lookup */ if (ctx->Pixel.MapColorFlag) { - _mesa_map_rgba_float(ctx, n, rgba); + _mesa_map_rgba(ctx, n, rgba); } - + /* color matrix transform */ if (ctx->ColorMatrix.type != MATRIX_IDENTITY || ctx->Pixel.ScaleOrBiasRGBApcm) { _mesa_transform_rgba(ctx, n, rgba); } + /* GL_SGI_color_table lookup */ + if (ctx->Pixel.ColorTableEnabled) { + _mesa_lookup_rgba(&ctx->ColorTable, n, rgba); + } } } - - /* - * XXX This is where more color table lookups, convolution, - * histograms, minmax, color matrix, etc would take place if - * implemented. - * See figure 3.7 in the OpenGL 1.2 specification for more info. - */ - - /* clamp to [0,1] */ { GLuint i; @@ -2469,12 +2477,11 @@ _mesa_unpack_index_span( const GLcontext *ctx, GLuint n, if (applyTransferOps) { if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) { /* shift and offset indexes */ - gl_shift_and_offset_ci(ctx, n, indexes); + _mesa_shift_and_offset_ci(ctx, n, indexes); } - if (ctx->Pixel.MapColorFlag) { /* Apply lookup table */ - gl_map_ci(ctx, n, indexes); + _mesa_map_ci(ctx, n, indexes); } } @@ -2569,7 +2576,7 @@ _mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n, if (applyTransferOps) { if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) { /* shift and offset indexes */ - gl_shift_and_offset_ci(ctx, n, indexes); + _mesa_shift_and_offset_ci(ctx, n, indexes); } if (ctx->Pixel.MapStencilFlag) { -- cgit v1.2.3