-/* $Id: image.c,v 1.38 2000/08/30 18:21:37 brianp Exp $ */
+/* $Id: image.c,v 1.39 2000/08/31 15:24:07 brianp Exp $ */
/*
* Mesa 3-D graphics library
void
_mesa_pack_rgba_span( GLcontext *ctx,
GLuint n, CONST GLubyte srcRgba[][4],
- GLenum format, GLenum type, GLvoid *destination,
- const struct gl_pixelstore_attrib *packing,
+ GLenum dstFormat, GLenum dstType,
+ GLvoid *dstAddr,
+ const struct gl_pixelstore_attrib *dstPacking,
GLuint transferOps)
{
ASSERT(ctx->ImageTransferState != UPDATE_IMAGE_TRANSFER_STATE);
/* Test for optimized case first */
- if (transferOps == 0 && format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
+ if (transferOps == 0 && dstFormat == GL_RGBA
+ && dstType == GL_UNSIGNED_BYTE) {
/* common simple case */
- MEMCPY( destination, srcRgba, n * 4 * sizeof(GLubyte) );
+ MEMCPY(dstAddr, srcRgba, n * 4 * sizeof(GLubyte));
}
- else if (transferOps == 0 && format == GL_RGB && type == GL_UNSIGNED_BYTE) {
+ else if (transferOps == 0 && dstFormat == GL_RGB
+ && dstType == GL_UNSIGNED_BYTE) {
/* common simple case */
GLint i;
- GLubyte *dest = (GLubyte *) destination;
+ GLubyte *dest = (GLubyte *) dstAddr;
for (i = 0; i < n; i++) {
dest[0] = srcRgba[i][RCOMP];
dest[1] = srcRgba[i][GCOMP];
rgba[i][ACOMP] = srcRgba[i][ACOMP] * ascale;
}
_mesa_pack_float_rgba_span(ctx, n, (const GLfloat (*)[4]) rgba,
- format, type, destination,
- packing, transferOps);
+ dstFormat, dstType, dstAddr,
+ dstPacking, transferOps);
}
}
void
_mesa_pack_float_rgba_span( GLcontext *ctx,
GLuint n, CONST GLfloat rgbaIn[][4],
- GLenum format, GLenum type, GLvoid *destination,
- const struct gl_pixelstore_attrib *packing,
+ GLenum dstFormat, GLenum dstType,
+ GLvoid *dstAddr,
+ const struct gl_pixelstore_attrib *dstPacking,
GLuint transferOps )
{
- const GLint comps = _mesa_components_in_format(format);
+ const GLint comps = _mesa_components_in_format(dstFormat);
GLfloat luminance[MAX_WIDTH];
GLfloat (*rgba)[4];
GLuint i;
/* XXX clamp rgba to [0,1]? */
- if (format == GL_LUMINANCE || format == GL_LUMINANCE_ALPHA) {
+ if (dstFormat == GL_LUMINANCE || dstFormat == GL_LUMINANCE_ALPHA) {
for (i = 0; i < n; i++) {
GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP];
luminance[i] = CLAMP(sum, 0.0F, 1.0F);
/*
* Pack/store the pixels. Ugh! Lots of cases!!!
*/
- switch (type) {
+ switch (dstType) {
case GL_UNSIGNED_BYTE:
{
- GLubyte *dst = (GLubyte *) destination;
- switch (format) {
+ GLubyte *dst = (GLubyte *) dstAddr;
+ switch (dstFormat) {
case GL_RED:
for (i=0;i<n;i++)
dst[i] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
break;
case GL_BYTE:
{
- GLbyte *dst = (GLbyte *) destination;
- switch (format) {
+ GLbyte *dst = (GLbyte *) dstAddr;
+ switch (dstFormat) {
case GL_RED:
for (i=0;i<n;i++)
dst[i] = FLOAT_TO_BYTE(rgba[i][RCOMP]);
break;
case GL_UNSIGNED_SHORT:
{
- GLushort *dst = (GLushort *) destination;
- switch (format) {
+ GLushort *dst = (GLushort *) dstAddr;
+ switch (dstFormat) {
case GL_RED:
for (i=0;i<n;i++)
dst[i] = FLOAT_TO_USHORT(rgba[i][RCOMP]);
default:
gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
- if (packing->SwapBytes) {
+ if (dstPacking->SwapBytes) {
_mesa_swap2( (GLushort *) dst, n * comps);
}
}
break;
case GL_SHORT:
{
- GLshort *dst = (GLshort *) destination;
- switch (format) {
+ GLshort *dst = (GLshort *) dstAddr;
+ switch (dstFormat) {
case GL_RED:
for (i=0;i<n;i++)
dst[i] = FLOAT_TO_SHORT(rgba[i][RCOMP]);
default:
gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
- if (packing->SwapBytes) {
+ if (dstPacking->SwapBytes) {
_mesa_swap2( (GLushort *) dst, n * comps );
}
}
break;
case GL_UNSIGNED_INT:
{
- GLuint *dst = (GLuint *) destination;
- switch (format) {
+ GLuint *dst = (GLuint *) dstAddr;
+ switch (dstFormat) {
case GL_RED:
for (i=0;i<n;i++)
dst[i] = FLOAT_TO_UINT(rgba[i][RCOMP]);
default:
gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
- if (packing->SwapBytes) {
+ if (dstPacking->SwapBytes) {
_mesa_swap4( (GLuint *) dst, n * comps );
}
}
break;
case GL_INT:
{
- GLint *dst = (GLint *) destination;
- switch (format) {
+ GLint *dst = (GLint *) dstAddr;
+ switch (dstFormat) {
case GL_RED:
for (i=0;i<n;i++)
dst[i] = FLOAT_TO_INT(rgba[i][RCOMP]);
default:
gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
- if (packing->SwapBytes) {
+ if (dstPacking->SwapBytes) {
_mesa_swap4( (GLuint *) dst, n * comps );
}
}
break;
case GL_FLOAT:
{
- GLfloat *dst = (GLfloat *) destination;
- switch (format) {
+ GLfloat *dst = (GLfloat *) dstAddr;
+ switch (dstFormat) {
case GL_RED:
for (i=0;i<n;i++)
dst[i] = rgba[i][RCOMP];
default:
gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
- if (packing->SwapBytes) {
+ if (dstPacking->SwapBytes) {
_mesa_swap4( (GLuint *) dst, n * comps );
}
}
break;
case GL_UNSIGNED_BYTE_3_3_2:
- if (format == GL_RGB) {
- GLubyte *dst = (GLubyte *) destination;
+ if (dstFormat == GL_RGB) {
+ GLubyte *dst = (GLubyte *) dstAddr;
for (i=0;i<n;i++) {
dst[i] = (((GLint) (rgba[i][RCOMP] * 7.0F)) << 5)
| (((GLint) (rgba[i][GCOMP] * 7.0F)) << 2)
}
break;
case GL_UNSIGNED_BYTE_2_3_3_REV:
- if (format == GL_RGB) {
- GLubyte *dst = (GLubyte *) destination;
+ if (dstFormat == GL_RGB) {
+ GLubyte *dst = (GLubyte *) dstAddr;
for (i=0;i<n;i++) {
dst[i] = (((GLint) (rgba[i][RCOMP] * 7.0F)) )
| (((GLint) (rgba[i][GCOMP] * 7.0F)) << 3)
}
break;
case GL_UNSIGNED_SHORT_5_6_5:
- if (format == GL_RGB) {
- GLushort *dst = (GLushort *) destination;
+ if (dstFormat == GL_RGB) {
+ GLushort *dst = (GLushort *) dstAddr;
for (i=0;i<n;i++) {
dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) << 11)
| (((GLint) (rgba[i][GCOMP] * 63.0F)) << 5)
}
break;
case GL_UNSIGNED_SHORT_5_6_5_REV:
- if (format == GL_RGB) {
- GLushort *dst = (GLushort *) destination;
+ if (dstFormat == GL_RGB) {
+ GLushort *dst = (GLushort *) dstAddr;
for (i=0;i<n;i++) {
dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) )
| (((GLint) (rgba[i][GCOMP] * 63.0F)) << 5)
}
break;
case GL_UNSIGNED_SHORT_4_4_4_4:
- if (format == GL_RGB) {
- GLushort *dst = (GLushort *) destination;
+ if (dstFormat == GL_RGB) {
+ GLushort *dst = (GLushort *) dstAddr;
for (i=0;i<n;i++) {
dst[i] = (((GLint) (rgba[i][RCOMP] * 15.0F)) << 12)
| (((GLint) (rgba[i][GCOMP] * 15.0F)) << 8)
}
break;
case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- if (format == GL_RGB) {
- GLushort *dst = (GLushort *) destination;
+ if (dstFormat == GL_RGB) {
+ GLushort *dst = (GLushort *) dstAddr;
for (i=0;i<n;i++) {
dst[i] = (((GLint) (rgba[i][RCOMP] * 15.0F)) )
| (((GLint) (rgba[i][GCOMP] * 15.0F)) << 4)
}
break;
case GL_UNSIGNED_SHORT_5_5_5_1:
- if (format == GL_RGB) {
- GLushort *dst = (GLushort *) destination;
+ if (dstFormat == GL_RGB) {
+ GLushort *dst = (GLushort *) dstAddr;
for (i=0;i<n;i++) {
dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) << 11)
| (((GLint) (rgba[i][GCOMP] * 31.0F)) << 6)
}
break;
case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- if (format == GL_RGB) {
- GLushort *dst = (GLushort *) destination;
+ if (dstFormat == GL_RGB) {
+ GLushort *dst = (GLushort *) dstAddr;
for (i=0;i<n;i++) {
dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) )
| (((GLint) (rgba[i][GCOMP] * 31.0F)) << 5)
}
break;
case GL_UNSIGNED_INT_8_8_8_8:
- if (format == GL_RGBA) {
- GLuint *dst = (GLuint *) destination;
+ if (dstFormat == GL_RGBA) {
+ GLuint *dst = (GLuint *) dstAddr;
for (i=0;i<n;i++) {
dst[i] = (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 24)
| (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 16)
| (((GLuint) (rgba[i][ACOMP] * 255.0F)) );
}
}
- else if (format == GL_BGRA) {
- GLuint *dst = (GLuint *) destination;
+ else if (dstFormat == GL_BGRA) {
+ GLuint *dst = (GLuint *) dstAddr;
for (i=0;i<n;i++) {
dst[i] = (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 24)
| (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 16)
| (((GLuint) (rgba[i][ACOMP] * 255.0F)) );
}
}
- else if (format == GL_ABGR_EXT) {
- GLuint *dst = (GLuint *) destination;
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLuint *dst = (GLuint *) dstAddr;
for (i=0;i<n;i++) {
dst[i] = (((GLuint) (rgba[i][ACOMP] * 255.0F)) << 24)
| (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 16)
}
break;
case GL_UNSIGNED_INT_8_8_8_8_REV:
- if (format == GL_RGBA) {
- GLuint *dst = (GLuint *) destination;
+ if (dstFormat == GL_RGBA) {
+ GLuint *dst = (GLuint *) dstAddr;
for (i=0;i<n;i++) {
dst[i] = (((GLuint) (rgba[i][RCOMP] * 255.0F)) )
| (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 8)
| (((GLuint) (rgba[i][ACOMP] * 255.0F)) << 24);
}
}
- else if (format == GL_BGRA) {
- GLuint *dst = (GLuint *) destination;
+ else if (dstFormat == GL_BGRA) {
+ GLuint *dst = (GLuint *) dstAddr;
for (i=0;i<n;i++) {
dst[i] = (((GLuint) (rgba[i][BCOMP] * 255.0F)) )
| (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 8)
| (((GLuint) (rgba[i][ACOMP] * 255.0F)) << 24);
}
}
- else if (format == GL_ABGR_EXT) {
- GLuint *dst = (GLuint *) destination;
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLuint *dst = (GLuint *) dstAddr;
for (i=0;i<n;i++) {
dst[i] = (((GLuint) (rgba[i][ACOMP] * 255.0F)) )
| (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 8)
}
break;
case GL_UNSIGNED_INT_10_10_10_2:
- if (format == GL_RGBA) {
- GLuint *dst = (GLuint *) destination;
+ if (dstFormat == GL_RGBA) {
+ GLuint *dst = (GLuint *) dstAddr;
for (i=0;i<n;i++) {
dst[i] = (((GLuint) (rgba[i][RCOMP] * 1023.0F)) << 22)
| (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 12)
| (((GLuint) (rgba[i][ACOMP] * 3.0F)) );
}
}
- else if (format == GL_BGRA) {
- GLuint *dst = (GLuint *) destination;
+ else if (dstFormat == GL_BGRA) {
+ GLuint *dst = (GLuint *) dstAddr;
for (i=0;i<n;i++) {
dst[i] = (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 22)
| (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 12)
| (((GLuint) (rgba[i][ACOMP] * 3.0F)) );
}
}
- else if (format == GL_ABGR_EXT) {
- GLuint *dst = (GLuint *) destination;
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLuint *dst = (GLuint *) dstAddr;
for (i=0;i<n;i++) {
dst[i] = (((GLuint) (rgba[i][ACOMP] * 1023.0F)) << 22)
| (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 12)
}
break;
case GL_UNSIGNED_INT_2_10_10_10_REV:
- if (format == GL_RGBA) {
- GLuint *dst = (GLuint *) destination;
+ if (dstFormat == GL_RGBA) {
+ GLuint *dst = (GLuint *) dstAddr;
for (i=0;i<n;i++) {
dst[i] = (((GLuint) (rgba[i][RCOMP] * 1023.0F)) )
| (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 10)
| (((GLuint) (rgba[i][ACOMP] * 3.0F)) << 30);
}
}
- else if (format == GL_BGRA) {
- GLuint *dst = (GLuint *) destination;
+ else if (dstFormat == GL_BGRA) {
+ GLuint *dst = (GLuint *) dstAddr;
for (i=0;i<n;i++) {
dst[i] = (((GLuint) (rgba[i][BCOMP] * 1023.0F)) )
| (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 10)
| (((GLuint) (rgba[i][ACOMP] * 3.0F)) << 30);
}
}
- else if (format == GL_ABGR_EXT) {
- GLuint *dst = (GLuint *) destination;
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLuint *dst = (GLuint *) dstAddr;
for (i=0;i<n;i++) {
dst[i] = (((GLuint) (rgba[i][ACOMP] * 1023.0F)) )
| (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 10)
* srcFormat - source image format
* srcType - source image datatype
* source - source image pointer
- * unpacking - pixel unpacking parameters
+ * srcPacking - pixel unpacking parameters
* transferOps - bitmask of IMAGE_*_BIT values of operations to apply
*
* XXX perhaps expand this to process whole images someday.
GLuint n, GLenum dstFormat, GLubyte dest[],
GLenum srcFormat, GLenum srcType,
const GLvoid *source,
- const struct gl_pixelstore_attrib *unpacking,
+ const struct gl_pixelstore_attrib *srcPacking,
GLuint transferOps )
{
ASSERT(dstFormat == GL_ALPHA ||
if (srcFormat == GL_COLOR_INDEX) {
GLuint indexes[MAX_WIDTH];
extract_uint_indexes(n, indexes, srcFormat, srcType, source,
- unpacking);
+ srcPacking);
if (transferOps & IMAGE_MAP_COLOR_BIT) {
_mesa_map_ci(ctx, n, indexes);
}
else {
extract_float_rgba(n, rgba, srcFormat, srcType, source,
- unpacking->SwapBytes);
+ srcPacking->SwapBytes);
/* scale and bias colors */
if (transferOps & IMAGE_SCALE_BIAS_BIT) {
GLuint n, GLenum dstFormat, GLfloat dest[],
GLenum srcFormat, GLenum srcType,
const GLvoid *source,
- const struct gl_pixelstore_attrib *unpacking,
+ const struct gl_pixelstore_attrib *srcPacking,
GLuint transferOps, GLboolean clamp )
{
ASSERT(dstFormat == GL_ALPHA ||
if (srcFormat == GL_COLOR_INDEX) {
GLuint indexes[MAX_WIDTH];
extract_uint_indexes(n, indexes, srcFormat, srcType, source,
- unpacking);
+ srcPacking);
if (transferOps & IMAGE_MAP_COLOR_BIT) {
_mesa_map_ci(ctx, n, indexes);
}
else {
extract_float_rgba(n, rgba, srcFormat, srcType, source,
- unpacking->SwapBytes);
+ srcPacking->SwapBytes);
/* scale and bias colors */
if (transferOps & IMAGE_SCALE_BIAS_BIT) {
* dest - destination array
* srcType - source pixel type
* source - source data pointer
- * unpacking - pixel unpacking parameters
+ * srcPacking - pixel unpacking parameters
* transferOps - the pixel transfer operations to apply
*/
void
_mesa_unpack_index_span( const GLcontext *ctx, GLuint n,
GLenum dstType, GLvoid *dest,
GLenum srcType, const GLvoid *source,
- const struct gl_pixelstore_attrib *unpacking,
+ const struct gl_pixelstore_attrib *srcPacking,
GLuint transferOps )
{
ASSERT(srcType == GL_BITMAP ||
MEMCPY(dest, source, n * sizeof(GLubyte));
}
else if (transferOps == 0 && srcType == GL_UNSIGNED_INT
- && dstType == GL_UNSIGNED_INT && !unpacking->SwapBytes) {
+ && dstType == GL_UNSIGNED_INT && !srcPacking->SwapBytes) {
MEMCPY(dest, source, n * sizeof(GLuint));
}
else {
assert(n <= MAX_WIDTH);
extract_uint_indexes(n, indexes, GL_COLOR_INDEX, srcType, source,
- unpacking);
+ srcPacking);
if (transferOps & IMAGE_SHIFT_OFFSET_BIT) {
/* shift and offset indexes */
* dest - destination array
* srcType - source pixel type
* source - source data pointer
- * unpacking - pixel unpacking parameters
+ * srcPacking - pixel unpacking parameters
* transferOps - apply offset/bias/lookup ops?
*/
void
_mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n,
GLenum dstType, GLvoid *dest,
GLenum srcType, const GLvoid *source,
- const struct gl_pixelstore_attrib *unpacking,
+ const struct gl_pixelstore_attrib *srcPacking,
GLuint transferOps )
{
ASSERT(srcType == GL_BITMAP ||
else if (transferOps == 0 &&
srcType == GL_UNSIGNED_INT &&
dstType == GL_UNSIGNED_INT &&
- !unpacking->SwapBytes) {
+ !srcPacking->SwapBytes) {
MEMCPY(dest, source, n * sizeof(GLuint));
}
else {
assert(n <= MAX_WIDTH);
extract_uint_indexes(n, indexes, GL_COLOR_INDEX, srcType, source,
- unpacking);
+ srcPacking);
if (transferOps) {
if (transferOps & IMAGE_SHIFT_OFFSET_BIT) {
void
_mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLdepth *dest,
GLenum srcType, const GLvoid *source,
- const struct gl_pixelstore_attrib *unpacking,
+ const struct gl_pixelstore_attrib *srcPacking,
GLuint transferOps )
{
GLfloat *depth = MALLOC(n * sizeof(GLfloat));