X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fimage.c;h=01fbe40a03b418f72ef98f9d1f81246dfaf0b9b7;hb=f0df08abbec173be183d3d6ecf3d4ba5206df179;hp=bd38e0c3d8c732a7e012fcc1bbc03d9616940512;hpb=2a6c6fe01e84ffd54b47ea11aa766960df6ddcaf;p=mesa.git diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index bd38e0c3d8c..01fbe40a03b 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1,8 +1,9 @@ /* * Mesa 3-D graphics library - * Version: 7.1 + * Version: 7.5 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -61,7 +62,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 +294,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 +507,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 */ } @@ -738,12 +756,20 @@ _mesa_image_image_stride( const struct gl_pixelstore_attrib *packing, GLint width, GLint height, GLenum format, GLenum type ) { + GLint bytesPerRow, bytesPerImage, remainder; + ASSERT(packing); - ASSERT(type != GL_BITMAP); - { + if (type == GL_BITMAP) { + if (packing->RowLength == 0) { + bytesPerRow = (width + 7) / 8; + } + else { + bytesPerRow = (packing->RowLength + 7) / 8; + } + } + else { const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type); - GLint bytesPerRow, bytesPerImage, remainder; if (bytesPerPixel <= 0) return -1; /* error */ @@ -753,17 +779,18 @@ _mesa_image_image_stride( const struct gl_pixelstore_attrib *packing, else { bytesPerRow = bytesPerPixel * packing->RowLength; } - remainder = bytesPerRow % packing->Alignment; - if (remainder > 0) - bytesPerRow += (packing->Alignment - remainder); + } - if (packing->ImageHeight == 0) - bytesPerImage = bytesPerRow * height; - else - bytesPerImage = bytesPerRow * packing->ImageHeight; + remainder = bytesPerRow % packing->Alignment; + if (remainder > 0) + bytesPerRow += (packing->Alignment - remainder); - return bytesPerImage; - } + if (packing->ImageHeight == 0) + bytesPerImage = bytesPerRow * height; + else + bytesPerImage = bytesPerRow * packing->ImageHeight; + + return bytesPerImage; } @@ -1660,7 +1687,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 +1701,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; @@ -1689,7 +1719,7 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4], if (dstFormat == GL_LUMINANCE || dstFormat == GL_LUMINANCE_ALPHA) { /* compute luminance values */ - if (dstType != GL_FLOAT || ctx->Color.ClampReadColor == GL_TRUE) { + 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); @@ -1774,6 +1804,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 +4556,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 +5313,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 +5326,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;