X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fimage.c;h=01fbe40a03b418f72ef98f9d1f81246dfaf0b9b7;hb=f0df08abbec173be183d3d6ecf3d4ba5206df179;hp=804e840820d4596fd2a6e3321212e530f887a70e;hpb=f786e46cf4fbf50a1cacfb81e22ee155ffe6edd3;p=mesa.git diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 804e840820d..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"), @@ -755,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 */ @@ -770,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; } @@ -1677,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. */ @@ -1691,19 +1700,12 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4], GLfloat luminance[MAX_WIDTH]; const GLint comps = _mesa_components_in_format(dstFormat); GLuint i; - /* clamping only applies to colors, not the dudv values, but still need - it if converting to unsigned values (which doesn't make much sense) */ - if (dstFormat == GL_DUDV_ATI || dstFormat == GL_DU8DV8_ATI) { - switch (dstType) { - case GL_UNSIGNED_BYTE: - case GL_UNSIGNED_SHORT: - case GL_UNSIGNED_INT: - transferOps |= IMAGE_CLAMP_BIT; - break; - /* actually might want clamp to [-1,1] otherwise but shouldn't matter? */ - } - } - else if (dstType != GL_FLOAT || ctx->Color.ClampReadColor == GL_TRUE) { + + /* 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; } @@ -2378,9 +2380,9 @@ _mesa_pack_rgba_span_float(GLcontext *ctx, GLuint n, GLfloat rgba[][4], if (dstFormat == GL_RGB) { GLubyte *dst = (GLubyte *) dstAddr; for (i=0;i> 8; + } + return; + } /* XXX may want to add additional cases here someday */ }