/** * Called via eglMakeCurrent(), drv->API.MakeCurrent(). */ static EGLBoolean xdri_eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *d, _EGLSurface *r, _EGLContext *context) { struct xdri_egl_context *xdri_ctx = lookup_context(context); struct xdri_egl_surface *draw = lookup_surface(d); struct xdri_egl_surface *read = lookup_surface(r); if (!_eglMakeCurrent(drv, dpy, d, r, context)) return EGL_FALSE; /* the symbol is defined in libGL.so */ _glapi_check_multithread(); if (xdri_ctx) { if (!xdri_ctx->driContext->bindContext(xdri_ctx->driContext, draw->driDrawable, read->driDrawable)) { return EGL_FALSE; } } else { _EGLContext *old = _eglGetCurrentContext(); if (old) { xdri_ctx = lookup_context(old); xdri_ctx->driContext->unbindContext(xdri_ctx->driContext); } } return EGL_TRUE; }
static EGLBoolean xlib_eglDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx) { struct xlib_egl_context *context = lookup_context(ctx); if (context) { if (context->Base.IsBound) { context->Base.DeletePending = EGL_TRUE; } else { /* API-dependent clean-up */ switch (context->Base.ClientAPI) { case EGL_OPENGL_ES_API: /* fall-through */ case EGL_OPENGL_API: st_destroy_context(context->Context); break; default: assert(0); } free(context); } return EGL_TRUE; } else { _eglError(EGL_BAD_CONTEXT, "eglDestroyContext"); return EGL_TRUE; } }
HOT_INLINE static void cb_Exit( hot_contextID_t id, unsigned *cs ) { hot_context_t s; hot_ens_Exit_cback exit_cb; void *env; begin_critical(); { s = lookup_context(id); if (!s->leaving) hot_sys_Panic("hot_ens_Exit_cbd: mbr state is not leaving"); env = s->env; exit_cb = s->conf.exit; } end_critical(); if (exit_cb != NULL) { (*exit_cb)(s, env); } begin_critical(); { release_context(s); } end_critical(); }
HOT_INLINE static void cb_Block( hot_contextID_t id, unsigned *cs ) { hot_context_t s; void *env; hot_ens_Block_cback block; begin_critical(); { s = lookup_context(id); env = s->env; block = s->conf.block; s->blocked = 1; } end_critical(); if (block != NULL) { (*block)(s, env); } /* Write the block_ok downcall. */ begin_write(); { write_hdr(s,DN_BLOCK_OK) ; } end_write(); }
HOT_INLINE static void cb_Send( hot_contextID_t id, unsigned *cs ) { hot_err_t err; hot_endpt_t endpt ; hot_uint32 origin ; hot_msg_t msg; hot_context_t s; void *env; hot_ens_ReceiveSend_cback receive_send; trace("cb_Send"); read_int(&origin); read_msg(&msg); begin_critical(); { s = lookup_context(id); env = s->env; assert(origin < s->nmembers) ; endpt = s->view[origin] ; receive_send = s->conf.receive_send; } end_critical(); if (receive_send != NULL) { trace("receive_send"); (*receive_send)(s, env, &endpt, msg); } err = hot_msg_Release(&msg); if (err != HOT_OK) hot_sys_Panic(hot_err_ErrString(err)); }
/** * Called via eglCreateContext(), drv->API.CreateContext(). */ static _EGLContext * xdri_eglCreateContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, _EGLContext *share_list, const EGLint *attrib_list) { struct xdri_egl_display *xdri_dpy = lookup_display(dpy); struct xdri_egl_config *xdri_config = lookup_config(conf); struct xdri_egl_context *shared = lookup_context(share_list); __GLXscreenConfigs *psc = xdri_dpy->psc; int renderType = GLX_RGBA_BIT; struct xdri_egl_context *xdri_ctx; xdri_ctx = CALLOC_STRUCT(xdri_egl_context); if (!xdri_ctx) { _eglError(EGL_BAD_ALLOC, "eglCreateContext"); return NULL; } xdri_ctx->dummy_gc = CALLOC_STRUCT(__GLXcontextRec); if (!xdri_ctx->dummy_gc) { _eglError(EGL_BAD_ALLOC, "eglCreateContext"); free(xdri_ctx); return NULL; } if (!_eglInitContext(drv, &xdri_ctx->Base, &xdri_config->Base, attrib_list)) { free(xdri_ctx->dummy_gc); free(xdri_ctx); return NULL; } /* the config decides the render buffer for the context */ xdri_ctx->Base.WindowRenderBuffer = xdri_config->window_render_buffer; xdri_ctx->driContext = psc->driScreen->createContext(psc, xdri_config->mode, xdri_ctx->dummy_gc, (shared) ? shared->dummy_gc : NULL, renderType); if (!xdri_ctx->driContext) { free(xdri_ctx->dummy_gc); free(xdri_ctx); return NULL; } /* fill in the required field */ xdri_ctx->dummy_gc->driContext = xdri_ctx->driContext; return &xdri_ctx->Base; }
static EGLBoolean xdri_eglDestroyContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) { struct xdri_egl_display *xdri_dpy = lookup_display(dpy); struct xdri_egl_context *xdri_ctx = lookup_context(ctx); if (!_eglIsContextBound(ctx)) { xdri_ctx->driContext->destroyContext(xdri_ctx->driContext, xdri_dpy->psc, xdri_dpy->dpy); free(xdri_ctx->dummy_gc); free(xdri_ctx); } return EGL_TRUE; }
/** * Called via eglMakeCurrent(), drv->API.MakeCurrent(). */ static EGLBoolean xlib_eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) { struct xlib_egl_context *context = lookup_context(ctx); struct xlib_egl_surface *draw_surf = lookup_surface(draw); struct xlib_egl_surface *read_surf = lookup_surface(read); if (!_eglMakeCurrent(drv, dpy, draw, read, context)) return EGL_FALSE; st_make_current((context ? context->Context : NULL), (draw_surf ? draw_surf->Framebuffer : NULL), (read_surf ? read_surf->Framebuffer : NULL)); if (draw_surf) check_and_update_buffer_size(draw_surf); if (read_surf && read_surf != draw_surf) check_and_update_buffer_size(draw_surf); return EGL_TRUE; }
HOT_INLINE static void cb_Heartbeat( hot_contextID_t id, unsigned *cs ) { hot_context_t s; void *env; hot_uint32 t; hot_ens_Heartbeat_cback heartbeat; read_int(&t); begin_critical(); { s = lookup_context(id); env = s->env; heartbeat = s->conf.heartbeat; } end_critical(); if (heartbeat != NULL) { (*heartbeat)(s, env, t); } }
HOT_INLINE static void cb_View( hot_contextID_t id, unsigned *cs ) { hot_uint32 tmp ; hot_view_state_t vs; hot_context_t s; void *env; hot_ens_AcceptedView_cback accepted_view; unsigned ncl; trace("VIEW"); read_string_prealloc(vs.version); trace("\t version: %s", vs.version); read_string_prealloc(vs.group_name); trace("\t group_name: %s", vs.group_name); read_endpList(&vs.nmembers, &vs.members); trace("\t nmembers: %d", vs.nmembers); { unsigned i; for (i = 0; i < vs.nmembers; i++) trace("\t\t member[%d] = %s", i, vs.members[i].name); } read_int(&tmp) ; vs.rank = tmp ; trace("\t rank: %d", vs.rank); read_string_prealloc(vs.protocol); trace("\t protocol: %s", vs.protocol); read_bool(&vs.groupd); trace("\t groupd: %d", vs.groupd); read_int(&tmp); vs.view_id.ltime = tmp ; trace("\t view_id.ltime: %d", vs.view_id.ltime); read_endpID(&vs.view_id.coord); trace("\t view_id.coord: %s", vs.view_id.coord.name); read_string_prealloc(vs.params); trace("\t params: %s", vs.params); read_bool(&vs.xfer_view); trace("\t xfer_view: %d", vs.xfer_view); read_bool(&vs.primary); trace("\t primary: %d", vs.primary); read_boolList(&ncl, &vs.clients); assert(ncl == vs.nmembers); read_string_prealloc(vs.key); trace("\t key: %s", vs.key); begin_critical(); { s = lookup_context(id); env = s->env; accepted_view = s->conf.accepted_view; /* The group is unblocked now. */ s->blocked = 0; } end_critical(); if (s->view) { assert(s->nmembers > 0) ; release_endpt_array(ch_endpt_array, s->view, s->nmembers) ; } s->nmembers = vs.nmembers ; assert(s->nmembers > 0) ; s->view = alloc_endpt_array(ch_endpt_array, s->nmembers) ; memcpy(s->view,vs.members,s->nmembers * sizeof(*vs.members)) ; if (accepted_view != NULL) { (*accepted_view)(s, env, &vs); } begin_critical(); { if (vs.members != NULL) { release_endpt_array(ch_endpt_array, vs.members, vs.nmembers) ; } if (vs.clients != NULL) { release_bool_array(ch_bool_array, vs.clients, vs.nmembers) ; } s->joining = 0 ; } end_critical(); }