* Brian Paul
*/
-/*
+/**
* The GL texture image functions in teximage.c basically just do
* error checking and data structure allocation. They in turn call
* device driver functions which actually copy/convert/store the user's
#include "texstore.h"
#include "enums.h"
+
enum {
ZERO = 4,
ONE = 5
};
-static GLboolean can_swizzle(GLenum logicalBaseFormat)
+
+/**
+ * Return GL_TRUE if the given image format is one that be converted
+ * to another format by swizzling.
+ */
+static GLboolean
+can_swizzle(GLenum logicalBaseFormat)
{
switch (logicalBaseFormat) {
case GL_RGBA:
-
-
-
-static int get_map_idx( GLenum value )
+/**
+ * Convert a GL image format enum to an IDX_* value (see above).
+ */
+static int
+get_map_idx(GLenum value)
{
switch (value) {
case GL_LUMINANCE: return IDX_LUMINANCE;
compute_component_mapping(GLenum inFormat, GLenum outFormat,
GLubyte *map)
{
- int in = get_map_idx(inFormat);
- int out = get_map_idx(outFormat);
- const GLubyte *in2rgba = mappings[in].to_rgba;
- const GLubyte *rgba2out = mappings[out].from_rgba;
+ const int inFmt = get_map_idx(inFormat);
+ const int outFmt = get_map_idx(outFormat);
+ const GLubyte *in2rgba = mappings[inFmt].to_rgba;
+ const GLubyte *rgba2out = mappings[outFmt].from_rgba;
int i;
for (i = 0; i < 4; i++)
* \param dstComponents number of color components in destination pixels
* \param src source pixels
* \param srcComponents number of color components in source pixels
- * \param map the swizzle mapping
+ * \param map the swizzle mapping. map[X] says where to find the X component
+ * in the source image's pixels. For example, if the source image
+ * is GL_BGRA and X = red, map[0] yields 2.
* \param count number of pixels to copy/swizzle.
*/
static void
swizzle_copy(GLubyte *dst, GLuint dstComponents, const GLubyte *src,
GLuint srcComponents, const GLubyte *map, GLuint count)
{
- GLubyte tmp[8];
+ GLubyte tmp[6];
GLuint i;
tmp[ZERO] = 0x0;
-
/**
* Transfer a GLubyte texture image with component swizzling.
*/
components = 1;
}
else {
- ASSERT(0);
- dstmap = map_identity;
- components = 4;
+ _mesa_problem(ctx, "Unexpected dstFormat in _mesa_texstore_rgba");
+ return GL_FALSE;
}
_mesa_swizzle_ubyte_image(ctx, dims,
}
+/**
+ * Store a texture in MESA_FORMAT_RGBA8888 or MESA_FORMAT_RGBA8888_REV.
+ */
GLboolean
_mesa_texstore_rgba8888(TEXSTORE_PARAMS)
{