From 3a4de321449551e48682ad42a57df020570fec6d Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Mon, 10 Nov 2014 17:45:55 +0100 Subject: [PATCH] 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 --- src/mesa/main/pack.c | 403 --------------------------------------- src/mesa/main/pack.h | 8 - src/mesa/main/pack_tmp.h | 196 ------------------- 3 files changed, 607 deletions(-) delete mode 100644 src/mesa/main/pack_tmp.h 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;iSwapBytes) { - 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); \ diff --git a/src/mesa/main/pack.h b/src/mesa/main/pack.h index 9ca6f68c6f3..27aaea86871 100644 --- a/src/mesa/main/pack.h +++ b/src/mesa/main/pack.h @@ -46,14 +46,6 @@ _mesa_pack_bitmap(GLint width, GLint height, const GLubyte *source, GLubyte *dest, const struct gl_pixelstore_attrib *packing); -extern 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); - - extern void _mesa_unpack_index_span(struct gl_context *ctx, GLuint n, GLenum dstType, GLvoid *dest, diff --git a/src/mesa/main/pack_tmp.h b/src/mesa/main/pack_tmp.h deleted file mode 100644 index 47acb01ee71..00000000000 --- a/src/mesa/main/pack_tmp.h +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright © 2012 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -static void -FN_NAME(struct gl_context *ctx, - DST_TYPE *dst, - GLenum dstFormat, - SRC_TYPE rgba[][4], - GLfloat *luminance, - int n) -{ - int i; - - switch (dstFormat) { -#ifdef FLOAT_SRC_CONVERT - case GL_RED: - for (i=0;i