summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2001-03-21 16:44:08 +0000
committerBrian Paul <[email protected]>2001-03-21 16:44:08 +0000
commit0299ad753224372c7a6147f598fdad33f576a714 (patch)
tree5e9d1404c3b23049c6075318c9beedcaa21c7ec0 /src
parentc8cfbf7c19d7c3c213d5b48e1ef5ce5c19d3a656 (diff)
renamed some vars, added a bunch of comments
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/texstore.c22
-rw-r--r--src/mesa/main/texstore.h4
-rw-r--r--src/mesa/main/texutil.c48
-rw-r--r--src/mesa/main/texutil_tmp.h58
4 files changed, 80 insertions, 52 deletions
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 6ae40c9e80f..3c4a08371c4 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -1,4 +1,4 @@
-/* $Id: texstore.c,v 1.17 2001/03/21 01:08:37 brianp Exp $ */
+/* $Id: texstore.c,v 1.18 2001/03/21 16:44:08 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -156,7 +156,7 @@ components_in_intformat( GLint format )
*/
void
_mesa_transfer_teximage(GLcontext *ctx, GLuint dimensions,
- GLenum texFormat, GLvoid *texDestAddr,
+ GLenum texDestFormat, GLvoid *texDestAddr,
GLint srcWidth, GLint srcHeight, GLint srcDepth,
GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
GLint dstRowStride, GLint dstImageStride,
@@ -180,12 +180,12 @@ _mesa_transfer_teximage(GLcontext *ctx, GLuint dimensions,
ASSERT(srcAddr);
ASSERT(srcPacking);
- texComponents = components_in_intformat(texFormat);
+ texComponents = components_in_intformat(texDestFormat);
/* try common 2D texture cases first */
if (!ctx->_ImageTransferState && dimensions == 2 && srcType == CHAN_TYPE) {
- if (srcFormat == texFormat) {
+ if (srcFormat == texDestFormat) {
/* This will cover the common GL_RGB, GL_RGBA, GL_ALPHA,
* GL_LUMINANCE_ALPHA, etc. texture formats. Use memcpy().
*/
@@ -210,7 +210,7 @@ _mesa_transfer_teximage(GLcontext *ctx, GLuint dimensions,
}
return; /* all done */
}
- else if (srcFormat == GL_RGBA && texFormat == GL_RGB) {
+ else if (srcFormat == GL_RGBA && texDestFormat == GL_RGB) {
/* commonly used by Quake */
const GLchan *src = (const GLchan *) _mesa_image_address(
srcPacking, srcAddr, srcWidth, srcHeight,
@@ -239,7 +239,7 @@ _mesa_transfer_teximage(GLcontext *ctx, GLuint dimensions,
/*
* General case solutions
*/
- if (texFormat == GL_COLOR_INDEX) {
+ if (texDestFormat == GL_COLOR_INDEX) {
/* color index texture */
const GLenum texType = CHAN_TYPE;
GLint img, row;
@@ -259,7 +259,7 @@ _mesa_transfer_teximage(GLcontext *ctx, GLuint dimensions,
dest += dstImageStride;
}
}
- else if (texFormat == GL_DEPTH_COMPONENT) {
+ else if (texDestFormat == GL_DEPTH_COMPONENT) {
/* Depth texture (shadow maps) */
GLint img, row;
GLubyte *dest = (GLubyte *) texDestAddr
@@ -342,7 +342,7 @@ _mesa_transfer_teximage(GLcontext *ctx, GLuint dimensions,
for (row = 0; row < convHeight; row++) {
_mesa_pack_float_rgba_span(ctx, convWidth,
(const GLfloat (*)[4]) srcf,
- texFormat, CHAN_TYPE,
+ texDestFormat, CHAN_TYPE,
dest, &_mesa_native_packing,
ctx->_ImageTransferState
& IMAGE_POST_CONVOLUTION_BITS);
@@ -368,9 +368,9 @@ _mesa_transfer_teximage(GLcontext *ctx, GLuint dimensions,
const GLvoid *srcRow = _mesa_image_address(srcPacking,
srcAddr, srcWidth, srcHeight,
srcFormat, srcType, img, row, 0);
- _mesa_unpack_chan_color_span(ctx, srcWidth, texFormat, destRow,
- srcFormat, srcType, srcRow, srcPacking,
- ctx->_ImageTransferState);
+ _mesa_unpack_chan_color_span(ctx, srcWidth, texDestFormat,
+ destRow, srcFormat, srcType, srcRow,
+ srcPacking, ctx->_ImageTransferState);
destRow += dstRowStride;
}
dest += dstImageStride;
diff --git a/src/mesa/main/texstore.h b/src/mesa/main/texstore.h
index 585d44efe9f..c78a32703c8 100644
--- a/src/mesa/main/texstore.h
+++ b/src/mesa/main/texstore.h
@@ -1,4 +1,4 @@
-/* $Id: texstore.h,v 1.4 2001/03/21 01:08:37 brianp Exp $ */
+/* $Id: texstore.h,v 1.5 2001/03/21 16:44:08 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -39,7 +39,7 @@
extern void
_mesa_transfer_teximage(GLcontext *ctx, GLuint dimensions,
- GLenum texFormat, GLvoid *texDestAddr,
+ GLenum texDestFormat, GLvoid *texDestAddr,
GLint srcWidth, GLint srcHeight, GLint srcDepth,
GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
GLint dstRowStride, GLint dstImageStride,
diff --git a/src/mesa/main/texutil.c b/src/mesa/main/texutil.c
index 217f1e2d6b8..033b17912bb 100644
--- a/src/mesa/main/texutil.c
+++ b/src/mesa/main/texutil.c
@@ -1,4 +1,4 @@
-/* $Id: texutil.c,v 1.16 2001/03/18 13:40:58 gareth Exp $ */
+/* $Id: texutil.c,v 1.17 2001/03/21 16:44:08 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -48,8 +48,9 @@ struct gl_texture_convert {
GLint xoffset, yoffset, zoffset; /* Subimage offset */
GLint width, height, depth; /* Subimage region */
- GLint imageWidth, imageHeight; /* Full image dimensions */
- GLenum format, type;
+ GLint dstImageWidth, dstImageHeight; /* Dest image size */
+ /* Needed for subimage replacement */
+ GLenum format, type; /* Source (user) format and type */
const struct gl_pixelstore_attrib *packing;
@@ -701,11 +702,38 @@ _mesa_convert_texsubimage1d( GLint mesaFormat,
return gl_convert_texsubimage2d_tab[mesaFormat]( &convert );
}
+
+/*
+ * Convert a user's 2D image into a texture image. This basically repacks
+ * pixel data into the special texture formats used by core Mesa and the DRI
+ * drivers. This function can do full images or subimages.
+ *
+ * We return a boolean because this function may not accept some kinds of
+ * source image formats and/or types. For example, if the incoming
+ * format/type = GL_BGR, GL_UNSIGNED_INT this function probably won't
+ * be able to do the conversion.
+ *
+ * In that case, the incoming image should first be simplified to one of
+ * the "canonical" formats (GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA,
+ * GL_INTENSITY, GL_RGB, GL_RGBA) and types (GL_CHAN). We can do that
+ * with the _mesa_transfer_teximage() function. That function will also
+ * do image transfer operations such as scale/bias and convolution.
+ *
+ * Input:
+ * mesaFormat - one of the MESA_FORMAT_* values from texformat.h
+ * xoffset, yoffset - position in dest image to put data
+ * width, height - incoming image size, also size of dest region.
+ * dstImageWidth - width (row stride) of dest image in pixels
+ * format, type - incoming image format and type
+ * packing - describes incoming image packing
+ * srcImage - pointer to source image
+ * destImage - pointer to dest image
+ */
GLboolean
_mesa_convert_texsubimage2d( GLint mesaFormat,
GLint xoffset, GLint yoffset,
GLint width, GLint height,
- GLint imageWidth,
+ GLint destImageWidth,
GLenum format, GLenum type,
const struct gl_pixelstore_attrib *packing,
const GLvoid *srcImage, GLvoid *dstImage )
@@ -725,7 +753,7 @@ _mesa_convert_texsubimage2d( GLint mesaFormat,
convert.yoffset = yoffset;
convert.width = width;
convert.height = height;
- convert.imageWidth = imageWidth;
+ convert.dstImageWidth = destImageWidth;
convert.format = format;
convert.type = type;
convert.packing = packing;
@@ -737,7 +765,7 @@ _mesa_convert_texsubimage2d( GLint mesaFormat,
if ( convert_needs_packing( packing, format, type ) )
convert.index |= CONVERT_PACKING_BIT;
- if ( width != imageWidth )
+ if ( width != destImageWidth )
convert.index |= CONVERT_STRIDE_BIT;
return gl_convert_texsubimage2d_tab[mesaFormat]( &convert );
@@ -747,7 +775,7 @@ GLboolean
_mesa_convert_texsubimage3d( GLint mesaFormat,
GLint xoffset, GLint yoffset, GLint zoffset,
GLint width, GLint height, GLint depth,
- GLint imageWidth, GLint imageHeight,
+ GLint dstImageWidth, GLint dstImageHeight,
GLenum format, GLenum type,
const struct gl_pixelstore_attrib *packing,
const GLvoid *srcImage, GLvoid *dstImage )
@@ -769,8 +797,8 @@ _mesa_convert_texsubimage3d( GLint mesaFormat,
convert.width = width;
convert.height = height;
convert.depth = depth;
- convert.imageWidth = imageWidth;
- convert.imageHeight = imageHeight;
+ convert.dstImageWidth = dstImageWidth;
+ convert.dstImageHeight = dstImageHeight;
convert.format = format;
convert.type = type;
convert.packing = packing;
@@ -782,7 +810,7 @@ _mesa_convert_texsubimage3d( GLint mesaFormat,
if ( convert_needs_packing( packing, format, type ) )
convert.index |= CONVERT_PACKING_BIT;
- if ( width != imageWidth || height != imageHeight )
+ if ( width != dstImageWidth || height != dstImageHeight )
convert.index |= CONVERT_STRIDE_BIT;
return gl_convert_texsubimage3d_tab[mesaFormat]( &convert );
diff --git a/src/mesa/main/texutil_tmp.h b/src/mesa/main/texutil_tmp.h
index 6a1f002fc8a..4d55e86414f 100644
--- a/src/mesa/main/texutil_tmp.h
+++ b/src/mesa/main/texutil_tmp.h
@@ -1,4 +1,4 @@
-/* $Id: texutil_tmp.h,v 1.4 2001/03/20 10:18:13 joukj Exp $ */
+/* $Id: texutil_tmp.h,v 1.5 2001/03/21 16:44:08 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -37,20 +37,20 @@
#define DST_TEXEL_BYTES (4 / DST_TEXELS_PER_DWORD)
#define DST_ROW_WIDTH (convert->width * DST_TEXEL_BYTES)
-#define DST_ROW_STRIDE (convert->imageWidth * DST_TEXEL_BYTES)
-#define DST_IMG_STRIDE (convert->imageWidth * \
- convert->imageHeight * DST_TEXEL_BYTES)
+#define DST_ROW_STRIDE (convert->dstImageWidth * DST_TEXEL_BYTES)
+#define DST_IMG_STRIDE (convert->dstImageWidth * \
+ convert->dstImageHeight * DST_TEXEL_BYTES)
/* ================================================================
- * PRE: No pixelstore attribs, width == imageWidth.
+ * PRE: No pixelstore attribs, width == dstImageWidth.
*/
static GLboolean
TAG(texsubimage2d)( struct gl_texture_convert *convert )
{
const GLubyte *src = (const GLubyte *)convert->srcImage;
GLuint *dst = (GLuint *)((GLubyte *)convert->dstImage +
- (convert->yoffset * convert->imageWidth +
+ (convert->yoffset * convert->dstImageWidth +
convert->xoffset) * DST_TEXEL_BYTES);
GLint dwords, i;
(void) dwords; (void) i;
@@ -73,7 +73,7 @@ TAG(texsubimage2d)( struct gl_texture_convert *convert )
return GL_TRUE;
}
-/* PRE: As above, height == imageHeight also.
+/* PRE: As above, height == dstImageHeight also.
*/
static GLboolean
TAG(texsubimage3d)( struct gl_texture_convert *convert )
@@ -107,25 +107,25 @@ TAG(texsubimage3d)( struct gl_texture_convert *convert )
/* ================================================================
- * PRE: No pixelstore attribs, width != imageWidth.
+ * PRE: No pixelstore attribs, width != dstImageWidth.
*/
static GLboolean
TAG(texsubimage2d_stride)( struct gl_texture_convert *convert )
{
const GLubyte *src = (const GLubyte *)convert->srcImage;
DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage +
- (convert->yoffset * convert->imageWidth +
+ (convert->yoffset * convert->dstImageWidth +
convert->xoffset) * DST_TEXEL_BYTES);
GLint adjust;
GLint row, col;
- adjust = convert->imageWidth - convert->width;
+ adjust = convert->dstImageWidth - convert->width;
if ( DBG ) {
fprintf( stderr, __FUNCTION__ ":\n" );
fprintf( stderr, " x=%d y=%d w=%d h=%d s=%d\n",
convert->xoffset, convert->yoffset, convert->width,
- convert->height, convert->imageWidth );
+ convert->height, convert->dstImageWidth );
fprintf( stderr, " adjust=%d\n", adjust );
}
@@ -140,26 +140,26 @@ TAG(texsubimage2d_stride)( struct gl_texture_convert *convert )
return GL_TRUE;
}
-/* PRE: As above, or height != imageHeight also.
+/* PRE: As above, or height != dstImageHeight also.
*/
static GLboolean
TAG(texsubimage3d_stride)( struct gl_texture_convert *convert )
{
const GLubyte *src = (const GLubyte *)convert->srcImage;
DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage +
- ((convert->zoffset * convert->imageHeight +
- convert->yoffset) * convert->imageWidth +
+ ((convert->zoffset * convert->dstImageHeight +
+ convert->yoffset) * convert->dstImageWidth +
convert->xoffset) * DST_TEXEL_BYTES);
GLint adjust;
GLint row, col, img;
- adjust = convert->imageWidth - convert->width;
+ adjust = convert->dstImageWidth - convert->width;
if ( DBG ) {
fprintf( stderr, __FUNCTION__ ":\n" );
fprintf( stderr, " x=%d y=%d w=%d h=%d s=%d\n",
convert->xoffset, convert->yoffset, convert->width,
- convert->height, convert->imageWidth );
+ convert->height, convert->dstImageWidth );
fprintf( stderr, " adjust=%d\n", adjust );
}
@@ -180,7 +180,7 @@ TAG(texsubimage3d_stride)( struct gl_texture_convert *convert )
/* ================================================================
- * PRE: Require pixelstore attribs, width == imageWidth.
+ * PRE: Require pixelstore attribs, width == dstImageWidth.
*/
static GLboolean
TAG(texsubimage2d_pack)( struct gl_texture_convert *convert )
@@ -223,7 +223,7 @@ TAG(texsubimage2d_pack)( struct gl_texture_convert *convert )
return GL_TRUE;
}
-/* PRE: as above, height == imageHeight also.
+/* PRE: as above, height == dstImageHeight also.
*/
static GLboolean
TAG(texsubimage3d_pack)( struct gl_texture_convert *convert )
@@ -272,7 +272,7 @@ TAG(texsubimage3d_pack)( struct gl_texture_convert *convert )
/* ================================================================
- * PRE: Require pixelstore attribs, width != imageWidth.
+ * PRE: Require pixelstore attribs, width != dstImageWidth.
*/
static GLboolean
TAG(texsubimage2d_stride_pack)( struct gl_texture_convert *convert )
@@ -285,19 +285,19 @@ TAG(texsubimage2d_stride_pack)( struct gl_texture_convert *convert )
_mesa_image_row_stride( convert->packing, convert->width,
convert->format, convert->type );
DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage +
- (convert->yoffset * convert->imageWidth +
+ (convert->yoffset * convert->dstImageWidth +
convert->xoffset) * DST_TEXEL_BYTES);
GLint adjust;
GLint row, col;
(void) col;
- adjust = convert->imageWidth - convert->width;
+ adjust = convert->dstImageWidth - convert->width;
if ( DBG ) {
fprintf( stderr, __FUNCTION__ ":\n" );
fprintf( stderr, " x=%d y=%d w=%d h=%d s=%d\n",
convert->xoffset, convert->yoffset, convert->width,
- convert->height, convert->imageWidth );
+ convert->height, convert->dstImageWidth );
fprintf( stderr, " adjust=%d\n", adjust );
}
@@ -305,7 +305,7 @@ TAG(texsubimage2d_stride_pack)( struct gl_texture_convert *convert )
#ifdef CONVERT_DIRECT
MEMCPY( dst, src, DST_ROW_WIDTH );
src += srcRowStride;
- dst += convert->imageWidth;
+ dst += convert->dstImageWidth;
#else
const GLubyte *srcRow = src;
for ( col = 0 ; col < convert->width ; col++ ) {
@@ -320,7 +320,7 @@ TAG(texsubimage2d_stride_pack)( struct gl_texture_convert *convert )
return GL_TRUE;
}
-/* PRE: As above, or height != imageHeight also.
+/* PRE: As above, or height != dstImageHeight also.
*/
static GLboolean
TAG(texsubimage3d_stride_pack)( struct gl_texture_convert *convert )
@@ -333,20 +333,20 @@ TAG(texsubimage3d_stride_pack)( struct gl_texture_convert *convert )
_mesa_image_row_stride( convert->packing, convert->width,
convert->format, convert->type );
DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage +
- ((convert->zoffset * convert->imageHeight +
- convert->yoffset) * convert->imageWidth +
+ ((convert->zoffset * convert->dstImageHeight +
+ convert->yoffset) * convert->dstImageWidth +
convert->xoffset) * DST_TEXEL_BYTES);
GLint adjust;
GLint row, col, img;
(void) col;
- adjust = convert->imageWidth - convert->width;
+ adjust = convert->dstImageWidth - convert->width;
if ( DBG ) {
fprintf( stderr, __FUNCTION__ ":\n" );
fprintf( stderr, " x=%d y=%d w=%d h=%d s=%d\n",
convert->xoffset, convert->yoffset, convert->width,
- convert->height, convert->imageWidth );
+ convert->height, convert->dstImageWidth );
fprintf( stderr, " adjust=%d\n", adjust );
}
@@ -355,7 +355,7 @@ TAG(texsubimage3d_stride_pack)( struct gl_texture_convert *convert )
#ifdef CONVERT_DIRECT
MEMCPY( dst, src, DST_ROW_WIDTH );
src += srcRowStride;
- dst += convert->imageWidth;
+ dst += convert->dstImageWidth;
#else
const GLubyte *srcRow = src;
for ( col = 0 ; col < convert->width ; col++ ) {