GLboolean nouveau_context_bind(__DRIcontextPrivate *driContextPriv, __DRIdrawablePrivate *driDrawPriv, __DRIdrawablePrivate *driReadPriv) { struct nouveau_context *nv; struct nouveau_framebuffer *draw, *read; if (!driContextPriv) { st_make_current(NULL, NULL, NULL); return GL_TRUE; } nv = driContextPriv->driverPrivate; draw = driDrawPriv->driverPrivate; read = driReadPriv->driverPrivate; st_make_current(nv->st, draw->stfb, read->stfb); if ((nv->dri_drawable != driDrawPriv) || (nv->last_stamp != driDrawPriv->lastStamp)) { nv->dri_drawable = driDrawPriv; st_resize_framebuffer(draw->stfb, driDrawPriv->w, driDrawPriv->h); nv->last_stamp = driDrawPriv->lastStamp; } if (driDrawPriv != driReadPriv) { st_resize_framebuffer(read->stfb, driReadPriv->w, driReadPriv->h); } return GL_TRUE; }
bool hsp_delete_context(uint64 ctxId) { TRACE("%s(ctxId: %d)\n", __FUNCTION__, ctxId); struct hsp_context *ctx = NULL; bool ret = false; if (!hsp_dev) { TRACE("%s> there's no hsp_dev so nothing to do\n", __FUNCTION__); return false; } pipe_mutex_lock(hsp_dev->mutex); ctx = hsp_lookup_context(ctxId); if (ctx) { TRACE("%s> found context: %p\n", __FUNCTION__, ctx); GLcontext *glctx = ctx->st->ctx; GET_CURRENT_CONTEXT(glcurctx); if (glcurctx == glctx) st_make_current(NULL, NULL, NULL); if (ctx->draw) { TRACE("%s> found context draw framebuffer, destroying: %p\n", __FUNCTION__, ctx->draw); framebuffer_destroy(ctx->draw); } if (ctx->read) { TRACE("%s> found context read framebuffer, destroying: %p\n", __FUNCTION__, ctx->read); framebuffer_destroy(ctx->read); } #warning TODO: destroy ctx->bitmap here ? st_destroy_context(ctx->st); FREE(ctx); hsp_dev->ctx_array[ctxId - 1].ctx = NULL; ret = true; } pipe_mutex_unlock(hsp_dev->mutex); return ret; }
/** * 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; }
bool hsp_make_current(Bitmap *bitmap, uint64 ctxId) { TRACE("%s(bitmap: %p ctxId: %d)\n", __FUNCTION__, bitmap, ctxId); struct hsp_context *ctx = NULL; GET_CURRENT_CONTEXT(glcurctx); GLuint width = 0; GLuint height = 0; struct hsp_context *curctx; if (!hsp_dev) { TRACE("%s> there's no hsp_dev so nothing to do\n", __FUNCTION__); return false; } pipe_mutex_lock(hsp_dev->mutex); ctx = hsp_lookup_context(ctxId); pipe_mutex_unlock(hsp_dev->mutex); if (ctx == NULL) { TRACE("%s> context not found\n", __FUNCTION__); return false; } current_bitmap = bitmap; current_ctx_id = ctxId; if (glcurctx != NULL) { curctx = (struct hsp_context*) glcurctx->DriverCtx; if (curctx != ctx) st_flush(glcurctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); } if (!bitmap || ctxId == 0) { st_make_current(NULL, NULL, NULL); return true; } if (glcurctx != NULL) { struct hsp_context *curctx = (struct hsp_context*) glcurctx->DriverCtx; if (curctx != NULL && curctx == ctx && ctx->bitmap == bitmap) return true; } if (bitmap != NULL) { get_bitmap_size(bitmap, &width, &height); TRACE("%s> found bitmap: %p with size: %dx%d\n", __FUNCTION__, bitmap, width, height); } if (ctx != NULL && bitmap != NULL ) { GLvisual *visual = &ctx->st->ctx->Visual; if (ctx->draw == NULL) { ctx->draw = framebuffer_create(bitmap, visual, width /*+ 1*/, height /*+ 1*/); } if ((hsp_dev->options & BGL_DOUBLE) == BGL_DOUBLE && ctx->read == NULL) { ctx->read = framebuffer_create(bitmap, visual, width /*+ 1*/, height /*+ 1*/); } } if (ctx) { if (ctx->draw && ctx->read == NULL) { st_make_current(ctx->st, ctx->draw->stfb, ctx->draw->stfb); framebuffer_resize(ctx->draw, width /*+ 1*/, height /*+ 1*/); } else if (ctx && ctx->draw && ctx->read) { st_make_current(ctx->st, ctx->draw->stfb, ctx->read->stfb); framebuffer_resize(ctx->draw, width /*+ 1*/, height /*+ 1*/); framebuffer_resize(ctx->read, width /*+ 1*/, height /*+ 1*/); } ctx->bitmap = bitmap; ctx->st->pipe->priv = bitmap; } else { st_make_current(NULL, NULL, NULL); } return true; }