In _mesa_pack_rgba_span_float() we don't need to make a temporary copy of
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.
diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c
index 63d254d..e934951 100644
--- a/src/mesa/main/colortab.c
+++ b/src/mesa/main/colortab.c
@@ -807,7 +807,7 @@
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) {
diff --git a/src/mesa/main/convolve.c b/src/mesa/main/convolve.c
index 6b97c7f..814c6a0 100644
--- a/src/mesa/main/convolve.c
+++ b/src/mesa/main/convolve.c
@@ -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 @@
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 @@
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 @@
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 @@
}
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 @@
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 */
diff --git a/src/mesa/main/histogram.c b/src/mesa/main/histogram.c
index 29aced0..6a7f094 100644
--- a/src/mesa/main/histogram.c
+++ b/src/mesa/main/histogram.c
@@ -748,8 +748,8 @@
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) {
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index 55753c2..af116af 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -1065,18 +1065,18 @@
* 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 @@
}
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 */
diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h
index d9d5830..5d50f5d 100644
--- a/src/mesa/main/image.h
+++ b/src/mesa/main/image.h
@@ -116,8 +116,7 @@
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 );
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 72ff73e..2a34cfb 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -398,7 +398,7 @@
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 @@
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 */
diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index 3b7fc3f..fb39427 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -377,8 +377,7 @@
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 @@
}
/* 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;