X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fimage.c;h=ddae456fa129b4b4c6f03bb80ed415c20d05c90d;hb=b6e8256899a9a93c665c34e10efcc918f2fcc095;hp=d3282d42e99bc8216213cd109908da9f2d01464c;hpb=5b714723895d321db753f896576de5e2c27778c3;p=mesa.git diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index d3282d42e99..ddae456fa12 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -61,7 +61,7 @@ /** * \return GL_TRUE if type is packed pixel type, GL_FALSE otherwise. */ -static GLboolean +GLboolean _mesa_type_is_packed(GLenum type) { switch (type) { @@ -293,6 +293,9 @@ _mesa_components_in_format( GLenum format ) return 2; case GL_DEPTH_STENCIL_EXT: return 2; + case GL_DUDV_ATI: + case GL_DU8DV8_ATI: + return 2; default: return -1; } @@ -503,6 +506,20 @@ _mesa_is_legal_format_and_type( GLcontext *ctx, GLenum format, GLenum type ) return GL_TRUE; else return GL_FALSE; + case GL_DUDV_ATI: + case GL_DU8DV8_ATI: + switch (type) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + case GL_SHORT: + case GL_UNSIGNED_SHORT: + case GL_INT: + case GL_UNSIGNED_INT: + case GL_FLOAT: + return GL_TRUE; + default: + return GL_FALSE; + } default: ; /* fall-through */ } @@ -1660,7 +1677,6 @@ _mesa_apply_stencil_transfer_ops(const GLcontext *ctx, GLuint n, * Used to pack an array [][4] of RGBA float colors as specified * by the dstFormat, dstType and dstPacking. Used by glReadPixels, * glGetConvolutionFilter(), etc. - * Incoming colors will be clamped to [0,1] if needed. * Note: the rgba values will be modified by this function when any pixel * transfer ops are enabled. */ @@ -1675,6 +1691,10 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4], const GLint comps = _mesa_components_in_format(dstFormat); GLuint i; + /* XXX + * This test should probably go away. Have the caller set/clear the + * IMAGE_CLAMP_BIT as needed. + */ if (dstType != GL_FLOAT || ctx->Color.ClampReadColor == GL_TRUE) { /* need to clamp to [0, 1] */ transferOps |= IMAGE_CLAMP_BIT; @@ -1774,6 +1794,13 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4], dst[i*4+3] = FLOAT_TO_UBYTE(rgba[i][RCOMP]); } break; + case GL_DUDV_ATI: + case GL_DU8DV8_ATI: + for (i=0;i 0); + + /* + * Extract image data and convert to RGBA floats + */ + assert(n <= MAX_WIDTH); + extract_float_rgba(n, rgba, srcFormat, srcType, source, + srcPacking->SwapBytes); + + + /* Now determine which color channels we need to produce. + * And determine the dest index (offset) within each color tuple. + */ + + /* Now pack results in the requested dstFormat */ + for (i = 0; i < n; i++) { + /* not sure - need clamp[-1,1] here? */ + dst[0] = FLOAT_TO_BYTE(rgba[i][RCOMP]); + dst[1] = FLOAT_TO_BYTE(rgba[i][GCOMP]); + dst += dstComponents; + } + } +} /* * Unpack a row of color index data from a client buffer according to @@ -4406,6 +4546,17 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, } return; } + if (srcType == GL_UNSIGNED_INT_24_8 + && dstType == GL_UNSIGNED_INT + && depthMax == 0xffffff) { + const GLuint *src = (const GLuint *) source; + GLuint *dst = (GLuint *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = src[i] >> 8; + } + return; + } /* XXX may want to add additional cases here someday */ } @@ -5152,7 +5303,7 @@ _mesa_clip_to_region(GLint xmin, GLint ymin, /* right clipping */ if (*x + *width > xmax) - *width -= (*x + *width - xmax - 1); + *width -= (*x + *width - xmax); if (*width <= 0) return GL_FALSE; @@ -5165,7 +5316,7 @@ _mesa_clip_to_region(GLint xmin, GLint ymin, /* top (or bottom) clipping */ if (*y + *height > ymax) - *height -= (*y + *height - ymax - 1); + *height -= (*y + *height - ymax); if (*height <= 0) return GL_FALSE;