summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/pack.c
diff options
context:
space:
mode:
authorIago Toral Quiroga <[email protected]>2014-11-10 17:45:55 +0100
committerIago Toral Quiroga <[email protected]>2015-01-12 11:20:29 +0100
commit3a4de321449551e48682ad42a57df020570fec6d (patch)
tree86b78de29ef8d37a867221cce71bc7006998786d /src/mesa/main/pack.c
parent873437e209cd54bed64e634cb9bd0e3332efb7b7 (diff)
mesa: Remove _mesa_pack_rgba_span_float and tmp_pack.h
_mesa_pack_rgba_span_float was the last of the color span functions and we have replaced all calls to it with calls to _mesa_format_convert, so we can remove it together with tmp_pack.h which was used to generate the pack functions for multiple types that were used from the various color span functions that have been removed. Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/mesa/main/pack.c')
-rw-r--r--src/mesa/main/pack.c403
1 files changed, 0 insertions, 403 deletions
diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c
index e0c2226cdf9..679ff9397cc 100644
--- a/src/mesa/main/pack.c
+++ b/src/mesa/main/pack.c
@@ -232,409 +232,6 @@ _mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source,
}
-/**
- * For small integer types, return the min and max possible values.
- * Used for clamping floats to unscaled integer types.
- * \return GL_TRUE if type is handled, GL_FALSE otherwise.
- */
-static GLboolean
-get_type_min_max(GLenum type, GLfloat *min, GLfloat *max)
-{
- switch (type) {
- case GL_BYTE:
- *min = -128.0;
- *max = 127.0;
- return GL_TRUE;
- case GL_UNSIGNED_BYTE:
- *min = 0.0;
- *max = 255.0;
- return GL_TRUE;
- case GL_SHORT:
- *min = -32768.0;
- *max = 32767.0;
- return GL_TRUE;
- case GL_UNSIGNED_SHORT:
- *min = 0.0;
- *max = 65535.0;
- return GL_TRUE;
- default:
- return GL_FALSE;
- }
-}
-
-/* Customization of float packing.
- */
-#define SRC_TYPE GLfloat
-
-#define DST_TYPE GLuint
-#define FLOAT_SRC_CONVERT(x) FLOAT_TO_UINT(x)
-#define SRC_CONVERT(x) (GLuint) x
-#define FN_NAME pack_uint_from_float_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FLOAT_SRC_CONVERT
-#undef FN_NAME
-
-#define DST_TYPE GLint
-#define FLOAT_SRC_CONVERT(x) FLOAT_TO_INT(x)
-#define SRC_CONVERT(x) (GLint) x
-#define FN_NAME pack_int_from_float_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FLOAT_SRC_CONVERT
-#undef FN_NAME
-
-#define DST_TYPE GLshort
-#define FLOAT_SRC_CONVERT(x) FLOAT_TO_SHORT_TEX(x)
-#define SRC_CONVERT(x) (GLshort) x
-#define FN_NAME pack_short_from_float_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FLOAT_SRC_CONVERT
-#undef FN_NAME
-
-#define DST_TYPE GLubyte
-#define FLOAT_SRC_CONVERT(x) FLOAT_TO_UBYTE(x)
-#define SRC_CONVERT(x) (GLubyte) x
-#define FN_NAME pack_ubyte_from_float_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FLOAT_SRC_CONVERT
-#undef FN_NAME
-
-#define DST_TYPE GLbyte
-#define FLOAT_SRC_CONVERT(x) FLOAT_TO_BYTE_TEX(x)
-#define SRC_CONVERT(x) (GLbyte) x
-#define FN_NAME pack_byte_from_float_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FLOAT_SRC_CONVERT
-#undef FN_NAME
-
-#define DST_TYPE GLfloat
-#define FLOAT_SRC_CONVERT(x) x
-#define SRC_CONVERT(x) x
-#define FN_NAME pack_float_from_float_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FLOAT_SRC_CONVERT
-#undef FN_NAME
-
-#define DST_TYPE GLhalfARB
-#define FLOAT_SRC_CONVERT(x) _mesa_float_to_half(x)
-#define FN_NAME pack_half_float_from_float_rgba
-#include "pack_tmp.h"
-#undef DST_TYPE
-#undef SRC_CONVERT
-#undef FLOAT_SRC_CONVERT
-#undef FN_NAME
-
-#undef SRC_TYPE
-
-/**
- * Used to pack an array [][4] of RGBA float colors as specified
- * by the dstFormat, dstType and dstPacking. Used by glReadPixels.
- * Historically, the RGBA values were in [0,1] and rescaled to fit
- * into GLubytes, etc. But with new integer formats, the RGBA values
- * may have any value and we don't always rescale when converting to
- * integers.
- *
- * Note: the rgba values will be modified by this function when any pixel
- * transfer ops are enabled.
- */
-void
-_mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4],
- GLenum dstFormat, GLenum dstType,
- GLvoid *dstAddr,
- const struct gl_pixelstore_attrib *dstPacking,
- GLbitfield transferOps)
-{
- GLfloat *luminance;
- const GLint comps = _mesa_components_in_format(dstFormat);
- const GLboolean intDstFormat = _mesa_is_enum_format_integer(dstFormat);
- GLuint i;
- uint32_t dstMesaFormat;
-
- if (dstFormat == GL_LUMINANCE ||
- dstFormat == GL_LUMINANCE_ALPHA ||
- dstFormat == GL_LUMINANCE_INTEGER_EXT ||
- dstFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT) {
- luminance = malloc(n * sizeof(GLfloat));
- if (!luminance) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel packing");
- return;
- }
- }
- else {
- luminance = NULL;
- }
-
- /* EXT_texture_integer specifies no transfer ops on integer
- * types in the resolved issues section. Just set them to 0
- * for integer surfaces.
- */
- if (intDstFormat)
- transferOps = 0;
-
- if (transferOps) {
- _mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgba);
- }
-
- /*
- * Component clamping (besides clamping to [0,1] in
- * _mesa_apply_rgba_transfer_ops()).
- */
- if (intDstFormat) {
- /* clamping to dest type's min/max values */
- GLfloat min, max;
- if (get_type_min_max(dstType, &min, &max)) {
- for (i = 0; i < n; i++) {
- rgba[i][RCOMP] = CLAMP(rgba[i][RCOMP], min, max);
- rgba[i][GCOMP] = CLAMP(rgba[i][GCOMP], min, max);
- rgba[i][BCOMP] = CLAMP(rgba[i][BCOMP], min, max);
- rgba[i][ACOMP] = CLAMP(rgba[i][ACOMP], min, max);
- }
- }
- }
- else if (dstFormat == GL_LUMINANCE || dstFormat == GL_LUMINANCE_ALPHA) {
- /* compute luminance values */
- if (transferOps & IMAGE_CLAMP_BIT) {
- for (i = 0; i < n; i++) {
- GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP];
- luminance[i] = CLAMP(sum, 0.0F, 1.0F);
- }
- }
- else {
- for (i = 0; i < n; i++) {
- luminance[i] = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP];
- }
- }
- }
-
- /*
- * Pack/store the pixels. Ugh! Lots of cases!!!
- */
- switch (dstType) {
- case GL_UNSIGNED_BYTE:
- pack_ubyte_from_float_rgba(ctx, dstAddr, dstFormat, rgba, luminance, n);
- break;
- case GL_BYTE:
- pack_byte_from_float_rgba(ctx, dstAddr, dstFormat, rgba, luminance, n);
- break;
- case GL_UNSIGNED_SHORT:
- {
- GLushort *dst = (GLushort *) dstAddr;
- switch (dstFormat) {
- case GL_RED:
- for (i=0;i<n;i++)
- CLAMPED_FLOAT_TO_USHORT(dst[i], rgba[i][RCOMP]);
- break;
- case GL_GREEN:
- for (i=0;i<n;i++)
- CLAMPED_FLOAT_TO_USHORT(dst[i], rgba[i][GCOMP]);
- break;
- case GL_BLUE:
- for (i=0;i<n;i++)
- CLAMPED_FLOAT_TO_USHORT(dst[i], rgba[i][BCOMP]);
- break;
- case GL_ALPHA:
- for (i=0;i<n;i++)
- CLAMPED_FLOAT_TO_USHORT(dst[i], rgba[i][ACOMP]);
- break;
- case GL_LUMINANCE:
- for (i=0;i<n;i++)
- UNCLAMPED_FLOAT_TO_USHORT(dst[i], luminance[i]);
- break;
- case GL_LUMINANCE_ALPHA:
- for (i=0;i<n;i++) {
- UNCLAMPED_FLOAT_TO_USHORT(dst[i*2+0], luminance[i]);
- CLAMPED_FLOAT_TO_USHORT(dst[i*2+1], rgba[i][ACOMP]);
- }
- break;
- case GL_RG:
- for (i=0;i<n;i++) {
- CLAMPED_FLOAT_TO_USHORT(dst[i*2+0], rgba[i][RCOMP]);
- CLAMPED_FLOAT_TO_USHORT(dst[i*2+1], rgba[i][GCOMP]);
- }
- break;
- case GL_RGB:
- for (i=0;i<n;i++) {
- CLAMPED_FLOAT_TO_USHORT(dst[i*3+0], rgba[i][RCOMP]);
- CLAMPED_FLOAT_TO_USHORT(dst[i*3+1], rgba[i][GCOMP]);
- CLAMPED_FLOAT_TO_USHORT(dst[i*3+2], rgba[i][BCOMP]);
- }
- break;
- case GL_RGBA:
- for (i=0;i<n;i++) {
- CLAMPED_FLOAT_TO_USHORT(dst[i*4+0], rgba[i][RCOMP]);
- CLAMPED_FLOAT_TO_USHORT(dst[i*4+1], rgba[i][GCOMP]);
- CLAMPED_FLOAT_TO_USHORT(dst[i*4+2], rgba[i][BCOMP]);
- CLAMPED_FLOAT_TO_USHORT(dst[i*4+3], rgba[i][ACOMP]);
- }
- break;
- case GL_BGR:
- for (i=0;i<n;i++) {
- CLAMPED_FLOAT_TO_USHORT(dst[i*3+0], rgba[i][BCOMP]);
- CLAMPED_FLOAT_TO_USHORT(dst[i*3+1], rgba[i][GCOMP]);
- CLAMPED_FLOAT_TO_USHORT(dst[i*3+2], rgba[i][RCOMP]);
- }
- break;
- case GL_BGRA:
- for (i=0;i<n;i++) {
- CLAMPED_FLOAT_TO_USHORT(dst[i*4+0], rgba[i][BCOMP]);
- CLAMPED_FLOAT_TO_USHORT(dst[i*4+1], rgba[i][GCOMP]);
- CLAMPED_FLOAT_TO_USHORT(dst[i*4+2], rgba[i][RCOMP]);
- CLAMPED_FLOAT_TO_USHORT(dst[i*4+3], rgba[i][ACOMP]);
- }
- break;
- case GL_ABGR_EXT:
- for (i=0;i<n;i++) {
- CLAMPED_FLOAT_TO_USHORT(dst[i*4+0], rgba[i][ACOMP]);
- CLAMPED_FLOAT_TO_USHORT(dst[i*4+1], rgba[i][BCOMP]);
- CLAMPED_FLOAT_TO_USHORT(dst[i*4+2], rgba[i][GCOMP]);
- CLAMPED_FLOAT_TO_USHORT(dst[i*4+3], rgba[i][RCOMP]);
- }
- break;
- case GL_RED_INTEGER_EXT:
- for (i=0;i<n;i++) {
- dst[i] = (GLushort) rgba[i][RCOMP];
- }
- break;
- case GL_GREEN_INTEGER_EXT:
- for (i=0;i<n;i++) {
- dst[i] = (GLushort) rgba[i][GCOMP];
- }
- break;
- case GL_BLUE_INTEGER_EXT:
- for (i=0;i<n;i++) {
- dst[i] = (GLushort) rgba[i][BCOMP];
- }
- break;
- case GL_ALPHA_INTEGER_EXT:
- for (i=0;i<n;i++) {
- dst[i] = (GLushort) rgba[i][ACOMP];
- }
- break;
- case GL_RG_INTEGER:
- for (i=0;i<n;i++) {
- dst[i*2+0] = (GLushort) rgba[i][RCOMP];
- dst[i*2+1] = (GLushort) rgba[i][GCOMP];
- }
- break;
- case GL_RGB_INTEGER_EXT:
- for (i=0;i<n;i++) {
- dst[i*3+0] = (GLushort) rgba[i][RCOMP];
- dst[i*3+1] = (GLushort) rgba[i][GCOMP];
- dst[i*3+2] = (GLushort) rgba[i][BCOMP];
- }
- break;
- case GL_RGBA_INTEGER_EXT:
- for (i=0;i<n;i++) {
- dst[i*4+0] = (GLushort) rgba[i][RCOMP];
- dst[i*4+1] = (GLushort) rgba[i][GCOMP];
- dst[i*4+2] = (GLushort) rgba[i][BCOMP];
- dst[i*4+3] = (GLushort) rgba[i][ACOMP];
- }
- break;
- case GL_BGR_INTEGER_EXT:
- for (i=0;i<n;i++) {
- dst[i*3+0] = (GLushort) rgba[i][BCOMP];
- dst[i*3+1] = (GLushort) rgba[i][GCOMP];
- dst[i*3+2] = (GLushort) rgba[i][RCOMP];
- }
- break;
- case GL_BGRA_INTEGER_EXT:
- for (i=0;i<n;i++) {
- dst[i*4+0] = (GLushort) rgba[i][BCOMP];
- dst[i*4+1] = (GLushort) rgba[i][GCOMP];
- dst[i*4+2] = (GLushort) rgba[i][RCOMP];
- dst[i*4+3] = (GLushort) rgba[i][ACOMP];
- }
- break;
- case GL_LUMINANCE_INTEGER_EXT:
- for (i=0;i<n;i++) {
- dst[i*2+0] = (GLushort) (rgba[i][RCOMP] +
- rgba[i][GCOMP] +
- rgba[i][BCOMP]);
- dst[i*2+1] = (GLushort) rgba[i][ACOMP];
- }
- break;
- case GL_LUMINANCE_ALPHA_INTEGER_EXT:
- for (i=0;i<n;i++) {
- dst[i] = (GLushort) (rgba[i][RCOMP] +
- rgba[i][GCOMP] +
- rgba[i][BCOMP]);
- }
- break;
- default:
- _mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
- }
- }
- break;
- case GL_SHORT:
- pack_short_from_float_rgba(ctx, dstAddr, dstFormat, rgba, luminance, n);
- break;
- case GL_UNSIGNED_INT:
- pack_uint_from_float_rgba(ctx, dstAddr, dstFormat, rgba, luminance, n);
- break;
- case GL_INT:
- pack_int_from_float_rgba(ctx, dstAddr, dstFormat, rgba, luminance, n);
- break;
- case GL_FLOAT:
- /* No conversion necessary. */
- pack_float_from_float_rgba(ctx, dstAddr, dstFormat, rgba, luminance, n);
- break;
- case GL_HALF_FLOAT_ARB:
- pack_half_float_from_float_rgba(ctx, dstAddr, dstFormat, rgba, luminance, n);
- break;
- case GL_UNSIGNED_BYTE_3_3_2:
- case GL_UNSIGNED_BYTE_2_3_3_REV:
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- case GL_UNSIGNED_INT_8_8_8_8:
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- case GL_UNSIGNED_INT_10_10_10_2:
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- case GL_UNSIGNED_INT_5_9_9_9_REV:
- case GL_UNSIGNED_INT_10F_11F_11F_REV:
- dstMesaFormat = _mesa_format_from_format_and_type(dstFormat, dstType);
- if (!(dstMesaFormat & MESA_ARRAY_FORMAT_BIT)) {
- _mesa_pack_float_rgba_row(dstMesaFormat, n, (void *)rgba[0], (void *)dstAddr);
- break;
- } else {
- /* Fall through */
- }
- default:
- _mesa_problem(ctx, "bad type in _mesa_pack_rgba_span_float");
- free(luminance);
- return;
- }
-
- if (dstPacking->SwapBytes) {
- GLint swapSize = _mesa_sizeof_packed_type(dstType);
- if (swapSize == 2) {
- _mesa_swap2((GLushort *) dstAddr, n * comps);
- }
- else if (swapSize == 4) {
- _mesa_swap4((GLuint *) dstAddr, n * comps);
- }
- }
-
- free(luminance);
-}
-
-
-
#define SWAP2BYTE(VALUE) \
{ \
GLubyte *bytes = (GLubyte *) &(VALUE); \