aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/texstore.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-02-01 08:27:16 +0100
committermarha <marha@users.sourceforge.net>2012-02-01 08:27:16 +0100
commit58ff764d4111bfaa7360c57bc62dd620fbdce06f (patch)
treeadc5c52beb88c10ecb1df7b33983e901afc7dea0 /mesalib/src/mesa/main/texstore.c
parentc7a181e449c6a2ea5f0ad0514865e7c559dbe6dc (diff)
downloadvcxsrv-58ff764d4111bfaa7360c57bc62dd620fbdce06f.tar.gz
vcxsrv-58ff764d4111bfaa7360c57bc62dd620fbdce06f.tar.bz2
vcxsrv-58ff764d4111bfaa7360c57bc62dd620fbdce06f.zip
xserver mesa pixman xkbcomp xkeyboard-config git update 1 feb 2012
Diffstat (limited to 'mesalib/src/mesa/main/texstore.c')
-rw-r--r--mesalib/src/mesa/main/texstore.c399
1 files changed, 72 insertions, 327 deletions
diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c
index 827fcb788..8c51a948e 100644
--- a/mesalib/src/mesa/main/texstore.c
+++ b/mesalib/src/mesa/main/texstore.c
@@ -55,6 +55,7 @@
#include "glheader.h"
#include "bufferobj.h"
#include "colormac.h"
+#include "format_pack.h"
#include "image.h"
#include "macros.h"
#include "mipmap.h"
@@ -967,6 +968,41 @@ memcpy_texture(struct gl_context *ctx,
}
+/**
+ * General-case function for storing a color texture images with
+ * components that can be represented with ubytes. Example destination
+ * texture formats are MESA_FORMAT_ARGB888, ARGB4444, RGB565.
+ */
+static GLboolean
+store_ubyte_texture(TEXSTORE_PARAMS)
+{
+ const GLint srcRowStride = srcWidth * 4 * sizeof(GLubyte);
+ GLubyte *tempImage, *src;
+ GLint img;
+
+ tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
+ baseInternalFormat,
+ GL_RGBA,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ if (!tempImage)
+ return GL_FALSE;
+
+ src = tempImage;
+ for (img = 0; img < srcDepth; img++) {
+ _mesa_pack_ubyte_rgba_rect(dstFormat, srcWidth, srcHeight,
+ src, srcRowStride,
+ dstSlices[img], dstRowStride);
+ src += srcHeight * srcRowStride;
+ }
+ free(tempImage);
+
+ return GL_TRUE;
+}
+
+
+
/**
* Store a 32-bit integer or float depth component texture image.
@@ -1132,8 +1168,6 @@ _mesa_texstore_z16(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_rgb565(TEXSTORE_PARAMS)
{
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
ASSERT(dstFormat == MESA_FORMAT_RGB565 ||
dstFormat == MESA_FORMAT_RGB565_REV);
ASSERT(_mesa_get_format_bytes(dstFormat) == 2);
@@ -1184,42 +1218,10 @@ _mesa_texstore_rgb565(TEXSTORE_PARAMS)
}
}
else {
- /* general path */
- const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- const GLubyte *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLushort *dstUS = (GLushort *) dstRow;
- /* check for byteswapped format */
- if (dstFormat == MESA_FORMAT_RGB565) {
- for (col = 0; col < srcWidth; col++) {
- 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( src[RCOMP],
- src[GCOMP],
- src[BCOMP] );
- src += 3;
- }
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
+ return store_ubyte_texture(ctx, dims, baseInternalFormat,
+ dstFormat, dstRowStride, dstSlices,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr, srcPacking);
}
return GL_TRUE;
}
@@ -1232,7 +1234,6 @@ static GLboolean
_mesa_texstore_rgba8888(TEXSTORE_PARAMS)
{
const GLboolean littleEndian = _mesa_little_endian();
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_RGBA8888 ||
dstFormat == MESA_FORMAT_RGBA8888_REV ||
@@ -1288,44 +1289,10 @@ _mesa_texstore_rgba8888(TEXSTORE_PARAMS)
srcPacking);
}
else {
- /* general path */
- const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- const GLubyte *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLuint *dstUI = (GLuint *) dstRow;
- if (dstFormat == MESA_FORMAT_RGBA8888 ||
- dstFormat == MESA_FORMAT_RGBX8888) {
- for (col = 0; col < srcWidth; col++) {
- 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( src[RCOMP],
- src[GCOMP],
- src[BCOMP],
- src[ACOMP] );
- src += 4;
- }
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
+ return store_ubyte_texture(ctx, dims, baseInternalFormat,
+ dstFormat, dstRowStride, dstSlices,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr, srcPacking);
}
return GL_TRUE;
}
@@ -1335,7 +1302,6 @@ static GLboolean
_mesa_texstore_argb8888(TEXSTORE_PARAMS)
{
const GLboolean littleEndian = _mesa_little_endian();
- const GLenum baseFormat = GL_RGBA;
ASSERT(dstFormat == MESA_FORMAT_ARGB8888 ||
dstFormat == MESA_FORMAT_ARGB8888_REV ||
@@ -1457,52 +1423,10 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
srcPacking);
}
else {
- /* general path */
- const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- const GLubyte *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLuint *dstUI = (GLuint *) dstRow;
- if (dstFormat == MESA_FORMAT_ARGB8888) {
- for (col = 0; col < srcWidth; col++) {
- 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,
- src[RCOMP],
- src[GCOMP],
- src[BCOMP] );
- src += 4;
- }
- }
- else {
- for (col = 0; col < srcWidth; col++) {
- dstUI[col] = PACK_COLOR_8888_REV( src[ACOMP],
- src[RCOMP],
- src[GCOMP],
- src[BCOMP] );
- src += 4;
- }
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
+ return store_ubyte_texture(ctx, dims, baseInternalFormat,
+ dstFormat, dstRowStride, dstSlices,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr, srcPacking);
}
return GL_TRUE;
}
@@ -1511,8 +1435,6 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_rgb888(TEXSTORE_PARAMS)
{
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
ASSERT(dstFormat == MESA_FORMAT_RGB888);
ASSERT(_mesa_get_format_bytes(dstFormat) == 3);
@@ -1574,49 +1496,10 @@ _mesa_texstore_rgb888(TEXSTORE_PARAMS)
srcPacking);
}
else {
- /* general path */
- const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- const GLubyte *src = (const GLubyte *) tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
-#if 0
- if (littleEndian) {
- for (col = 0; col < srcWidth; col++) {
- 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] = srcUB[BCOMP];
- dstRow[col * 3 + 1] = srcUB[GCOMP];
- dstRow[col * 3 + 2] = srcUB[RCOMP];
- srcUB += 3;
- }
- }
-#else
- for (col = 0; col < srcWidth; col++) {
- dstRow[col * 3 + 0] = src[BCOMP];
- dstRow[col * 3 + 1] = src[GCOMP];
- dstRow[col * 3 + 2] = src[RCOMP];
- src += 3;
- }
-#endif
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
+ return store_ubyte_texture(ctx, dims, baseInternalFormat,
+ dstFormat, dstRowStride, dstSlices,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr, srcPacking);
}
return GL_TRUE;
}
@@ -1625,8 +1508,6 @@ _mesa_texstore_rgb888(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_bgr888(TEXSTORE_PARAMS)
{
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
ASSERT(dstFormat == MESA_FORMAT_BGR888);
ASSERT(_mesa_get_format_bytes(dstFormat) == 3);
@@ -1688,30 +1569,10 @@ _mesa_texstore_bgr888(TEXSTORE_PARAMS)
srcPacking);
}
else {
- /* general path */
- const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- const GLubyte *src = (const GLubyte *) tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- for (col = 0; col < srcWidth; col++) {
- dstRow[col * 3 + 0] = src[RCOMP];
- dstRow[col * 3 + 1] = src[GCOMP];
- dstRow[col * 3 + 2] = src[BCOMP];
- src += 3;
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
+ return store_ubyte_texture(ctx, dims, baseInternalFormat,
+ dstFormat, dstRowStride, dstSlices,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr, srcPacking);
}
return GL_TRUE;
}
@@ -1720,8 +1581,6 @@ _mesa_texstore_bgr888(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_argb4444(TEXSTORE_PARAMS)
{
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
ASSERT(dstFormat == MESA_FORMAT_ARGB4444 ||
dstFormat == MESA_FORMAT_ARGB4444_REV);
ASSERT(_mesa_get_format_bytes(dstFormat) == 2);
@@ -1738,43 +1597,10 @@ _mesa_texstore_argb4444(TEXSTORE_PARAMS)
srcAddr, srcPacking);
}
else {
- /* general path */
- const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- const GLubyte *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLushort *dstUS = (GLushort *) dstRow;
- if (dstFormat == MESA_FORMAT_ARGB4444) {
- for (col = 0; col < srcWidth; col++) {
- 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( src[ACOMP],
- src[RCOMP],
- src[GCOMP],
- src[BCOMP] );
- src += 4;
- }
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
+ return store_ubyte_texture(ctx, dims, baseInternalFormat,
+ dstFormat, dstRowStride, dstSlices,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr, srcPacking);
}
return GL_TRUE;
}
@@ -1782,8 +1608,6 @@ _mesa_texstore_argb4444(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_rgba5551(TEXSTORE_PARAMS)
{
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
ASSERT(dstFormat == MESA_FORMAT_RGBA5551);
ASSERT(_mesa_get_format_bytes(dstFormat) == 2);
@@ -1799,32 +1623,10 @@ _mesa_texstore_rgba5551(TEXSTORE_PARAMS)
srcAddr, srcPacking);
}
else {
- /* general path */
- const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- const GLubyte *src =tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLushort *dstUS = (GLushort *) dstRow;
- for (col = 0; col < srcWidth; col++) {
- dstUS[col] = PACK_COLOR_5551( src[RCOMP],
- src[GCOMP],
- src[BCOMP],
- src[ACOMP] );
- src += 4;
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
+ return store_ubyte_texture(ctx, dims, baseInternalFormat,
+ dstFormat, dstRowStride, dstSlices,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr, srcPacking);
}
return GL_TRUE;
}
@@ -1832,8 +1634,6 @@ _mesa_texstore_rgba5551(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_argb1555(TEXSTORE_PARAMS)
{
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
ASSERT(dstFormat == MESA_FORMAT_ARGB1555 ||
dstFormat == MESA_FORMAT_ARGB1555_REV);
ASSERT(_mesa_get_format_bytes(dstFormat) == 2);
@@ -1850,43 +1650,10 @@ _mesa_texstore_argb1555(TEXSTORE_PARAMS)
srcAddr, srcPacking);
}
else {
- /* general path */
- const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- const GLubyte *src =tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- GLushort *dstUS = (GLushort *) dstRow;
- if (dstFormat == MESA_FORMAT_ARGB1555) {
- for (col = 0; col < srcWidth; col++) {
- 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( src[ACOMP],
- src[RCOMP],
- src[GCOMP],
- src[BCOMP] );
- src += 4;
- }
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
+ return store_ubyte_texture(ctx, dims, baseInternalFormat,
+ dstFormat, dstRowStride, dstSlices,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr, srcPacking);
}
return GL_TRUE;
}
@@ -2396,8 +2163,6 @@ _mesa_texstore_signed_rgba_16(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_rgb332(TEXSTORE_PARAMS)
{
- const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
-
ASSERT(dstFormat == MESA_FORMAT_RGB332);
ASSERT(_mesa_get_format_bytes(dstFormat) == 1);
@@ -2413,30 +2178,10 @@ _mesa_texstore_rgb332(TEXSTORE_PARAMS)
srcAddr, srcPacking);
}
else {
- /* general path */
- const GLubyte *tempImage = _mesa_make_temp_ubyte_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking);
- const GLubyte *src = tempImage;
- GLint img, row, col;
- if (!tempImage)
- return GL_FALSE;
- for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstSlices[img];
- for (row = 0; row < srcHeight; row++) {
- for (col = 0; col < srcWidth; col++) {
- dstRow[col] = PACK_COLOR_332( src[RCOMP],
- src[GCOMP],
- src[BCOMP] );
- src += 3;
- }
- dstRow += dstRowStride;
- }
- }
- free((void *) tempImage);
+ return store_ubyte_texture(ctx, dims, baseInternalFormat,
+ dstFormat, dstRowStride, dstSlices,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr, srcPacking);
}
return GL_TRUE;
}