示例#1
0
static int
ephyrGLXGetStringReal (__GLXclientState *a_cl, GLbyte *a_pc, Bool a_do_swap)
{
    ClientPtr client=NULL ;
    int context_tag=0, name=0, res=BadImplementation, length=0 ;
    char *string=NULL;
    __GLX_DECLARE_SWAP_VARIABLES;

    EPHYR_RETURN_VAL_IF_FAIL (a_cl && a_pc, BadValue) ;

    EPHYR_LOG ("enter\n") ;

    client = a_cl->client ;

    if (a_do_swap) {
        __GLX_SWAP_INT (a_pc + 4);
        __GLX_SWAP_INT (a_pc + __GLX_SINGLE_HDR_SIZE);
    }
    context_tag = __GLX_GET_SINGLE_CONTEXT_TAG (a_pc) ;
    a_pc += __GLX_SINGLE_HDR_SIZE;
    name = *(GLenum*)(a_pc + 0);
    EPHYR_LOG ("context_tag:%d, name:%d\n", context_tag, name) ;
    if (!ephyrHostGLXGetStringFromServer (context_tag,
                                          name,
                                          EPHYR_HOST_GLX_GetString,
                                          &string)) {
        EPHYR_LOG_ERROR ("failed to get string from server\n") ;
        goto out ;
    }
    if (string) {
        length = strlen (string) + 1;
        EPHYR_LOG ("got string:'%s', size:%d\n", string, length) ;
    } else {
        EPHYR_LOG ("got string: string (null)\n") ;
    }
    __GLX_BEGIN_REPLY (length);
    __GLX_PUT_SIZE (length);
    __GLX_SEND_HEADER ();
    if (a_do_swap) {
        __GLX_SWAP_REPLY_SIZE ();
        __GLX_SWAP_REPLY_HEADER ();
    }
    WriteToClient (client, length, (char *)string);

    res = Success ;
out:
    EPHYR_LOG ("leave\n") ;
    return res ;
}
示例#2
0
int DoGetString(__GLXclientState *cl, GLbyte *pc, GLboolean need_swap)
{
    ClientPtr client;
    __GLXcontext *cx;
    GLenum name;
    const char *string;
    __GLX_DECLARE_SWAP_VARIABLES;
    int error;
    char *buf = NULL, *buf1 = NULL;
    GLint length = 0;

    /* If the client has the opposite byte order, swap the contextTag and
     * the name.
     */
    if ( need_swap ) {
	__GLX_SWAP_INT(pc + 4);
	__GLX_SWAP_INT(pc + __GLX_SINGLE_HDR_SIZE);
    }

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

    pc += __GLX_SINGLE_HDR_SIZE;
    name = *(GLenum *)(pc + 0);
    string = (const char *) CALL_GetString( GET_DISPATCH(), (name) );
    client = cl->client;

    if (string == NULL)
      string = "";

    /*
    ** Restrict extensions to those that are supported by both the
    ** implementation and the connection.  That is, return the
    ** intersection of client, server, and core extension strings.
    */
    if (name == GL_EXTENSIONS) {
	buf1 = __glXcombine_strings(string,
				      cl->GLClientextensions);
	buf = __glXcombine_strings(buf1,
				      cx->pGlxScreen->GLextensions);
	free(buf1);
	string = buf;
    }
    else if ( name == GL_VERSION ) {
	if ( atof( string ) > atof( GLServerVersion ) ) {
	    buf = malloc( strlen( string ) + strlen( GLServerVersion ) + 4 );
	    if ( buf == NULL ) {
		string = GLServerVersion;
	    }
	    else {
		sprintf( buf, "%s (%s)", GLServerVersion, string );
		string = buf;
	    }
	}
    }
    if (string) {
	length = strlen((const char *) string) + 1;
    }

    __GLX_BEGIN_REPLY(length);
    __GLX_PUT_SIZE(length);

    if ( need_swap ) {
	__GLX_SWAP_REPLY_SIZE();
	__GLX_SWAP_REPLY_HEADER();
    }

    __GLX_SEND_HEADER();
    WriteToClient(client, length, (char *) string); 
    free(buf);

    return Success;
}
static int
ephyrGLXMakeCurrentReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap)
{
    int res = BadImplementation;
    xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) a_pc;
    xGLXMakeCurrentReply reply;
    DrawablePtr drawable = NULL;
    GLXContextTag contextTag = 0;
    int rc = 0;

    EPHYR_LOG("enter\n");
    rc = dixLookupDrawable(&drawable,
                           req->drawable, a_cl->client, 0, DixReadAccess);
    EPHYR_RETURN_VAL_IF_FAIL(drawable, BadValue);
    EPHYR_RETURN_VAL_IF_FAIL(drawable->pScreen, BadValue);
    EPHYR_LOG("screen nummber requested:%d\n", drawable->pScreen->myNum);

    if (!ephyrHostGLXMakeCurrent(hostx_get_window(drawable->pScreen->myNum),
                                 req->context,
                                 req->oldContextTag,
                                 (int *) &contextTag)) {
        EPHYR_LOG_ERROR("ephyrHostGLXMakeCurrent() failed\n");
        goto out;
    }
    reply = (xGLXMakeCurrentReply) {
        .type = X_Reply,
        .sequenceNumber = a_cl->client->sequence,
        .length = 0,
        .contextTag = contextTag
    };
    if (a_do_swap) {
        __GLX_DECLARE_SWAP_VARIABLES;
        __GLX_SWAP_SHORT(&reply.sequenceNumber);
        __GLX_SWAP_INT(&reply.length);
        __GLX_SWAP_INT(&reply.contextTag);
    }
    WriteToClient(a_cl->client, sz_xGLXMakeCurrentReply, &reply);

    res = Success;
 out:
    EPHYR_LOG("leave\n");
    return res;
}

