diff options
author | marha <marha@users.sourceforge.net> | 2012-03-23 10:05:55 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-03-23 10:05:55 +0100 |
commit | 0f834b91a4768673833ab4917e87d86c237bb1a6 (patch) | |
tree | 363489504ed4b2d360259b8de4c9e392918e5d02 /xorg-server/glx/rensize.c | |
parent | fc72edebf875378459368c5383d9023730cbca54 (diff) | |
download | vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.gz vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.bz2 vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.zip |
libX11 xserver fontconfig mesa pixman xkbcomp xkeyboard-config git update
23 Mar 2012
Diffstat (limited to 'xorg-server/glx/rensize.c')
-rw-r--r-- | xorg-server/glx/rensize.c | 475 |
1 files changed, 250 insertions, 225 deletions
diff --git a/xorg-server/glx/rensize.c b/xorg-server/glx/rensize.c index 8a58e08d7..bcc3a53ad 100644 --- a/xorg-server/glx/rensize.c +++ b/xorg-server/glx/rensize.c @@ -43,80 +43,88 @@ (((a & 0xff000000U)>>24) | ((a & 0xff0000U)>>8) | \ ((a & 0xff00U)<<8) | ((a & 0xffU)<<24)) -static int Map1Size( GLint k, GLint order) +static int +Map1Size(GLint k, GLint order) { - if (order <= 0 || k < 0) return -1; + if (order <= 0 || k < 0) + return -1; return k * order; } -int __glXMap1dReqSize( const GLbyte *pc, Bool swap ) +int +__glXMap1dReqSize(const GLbyte * pc, Bool swap) { GLenum target; GLint order, k; - target = *(GLenum*) (pc + 16); - order = *(GLint*) (pc + 20); + target = *(GLenum *) (pc + 16); + order = *(GLint *) (pc + 20); if (swap) { - target = SWAPL( target ); - order = SWAPL( order ); + target = SWAPL(target); + order = SWAPL(order); } - k = __glMap1d_size( target ); - return 8 * Map1Size( k, order ); + k = __glMap1d_size(target); + return 8 * Map1Size(k, order); } -int __glXMap1fReqSize( const GLbyte *pc, Bool swap ) +int +__glXMap1fReqSize(const GLbyte * pc, Bool swap) { GLenum target; GLint order, k; - target = *(GLenum *)(pc + 0); - order = *(GLint *)(pc + 12); + target = *(GLenum *) (pc + 0); + order = *(GLint *) (pc + 12); if (swap) { - target = SWAPL( target ); - order = SWAPL( order ); + target = SWAPL(target); + order = SWAPL(order); } k = __glMap1f_size(target); return 4 * Map1Size(k, order); } -static int Map2Size(int k, int majorOrder, int minorOrder) +static int +Map2Size(int k, int majorOrder, int minorOrder) { - if (majorOrder <= 0 || minorOrder <= 0 || k < 0) return -1; + if (majorOrder <= 0 || minorOrder <= 0 || k < 0) + return -1; return k * majorOrder * minorOrder; } -int __glXMap2dReqSize( const GLbyte *pc, Bool swap ) +int +__glXMap2dReqSize(const GLbyte * pc, Bool swap) { GLenum target; GLint uorder, vorder, k; - target = *(GLenum *)(pc + 32); - uorder = *(GLint *)(pc + 36); - vorder = *(GLint *)(pc + 40); + target = *(GLenum *) (pc + 32); + uorder = *(GLint *) (pc + 36); + vorder = *(GLint *) (pc + 40); if (swap) { - target = SWAPL( target ); - uorder = SWAPL( uorder ); - vorder = SWAPL( vorder ); + target = SWAPL(target); + uorder = SWAPL(uorder); + vorder = SWAPL(vorder); } - k = __glMap2d_size( target ); - return 8 * Map2Size( k, uorder, vorder ); + k = __glMap2d_size(target); + return 8 * Map2Size(k, uorder, vorder); } -int __glXMap2fReqSize( const GLbyte *pc, Bool swap ) +int +__glXMap2fReqSize(const GLbyte * pc, Bool swap) { GLenum target; GLint uorder, vorder, k; - target = *(GLenum *)(pc + 0); - uorder = *(GLint *)(pc + 12); - vorder = *(GLint *)(pc + 24); + target = *(GLenum *) (pc + 0); + uorder = *(GLint *) (pc + 12); + vorder = *(GLint *) (pc + 24); if (swap) { - target = SWAPL( target ); - uorder = SWAPL( uorder ); - vorder = SWAPL( vorder ); + target = SWAPL(target); + uorder = SWAPL(uorder); + vorder = SWAPL(vorder); } - k = __glMap2f_size( target ); - return 4 * Map2Size( k, uorder, vorder ); + k = __glMap2f_size(target); + return 4 * Map2Size(k, uorder, vorder); } /** @@ -158,22 +166,24 @@ int __glXMap2fReqSize( const GLbyte *pc, Bool swap ) * are invalid, -1 is returned. If \c target is one of \c GL_PROXY_*, zero * is returned. */ -int __glXImageSize( GLenum format, GLenum type, GLenum target, - GLsizei w, GLsizei h, GLsizei d, - GLint imageHeight, GLint rowLength, - GLint skipImages, GLint skipRows, GLint alignment ) +int +__glXImageSize(GLenum format, GLenum type, GLenum target, + GLsizei w, GLsizei h, GLsizei d, + GLint imageHeight, GLint rowLength, + GLint skipImages, GLint skipRows, GLint alignment) { GLint bytesPerElement, elementsPerGroup, groupsPerRow; GLint groupSize, rowSize, padding, imageSize; if (w < 0 || h < 0 || d < 0 || - (type == GL_BITMAP && - (format != GL_COLOR_INDEX && format != GL_STENCIL_INDEX))) { - return -1; + (type == GL_BITMAP && + (format != GL_COLOR_INDEX && format != GL_STENCIL_INDEX))) { + return -1; } - if (w==0 || h==0 || d == 0) return 0; + if (w == 0 || h == 0 || d == 0) + return 0; - switch( target ) { + switch (target) { case GL_PROXY_TEXTURE_1D: case GL_PROXY_TEXTURE_2D: case GL_PROXY_TEXTURE_3D: @@ -186,139 +196,153 @@ int __glXImageSize( GLenum format, GLenum type, GLenum target, case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE: case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE: case GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP: - return 0; + return 0; } if (type == GL_BITMAP) { - if (rowLength > 0) { - groupsPerRow = rowLength; - } else { - groupsPerRow = w; - } - rowSize = bits_to_bytes(groupsPerRow); - padding = (rowSize % alignment); - if (padding) { - rowSize += alignment - padding; - } - return ((h + skipRows) * rowSize); - } else { - switch(format) { - case GL_COLOR_INDEX: - case GL_STENCIL_INDEX: - case GL_DEPTH_COMPONENT: - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_ALPHA: - case GL_LUMINANCE: - case GL_INTENSITY: - elementsPerGroup = 1; - break; - case GL_422_EXT: - case GL_422_REV_EXT: - case GL_422_AVERAGE_EXT: - case GL_422_REV_AVERAGE_EXT: - case GL_DEPTH_STENCIL_NV: - case GL_DEPTH_STENCIL_MESA: - case GL_YCBCR_MESA: - case GL_LUMINANCE_ALPHA: - elementsPerGroup = 2; - break; - case GL_RGB: - case GL_BGR: - elementsPerGroup = 3; - break; - case GL_RGBA: - case GL_BGRA: - case GL_ABGR_EXT: - elementsPerGroup = 4; - break; - default: - return -1; - } - switch(type) { - case GL_UNSIGNED_BYTE: - case GL_BYTE: - bytesPerElement = 1; - break; - case GL_UNSIGNED_BYTE_3_3_2: - case GL_UNSIGNED_BYTE_2_3_3_REV: - bytesPerElement = 1; - elementsPerGroup = 1; - break; - case GL_UNSIGNED_SHORT: - case GL_SHORT: - bytesPerElement = 2; - break; - 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_SHORT_8_8_APPLE: - case GL_UNSIGNED_SHORT_8_8_REV_APPLE: - case GL_UNSIGNED_SHORT_15_1_MESA: - case GL_UNSIGNED_SHORT_1_15_REV_MESA: - bytesPerElement = 2; - elementsPerGroup = 1; - break; - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - bytesPerElement = 4; - break; - 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_24_8_NV: - case GL_UNSIGNED_INT_24_8_MESA: - case GL_UNSIGNED_INT_8_24_REV_MESA: - bytesPerElement = 4; - elementsPerGroup = 1; - break; - default: - return -1; - } - groupSize = bytesPerElement * elementsPerGroup; - if (rowLength > 0) { - groupsPerRow = rowLength; - } else { - groupsPerRow = w; - } - rowSize = groupsPerRow * groupSize; - padding = (rowSize % alignment); - if (padding) { - rowSize += alignment - padding; - } - if (imageHeight > 0) { - imageSize = (imageHeight + skipRows) * rowSize; - } else { - imageSize = (h + skipRows) * rowSize; - } - return ((d + skipImages) * imageSize); + if (rowLength > 0) { + groupsPerRow = rowLength; + } + else { + groupsPerRow = w; + } + rowSize = bits_to_bytes(groupsPerRow); + padding = (rowSize % alignment); + if (padding) { + rowSize += alignment - padding; + } + return ((h + skipRows) * rowSize); + } + else { + switch (format) { + case GL_COLOR_INDEX: + case GL_STENCIL_INDEX: + case GL_DEPTH_COMPONENT: + case GL_RED: + case GL_GREEN: + case GL_BLUE: + case GL_ALPHA: + case GL_LUMINANCE: + case GL_INTENSITY: + elementsPerGroup = 1; + break; + case GL_422_EXT: + case GL_422_REV_EXT: + case GL_422_AVERAGE_EXT: + case GL_422_REV_AVERAGE_EXT: + case GL_DEPTH_STENCIL_NV: + case GL_DEPTH_STENCIL_MESA: + case GL_YCBCR_MESA: + case GL_LUMINANCE_ALPHA: + elementsPerGroup = 2; + break; + case GL_RGB: + case GL_BGR: + elementsPerGroup = 3; + break; + case GL_RGBA: + case GL_BGRA: + case GL_ABGR_EXT: + elementsPerGroup = 4; + break; + default: + return -1; + } + switch (type) { + case GL_UNSIGNED_BYTE: + case GL_BYTE: + bytesPerElement = 1; + break; + case GL_UNSIGNED_BYTE_3_3_2: + case GL_UNSIGNED_BYTE_2_3_3_REV: + bytesPerElement = 1; + elementsPerGroup = 1; + break; + case GL_UNSIGNED_SHORT: + case GL_SHORT: + bytesPerElement = 2; + break; + 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_SHORT_8_8_APPLE: + case GL_UNSIGNED_SHORT_8_8_REV_APPLE: + case GL_UNSIGNED_SHORT_15_1_MESA: + case GL_UNSIGNED_SHORT_1_15_REV_MESA: + bytesPerElement = 2; + elementsPerGroup = 1; + break; + case GL_INT: + case GL_UNSIGNED_INT: + case GL_FLOAT: + bytesPerElement = 4; + break; + 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_24_8_NV: + case GL_UNSIGNED_INT_24_8_MESA: + case GL_UNSIGNED_INT_8_24_REV_MESA: + bytesPerElement = 4; + elementsPerGroup = 1; + break; + default: + return -1; + } + groupSize = bytesPerElement * elementsPerGroup; + if (rowLength > 0) { + groupsPerRow = rowLength; + } + else { + groupsPerRow = w; + } + rowSize = groupsPerRow * groupSize; + padding = (rowSize % alignment); + if (padding) { + rowSize += alignment - padding; + } + if (imageHeight > 0) { + imageSize = (imageHeight + skipRows) * rowSize; + } + else { + imageSize = (h + skipRows) * rowSize; + } + return ((d + skipImages) * imageSize); } } - /* XXX this is used elsewhere - should it be exported from glxserver.h? */ -int __glXTypeSize(GLenum enm) +int +__glXTypeSize(GLenum enm) { - switch(enm) { - case GL_BYTE: return sizeof(GLbyte); - case GL_UNSIGNED_BYTE: return sizeof(GLubyte); - case GL_SHORT: return sizeof(GLshort); - case GL_UNSIGNED_SHORT: return sizeof(GLushort); - case GL_INT: return sizeof(GLint); - case GL_UNSIGNED_INT: return sizeof(GLint); - case GL_FLOAT: return sizeof(GLfloat); - case GL_DOUBLE: return sizeof(GLdouble); - default: return -1; - } + switch (enm) { + case GL_BYTE: + return sizeof(GLbyte); + case GL_UNSIGNED_BYTE: + return sizeof(GLubyte); + case GL_SHORT: + return sizeof(GLshort); + case GL_UNSIGNED_SHORT: + return sizeof(GLushort); + case GL_INT: + return sizeof(GLint); + case GL_UNSIGNED_INT: + return sizeof(GLint); + case GL_FLOAT: + return sizeof(GLfloat); + case GL_DOUBLE: + return sizeof(GLdouble); + default: + return -1; + } } -int __glXDrawArraysReqSize( const GLbyte *pc, Bool swap ) +int +__glXDrawArraysReqSize(const GLbyte * pc, Bool swap) { __GLXdispatchDrawArraysHeader *hdr = (__GLXdispatchDrawArraysHeader *) pc; __GLXdispatchDrawArraysComponentHeader *compHeader; @@ -328,67 +352,68 @@ int __glXDrawArraysReqSize( const GLbyte *pc, Bool swap ) int i; if (swap) { - numVertexes = SWAPL( numVertexes ); - numComponents = SWAPL( numComponents ); + numVertexes = SWAPL(numVertexes); + numComponents = SWAPL(numComponents); } pc += sizeof(__GLXdispatchDrawArraysHeader); compHeader = (__GLXdispatchDrawArraysComponentHeader *) pc; - for (i=0; i<numComponents; i++) { - GLenum datatype = compHeader[i].datatype; - GLint numVals = compHeader[i].numVals; - GLint component = compHeader[i].component; - - if (swap) { - datatype = SWAPL( datatype ); - numVals = SWAPL( numVals ); - component = SWAPL( component ); - } - - switch (component) { - case GL_VERTEX_ARRAY: - case GL_COLOR_ARRAY: - case GL_TEXTURE_COORD_ARRAY: - break; - case GL_SECONDARY_COLOR_ARRAY: - case GL_NORMAL_ARRAY: - if (numVals != 3) { - /* bad size */ - return -1; - } - break; - case GL_FOG_COORD_ARRAY: - case GL_INDEX_ARRAY: - if (numVals != 1) { - /* bad size */ - return -1; - } - break; - case GL_EDGE_FLAG_ARRAY: - if ((numVals != 1) && (datatype != GL_UNSIGNED_BYTE)) { - /* bad size or bad type */ - return -1; - } - break; - default: - /* unknown component type */ - return -1; - } - - arrayElementSize += __GLX_PAD(numVals * __glXTypeSize(datatype)); - - pc += sizeof(__GLXdispatchDrawArraysComponentHeader); + for (i = 0; i < numComponents; i++) { + GLenum datatype = compHeader[i].datatype; + GLint numVals = compHeader[i].numVals; + GLint component = compHeader[i].component; + + if (swap) { + datatype = SWAPL(datatype); + numVals = SWAPL(numVals); + component = SWAPL(component); + } + + switch (component) { + case GL_VERTEX_ARRAY: + case GL_COLOR_ARRAY: + case GL_TEXTURE_COORD_ARRAY: + break; + case GL_SECONDARY_COLOR_ARRAY: + case GL_NORMAL_ARRAY: + if (numVals != 3) { + /* bad size */ + return -1; + } + break; + case GL_FOG_COORD_ARRAY: + case GL_INDEX_ARRAY: + if (numVals != 1) { + /* bad size */ + return -1; + } + break; + case GL_EDGE_FLAG_ARRAY: + if ((numVals != 1) && (datatype != GL_UNSIGNED_BYTE)) { + /* bad size or bad type */ + return -1; + } + break; + default: + /* unknown component type */ + return -1; + } + + arrayElementSize += __GLX_PAD(numVals * __glXTypeSize(datatype)); + + pc += sizeof(__GLXdispatchDrawArraysComponentHeader); } return ((numComponents * sizeof(__GLXdispatchDrawArraysComponentHeader)) + - (numVertexes * arrayElementSize)); + (numVertexes * arrayElementSize)); } -int __glXSeparableFilter2DReqSize( const GLbyte *pc, Bool swap ) +int +__glXSeparableFilter2DReqSize(const GLbyte * pc, Bool swap) { __GLXdispatchConvolutionFilterHeader *hdr = - (__GLXdispatchConvolutionFilterHeader *) pc; + (__GLXdispatchConvolutionFilterHeader *) pc; GLint image1size, image2size; GLenum format = hdr->format; @@ -399,20 +424,20 @@ int __glXSeparableFilter2DReqSize( const GLbyte *pc, Bool swap ) GLint alignment = hdr->alignment; if (swap) { - format = SWAPL( format ); - type = SWAPL( type ); - w = SWAPL( w ); - h = SWAPL( h ); - rowLength = SWAPL( rowLength ); - alignment = SWAPL( alignment ); + format = SWAPL(format); + type = SWAPL(type); + w = SWAPL(w); + h = SWAPL(h); + rowLength = SWAPL(rowLength); + alignment = SWAPL(alignment); } /* XXX Should rowLength be used for either or both image? */ - image1size = __glXImageSize( format, type, 0, w, 1, 1, - 0, rowLength, 0, 0, alignment ); + image1size = __glXImageSize(format, type, 0, w, 1, 1, + 0, rowLength, 0, 0, alignment); image1size = __GLX_PAD(image1size); - image2size = __glXImageSize( format, type, 0, h, 1, 1, - 0, rowLength, 0, 0, alignment ); + image2size = __glXImageSize(format, type, 0, h, 1, 1, + 0, rowLength, 0, 0, alignment); return image1size + image2size; } |