示例#1
0
static void
SendSwappedReply(ClientPtr client,
                 xGLXVendorPrivReply * reply, char *buf, int buf_size)
{
    __GLX_DECLARE_SWAP_VARIABLES;
    __GLX_SWAP_SHORT(&reply->sequenceNumber);
    __GLX_SWAP_INT(&reply->length);
    __GLX_SWAP_INT(&reply->retval);
    __GLX_SWAP_INT(&reply->size);

    if ((buf_size == 0) && (swap_vec_element_size > 0)) {
        /*
         * the reply has single component - need to swap pad3
         */
        if (swap_vec_element_size == 2) {
            __GLX_SWAP_SHORT(&reply->pad3);
        }
        else if (swap_vec_element_size == 4) {
            __GLX_SWAP_INT(&reply->pad3);
            __GLX_SWAP_INT(&reply->pad4);
        }
        else if (swap_vec_element_size == 8) {
            __GLX_SWAP_DOUBLE(&reply->pad3);
        }
    }
    else if ((buf_size > 0) && (swap_vec_element_size > 0)) {
        /*
         * the reply has vector of elements which needs to be swapped
         */
        int vsize = buf_size / swap_vec_element_size;
        char *p = buf;
        int i;

        for (i = 0; i < vsize; i++) {
            if (swap_vec_element_size == 2) {
                __GLX_SWAP_SHORT(p);
            }
            else if (swap_vec_element_size == 4) {
                __GLX_SWAP_INT(p);
            }
            else if (swap_vec_element_size == 8) {
                __GLX_SWAP_DOUBLE(p);
            }

            p += swap_vec_element_size;
        }

        __GLX_SWAP_INT(&reply->pad3);
        __GLX_SWAP_INT(&reply->pad4);
        __GLX_SWAP_INT(&reply->pad5);
        __GLX_SWAP_INT(&reply->pad6);

    }

    WriteToClient(client, sizeof(xGLXVendorPrivReply), reply);
    if (buf_size > 0)
        WriteToClient(client, buf_size, buf);

}
示例#2
0
void
__glXDispSwap_Map2d(GLbyte * pc)
{
    GLdouble u1, u2, v1, v2, *points;
    GLint uorder, vorder, ustride, vstride, k, compsize;
    GLenum target;

    __GLX_DECLARE_SWAP_VARIABLES;
    __GLX_DECLARE_SWAP_ARRAY_VARIABLES;

    __GLX_SWAP_DOUBLE(pc + 0);
    __GLX_SWAP_DOUBLE(pc + 8);
    __GLX_SWAP_DOUBLE(pc + 16);
    __GLX_SWAP_DOUBLE(pc + 24);
    __GLX_SWAP_INT(pc + 32);
    __GLX_SWAP_INT(pc + 36);
    __GLX_SWAP_INT(pc + 40);

    target = *(GLenum *) (pc + 32);
    uorder = *(GLint *) (pc + 36);
    vorder = *(GLint *) (pc + 40);
    k = __glMap2d_size(target);
    if (vorder <= 0 || uorder <= 0 || k < 0) {
        /* Erroneous command. */
        compsize = 0;
    }
    else {
        compsize = uorder * vorder * k;
    }
    __GLX_GET_DOUBLE(u1, pc);
    __GLX_GET_DOUBLE(u2, pc + 8);
    __GLX_GET_DOUBLE(v1, pc + 16);
    __GLX_GET_DOUBLE(v2, pc + 24);
    __GLX_SWAP_DOUBLE_ARRAY(pc + 44, compsize);
    pc += 44;
    ustride = vorder * k;
    vstride = k;

#ifdef __GLX_ALIGN64
    if (((unsigned long) pc) & 7) {
        /*
         ** Copy the doubles up 4 bytes, trashing the command but aligning
         ** the data in the process
         */
        __GLX_MEM_COPY(pc - 4, pc, compsize * 8);
        points = (GLdouble *) (pc - 4);
    }
    else {
        points = (GLdouble *) pc;
    }
#else
    points = (GLdouble *) pc;
#endif
    CALL_Map2d(GET_DISPATCH(),
               (target, u1, u2, ustride, uorder, v1, v2, vstride, vorder,
                points));
}
示例#3
0
void __glXDispSwap_DepthRange(GLbyte *pc)
{
	__GLX_DECLARE_SWAP_VARIABLES;


#ifdef __GLX_ALIGN64
	if ((unsigned long)(pc) & 7) {
	    __GLX_MEM_COPY(pc-4, pc, 16);
	    pc -= 4;
	}
#endif
	__GLX_SWAP_DOUBLE(pc + 0);
	__GLX_SWAP_DOUBLE(pc + 8);

}
示例#4
0
void
__glXDispSwap_Map1d(GLbyte * pc)
{
    GLint order, k, compsize;
    GLenum target;
    GLdouble u1, u2, *points;

    __GLX_DECLARE_SWAP_VARIABLES;
    __GLX_DECLARE_SWAP_ARRAY_VARIABLES;

    __GLX_SWAP_DOUBLE(pc + 0);
    __GLX_SWAP_DOUBLE(pc + 8);
    __GLX_SWAP_INT(pc + 16);
    __GLX_SWAP_INT(pc + 20);

    target = *(GLenum *) (pc + 16);
    order = *(GLint *) (pc + 20);
    k = __glMap1d_size(target);
    if (order <= 0 || k < 0) {
        /* Erroneous command. */
        compsize = 0;
    }
    else {
        compsize = order * k;
    }
    __GLX_GET_DOUBLE(u1, pc);
    __GLX_GET_DOUBLE(u2, pc + 8);
    __GLX_SWAP_DOUBLE_ARRAY(pc + 24, compsize);
    pc += 24;

#ifdef __GLX_ALIGN64
    if (((unsigned long) pc) & 7) {
        /*
         ** Copy the doubles up 4 bytes, trashing the command but aligning
         ** the data in the process
         */
        __GLX_MEM_COPY(pc - 4, pc, compsize * 8);
        points = (GLdouble *) (pc - 4);
    }
    else {
        points = (GLdouble *) pc;
    }
#else
    points = (GLdouble *) pc;
#endif
    glMap1d(target, u1, u2, k, order, points);
}
示例#5
0
static void
swapArray(GLint numVals, GLenum datatype,
          GLint stride, GLint numVertexes, GLbyte * pc)
{
    int i, j;

    __GLX_DECLARE_SWAP_VARIABLES;

    switch (datatype) {
    case GL_BYTE:
    case GL_UNSIGNED_BYTE:
        /* don't need to swap */
        return;
    case GL_SHORT:
    case GL_UNSIGNED_SHORT:
        for (i = 0; i < numVertexes; i++) {
            GLshort *pVal = (GLshort *) pc;

            for (j = 0; j < numVals; j++) {
                __GLX_SWAP_SHORT(&pVal[j]);
            }
            pc += stride;
        }
        break;
    case GL_INT:
    case GL_UNSIGNED_INT:
        for (i = 0; i < numVertexes; i++) {
            GLint *pVal = (GLint *) pc;

            for (j = 0; j < numVals; j++) {
                __GLX_SWAP_INT(&pVal[j]);
            }
            pc += stride;
        }
        break;
    case GL_FLOAT:
        for (i = 0; i < numVertexes; i++) {
            GLfloat *pVal = (GLfloat *) pc;

            for (j = 0; j < numVals; j++) {
                __GLX_SWAP_FLOAT(&pVal[j]);
            }
            pc += stride;
        }
        break;
    case GL_DOUBLE:
        for (i = 0; i < numVertexes; i++) {
            GLdouble *pVal = (GLdouble *) pc;

            for (j = 0; j < numVals; j++) {
                __GLX_SWAP_DOUBLE(&pVal[j]);
            }
            pc += stride;
        }
        break;
    default:
        return;
    }
}
示例#6
0
void __glXDispSwap_MapGrid2d(GLbyte *pc)
{
	__GLX_DECLARE_SWAP_VARIABLES;


#ifdef __GLX_ALIGN64
	if ((unsigned long)(pc) & 7) {
	    __GLX_MEM_COPY(pc-4, pc, 40);
	    pc -= 4;
	}
#endif
	__GLX_SWAP_INT(pc + 32);
	__GLX_SWAP_DOUBLE(pc + 0);
	__GLX_SWAP_DOUBLE(pc + 8);
	__GLX_SWAP_INT(pc + 36);
	__GLX_SWAP_DOUBLE(pc + 16);
	__GLX_SWAP_DOUBLE(pc + 24);

}