diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 4358503e3ca..09025327cf3 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -466,130 +466,6 @@ _mesa_expand_bitmap(GLsizei width, GLsizei height, -/** - * Convert an array of RGBA colors from one datatype to another. - * NOTE: src may equal dst. In that case, we use a temporary buffer. - */ -void -_mesa_convert_colors(GLenum srcType, const GLvoid *src, - GLenum dstType, GLvoid *dst, - GLuint count, const GLubyte mask[]) -{ - GLuint *tempBuffer; - const GLboolean useTemp = (src == dst); - - tempBuffer = malloc(count * MAX_PIXEL_BYTES); - if (!tempBuffer) - return; - - assert(srcType != dstType); - - switch (srcType) { - case GL_UNSIGNED_BYTE: - if (dstType == GL_UNSIGNED_SHORT) { - const GLubyte (*src1)[4] = (const GLubyte (*)[4]) src; - GLushort (*dst2)[4] = (GLushort (*)[4]) (useTemp ? tempBuffer : dst); - GLuint i; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst2[i][RCOMP] = UBYTE_TO_USHORT(src1[i][RCOMP]); - dst2[i][GCOMP] = UBYTE_TO_USHORT(src1[i][GCOMP]); - dst2[i][BCOMP] = UBYTE_TO_USHORT(src1[i][BCOMP]); - dst2[i][ACOMP] = UBYTE_TO_USHORT(src1[i][ACOMP]); - } - } - if (useTemp) - memcpy(dst, tempBuffer, count * 4 * sizeof(GLushort)); - } - else { - const GLubyte (*src1)[4] = (const GLubyte (*)[4]) src; - GLfloat (*dst4)[4] = (GLfloat (*)[4]) (useTemp ? tempBuffer : dst); - GLuint i; - assert(dstType == GL_FLOAT); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst4[i][RCOMP] = UBYTE_TO_FLOAT(src1[i][RCOMP]); - dst4[i][GCOMP] = UBYTE_TO_FLOAT(src1[i][GCOMP]); - dst4[i][BCOMP] = UBYTE_TO_FLOAT(src1[i][BCOMP]); - dst4[i][ACOMP] = UBYTE_TO_FLOAT(src1[i][ACOMP]); - } - } - if (useTemp) - memcpy(dst, tempBuffer, count * 4 * sizeof(GLfloat)); - } - break; - case GL_UNSIGNED_SHORT: - if (dstType == GL_UNSIGNED_BYTE) { - const GLushort (*src2)[4] = (const GLushort (*)[4]) src; - GLubyte (*dst1)[4] = (GLubyte (*)[4]) (useTemp ? tempBuffer : dst); - GLuint i; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst1[i][RCOMP] = USHORT_TO_UBYTE(src2[i][RCOMP]); - dst1[i][GCOMP] = USHORT_TO_UBYTE(src2[i][GCOMP]); - dst1[i][BCOMP] = USHORT_TO_UBYTE(src2[i][BCOMP]); - dst1[i][ACOMP] = USHORT_TO_UBYTE(src2[i][ACOMP]); - } - } - if (useTemp) - memcpy(dst, tempBuffer, count * 4 * sizeof(GLubyte)); - } - else { - const GLushort (*src2)[4] = (const GLushort (*)[4]) src; - GLfloat (*dst4)[4] = (GLfloat (*)[4]) (useTemp ? tempBuffer : dst); - GLuint i; - assert(dstType == GL_FLOAT); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - dst4[i][RCOMP] = USHORT_TO_FLOAT(src2[i][RCOMP]); - dst4[i][GCOMP] = USHORT_TO_FLOAT(src2[i][GCOMP]); - dst4[i][BCOMP] = USHORT_TO_FLOAT(src2[i][BCOMP]); - dst4[i][ACOMP] = USHORT_TO_FLOAT(src2[i][ACOMP]); - } - } - if (useTemp) - memcpy(dst, tempBuffer, count * 4 * sizeof(GLfloat)); - } - break; - case GL_FLOAT: - if (dstType == GL_UNSIGNED_BYTE) { - const GLfloat (*src4)[4] = (const GLfloat (*)[4]) src; - GLubyte (*dst1)[4] = (GLubyte (*)[4]) (useTemp ? tempBuffer : dst); - GLuint i; - for (i = 0; i < count; i++) { - if (!mask || mask[i]) - _mesa_unclamped_float_rgba_to_ubyte(dst1[i], src4[i]); - } - if (useTemp) - memcpy(dst, tempBuffer, count * 4 * sizeof(GLubyte)); - } - else { - const GLfloat (*src4)[4] = (const GLfloat (*)[4]) src; - GLushort (*dst2)[4] = (GLushort (*)[4]) (useTemp ? tempBuffer : dst); - GLuint i; - assert(dstType == GL_UNSIGNED_SHORT); - for (i = 0; i < count; i++) { - if (!mask || mask[i]) { - UNCLAMPED_FLOAT_TO_USHORT(dst2[i][RCOMP], src4[i][RCOMP]); - UNCLAMPED_FLOAT_TO_USHORT(dst2[i][GCOMP], src4[i][GCOMP]); - UNCLAMPED_FLOAT_TO_USHORT(dst2[i][BCOMP], src4[i][BCOMP]); - UNCLAMPED_FLOAT_TO_USHORT(dst2[i][ACOMP], src4[i][ACOMP]); - } - } - if (useTemp) - memcpy(dst, tempBuffer, count * 4 * sizeof(GLushort)); - } - break; - default: - unreachable("Invalid datatype in _mesa_convert_colors"); - } - - free(tempBuffer); -} - - - - /** * Perform basic clipping for glDrawPixels. The image's position and size * and the unpack SkipPixels and SkipRows are adjusted so that the image diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h index 7955bbb7ca6..32cbaf5fe47 100644 --- a/src/mesa/main/image.h +++ b/src/mesa/main/image.h @@ -96,12 +96,6 @@ _mesa_expand_bitmap(GLsizei width, GLsizei height, GLubyte onValue); -extern void -_mesa_convert_colors(GLenum srcType, const GLvoid *src, - GLenum dstType, GLvoid *dst, - GLuint count, const GLubyte mask[]); - - extern GLboolean _mesa_clip_drawpixels(const struct gl_context *ctx, GLint *destX, GLint *destY,