/**
- * Make a temporary (color) texture image with GLchan components.
+ * Make a temporary (color) texture image with GLubyte components.
* Apply all needed pixel unpacking and pixel transfer operations.
* Note that there are both logicalBaseFormat and textureBaseFormat parameters.
* Suppose the user specifies GL_LUMINANCE as the internal texture format
* \param srcType source image type
* \param srcAddr source image address
* \param srcPacking source image pixel packing
- * \return resulting image with format = textureBaseFormat and type = GLchan.
+ * \return resulting image with format = textureBaseFormat and type = GLubyte.
*/
-GLchan *
-_mesa_make_temp_chan_image(struct gl_context *ctx, GLuint dims,
- GLenum logicalBaseFormat,
- GLenum textureBaseFormat,
- GLint srcWidth, GLint srcHeight, GLint srcDepth,
- GLenum srcFormat, GLenum srcType,
- const GLvoid *srcAddr,
- const struct gl_pixelstore_attrib *srcPacking)
+GLubyte *
+_mesa_make_temp_ubyte_image(struct gl_context *ctx, GLuint dims,
+ GLenum logicalBaseFormat,
+ GLenum textureBaseFormat,
+ GLint srcWidth, GLint srcHeight, GLint srcDepth,
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *srcAddr,
+ const struct gl_pixelstore_attrib *srcPacking)
{
GLuint transferOps = ctx->_ImageTransferState;
const GLint components = _mesa_components_in_format(logicalBaseFormat);
GLint img, row;
- GLchan *tempImage, *dst;
+ GLubyte *tempImage, *dst;
ASSERT(dims >= 1 && dims <= 3);
textureBaseFormat == GL_INTENSITY);
/* unpack and transfer the source image */
- tempImage = (GLchan *) malloc(srcWidth * srcHeight * srcDepth
- * components * sizeof(GLchan));
+ tempImage = (GLubyte *) malloc(srcWidth * srcHeight * srcDepth
+ * components * sizeof(GLubyte));
if (!tempImage) {
return NULL;
}
/* one more conversion step */
GLint texComponents = _mesa_components_in_format(textureBaseFormat);
GLint logComponents = _mesa_components_in_format(logicalBaseFormat);
- GLchan *newImage;
+ GLubyte *newImage;
GLint i, n;
GLubyte map[6];
*/
ASSERT(texComponents >= logComponents);
- newImage = (GLchan *) malloc(srcWidth * srcHeight * srcDepth
- * texComponents * sizeof(GLchan));
+ newImage = (GLubyte *) malloc(srcWidth * srcHeight * srcDepth
+ * texComponents * sizeof(GLubyte));
if (!newImage) {
free(tempImage);
return NULL;
if (j == ZERO)
newImage[i * texComponents + k] = 0;
else if (j == ONE)
- newImage[i * texComponents + k] = CHAN_MAX;
+ newImage[i * texComponents + k] = 255;
else
newImage[i * texComponents + k] = tempImage[i * logComponents + j];
}
}
else {
/* general path */
- const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
baseInternalFormat,
baseFormat,
srcWidth, srcHeight, srcDepth,
srcFormat, srcType, srcAddr,
srcPacking);
- const GLchan *src = tempImage;
+ const GLubyte *src = tempImage;
GLint img, row, col;
if (!tempImage)
return GL_FALSE;
/* check for byteswapped format */
if (dstFormat == MESA_FORMAT_RGB565) {
for (col = 0; col < srcWidth; col++) {
- dstUS[col] = PACK_COLOR_565( CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]) );
+ dstUS[col] = PACK_COLOR_565( src[RCOMP],
+ src[GCOMP],
+ src[BCOMP] );
src += 3;
}
}
else {
for (col = 0; col < srcWidth; col++) {
- dstUS[col] = PACK_COLOR_565_REV( CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]) );
+ dstUS[col] = PACK_COLOR_565_REV( src[RCOMP],
+ src[GCOMP],
+ src[BCOMP] );
src += 3;
}
}
}
else {
/* general path */
- const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
baseInternalFormat,
baseFormat,
srcWidth, srcHeight, srcDepth,
srcFormat, srcType, srcAddr,
srcPacking);
- const GLchan *src = tempImage;
+ const GLubyte *src = tempImage;
GLint img, row, col;
if (!tempImage)
return GL_FALSE;
GLuint *dstUI = (GLuint *) dstRow;
if (dstFormat == MESA_FORMAT_RGBA8888) {
for (col = 0; col < srcWidth; col++) {
- dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]),
- CHAN_TO_UBYTE(src[ACOMP]) );
+ dstUI[col] = PACK_COLOR_8888( src[RCOMP],
+ src[GCOMP],
+ src[BCOMP],
+ src[ACOMP] );
src += 4;
}
}
else {
for (col = 0; col < srcWidth; col++) {
- dstUI[col] = PACK_COLOR_8888_REV( CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]),
- CHAN_TO_UBYTE(src[ACOMP]) );
+ dstUI[col] = PACK_COLOR_8888_REV( src[RCOMP],
+ src[GCOMP],
+ src[BCOMP],
+ src[ACOMP] );
src += 4;
}
}
}
else {
/* general path */
- const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
baseInternalFormat,
baseFormat,
srcWidth, srcHeight, srcDepth,
srcFormat, srcType, srcAddr,
srcPacking);
- const GLchan *src = tempImage;
+ const GLubyte *src = tempImage;
GLint img, row, col;
if (!tempImage)
return GL_FALSE;
GLuint *dstUI = (GLuint *) dstRow;
if (dstFormat == MESA_FORMAT_ARGB8888) {
for (col = 0; col < srcWidth; col++) {
- dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[ACOMP]),
- CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]) );
+ dstUI[col] = PACK_COLOR_8888( src[ACOMP],
+ src[RCOMP],
+ src[GCOMP],
+ src[BCOMP] );
src += 4;
}
}
else if (dstFormat == MESA_FORMAT_XRGB8888) {
for (col = 0; col < srcWidth; col++) {
dstUI[col] = PACK_COLOR_8888( 0xff,
- CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]) );
+ src[RCOMP],
+ src[GCOMP],
+ src[BCOMP] );
src += 4;
}
}
else {
for (col = 0; col < srcWidth; col++) {
- dstUI[col] = PACK_COLOR_8888_REV( CHAN_TO_UBYTE(src[ACOMP]),
- CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]) );
+ dstUI[col] = PACK_COLOR_8888_REV( src[ACOMP],
+ src[RCOMP],
+ src[GCOMP],
+ src[BCOMP] );
src += 4;
}
}
}
else {
/* general path */
- const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
baseInternalFormat,
baseFormat,
srcWidth, srcHeight, srcDepth,
srcFormat, srcType, srcAddr,
srcPacking);
- const GLchan *src = (const GLchan *) tempImage;
+ const GLubyte *src = (const GLubyte *) tempImage;
GLint img, row, col;
if (!tempImage)
return GL_FALSE;
#if 0
if (littleEndian) {
for (col = 0; col < srcWidth; col++) {
- dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[RCOMP]);
- dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]);
- dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[BCOMP]);
+ dstRow[col * 3 + 0] = src[RCOMP];
+ dstRow[col * 3 + 1] = src[GCOMP];
+ dstRow[col * 3 + 2] = src[BCOMP];
srcUB += 3;
}
}
}
#else
for (col = 0; col < srcWidth; col++) {
- dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[BCOMP]);
- dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]);
- dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[RCOMP]);
+ dstRow[col * 3 + 0] = src[BCOMP];
+ dstRow[col * 3 + 1] = src[GCOMP];
+ dstRow[col * 3 + 2] = src[RCOMP];
src += 3;
}
#endif
}
else {
/* general path */
- const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
baseInternalFormat,
baseFormat,
srcWidth, srcHeight, srcDepth,
srcFormat, srcType, srcAddr,
srcPacking);
- const GLchan *src = (const GLchan *) tempImage;
+ const GLubyte *src = (const GLubyte *) tempImage;
GLint img, row, col;
if (!tempImage)
return GL_FALSE;
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
for (col = 0; col < srcWidth; col++) {
- dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[RCOMP]);
- dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]);
- dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[BCOMP]);
+ dstRow[col * 3 + 0] = src[RCOMP];
+ dstRow[col * 3 + 1] = src[GCOMP];
+ dstRow[col * 3 + 2] = src[BCOMP];
src += 3;
}
dstRow += dstRowStride;
}
else {
/* general path */
- const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
baseInternalFormat,
baseFormat,
srcWidth, srcHeight, srcDepth,
srcFormat, srcType, srcAddr,
srcPacking);
- const GLchan *src = tempImage;
+ const GLubyte *src = tempImage;
GLint img, row, col;
if (!tempImage)
return GL_FALSE;
GLushort *dstUS = (GLushort *) dstRow;
if (dstFormat == MESA_FORMAT_ARGB4444) {
for (col = 0; col < srcWidth; col++) {
- dstUS[col] = PACK_COLOR_4444( CHAN_TO_UBYTE(src[ACOMP]),
- CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]) );
+ dstUS[col] = PACK_COLOR_4444( src[ACOMP],
+ src[RCOMP],
+ src[GCOMP],
+ src[BCOMP] );
src += 4;
}
}
else {
for (col = 0; col < srcWidth; col++) {
- dstUS[col] = PACK_COLOR_4444_REV( CHAN_TO_UBYTE(src[ACOMP]),
- CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]) );
+ dstUS[col] = PACK_COLOR_4444_REV( src[ACOMP],
+ src[RCOMP],
+ src[GCOMP],
+ src[BCOMP] );
src += 4;
}
}
}
else {
/* general path */
- const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
baseInternalFormat,
baseFormat,
srcWidth, srcHeight, srcDepth,
srcFormat, srcType, srcAddr,
srcPacking);
- const GLchan *src =tempImage;
+ const GLubyte *src =tempImage;
GLint img, row, col;
if (!tempImage)
return GL_FALSE;
for (row = 0; row < srcHeight; row++) {
GLushort *dstUS = (GLushort *) dstRow;
for (col = 0; col < srcWidth; col++) {
- dstUS[col] = PACK_COLOR_5551( CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]),
- CHAN_TO_UBYTE(src[ACOMP]) );
+ dstUS[col] = PACK_COLOR_5551( src[RCOMP],
+ src[GCOMP],
+ src[BCOMP],
+ src[ACOMP] );
src += 4;
}
dstRow += dstRowStride;
}
else {
/* general path */
- const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
baseInternalFormat,
baseFormat,
srcWidth, srcHeight, srcDepth,
srcFormat, srcType, srcAddr,
srcPacking);
- const GLchan *src =tempImage;
+ const GLubyte *src =tempImage;
GLint img, row, col;
if (!tempImage)
return GL_FALSE;
GLushort *dstUS = (GLushort *) dstRow;
if (dstFormat == MESA_FORMAT_ARGB1555) {
for (col = 0; col < srcWidth; col++) {
- dstUS[col] = PACK_COLOR_1555( CHAN_TO_UBYTE(src[ACOMP]),
- CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]) );
+ dstUS[col] = PACK_COLOR_1555( src[ACOMP],
+ src[RCOMP],
+ src[GCOMP],
+ src[BCOMP] );
src += 4;
}
}
else {
for (col = 0; col < srcWidth; col++) {
- dstUS[col] = PACK_COLOR_1555_REV( CHAN_TO_UBYTE(src[ACOMP]),
- CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]) );
+ dstUS[col] = PACK_COLOR_1555_REV( src[ACOMP],
+ src[RCOMP],
+ src[GCOMP],
+ src[BCOMP] );
src += 4;
}
}
{
/* general path */
- const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
baseInternalFormat,
baseFormat,
srcWidth, srcHeight, srcDepth,
srcFormat, srcType, srcAddr,
srcPacking);
- const GLchan *src = tempImage;
+ const GLubyte *src = tempImage;
GLint img, row, col;
if (!tempImage)
return GL_FALSE;
GLubyte *dstUS = (GLubyte *) dstRow;
for (col = 0; col < srcWidth; col++) {
/* src[0] is luminance, src[1] is alpha */
- dstUS[col] = PACK_COLOR_44( CHAN_TO_UBYTE(src[1]),
- CHAN_TO_UBYTE(src[0]) );
+ dstUS[col] = PACK_COLOR_44( src[1],
+ src[0] );
src += 2;
}
dstRow += dstRowStride;
}
else {
/* general path */
- const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
baseInternalFormat,
baseFormat,
srcWidth, srcHeight, srcDepth,
srcFormat, srcType, srcAddr,
srcPacking);
- const GLchan *src = tempImage;
+ const GLubyte *src = tempImage;
GLint img, row, col;
if (!tempImage)
return GL_FALSE;
dstFormat == MESA_FORMAT_RG88) {
for (col = 0; col < srcWidth; col++) {
/* src[0] is luminance, src[1] is alpha */
- dstUS[col] = PACK_COLOR_88( CHAN_TO_UBYTE(src[1]),
- CHAN_TO_UBYTE(src[0]) );
+ dstUS[col] = PACK_COLOR_88( src[1],
+ src[0] );
src += 2;
}
}
else {
for (col = 0; col < srcWidth; col++) {
/* src[0] is luminance, src[1] is alpha */
- dstUS[col] = PACK_COLOR_88_REV( CHAN_TO_UBYTE(src[1]),
- CHAN_TO_UBYTE(src[0]) );
+ dstUS[col] = PACK_COLOR_88_REV( src[1],
+ src[0] );
src += 2;
}
}
}
else {
/* general path */
- const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
baseInternalFormat,
baseFormat,
srcWidth, srcHeight, srcDepth,
srcFormat, srcType, srcAddr,
srcPacking);
- const GLchan *src = tempImage;
+ const GLubyte *src = tempImage;
GLint img, row, col;
if (!tempImage)
return GL_FALSE;
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
for (col = 0; col < srcWidth; col++) {
- dstRow[col] = PACK_COLOR_332( CHAN_TO_UBYTE(src[RCOMP]),
- CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]) );
+ dstRow[col] = PACK_COLOR_332( src[RCOMP],
+ src[GCOMP],
+ src[BCOMP] );
src += 3;
}
dstRow += dstRowStride;
}
else {
/* general path */
- const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
baseInternalFormat,
baseFormat,
srcWidth, srcHeight, srcDepth,
srcFormat, srcType, srcAddr,
srcPacking);
- const GLchan *src = tempImage;
+ const GLubyte *src = tempImage;
GLint img, row, col;
if (!tempImage)
return GL_FALSE;
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
for (col = 0; col < srcWidth; col++) {
- dstRow[col] = CHAN_TO_UBYTE(src[col]);
+ dstRow[col] = src[col];
}
dstRow += dstRowStride;
src += srcWidth;