static int ephyrGLXMakeCurrentReal(__GLXclientState * a_cl, GLXDrawable write, GLXDrawable read, GLXContextTag ctx, GLXContextTag old_ctx, Bool a_do_swap) { int res = BadImplementation; xGLXMakeCurrentReply reply; DrawablePtr drawableR = NULL, drawableW = NULL; GLXContextTag new_ctx = 0; EPHYR_LOG("enter\n"); res = dixLookupDrawable(&drawableW, write, a_cl->client, 0, DixReadAccess); EPHYR_RETURN_VAL_IF_FAIL(drawableW, BadValue); EPHYR_RETURN_VAL_IF_FAIL(drawableW->pScreen, BadValue); EPHYR_LOG("screen nummber requested:%d\n", drawableW->pScreen->myNum); if (read != write) { res = dixLookupDrawable(&drawableR, read, a_cl->client, 0, DixReadAccess); EPHYR_RETURN_VAL_IF_FAIL(drawableR, BadValue); EPHYR_RETURN_VAL_IF_FAIL(drawableR->pScreen, BadValue); } else { drawableR = drawableW; } if (!ephyrHostGLXMakeCurrent(hostx_get_window(drawableW->pScreen->myNum), hostx_get_window(drawableR->pScreen->myNum), ctx, old_ctx, (int *) &new_ctx)) { EPHYR_LOG_ERROR("ephyrHostGLXMakeCurrent() failed\n"); goto out; } reply = (xGLXMakeCurrentReply) { .type = X_Reply, .sequenceNumber = a_cl->client->sequence, .length = 0, .contextTag = new_ctx }; 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) { xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) a_pc; return ephyrGLXMakeCurrentReal(a_cl, req->drawable, req->drawable, req->context, req->oldContextTag, FALSE); }
static int ephyrGLXCreateContextReal(xGLXCreateContextReq * a_req, Bool a_do_swap) { int res = BadImplementation; EphyrHostWindowAttributes host_w_attrs; __GLX_DECLARE_SWAP_VARIABLES; EPHYR_RETURN_VAL_IF_FAIL(a_req, BadValue); EPHYR_LOG("enter\n"); if (a_do_swap) { __GLX_SWAP_SHORT(&a_req->length); __GLX_SWAP_INT(&a_req->context); __GLX_SWAP_INT(&a_req->visual); __GLX_SWAP_INT(&a_req->screen); __GLX_SWAP_INT(&a_req->shareList); } EPHYR_LOG("context creation requested. localid:%d, " "screen:%d, visual:%d, direct:%d\n", (int) a_req->context, (int) a_req->screen, (int) a_req->visual, (int) a_req->isDirect); memset(&host_w_attrs, 0, sizeof(host_w_attrs)); if (!hostx_get_window_attributes(hostx_get_window(a_req->screen), &host_w_attrs)) { EPHYR_LOG_ERROR("failed to get host window attrs\n"); goto out; } EPHYR_LOG("host window visual id: %d\n", host_w_attrs.visualid); if (!ephyrHostGLXCreateContext(a_req->screen, host_w_attrs.visualid, a_req->context, a_req->shareList, 0, a_req->isDirect, X_GLXCreateContext)) { EPHYR_LOG_ERROR("ephyrHostGLXCreateContext() failed\n"); goto out; } res = Success; out: EPHYR_LOG("leave\n"); return res; }
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; 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) ; memset (&reply, 0, sizeof (reply)) ; if (!ephyrHostGLXMakeCurrent (hostx_get_window (drawable->pScreen->myNum), req->context, req->oldContextTag, (int*)&reply.contextTag)) { EPHYR_LOG_ERROR ("ephyrHostGLXMakeCurrent() failed\n") ; goto out; } reply.length = 0; reply.type = X_Reply; reply.sequenceNumber = a_cl->client->sequence; 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, (char *)&reply); res = Success ; out: EPHYR_LOG ("leave\n") ; return res ; }
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; }