示例#1
0
文件: rensize.c 项目: theqvd/vcxsrv
int
__glXSeparableFilter2DReqSize(const GLbyte * pc, Bool swap, int reqlen)
{
    __GLXdispatchConvolutionFilterHeader *hdr =
        (__GLXdispatchConvolutionFilterHeader *) pc;

    GLint image1size, image2size;
    GLenum format = hdr->format;
    GLenum type = hdr->type;
    GLint w = hdr->width;
    GLint h = hdr->height;
    GLint rowLength = hdr->rowLength;
    GLint alignment = hdr->alignment;

    if (swap) {
        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);
    image2size = __glXImageSize(format, type, 0, h, 1, 1,
                                0, rowLength, 0, 0, alignment);
    return safe_add(safe_pad(image1size), image2size);
}
示例#2
0
int
__glXProgramNamedParameter4fvNVReqSize( const GLbyte * pc, Bool swap, int reqlen )
{
GLsizei len        = *(GLsizei *)(pc + 4);

    if (swap) {
        len = bswap_32(len);
    }

    return safe_pad(len);
}
示例#3
0
int
__glXProgramParameters4fvNVReqSize( const GLbyte * pc, Bool swap, int reqlen )
{
GLsizei num        = *(GLsizei *)(pc + 8);

    if (swap) {
        num = bswap_32(num);
    }

    return safe_pad(safe_mul(num , 16));
}
示例#4
0
int
__glXVertexAttribs4dvNVReqSize( const GLbyte * pc, Bool swap, int reqlen )
{
GLsizei n          = *(GLsizei *)(pc + 4);

    if (swap) {
        n = bswap_32(n);
    }

    return safe_pad(safe_mul(n , 32));
}
示例#5
0
int
__glXDrawBuffersReqSize( const GLbyte * pc, Bool swap, int reqlen )
{
GLsizei n          = *(GLsizei *)(pc + 0);

    if (swap) {
        n = bswap_32(n);
    }

    return safe_pad(safe_mul(n , 4));
}
示例#6
0
int
__glXProgramStringARBReqSize( const GLbyte * pc, Bool swap, int reqlen )
{
GLsizei len        = *(GLsizei *)(pc + 8);

    if (swap) {
        len = bswap_32(len);
    }

    return safe_pad(len);
}
示例#7
0
int
__glXCompressedTexSubImage3DReqSize( const GLbyte * pc, Bool swap, int reqlen )
{
GLsizei imageSize  = *(GLsizei *)(pc + 36);

    if (swap) {
        imageSize = bswap_32(imageSize);
    }

    return safe_pad(imageSize);
}
示例#8
0
int
__glXPrioritizeTexturesReqSize( const GLbyte * pc, Bool swap, int reqlen )
{
GLsizei n          = *(GLsizei *)(pc + 0);

    if (swap) {
        n = bswap_32(n);
    }

    return safe_pad(safe_add(safe_mul(n , 4), safe_mul(n , 4)));
}
示例#9
0
int
__glXPixelMapusvReqSize( const GLbyte * pc, Bool swap, int reqlen )
{
GLsizei mapsize    = *(GLsizei *)(pc + 4);

    if (swap) {
        mapsize = bswap_32(mapsize);
    }

    return safe_pad(safe_mul(mapsize , 2));
}
示例#10
0
int
__glXFogfvReqSize( const GLbyte * pc, Bool swap, int reqlen )
{
GLenum pname       = * (GLenum *)(pc + 0);
    GLsizei compsize;

    if (swap) {
        pname = bswap_32(pname);
    }

    compsize = __glFogfv_size(pname);
    return safe_pad(safe_mul(compsize , 4));
}
示例#11
0
int
__glXConvolutionParameterfvReqSize( const GLbyte * pc, Bool swap, int reqlen )
{
GLenum pname       = * (GLenum *)(pc + 4);
    GLsizei compsize;

    if (swap) {
        pname = bswap_32(pname);
    }

    compsize = __glConvolutionParameterfv_size(pname);
    return safe_pad(safe_mul(compsize , 4));
}
示例#12
0
int
__glXCallListsReqSize( const GLbyte * pc, Bool swap, int reqlen )
{
GLsizei n          = *(GLsizei *)(pc + 0);
GLenum type        = * (GLenum *)(pc + 4);
    GLsizei compsize;

    if (swap) {
        n = bswap_32(n);
        type = bswap_32(type);
    }

    compsize = __glCallLists_size(type);
    return safe_pad(safe_mul(compsize , n));
}
示例#13
0
文件: rensize.c 项目: theqvd/vcxsrv
int
__glXDrawArraysReqSize(const GLbyte * pc, Bool swap, int reqlen)
{
    __GLXdispatchDrawArraysHeader *hdr = (__GLXdispatchDrawArraysHeader *) pc;
    __GLXdispatchDrawArraysComponentHeader *compHeader;
    GLint numVertexes = hdr->numVertexes;
    GLint numComponents = hdr->numComponents;
    GLint arrayElementSize = 0;
    GLint x, size;
    int i;

    if (swap) {
        numVertexes = SWAPL(numVertexes);
        numComponents = SWAPL(numComponents);
    }

    pc += sizeof(__GLXdispatchDrawArraysHeader);
    reqlen -= sizeof(__GLXdispatchDrawArraysHeader);

    size = safe_mul(sizeof(__GLXdispatchDrawArraysComponentHeader),
                    numComponents);
    if (size < 0 || reqlen < 0 || reqlen < size)
        return -1;

    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;
        }

        x = safe_pad(safe_mul(numVals, __glXTypeSize(datatype)));
        if ((arrayElementSize = safe_add(arrayElementSize, x)) < 0)
            return -1;

        pc += sizeof(__GLXdispatchDrawArraysComponentHeader);
    }

    return safe_add(size, safe_mul(numVertexes, arrayElementSize));
}
示例#14
0
static int
GetSeparableFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
{
    GLint compsize, compsize2;
    GLenum format, type, target;
    GLboolean swapBytes;
    __GLXcontext *cx;
    ClientPtr client = cl->client;
    int error;

    __GLX_DECLARE_SWAP_VARIABLES;
    char *answer, answerBuffer[200];
    GLint width = 0, height = 0;
    xGLXSingleReply reply = { 0, };

    cx = __glXForceCurrent(cl, tag, &error);
    if (!cx) {
        return error;
    }

    __GLX_SWAP_INT(pc + 0);
    __GLX_SWAP_INT(pc + 4);
    __GLX_SWAP_INT(pc + 8);

    format = *(GLenum *) (pc + 4);
    type = *(GLenum *) (pc + 8);
    target = *(GLenum *) (pc + 0);
    swapBytes = *(GLboolean *) (pc + 12);

    /* target must be SEPARABLE_2D, however I guess we can let the GL
       barf on this one.... */

    glGetConvolutionParameteriv(target, GL_CONVOLUTION_WIDTH, &width);
    glGetConvolutionParameteriv(target, GL_CONVOLUTION_HEIGHT, &height);
    /*
     * The two queries above might fail if we're in a state where queries
     * are illegal, but then width and height would still be zero anyway.
     */
    compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1);
    compsize2 = __glGetTexImage_size(target, 1, format, type, height, 1, 1);

    if ((compsize = safe_pad(compsize)) < 0)
        return BadLength;
    if ((compsize2 = safe_pad(compsize2)) < 0)
        return BadLength;

    glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
    __GLX_GET_ANSWER_BUFFER(answer, cl, safe_add(compsize, compsize2), 1);
    __glXClearErrorOccured();
    glGetSeparableFilter(*(GLenum *) (pc + 0), *(GLenum *) (pc + 4),
                         *(GLenum *) (pc + 8), answer, answer + compsize, NULL);

    if (__glXErrorOccured()) {
        __GLX_BEGIN_REPLY(0);
        __GLX_SWAP_REPLY_HEADER();
    }
    else {
        __GLX_BEGIN_REPLY(compsize + compsize2);
        __GLX_SWAP_REPLY_HEADER();
        __GLX_SWAP_INT(&width);
        __GLX_SWAP_INT(&height);
        ((xGLXGetSeparableFilterReply *) &reply)->width = width;
        ((xGLXGetSeparableFilterReply *) &reply)->height = height;
        __GLX_SEND_VOID_ARRAY(compsize + compsize2);
    }

    return Success;
}