In _mesa_pack_rgba_span_float() we don't need to make a temporary copy of
authorBrian Paul <brian.paul@tungstengraphics.com>
Fri, 13 Oct 2006 16:34:25 +0000 (16:34 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Fri, 13 Oct 2006 16:34:25 +0000 (16:34 +0000)
incoming colors when applying pixel transfer ops.  In all cases, the
caller either indicates there's no pixel transfer ops, or the incoming
colors are coming from temporary storage already and can be safely
modified.

src/mesa/main/colortab.c
src/mesa/main/convolve.c
src/mesa/main/histogram.c
src/mesa/main/image.c
src/mesa/main/image.h
src/mesa/main/texstore.c
src/mesa/swrast/s_readpix.c

index 63d254d..e934951 100644 (file)
@@ -807,7 +807,7 @@ _mesa_GetColorTable( GLenum target, GLenum format,
       data = ADD_POINTERS(buf, data);
    }
 
-   _mesa_pack_rgba_span_float(ctx, table->Size, (const GLfloat (*)[4]) rgba,
+   _mesa_pack_rgba_span_float(ctx, table->Size, rgba,
                               format, type, data, &ctx->Pack, 0x0);
 
    if (ctx->Pack.BufferObj->Name) {
index 6b97c7f..814c6a0 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.3
+ * Version:  6.5.2
  *
- * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -560,9 +560,10 @@ _mesa_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat, GLint x, GLi
 
 
 void GLAPIENTRY
-_mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, GLvoid *image)
+_mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type,
+                           GLvoid *image)
 {
-   const struct gl_convolution_attrib *filter;
+   struct gl_convolution_attrib *filter;
    GLuint row;
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -623,10 +624,9 @@ _mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, GLvoid *im
       GLvoid *dst = _mesa_image_address2d(&ctx->Pack, image, filter->Width,
                                           filter->Height, format, type,
                                           row, 0);
-      const GLfloat *src = filter->Filter + row * filter->Width * 4;
-      _mesa_pack_rgba_span_float(ctx, filter->Width,
-                                 (const GLfloat (*)[4]) src,
-                                 format, type, dst, &ctx->Pack, 0);
+      GLfloat (*src)[4] = (GLfloat (*)[4]) (filter->Filter + row * filter->Width * 4);
+      _mesa_pack_rgba_span_float(ctx, filter->Width, src,
+                                 format, type, dst, &ctx->Pack, 0x0);
    }
 
    if (ctx->Pack.BufferObj->Name) {
@@ -768,10 +768,11 @@ _mesa_GetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params)
 
 
 void GLAPIENTRY
-_mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span)
+_mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type,
+                         GLvoid *row, GLvoid *column, GLvoid *span)
 {
    const GLint colStart = MAX_CONVOLUTION_WIDTH * 4;
-   const struct gl_convolution_attrib *filter;
+   struct gl_convolution_attrib *filter;
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
@@ -785,7 +786,8 @@ _mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid *row,
    }
 
    if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
-      _mesa_error(ctx, GL_INVALID_OPERATION, "glGetConvolutionFilter(format or type)");
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glGetConvolutionFilter(format or type)");
       return;
    }
 
@@ -833,18 +835,17 @@ _mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid *row,
       GLvoid *dst = _mesa_image_address1d(&ctx->Pack, row, filter->Width,
                                           format, type, 0);
       _mesa_pack_rgba_span_float(ctx, filter->Width,
-                                 (const GLfloat (*)[4]) filter->Filter,
-                                 format, type, dst, &ctx->Pack, 0);
+                                 (GLfloat (*)[4]) filter->Filter,
+                                 format, type, dst, &ctx->Pack, 0x0);
    }
 
    /* Column filter */
    if (column) {
       GLvoid *dst = _mesa_image_address1d(&ctx->Pack, column, filter->Height,
                                           format, type, 0);
-      const GLfloat *src = filter->Filter + colStart;
-      _mesa_pack_rgba_span_float(ctx, filter->Height,
-                                 (const GLfloat (*)[4]) src,
-                                 format, type, dst, &ctx->Pack, 0);
+      GLfloat (*src)[4] = (GLfloat (*)[4]) (filter->Filter + colStart);
+      _mesa_pack_rgba_span_float(ctx, filter->Height, src,
+                                 format, type, dst, &ctx->Pack, 0x0);
    }
 
    (void) span;  /* unused at this time */
index 29aced0..6a7f094 100644 (file)
@@ -748,8 +748,8 @@ _mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvo
       minmax[1][GCOMP] = CLAMP(ctx->MinMax.Max[GCOMP], 0.0F, 1.0F);
       minmax[1][BCOMP] = CLAMP(ctx->MinMax.Max[BCOMP], 0.0F, 1.0F);
       minmax[1][ACOMP] = CLAMP(ctx->MinMax.Max[ACOMP], 0.0F, 1.0F);