int
ephyrGLXMakeCurrent(__GLXclientState * a_cl, GLbyte * a_pc)
{
    return ephyrGLXMakeCurrentReal(a_cl, a_pc, FALSE);
}

int
ephyrGLXMakeCurrentSwap(__GLXclientState * a_cl, GLbyte * a_pc)
{
    return ephyrGLXMakeCurrentReal(a_cl, a_pc, TRUE);
}

static int
ephyrGLXGetStringReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap)
{
    ClientPtr client = NULL;
    int context_tag = 0, name = 0, res = BadImplementation, length = 0;
    char *string = NULL;

    __GLX_DECLARE_SWAP_VARIABLES;

    EPHYR_RETURN_VAL_IF_FAIL(a_cl && a_pc, BadValue);

    EPHYR_LOG("enter\n");

    client = a_cl->client;

    if (a_do_swap) {
        __GLX_SWAP_INT(a_pc + 4);
        __GLX_SWAP_INT(a_pc + __GLX_SINGLE_HDR_SIZE);
    }
    context_tag = __GLX_GET_SINGLE_CONTEXT_TAG(a_pc);
    a_pc += __GLX_SINGLE_HDR_SIZE;
    name = *(GLenum *) (a_pc + 0);
    EPHYR_LOG("context_tag:%d, name:%d\n", context_tag, name);
    if (!ephyrHostGLXGetStringFromServer(context_tag,
                                         name,
                                         EPHYR_HOST_GLX_GetString, &string)) {
        EPHYR_LOG_ERROR("failed to get string from server\n");
        goto out;
    }
    if (string) {
        length = strlen(string) + 1;
        EPHYR_LOG("got string:'%s', size:%d\n", string, length);
    }
    else {
        EPHYR_LOG("got string: string (null)\n");
    }
    __GLX_BEGIN_REPLY(length);
    __GLX_PUT_SIZE(length);
    __GLX_SEND_HEADER();
    if (a_do_swap) {
        __GLX_SWAP_REPLY_SIZE();
        __GLX_SWAP_REPLY_HEADER();
    }
    WriteToClient(client, length, string);

    res = Success;
 out:
    EPHYR_LOG("leave\n");
    return res;
}