}
-/**
- * \sa extract_float_rgba()
- */
-static void
-extract_uint_rgba(GLuint n, GLuint rgba[][4],
- GLenum srcFormat, GLenum srcType, const GLvoid *src,
- GLboolean swapBytes)
-{
- GLint rSrc, gSrc, bSrc, aSrc;
- GLint stride;
- GLint rDst, bDst, gDst, aDst;
-
- ASSERT(srcFormat == GL_RED ||
- srcFormat == GL_GREEN ||
- srcFormat == GL_BLUE ||
- srcFormat == GL_ALPHA ||
- srcFormat == GL_LUMINANCE ||
- srcFormat == GL_LUMINANCE_ALPHA ||
- srcFormat == GL_INTENSITY ||
- srcFormat == GL_RG ||
- srcFormat == GL_RGB ||
- srcFormat == GL_BGR ||
- srcFormat == GL_RGBA ||
- srcFormat == GL_BGRA ||
- srcFormat == GL_ABGR_EXT ||
- srcFormat == GL_RED_INTEGER_EXT ||
- srcFormat == GL_RG_INTEGER ||
- srcFormat == GL_GREEN_INTEGER_EXT ||
- srcFormat == GL_BLUE_INTEGER_EXT ||
- srcFormat == GL_ALPHA_INTEGER_EXT ||
- srcFormat == GL_RGB_INTEGER_EXT ||
- srcFormat == GL_RGBA_INTEGER_EXT ||
- srcFormat == GL_BGR_INTEGER_EXT ||
- srcFormat == GL_BGRA_INTEGER_EXT ||
- srcFormat == GL_LUMINANCE_INTEGER_EXT ||
- srcFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT);
-
- ASSERT(srcType == GL_UNSIGNED_BYTE ||
- srcType == GL_BYTE ||
- srcType == GL_UNSIGNED_SHORT ||
- srcType == GL_SHORT ||
- srcType == GL_UNSIGNED_INT ||
- srcType == GL_INT ||
- srcType == GL_HALF_FLOAT_ARB ||
- srcType == GL_FLOAT ||
- srcType == GL_UNSIGNED_BYTE_3_3_2 ||
- srcType == GL_UNSIGNED_BYTE_2_3_3_REV ||
- srcType == GL_UNSIGNED_SHORT_5_6_5 ||
- srcType == GL_UNSIGNED_SHORT_5_6_5_REV ||
- srcType == GL_UNSIGNED_SHORT_4_4_4_4 ||
- srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV ||
- srcType == GL_UNSIGNED_SHORT_5_5_5_1 ||
- srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV ||
- srcType == GL_UNSIGNED_INT_8_8_8_8 ||
- srcType == GL_UNSIGNED_INT_8_8_8_8_REV ||
- srcType == GL_UNSIGNED_INT_10_10_10_2 ||
- srcType == GL_UNSIGNED_INT_2_10_10_10_REV ||
- srcType == GL_UNSIGNED_INT_5_9_9_9_REV ||
- srcType == GL_UNSIGNED_INT_10F_11F_11F_REV);
-
- get_component_mapping(srcFormat,
- &rSrc, &gSrc, &bSrc, &aSrc,
- &rDst, &gDst, &bDst, &aDst);
-
- stride = _mesa_components_in_format(srcFormat);
-
-#define PROCESS(SRC_INDEX, DST_INDEX, DEFAULT, TYPE, CONVERSION) \
- if ((SRC_INDEX) < 0) { \
- GLuint i; \
- for (i = 0; i < n; i++) { \
- rgba[i][DST_INDEX] = DEFAULT; \
- } \
- } \
- else if (swapBytes) { \
- const TYPE *s = (const TYPE *) src; \
- GLuint i; \
- for (i = 0; i < n; i++) { \
- TYPE value = s[SRC_INDEX]; \
- if (sizeof(TYPE) == 2) { \
- SWAP2BYTE(value); \
- } \
- else if (sizeof(TYPE) == 4) { \
- SWAP4BYTE(value); \
- } \
- rgba[i][DST_INDEX] = CONVERSION(value); \
- s += stride; \
- } \
- } \
- else { \
- const TYPE *s = (const TYPE *) src; \
- GLuint i; \
- for (i = 0; i < n; i++) { \
- rgba[i][DST_INDEX] = CONVERSION(s[SRC_INDEX]); \
- s += stride; \
- } \
- }
-
- switch (srcType) {
- case GL_UNSIGNED_BYTE:
- PROCESS(rSrc, RCOMP, 0, GLubyte, (GLuint));
- PROCESS(gSrc, GCOMP, 0, GLubyte, (GLuint));
- PROCESS(bSrc, BCOMP, 0, GLubyte, (GLuint));
- PROCESS(aSrc, ACOMP, 1, GLubyte, (GLuint));
- break;
- case GL_BYTE:
- PROCESS(rSrc, RCOMP, 0, GLbyte, (GLuint));
- PROCESS(gSrc, GCOMP, 0, GLbyte, (GLuint));
- PROCESS(bSrc, BCOMP, 0, GLbyte, (GLuint));
- PROCESS(aSrc, ACOMP, 1, GLbyte, (GLuint));
- break;
- case GL_UNSIGNED_SHORT:
- PROCESS(rSrc, RCOMP, 0, GLushort, (GLuint));
- PROCESS(gSrc, GCOMP, 0, GLushort, (GLuint));
- PROCESS(bSrc, BCOMP, 0, GLushort, (GLuint));
- PROCESS(aSrc, ACOMP, 1, GLushort, (GLuint));
- break;
- case GL_SHORT:
- PROCESS(rSrc, RCOMP, 0, GLshort, (GLuint));
- PROCESS(gSrc, GCOMP, 0, GLshort, (GLuint));
- PROCESS(bSrc, BCOMP, 0, GLshort, (GLuint));
- PROCESS(aSrc, ACOMP, 1, GLshort, (GLuint));
- break;
- case GL_UNSIGNED_INT:
- PROCESS(rSrc, RCOMP, 0, GLuint, (GLuint));
- PROCESS(gSrc, GCOMP, 0, GLuint, (GLuint));
- PROCESS(bSrc, BCOMP, 0, GLuint, (GLuint));
- PROCESS(aSrc, ACOMP, 1, GLuint, (GLuint));
- break;
- case GL_INT:
- PROCESS(rSrc, RCOMP, 0, GLint, (GLuint));
- PROCESS(gSrc, GCOMP, 0, GLint, (GLuint));
- PROCESS(bSrc, BCOMP, 0, GLint, (GLuint));
- PROCESS(aSrc, ACOMP, 1, GLint, (GLuint));
- break;
- case GL_FLOAT:
- PROCESS(rSrc, RCOMP, 0, GLfloat, clamp_float_to_uint);
- PROCESS(gSrc, GCOMP, 0, GLfloat, clamp_float_to_uint);
- PROCESS(bSrc, BCOMP, 0, GLfloat, clamp_float_to_uint);
- PROCESS(aSrc, ACOMP, 1, GLfloat, clamp_float_to_uint);
- break;
- case GL_HALF_FLOAT_ARB:
- PROCESS(rSrc, RCOMP, 0, GLhalfARB, clamp_half_to_uint);
- PROCESS(gSrc, GCOMP, 0, GLhalfARB, clamp_half_to_uint);
- PROCESS(bSrc, BCOMP, 0, GLhalfARB, clamp_half_to_uint);
- PROCESS(aSrc, ACOMP, 1, GLhalfARB, clamp_half_to_uint);
- break;
- case GL_UNSIGNED_BYTE_3_3_2:
- {
- const GLubyte *ubsrc = (const GLubyte *) src;
- GLuint i;
- for (i = 0; i < n; i ++) {
- GLubyte p = ubsrc[i];
- rgba[i][rDst] = ((p >> 5) );
- rgba[i][gDst] = ((p >> 2) & 0x7);
- rgba[i][bDst] = ((p ) & 0x3);
- rgba[i][aDst] = 1;
- }
- }
- break;
- case GL_UNSIGNED_BYTE_2_3_3_REV:
- {
- const GLubyte *ubsrc = (const GLubyte *) src;
- GLuint i;
- for (i = 0; i < n; i ++) {
- GLubyte p = ubsrc[i];
- rgba[i][rDst] = ((p ) & 0x7);
- rgba[i][gDst] = ((p >> 3) & 0x7);
- rgba[i][bDst] = ((p >> 6) );
- rgba[i][aDst] = 1;
- }
- }
- break;
- case GL_UNSIGNED_SHORT_5_6_5:
- if (swapBytes) {
- const GLushort *ussrc = (const GLushort *) src;
- GLuint i;
- for (i = 0; i < n; i ++) {
- GLushort p = ussrc[i];
- SWAP2BYTE(p);
- rgba[i][rDst] = ((p >> 11) );
- rgba[i][gDst] = ((p >> 5) & 0x3f);
- rgba[i][bDst] = ((p ) & 0x1f);
- rgba[i][aDst] = 1;
- }
- }
- else {
- const GLushort *ussrc = (const GLushort *) src;
- GLuint i;
- for (i = 0; i < n; i ++) {
- GLushort p = ussrc[i];
- rgba[i][rDst] = ((p >> 11) );
- rgba[i][gDst] = ((p >> 5) & 0x3f);
- rgba[i][bDst] = ((p ) & 0x1f);
- rgba[i][aDst] = 1;
- }
- }
- break;
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- if (swapBytes) {
- const GLushort *ussrc = (const GLushort *) src;
- GLuint i;
- for (i = 0; i < n; i ++) {
- GLushort p = ussrc[i];
- SWAP2BYTE(p);
- rgba[i][rDst] = ((p ) & 0x1f);
- rgba[i][gDst] = ((p >> 5) & 0x3f);
- rgba[i][bDst] = ((p >> 11) );
- rgba[i][aDst] = 1;
- }
- }
- else {
- const GLushort *ussrc = (const GLushort *) src;
- GLuint i;
- for (i = 0; i < n; i ++) {
- GLushort p = ussrc[i];
- rgba[i][rDst] = ((p ) & 0x1f);
- rgba[i][gDst] = ((p >> 5) & 0x3f);
- rgba[i][bDst] = ((p >> 11) );
- rgba[i][aDst] = 1;
- }
- }
- break;
- case GL_UNSIGNED_SHORT_4_4_4_4:
- if (swapBytes) {
- const GLushort *ussrc = (const GLushort *) src;
- GLuint i;
- for (i = 0; i < n; i ++) {
- GLushort p = ussrc[i];
- SWAP2BYTE(p);
- rgba[i][rDst] = ((p >> 12) );
- rgba[i][gDst] = ((p >> 8) & 0xf);
- rgba[i][bDst] = ((p >> 4) & 0xf);
- rgba[i][aDst] = ((p ) & 0xf);
- }
- }
- else {
- const GLushort *ussrc = (const GLushort *) src;
- GLuint i;
- for (i = 0; i < n; i ++) {
- GLushort p = ussrc[i];
- rgba[i][rDst] = ((p >> 12) );
- rgba[i][gDst] = ((p >> 8) & 0xf);
- rgba[i][bDst] = ((p >> 4) & 0xf);
- rgba[i][aDst] = ((p ) & 0xf);
- }
- }
- break;
- case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- if (swapBytes) {
- const GLushort *ussrc = (const GLushort *) src;
- GLuint i;
- for (i = 0; i < n; i ++) {
- GLushort p = ussrc[i];
- SWAP2BYTE(p);
- rgba[i][rDst] = ((p ) & 0xf);
- rgba[i][gDst] = ((p >> 4) & 0xf);
- rgba[i][bDst] = ((p >> 8) & 0xf);
- rgba[i][aDst] = ((p >> 12) );
- }
- }
- else {
- const GLushort *ussrc = (const GLushort *) src;
- GLuint i;
- for (i = 0; i < n; i ++) {
- GLushort p = ussrc[i];
- rgba[i][rDst] = ((p ) & 0xf);
- rgba[i][gDst] = ((p >> 4) & 0xf);
- rgba[i][bDst] = ((p >> 8) & 0xf);
- rgba[i][aDst] = ((p >> 12) );
- }
- }
- break;
- case GL_UNSIGNED_SHORT_5_5_5_1:
- if (swapBytes) {
- const GLushort *ussrc = (const GLushort *) src;
- GLuint i;
- for (i = 0; i < n; i ++) {
- GLushort p = ussrc[i];
- SWAP2BYTE(p);
- rgba[i][rDst] = ((p >> 11) );
- rgba[i][gDst] = ((p >> 6) & 0x1f);
- rgba[i][bDst] = ((p >> 1) & 0x1f);
- rgba[i][aDst] = ((p ) & 0x1 );
- }
- }
- else {
- const GLushort *ussrc = (const GLushort *) src;
- GLuint i;
- for (i = 0; i < n; i ++) {
- GLushort p = ussrc[i];
- rgba[i][rDst] = ((p >> 11) );
- rgba[i][gDst] = ((p >> 6) & 0x1f);
- rgba[i][bDst] = ((p >> 1) & 0x1f);
- rgba[i][aDst] = ((p ) & 0x1 );
- }
- }
- break;
- case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- if (swapBytes) {
- const GLushort *ussrc = (const GLushort *) src;
- GLuint i;
- for (i = 0; i < n; i ++) {
- GLushort p = ussrc[i];
- SWAP2BYTE(p);
- rgba[i][rDst] = ((p ) & 0x1f);
- rgba[i][gDst] = ((p >> 5) & 0x1f);
- rgba[i][bDst] = ((p >> 10) & 0x1f);
- rgba[i][aDst] = ((p >> 15) );
- }
- }
- else {
- const GLushort *ussrc = (const GLushort *) src;
- GLuint i;
- for (i = 0; i < n; i ++) {
- GLushort p = ussrc[i];
- rgba[i][rDst] = ((p ) & 0x1f);
- rgba[i][gDst] = ((p >> 5) & 0x1f);
- rgba[i][bDst] = ((p >> 10) & 0x1f);
- rgba[i][aDst] = ((p >> 15) );
- }
- }
- break;
- case GL_UNSIGNED_INT_8_8_8_8:
- if (swapBytes) {
- const GLuint *uisrc = (const GLuint *) src;
- GLuint i;
- for (i = 0; i < n; i ++) {
- GLuint p = uisrc[i];
- rgba[i][rDst] = ((p ) & 0xff);
- rgba[i][gDst] = ((p >> 8) & 0xff);
- rgba[i][bDst] = ((p >> 16) & 0xff);
- rgba[i][aDst] = ((p >> 24) );
- }
- }
- else {
- const GLuint *uisrc = (const GLuint *) src;
- GLuint i;
- for (i = 0; i < n; i ++) {
- GLuint p = uisrc[i];
- rgba[i][rDst] = ((p >> 24) );
- rgba[i][gDst] = ((p >> 16) & 0xff);
- rgba[i][bDst] = ((p >> 8) & 0xff);
- rgba[i][aDst] = ((p ) & 0xff);
- }
- }
- break;
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- if (swapBytes) {
- const GLuint *uisrc = (const GLuint *) src;
- GLuint i;
- for (i = 0; i < n; i ++) {
- GLuint p = uisrc[i];
- rgba[i][rDst] = ((p >> 24) );
- rgba[i][gDst] = ((p >> 16) & 0xff);
- rgba[i][bDst] = ((p >> 8) & 0xff);
- rgba[i][aDst] = ((p ) & 0xff);
- }
- }
- else {
- const GLuint *uisrc = (const GLuint *) src;
- GLuint i;
- for (i = 0; i < n; i ++) {
- GLuint p = uisrc[i];
- rgba[i][rDst] = ((p ) & 0xff);
- rgba[i][gDst] = ((p >> 8) & 0xff);
- rgba[i][bDst] = ((p >> 16) & 0xff);
- rgba[i][aDst] = ((p >> 24) );
- }
- }
- break;
- case GL_UNSIGNED_INT_10_10_10_2:
- if (swapBytes) {
- const GLuint *uisrc = (const GLuint *) src;
- GLuint i;
- for (i = 0; i < n; i ++) {
- GLuint p = uisrc[i];
- SWAP4BYTE(p);
- rgba[i][rDst] = ((p >> 22) );
- rgba[i][gDst] = ((p >> 12) & 0x3ff);
- rgba[i][bDst] = ((p >> 2) & 0x3ff);
- rgba[i][aDst] = ((p ) & 0x3 );
- }
- }
- else {
- const GLuint *uisrc = (const GLuint *) src;
- GLuint i;
- for (i = 0; i < n; i ++) {
- GLuint p = uisrc[i];
- rgba[i][rDst] = ((p >> 22) );
- rgba[i][gDst] = ((p >> 12) & 0x3ff);
- rgba[i][bDst] = ((p >> 2) & 0x3ff);
- rgba[i][aDst] = ((p ) & 0x3 );
- }
- }
- break;
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- if (swapBytes) {
- const GLuint *uisrc = (const GLuint *) src;
- GLuint i;
- for (i = 0; i < n; i ++) {
- GLuint p = uisrc[i];
- SWAP4BYTE(p);
- rgba[i][rDst] = ((p ) & 0x3ff);
- rgba[i][gDst] = ((p >> 10) & 0x3ff);
- rgba[i][bDst] = ((p >> 20) & 0x3ff);
- rgba[i][aDst] = ((p >> 30) );
- }
- }
- else {
- const GLuint *uisrc = (const GLuint *) src;
- GLuint i;
- for (i = 0; i < n; i ++) {
- GLuint p = uisrc[i];
- rgba[i][rDst] = ((p ) & 0x3ff);
- rgba[i][gDst] = ((p >> 10) & 0x3ff);
- rgba[i][bDst] = ((p >> 20) & 0x3ff);
- rgba[i][aDst] = ((p >> 30) );
- }
- }
- break;
- case GL_UNSIGNED_INT_5_9_9_9_REV:
- if (swapBytes) {
- const GLuint *uisrc = (const GLuint *) src;
- GLuint i;
- float f[3];
- for (i = 0; i < n; i ++) {
- GLuint p = uisrc[i];
- SWAP4BYTE(p);
- rgb9e5_to_float3(p, f);
- rgba[i][rDst] = clamp_float_to_uint(f[0]);
- rgba[i][gDst] = clamp_float_to_uint(f[1]);
- rgba[i][bDst] = clamp_float_to_uint(f[2]);
- rgba[i][aDst] = 1;
- }
- }
- else {
- const GLuint *uisrc = (const GLuint *) src;
- GLuint i;
- float f[3];
- for (i = 0; i < n; i ++) {
- GLuint p = uisrc[i];
- rgb9e5_to_float3(p, f);
- rgba[i][rDst] = clamp_float_to_uint(f[0]);
- rgba[i][gDst] = clamp_float_to_uint(f[1]);
- rgba[i][bDst] = clamp_float_to_uint(f[2]);
- rgba[i][aDst] = 1;
- }
- }
- break;
- case GL_UNSIGNED_INT_10F_11F_11F_REV:
- if (swapBytes) {
- const GLuint *uisrc = (const GLuint *) src;
- GLuint i;
- float f[3];
- for (i = 0; i < n; i ++) {
- GLuint p = uisrc[i];
- SWAP4BYTE(p);
- r11g11b10f_to_float3(p, f);
- rgba[i][rDst] = clamp_float_to_uint(f[0]);
- rgba[i][gDst] = clamp_float_to_uint(f[1]);
- rgba[i][bDst] = clamp_float_to_uint(f[2]);
- rgba[i][aDst] = 1;
- }
- }
- else {
- const GLuint *uisrc = (const GLuint *) src;
- GLuint i;
- float f[3];
- for (i = 0; i < n; i ++) {
- GLuint p = uisrc[i];
- r11g11b10f_to_float3(p, f);
- rgba[i][rDst] = clamp_float_to_uint(f[0]);
- rgba[i][gDst] = clamp_float_to_uint(f[1]);
- rgba[i][bDst] = clamp_float_to_uint(f[2]);
- rgba[i][aDst] = 1;
- }
- }
- break;
- default:
- _mesa_problem(NULL, "bad srcType in extract uint data");
- break;
- }
-#undef PROCESS
-}
-
-
-
/*
* Unpack a row of color image data from a client buffer according to
* the pixel unpacking parameters.
}
-/**
- * Same as _mesa_unpack_color_span_ubyte(), but return GLuint data
- * instead of GLubyte.
- * No pixel transfer ops are applied.
- */
-void
-_mesa_unpack_color_span_uint(struct gl_context *ctx,
- GLuint n, GLenum dstFormat, GLuint *dest,
- GLenum srcFormat, GLenum srcType,
- const GLvoid *source,
- const struct gl_pixelstore_attrib *srcPacking)
-{
- GLuint (*rgba)[4] = malloc(n * 4 * sizeof(GLfloat));
-
- if (!rgba) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking");
- return;
- }
-
- ASSERT(dstFormat == GL_ALPHA ||
- dstFormat == GL_LUMINANCE ||
- dstFormat == GL_LUMINANCE_ALPHA ||
- dstFormat == GL_INTENSITY ||
- dstFormat == GL_RED ||
- dstFormat == GL_RG ||
- dstFormat == GL_RGB ||
- dstFormat == GL_RGBA);
-
- ASSERT(srcFormat == GL_RED ||
- srcFormat == GL_GREEN ||
- srcFormat == GL_BLUE ||
- srcFormat == GL_ALPHA ||
- srcFormat == GL_LUMINANCE ||
- srcFormat == GL_LUMINANCE_ALPHA ||
- srcFormat == GL_INTENSITY ||
- srcFormat == GL_RG ||
- srcFormat == GL_RGB ||
- srcFormat == GL_BGR ||
- srcFormat == GL_RGBA ||
- srcFormat == GL_BGRA ||
- srcFormat == GL_ABGR_EXT ||
- srcFormat == GL_RED_INTEGER_EXT ||
- srcFormat == GL_GREEN_INTEGER_EXT ||
- srcFormat == GL_BLUE_INTEGER_EXT ||
- srcFormat == GL_ALPHA_INTEGER_EXT ||
- srcFormat == GL_RG_INTEGER ||
- srcFormat == GL_RGB_INTEGER_EXT ||
- srcFormat == GL_RGBA_INTEGER_EXT ||
- srcFormat == GL_BGR_INTEGER_EXT ||
- srcFormat == GL_BGRA_INTEGER_EXT ||
- srcFormat == GL_LUMINANCE_INTEGER_EXT ||
- srcFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT);
-
- ASSERT(srcType == GL_UNSIGNED_BYTE ||
- srcType == GL_BYTE ||
- srcType == GL_UNSIGNED_SHORT ||
- srcType == GL_SHORT ||
- srcType == GL_UNSIGNED_INT ||
- srcType == GL_INT ||
- srcType == GL_HALF_FLOAT_ARB ||
- srcType == GL_FLOAT ||
- srcType == GL_UNSIGNED_BYTE_3_3_2 ||
- srcType == GL_UNSIGNED_BYTE_2_3_3_REV ||
- srcType == GL_UNSIGNED_SHORT_5_6_5 ||
- srcType == GL_UNSIGNED_SHORT_5_6_5_REV ||
- srcType == GL_UNSIGNED_SHORT_4_4_4_4 ||
- srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV ||
- srcType == GL_UNSIGNED_SHORT_5_5_5_1 ||
- srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV ||
- srcType == GL_UNSIGNED_INT_8_8_8_8 ||
- srcType == GL_UNSIGNED_INT_8_8_8_8_REV ||
- srcType == GL_UNSIGNED_INT_10_10_10_2 ||
- srcType == GL_UNSIGNED_INT_2_10_10_10_REV ||
- srcType == GL_UNSIGNED_INT_5_9_9_9_REV ||
- srcType == GL_UNSIGNED_INT_10F_11F_11F_REV);
-
-
- /* Extract image data as uint[4] pixels */
- extract_uint_rgba(n, rgba, srcFormat, srcType, source,
- srcPacking->SwapBytes);
-
- if (dstFormat == GL_RGBA) {
- /* simple case */
- memcpy(dest, rgba, 4 * sizeof(GLuint) * n);
- }
- else {
- /* general case */
- GLint rDst, gDst, bDst, aDst, lDst, iDst;
- GLint dstComponents = _mesa_components_in_format( dstFormat );
-
- assert(dstComponents > 0);
-
- get_component_indexes(dstFormat,
- &rDst, &gDst, &bDst, &aDst, &lDst, &iDst);
-
- /* Now pack values in the requested dest format */
- if (rDst >= 0) {
- GLuint *dst = dest;
- GLuint i;
- for (i = 0; i < n; i++) {
- dst[rDst] = rgba[i][RCOMP];
- dst += dstComponents;
- }
- }
-
- if (gDst >= 0) {
- GLuint *dst = dest;
- GLuint i;
- for (i = 0; i < n; i++) {
- dst[gDst] = rgba[i][GCOMP];
- dst += dstComponents;
- }
- }
-
- if (bDst >= 0) {
- GLuint *dst = dest;
- GLuint i;
- for (i = 0; i < n; i++) {
- dst[bDst] = rgba[i][BCOMP];
- dst += dstComponents;
- }
- }
-
- if (aDst >= 0) {
- GLuint *dst = dest;
- GLuint i;
- for (i = 0; i < n; i++) {
- dst[aDst] = rgba[i][ACOMP];
- dst += dstComponents;
- }
- }
-
- if (iDst >= 0) {
- GLuint *dst = dest;
- GLuint i;
- assert(iDst == 0);
- assert(dstComponents == 1);
- for (i = 0; i < n; i++) {
- /* Intensity comes from red channel */
- dst[i] = rgba[i][RCOMP];
- }
- }
-
- if (lDst >= 0) {
- GLuint *dst = dest;
- GLuint i;
- assert(lDst == 0);
- for (i = 0; i < n; i++) {
- /* Luminance comes from red channel */
- dst[0] = rgba[i][RCOMP];
- dst += dstComponents;
- }
- }
- }
-
- free(rgba);
-}
-
-
/*
* Unpack a row of color index data from a client buffer according to
* the pixel unpacking parameters.