summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/image.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-11-09 16:30:50 +0000
committerBrian Paul <[email protected]>2005-11-09 16:30:50 +0000
commita8717180d9805de3bf1ca30eff5487575fcfb384 (patch)
tree2d05b0de5082c397acd208587c7c766df05ef557 /src/mesa/main/image.c
parentcfca72cfb19367d824a3254b40566b3fc01723ea (diff)
Bug 4996.
Replace use of FLOAT_TO_USHORT with either CLAMPED_FLOAT_TO_USHORT or UNCLAMPED_FLOAT_TO_USHORT. Same should be done for UBYTE, UINT, etc.
Diffstat (limited to 'src/mesa/main/image.c')
-rw-r--r--src/mesa/main/image.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index 3523505cfcb..b9a032307c2 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -1042,10 +1042,11 @@ _mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLuint transferOps,
-/*
+/**
* Used to pack an array [][4] of RGBA float colors as specified
* by the dstFormat, dstType and dstPacking. Used by glReadPixels,
* glGetConvolutionFilter(), etc.
+ * NOTE: it's assumed the incoming float colors are all in [0,1].
*/
void
_mesa_pack_rgba_span_float( GLcontext *ctx,
@@ -1246,66 +1247,66 @@ _mesa_pack_rgba_span_float( GLcontext *ctx,
switch (dstFormat) {
case GL_RED:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_USHORT(rgba[i][RCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i], rgba[i][RCOMP]);
break;
case GL_GREEN:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_USHORT(rgba[i][GCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i], rgba[i][GCOMP]);
break;
case GL_BLUE:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_USHORT(rgba[i][BCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i], rgba[i][BCOMP]);
break;
case GL_ALPHA:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_USHORT(rgba[i][ACOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i], rgba[i][ACOMP]);
break;
case GL_LUMINANCE:
for (i=0;i<n;i++)
- dst[i] = FLOAT_TO_USHORT(luminance[i]);
+ UNCLAMPED_FLOAT_TO_USHORT(dst[i], 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]);
+ UNCLAMPED_FLOAT_TO_USHORT(dst[i*2+0], luminance[i]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*2+1], 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]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*3+0], rgba[i][RCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*3+1], rgba[i][GCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*3+2], 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]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*4+0], rgba[i][RCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*4+1], rgba[i][GCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*4+2], rgba[i][BCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*4+3], 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]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*3+0], rgba[i][BCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*3+1], rgba[i][GCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*3+2], 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]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*4+0], rgba[i][BCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*4+1], rgba[i][GCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*4+2], rgba[i][RCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*4+3], 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]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*4+0], rgba[i][ACOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*4+1], rgba[i][BCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*4+2], rgba[i][GCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*4+3], rgba[i][RCOMP]);
}
break;
default:
@@ -4011,7 +4012,7 @@ _mesa_pack_depth_span( const GLcontext *ctx, GLuint n, GLvoid *dest,
GLushort *dst = (GLushort *) dest;
GLuint i;
for (i = 0; i < n; i++) {
- dst[i] = FLOAT_TO_USHORT( depthSpan[i] );
+ CLAMPED_FLOAT_TO_USHORT(dst[i], depthSpan[i]);
}
if (dstPacking->SwapBytes) {
_mesa_swap2( (GLushort *) dst, n );