-      _mesa_pack_rgba_span_float(ctx, 2, (CONST GLfloat (*)[4]) minmax,
-                                 format, type, values, &ctx->Pack, 0);
+      _mesa_pack_rgba_span_float(ctx, 2, minmax,
+                                 format, type, values, &ctx->Pack, 0x0);
    }
 
    if (ctx->Pack.BufferObj->Name) {
index 55753c2..af116af 100644 (file)
@@ -1065,18 +1065,18 @@ _mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLbitfield transferOps,
  * by the dstFormat, dstType and dstPacking.  Used by glReadPixels,
  * glGetConvolutionFilter(), etc.
  * Incoming colors will be clamped to [0,1] if needed.
+ * Note: the rgba values will be modified by this function when any pixel
+ * transfer ops are enabled.
  */
 void
-_mesa_pack_rgba_span_float( GLcontext *ctx,
-                            GLuint n, CONST GLfloat rgbaIn[][4],
-                            GLenum dstFormat, GLenum dstType,
-                            GLvoid *dstAddr,
-                            const struct gl_pixelstore_attrib *dstPacking,
-                            GLbitfield transferOps )
+_mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4],
+                           GLenum dstFormat, GLenum dstType,
+                           GLvoid *dstAddr,
+                           const struct gl_pixelstore_attrib *dstPacking,
+                           GLbitfield transferOps)
 {
+   GLfloat luminance[MAX_WIDTH];
    const GLint comps = _mesa_components_in_format(dstFormat);
-   GLfloat rgbaCopy[MAX_WIDTH][4], luminance[MAX_WIDTH];
-   const GLfloat (*rgba)[4];
    GLuint i;
 
    if (dstType != GL_FLOAT) {
@@ -1085,19 +1085,11 @@ _mesa_pack_rgba_span_float( GLcontext *ctx,
    }
 
    if (transferOps) {
-      /* make copy of incoming data */
-      _mesa_memcpy(rgbaCopy, rgbaIn, n * 4 * sizeof(GLfloat));
-      _mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgbaCopy);
-      rgba = (const GLfloat (*)[4]) rgbaCopy;
-
+      _mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgba);
       if ((transferOps & IMAGE_MIN_MAX_BIT) && ctx->MinMax.Sink) {
          return;
       }
    }
-   else {
-      /* use incoming data, not a copy */
-      rgba = (const GLfloat (*)[4]) rgbaIn;
-   }
 
    if (dstFormat == GL_LUMINANCE || dstFormat == GL_LUMINANCE_ALPHA) {
       /* compute luminance values */
index d9d5830..5d50f5d 100644 (file)
@@ -116,8 +116,7 @@ _mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLbitfield transferOps,
                               GLuint n, GLfloat rgba[][4]);
 
 extern void
-_mesa_pack_rgba_span_float( GLcontext *ctx,
-                            GLuint n, CONST GLfloat rgba[][4],
+_mesa_pack_rgba_span_float( GLcontext *ctx, GLuint n, GLfloat rgba[][4],
                             GLenum dstFormat, GLenum dstType, GLvoid *dstAddr,
                             const struct gl_pixelstore_attrib *dstPacking,
                             GLbitfield transferOps );
index 72ff73e..2a34cfb 100644 (file)
@@ -398,7 +398,7 @@ make_temp_float_image(GLcontext *ctx, GLuint dims,
             GLfloat *dst = tempImage + img * (convWidth * convHeight * 4);
             for (row = 0; row < convHeight; row++) {
                _mesa_pack_rgba_span_float(ctx, convWidth,
-                                          (const GLfloat (*)[4]) src,
+                                          (GLfloat (*)[4]) src,
                                           logicalBaseFormat, GL_FLOAT,
                                           dst, &ctx->DefaultPacking,
                                           postConvTransferOps);
@@ -3607,10 +3607,9 @@ _mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level,
                for (col = 0; col < width; col++) {
                   (*texImage->FetchTexelf)(texImage, col, row, img, rgba[col]);
                }
-               _mesa_pack_rgba_span_float(ctx, width,
-                                          (const GLfloat (*)[4]) rgba,
-                                          format, type, dest, &ctx->Pack,
-                                          0 /* no image transfer */);
+               _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba,
+                                          format, type, dest,
+                                          &ctx->Pack, 0x0 /*image xfer ops*/);
             } /* format */
          } /* row */
       } /* img */
index 3b7fc3f..fb39427 100644 (file)
@@ -377,8 +377,7 @@ read_rgba_pixels( GLcontext *ctx,
          GLvoid *dest;
          dest = _mesa_image_address2d(packing, pixels, width, height,
                                       format, type, row, 0);
-         _mesa_pack_rgba_span_float(ctx, width,
-                                    (const GLfloat (*)[4]) src,
+         _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) src,
                                     format, type, dest, packing,
                                     transferOps & IMAGE_POST_CONVOLUTION_BITS);
          src += width * 4;
@@ -419,8 +418,7 @@ read_rgba_pixels( GLcontext *ctx,
          }
 
          /* pack the row of RGBA pixels into user's buffer */
-         _mesa_pack_rgba_span_float(ctx, width, (CONST GLfloat (*)[4]) rgba,
-                                    format, type, dst,
+         _mesa_pack_rgba_span_float(ctx, width, rgba, format, type, dst,
                                     packing, ctx->_ImageTransferState);
 
          dst += dstStride;