aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/texstore.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2004-05-12 01:50:30 +0000
committerBrian Paul <[email protected]>2004-05-12 01:50:30 +0000
commita156b49800c1419785d0709b78ef0d35e6dab5df (patch)
tree3831a74900723783b3117e2f1604ff3ebd9797c5 /src/mesa/main/texstore.c
parent939f6a724e991a9f994c6e2fffe96c5971a1f749 (diff)
Added big-endian texture formats.
Moved CI->RGBA palette lookup into texel fetch function.
Diffstat (limited to 'src/mesa/main/texstore.c')
-rw-r--r--src/mesa/main/texstore.c558
1 files changed, 515 insertions, 43 deletions
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 75845b11bac..f5d58f2d5e5 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -671,19 +671,19 @@ _mesa_texstore_rgba(GLcontext *ctx, GLuint dims,
/**
- * Store a color index texture image
+ * Store a floating point depth component texture image.
*/
GLboolean
-_mesa_texstore_color_index(STORE_PARAMS)
+_mesa_texstore_depth_component_float32(STORE_PARAMS)
{
- ASSERT(dstFormat == &_mesa_texformat_color_index);
- ASSERT(dstFormat->TexelBytes == 1 * sizeof(GLchan));
+ ASSERT(dstFormat == &_mesa_texformat_depth_component_float32);
+ ASSERT(dstFormat->TexelBytes == sizeof(GLfloat));
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
- baseInternalFormat == GL_COLOR_INDEX &&
- srcFormat == GL_COLOR_INDEX &&
- srcType == CHAN_TYPE) {
+ baseInternalFormat == GL_DEPTH_COMPONENT &&
+ srcFormat == GL_DEPTH_COMPONENT &&
+ srcType == GL_FLOAT) {
/* simple memcpy path */
memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride,
@@ -702,9 +702,8 @@ _mesa_texstore_color_index(STORE_PARAMS)
for (row = 0; row < srcHeight; row++) {
const GLvoid *src = _mesa_image_address(srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
- _mesa_unpack_index_span(ctx, srcWidth, CHAN_TYPE, dstRow,
- srcType, src, srcPacking,
- ctx->_ImageTransferState);
+ _mesa_unpack_depth_span(ctx, srcWidth, (GLfloat *) dstRow,
+ srcType, src, srcPacking);
dstRow += dstRowStride;
}
dstImage += dstImageStride;
@@ -715,19 +714,19 @@ _mesa_texstore_color_index(STORE_PARAMS)
/**
- * Store a floating point depth component texture image.
+ * Store a 16-bit integer depth component texture image.
*/
GLboolean
-_mesa_texstore_depth_component_float32(STORE_PARAMS)
+_mesa_texstore_depth_component16(STORE_PARAMS)
{
- ASSERT(dstFormat == &_mesa_texformat_depth_component_float32);
- ASSERT(dstFormat->TexelBytes == sizeof(GLfloat));
+ ASSERT(dstFormat == &_mesa_texformat_depth_component16);
+ ASSERT(dstFormat->TexelBytes == sizeof(GLushort));
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
baseInternalFormat == GL_DEPTH_COMPONENT &&
srcFormat == GL_DEPTH_COMPONENT &&
- srcType == GL_FLOAT) {
+ srcType == GL_UNSIGNED_SHORT) {
/* simple memcpy path */
memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride,
@@ -740,14 +739,19 @@ _mesa_texstore_depth_component_float32(STORE_PARAMS)
+ dstZoffset * dstImageStride
+ dstYoffset * dstRowStride
+ dstXoffset * dstFormat->TexelBytes;
- GLint img, row;
+ GLint img, row, col;
for (img = 0; img < srcDepth; img++) {
GLubyte *dstRow = dstImage;
for (row = 0; row < srcHeight; row++) {
+ GLfloat depthTemp[MAX_WIDTH];
const GLvoid *src = _mesa_image_address(srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
- _mesa_unpack_depth_span(ctx, srcWidth, (GLfloat *) dstRow,
+ GLushort *dst16 = (GLushort *) dstRow;
+ _mesa_unpack_depth_span(ctx, srcWidth, depthTemp,
srcType, src, srcPacking);
+ for (col = 0; col < srcWidth; col++) {
+ dst16[col] = (GLushort) (depthTemp[col] * 65535.0F);
+ }
dstRow += dstRowStride;
}
dstImage += dstImageStride;
@@ -758,69 +762,104 @@ _mesa_texstore_depth_component_float32(STORE_PARAMS)
/**
- * Store a 16-bit integer depth component texture image.
+ * Store an rgb565 texture image.
*/
GLboolean
-_mesa_texstore_depth_component16(STORE_PARAMS)
+_mesa_texstore_rgb565(STORE_PARAMS)
{
- ASSERT(dstFormat == &_mesa_texformat_depth_component16);
- ASSERT(dstFormat->TexelBytes == sizeof(GLushort));
+ ASSERT(dstFormat == &_mesa_texformat_rgb565);
+ ASSERT(dstFormat->TexelBytes == 2);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
- baseInternalFormat == GL_DEPTH_COMPONENT &&
- srcFormat == GL_DEPTH_COMPONENT &&
- srcType == GL_UNSIGNED_SHORT) {
+ baseInternalFormat == GL_RGB &&
+ srcFormat == GL_RGB &&
+ srcType == GL_UNSIGNED_SHORT_5_6_5) {
/* simple memcpy path */
memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
+ else if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_RGB &&
+ srcFormat == GL_RGB &&
+ srcType == GL_UNSIGNED_BYTE &&
+ dims == 2) {
+ /* do optimized tex store */
+ const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth,
+ srcFormat, srcType);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(srcPacking, srcAddr, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
+ GLubyte *dst = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint row, col;
+ for (row = 0; row < srcHeight; row++) {
+ const GLubyte *srcUB = (const GLubyte *) src;
+ GLushort *dstUS = (GLushort *) dst;
+ for (col = 0; col < srcWidth; col++) {
+ dstUS[col] = PACK_COLOR_565( srcUB[0], srcUB[1], srcUB[2] );
+ srcUB += 3;
+ }
+ dst += dstRowStride;
+ src += srcRowStride;
+ }
+ }
else {
/* general path */
+ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
GLubyte *dstImage = (GLubyte *) dstAddr
+ dstZoffset * dstImageStride
+ dstYoffset * dstRowStride
+ dstXoffset * dstFormat->TexelBytes;
GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
for (img = 0; img < srcDepth; img++) {
GLubyte *dstRow = dstImage;
for (row = 0; row < srcHeight; row++) {
- GLfloat depthTemp[MAX_WIDTH];
- const GLvoid *src = _mesa_image_address(srcPacking,
- srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
- GLushort *dst16 = (GLushort *) dstRow;
- _mesa_unpack_depth_span(ctx, srcWidth, depthTemp,
- srcType, src, srcPacking);
+ GLushort *dstUS = (GLushort *) dstRow;
for (col = 0; col < srcWidth; col++) {
- dst16[col] = (GLushort) (depthTemp[col] * 65535.0F);
+ dstUS[col] = PACK_COLOR_565( CHAN_TO_UBYTE(src[RCOMP]),
+ CHAN_TO_UBYTE(src[GCOMP]),
+ CHAN_TO_UBYTE(src[BCOMP]) );
+ src += 3;
}
dstRow += dstRowStride;
}
dstImage += dstImageStride;
}
+ _mesa_free((void *) tempImage);
}
return GL_TRUE;
}
-
-
/**
- * Store an rgb565 texture image.
+ * Store an bgr565 texture image.
*/
GLboolean
-_mesa_texstore_rgb565(STORE_PARAMS)
+_mesa_texstore_bgr565(STORE_PARAMS)
{
- ASSERT(dstFormat == &_mesa_texformat_rgb565);
+ ASSERT(dstFormat == &_mesa_texformat_bgr565);
ASSERT(dstFormat->TexelBytes == 2);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
baseInternalFormat == GL_RGB &&
srcFormat == GL_RGB &&
- srcType == GL_UNSIGNED_SHORT_5_6_5) {
+ srcType == GL_UNSIGNED_SHORT_5_6_5_REV) {
/* simple memcpy path */
memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride, dstImageStride,
@@ -830,7 +869,7 @@ _mesa_texstore_rgb565(STORE_PARAMS)
else if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
baseInternalFormat == GL_RGB &&
- srcFormat == GL_RGB &&
+ srcFormat == GL_BGR &&
srcType == GL_UNSIGNED_BYTE &&
dims == 2) {
/* do optimized tex store */
@@ -848,7 +887,7 @@ _mesa_texstore_rgb565(STORE_PARAMS)
const GLubyte *srcUB = (const GLubyte *) src;
GLushort *dstUS = (GLushort *) dst;
for (col = 0; col < srcWidth; col++) {
- dstUS[col] = PACK_COLOR_565( srcUB[0], srcUB[1], srcUB[2] );
+ dstUS[col] = PACK_COLOR_565( srcUB[2], srcUB[1], srcUB[0] );
srcUB += 3;
}
dst += dstRowStride;
@@ -877,9 +916,9 @@ _mesa_texstore_rgb565(STORE_PARAMS)
for (row = 0; row < srcHeight; row++) {
GLushort *dstUS = (GLushort *) dstRow;
for (col = 0; col < srcWidth; col++) {
- dstUS[col] = PACK_COLOR_565( CHAN_TO_UBYTE(src[RCOMP]),
+ dstUS[col] = PACK_COLOR_565( CHAN_TO_UBYTE(src[BCOMP]),
CHAN_TO_UBYTE(src[GCOMP]),
- CHAN_TO_UBYTE(src[BCOMP]) );
+ CHAN_TO_UBYTE(src[RCOMP]) );
src += 3;
}
dstRow += dstRowStride;
@@ -952,6 +991,65 @@ _mesa_texstore_rgba8888(STORE_PARAMS)
GLboolean
+_mesa_texstore_abgr8888(STORE_PARAMS)
+{
+ const GLuint ui = 1;
+ const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+ ASSERT(dstFormat == &_mesa_texformat_abgr8888);
+ ASSERT(dstFormat->TexelBytes == 4);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_RGBA &&
+ srcFormat == GL_ABGR_EXT &&
+ ((srcType == GL_UNSIGNED_INT_8_8_8_8_REV && littleEndian) ||
+ (srcType == GL_UNSIGNED_INT_8_8_8_8 && !littleEndian))) {
+ /* simple memcpy path */
+ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ GLuint *dstUI = (GLuint *) dstRow;
+ for (col = 0; col < srcWidth; col++) {
+ dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[ACOMP]),
+ CHAN_TO_UBYTE(src[BCOMP]),
+ CHAN_TO_UBYTE(src[GCOMP]),
+ CHAN_TO_UBYTE(src[RCOMP]) );
+ src += 4;
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+GLboolean
_mesa_texstore_argb8888(STORE_PARAMS)
{
const GLuint ui = 1;
@@ -1011,6 +1109,65 @@ _mesa_texstore_argb8888(STORE_PARAMS)
}
+GLboolean
+_mesa_texstore_bgra8888(STORE_PARAMS)
+{
+ const GLuint ui = 1;
+ const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+ ASSERT(dstFormat == &_mesa_texformat_bgra8888);
+ ASSERT(dstFormat->TexelBytes == 4);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_RGBA &&
+ srcFormat == GL_BGRA &&
+ ((srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
+ (srcType == GL_UNSIGNED_INT_8_8_8_8_REV && !littleEndian) ||
+ (srcType == GL_UNSIGNED_INT_8_8_8_8 && littleEndian))) {
+ /* simple memcpy path */
+ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ GLuint *dstUI = (GLuint *) dstRow;
+ for (col = 0; col < srcWidth; col++) {
+ dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[BCOMP]),
+ CHAN_TO_UBYTE(src[GCOMP]),
+ CHAN_TO_UBYTE(src[RCOMP]),
+ CHAN_TO_UBYTE(src[ACOMP]) );
+ src += 4;
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
GLboolean
_mesa_texstore_rgb888(STORE_PARAMS)
@@ -1037,7 +1194,7 @@ _mesa_texstore_rgb888(STORE_PARAMS)
!srcPacking->SwapBytes &&
srcFormat == GL_RGBA &&
srcType == GL_UNSIGNED_BYTE) {
- /* extract BGR from RGBA */
+ /* extract RGB from RGBA */
int img, row, col;
GLubyte *dstImage = (GLubyte *) dstAddr
+ dstZoffset * dstImageStride
@@ -1117,6 +1274,91 @@ _mesa_texstore_rgb888(STORE_PARAMS)
GLboolean
+_mesa_texstore_bgr888(STORE_PARAMS)
+{
+ const GLuint ui = 1;
+ const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+ ASSERT(dstFormat == &_mesa_texformat_bgr888);
+ ASSERT(dstFormat->TexelBytes == 3);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_RGB &&
+ srcFormat == GL_RGB &&
+ srcType == GL_UNSIGNED_BYTE &&
+ littleEndian) {
+ /* simple memcpy path */
+ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ srcFormat == GL_RGBA &&
+ srcType == GL_UNSIGNED_BYTE) {
+ /* extract BGR from RGBA */
+ int img, row, col;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ for (img = 0; img < srcDepth; img++) {
+ const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
+ srcWidth, srcFormat, srcType);
+ GLubyte *srcRow = (GLubyte *) _mesa_image_address(srcPacking, srcAddr,
+ srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ for (col = 0; col < srcWidth; col++) {
+ dstRow[col * 3 + 0] = srcRow[col * 4 + RCOMP];
+ dstRow[col * 3 + 1] = srcRow[col * 4 + GCOMP];
+ dstRow[col * 3 + 2] = srcRow[col * 4 + BCOMP];
+ }
+ dstRow += dstRowStride;
+ srcRow += srcRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = (const GLubyte *) tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ 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]);
+ src += 3;
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+GLboolean
_mesa_texstore_argb4444(STORE_PARAMS)
{
const GLuint ui = 1;
@@ -1176,6 +1418,65 @@ _mesa_texstore_argb4444(STORE_PARAMS)
GLboolean
+_mesa_texstore_bgra4444(STORE_PARAMS)
+{
+ const GLuint ui = 1;
+ const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+ ASSERT(dstFormat == &_mesa_texformat_bgra4444);
+ ASSERT(dstFormat->TexelBytes == 2);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_RGBA &&
+ srcFormat == GL_BGRA &&
+ ((srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV && !littleEndian) ||
+ (srcType == GL_UNSIGNED_SHORT_4_4_4_4 && littleEndian))) {
+ /* simple memcpy path */
+ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ GLushort *dstUS = (GLushort *) dstRow;
+ for (col = 0; col < srcWidth; col++) {
+ dstUS[col] = PACK_COLOR_4444( CHAN_TO_UBYTE(src[BCOMP]),
+ CHAN_TO_UBYTE(src[GCOMP]),
+ CHAN_TO_UBYTE(src[RCOMP]),
+ CHAN_TO_UBYTE(src[ACOMP]) );
+ src += 4;
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+GLboolean
_mesa_texstore_argb1555(STORE_PARAMS)
{
const GLuint ui = 1;
@@ -1233,6 +1534,64 @@ _mesa_texstore_argb1555(STORE_PARAMS)
return GL_TRUE;
}
+GLboolean
+_mesa_texstore_bgra5551(STORE_PARAMS)
+{
+ const GLuint ui = 1;
+ const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+ ASSERT(dstFormat == &_mesa_texformat_bgra5551);
+ ASSERT(dstFormat->TexelBytes == 2);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_RGBA &&
+ srcFormat == GL_BGRA &&
+ ((srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV && !littleEndian) ||
+ (srcType == GL_UNSIGNED_SHORT_5_5_5_1 && littleEndian))) {
+ /* simple memcpy path */
+ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src =tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ 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]) );
+ src += 4;
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
GLboolean
_mesa_texstore_al88(STORE_PARAMS)
@@ -1292,6 +1651,63 @@ _mesa_texstore_al88(STORE_PARAMS)
GLboolean
+_mesa_texstore_la88(STORE_PARAMS)
+{
+ const GLuint ui = 1;
+ const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+ ASSERT(dstFormat == &_mesa_texformat_la88);
+ ASSERT(dstFormat->TexelBytes == 2);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_LUMINANCE_ALPHA &&
+ srcFormat == GL_LUMINANCE_ALPHA &&
+ srcType == GL_UNSIGNED_BYTE &&
+ !littleEndian) {
+ /* simple memcpy path */
+ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ GLushort *dstUS = (GLushort *) dstRow;
+ for (col = 0; col < srcWidth; col++) {
+ dstUS[col] = PACK_COLOR_88( CHAN_TO_UBYTE(src[RCOMP]),
+ CHAN_TO_UBYTE(src[ACOMP]) );
+ src += 2;
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+GLboolean
_mesa_texstore_rgb332(STORE_PARAMS)
{
ASSERT(dstFormat == &_mesa_texformat_rgb332);
@@ -1343,6 +1759,58 @@ _mesa_texstore_rgb332(STORE_PARAMS)
}
+GLboolean
+_mesa_texstore_bgr233(STORE_PARAMS)
+{
+ ASSERT(dstFormat == &_mesa_texformat_bgr233);
+ ASSERT(dstFormat->TexelBytes == 1);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_RGB &&
+ srcFormat == GL_BGR && srcType == GL_UNSIGNED_BYTE_3_3_2) {
+ /* simple memcpy path */
+ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ for (col = 0; col < srcWidth; col++) {
+ dstRow[col] = PACK_COLOR_233( CHAN_TO_UBYTE(src[BCOMP]),
+ CHAN_TO_UBYTE(src[GCOMP]),
+ CHAN_TO_UBYTE(src[RCOMP]) );
+ src += 3;
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
/**
* Texstore for _mesa_texformat_a8, _mesa_texformat_l8, _mesa_texformat_i8.
@@ -2300,7 +2768,6 @@ do_row(const struct gl_texture_format *format, GLint srcWidth,
case MESA_FORMAT_ALPHA:
case MESA_FORMAT_LUMINANCE:
case MESA_FORMAT_INTENSITY:
- case MESA_FORMAT_COLOR_INDEX:
{
GLuint i, j, k;
const GLchan *rowA = (const GLchan *) srcRowA;
@@ -2353,7 +2820,9 @@ do_row(const struct gl_texture_format *format, GLint srcWidth,
return;
/* Begin hardware formats */
case MESA_FORMAT_RGBA8888:
+ case MESA_FORMAT_ABGR8888:
case MESA_FORMAT_ARGB8888:
+ case MESA_FORMAT_BGRA8888:
{
GLuint i, j, k;
const GLubyte (*rowA)[4] = (const GLubyte (*)[4]) srcRowA;
@@ -2373,6 +2842,7 @@ do_row(const struct gl_texture_format *format, GLint srcWidth,
}
return;
case MESA_FORMAT_RGB888:
+ case MESA_FORMAT_BGR888:
{
GLuint i, j, k;
const GLubyte (*rowA)[3] = (const GLubyte (*)[3]) srcRowA;
@@ -2390,6 +2860,7 @@ do_row(const struct gl_texture_format *format, GLint srcWidth,
}
return;
case MESA_FORMAT_RGB565:
+ case MESA_FORMAT_BGR565:
{
GLuint i, j, k;
const GLushort *rowA = (const GLushort *) srcRowA;
@@ -2417,6 +2888,7 @@ do_row(const struct gl_texture_format *format, GLint srcWidth,
}
return;
case MESA_FORMAT_ARGB4444:
+ case MESA_FORMAT_BGRA4444:
{
GLuint i, j, k;
const GLushort *rowA = (const GLushort *) srcRowA;