EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLContext *context = _eglLookupContext(ctx, disp); _EGLSurface *draw_surf = _eglLookupSurface(draw, disp); _EGLSurface *read_surf = _eglLookupSurface(read, disp); _EGLDriver *drv; EGLBoolean ret; if (!disp) RETURN_EGL_ERROR(disp, EGL_BAD_DISPLAY, EGL_FALSE); drv = disp->Driver; /* display is allowed to be uninitialized under certain condition */ if (!disp->Initialized) { if (draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE || ctx != EGL_NO_CONTEXT) RETURN_EGL_ERROR(disp, EGL_BAD_DISPLAY, EGL_FALSE); } if (!drv) RETURN_EGL_SUCCESS(disp, EGL_TRUE); if (!context && ctx != EGL_NO_CONTEXT) RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_FALSE); if (!draw_surf || !read_surf) { /* surfaces may be NULL if surfaceless */ if (!disp->Extensions.KHR_surfaceless_gles1 && !disp->Extensions.KHR_surfaceless_gles2 && !disp->Extensions.KHR_surfaceless_opengl) RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE); if ((!draw_surf && draw != EGL_NO_SURFACE) || (!read_surf && read != EGL_NO_SURFACE)) RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE); if (draw_surf || read_surf) RETURN_EGL_ERROR(disp, EGL_BAD_MATCH, EGL_FALSE); } ret = drv->API.MakeCurrent(drv, disp, draw_surf, read_surf, context); RETURN_EGL_EVAL(disp, ret); }
EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLSurface *surf = _eglLookupSurface(surface, disp); _EGLDriver *drv; EGLBoolean ret; _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); ret = drv->API.ReleaseTexImage(drv, disp, surf, buffer); RETURN_EGL_EVAL(disp, ret); }
EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLSurface *surf = _eglLookupSurface(surface, disp); _EGLDriver *drv; EGLBoolean ret; _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); ret = drv->API.SurfaceAttrib(drv, disp, surf, attribute, value); RETURN_EGL_EVAL(disp, ret); }
EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface) { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLSurface *surf = _eglLookupSurface(surface, disp); _EGLDriver *drv; EGLBoolean ret; _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); _eglUnlinkSurface(surf); ret = drv->API.DestroySurface(drv, disp, surf); RETURN_EGL_EVAL(disp, ret); }
EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLSurface *surf = _eglLookupSurface(surface, disp); _EGLDriver *drv; EGLBoolean ret; _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); if (disp->Platform != _eglGetNativePlatform(disp->PlatformDisplay)) RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_PIXMAP, EGL_FALSE); ret = drv->API.CopyBuffers(drv, disp, surf, target); RETURN_EGL_EVAL(disp, ret); }
EGLBoolean EGLAPIENTRY eglPostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height) { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLSurface *surf = _eglLookupSurface(surface, disp); _EGLDriver *drv; EGLBoolean ret; _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); if (!disp->Extensions.NV_post_sub_buffer) RETURN_EGL_EVAL(disp, EGL_FALSE); ret = drv->API.PostSubBufferNV(drv, disp, surf, x, y, width, height); RETURN_EGL_EVAL(disp, ret); }
EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) { _EGLContext *ctx = _eglGetCurrentContext(); _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLSurface *surf = _eglLookupSurface(surface, disp); _EGLDriver *drv; EGLBoolean ret; _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); /* surface must be bound to current context in EGL 1.4 */ if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || surf != ctx->DrawSurface) RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE); ret = drv->API.SwapBuffers(drv, disp, surf); RETURN_EGL_EVAL(disp, ret); }
EGLBoolean EGLAPIENTRY eglShowScreenSurfaceMESA(EGLDisplay dpy, EGLint screen, EGLSurface surface, EGLModeMESA mode) { _EGLDisplay *disp = _eglLockDisplay(dpy); _EGLScreen *scrn = _eglLookupScreen((EGLScreenMESA) screen, disp); _EGLSurface *surf = _eglLookupSurface(surface, disp); _EGLMode *m = _eglLookupMode(mode, disp); _EGLDriver *drv; EGLBoolean ret; _EGL_CHECK_SCREEN(disp, scrn, EGL_FALSE, drv); if (!surf && surface != EGL_NO_SURFACE) RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE); if (!m && mode != EGL_NO_MODE_MESA) RETURN_EGL_ERROR(disp, EGL_BAD_MODE_MESA, EGL_FALSE); ret = drv->API.ShowScreenSurfaceMESA(drv, disp, scrn, surf, m); RETURN_EGL_EVAL(disp, ret); }
/** * Show the given surface on the named screen. * If surface is EGL_NO_SURFACE, disable the screen's output. * * This is just a placeholder function; drivers will always override * this with code that _really_ shows the surface. */ EGLBoolean _eglShowScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLSurface surface, EGLModeMESA m) { _EGLScreen *scrn = _eglLookupScreen(dpy, screen); _EGLMode *mode = _eglLookupMode(dpy, m); if (!scrn) { _eglError(EGL_BAD_SCREEN_MESA, "eglShowSurfaceMESA"); return EGL_FALSE; } if (!mode && (m != EGL_NO_MODE_MESA )) { _eglError(EGL_BAD_MODE_MESA, "eglShowSurfaceMESA"); return EGL_FALSE; } if (surface == EGL_NO_SURFACE) { scrn->CurrentSurface = NULL; } else { _EGLSurface *surf = _eglLookupSurface(surface); if (!surf || surf->Type != EGL_SCREEN_BIT_MESA) { _eglError(EGL_BAD_SURFACE, "eglShowSurfaceMESA"); return EGL_FALSE; } if (surf->Width < mode->Width || surf->Height < mode->Height) { _eglError(EGL_BAD_SURFACE, "eglShowSurfaceMESA(surface smaller than screen size)"); return EGL_FALSE; } scrn->CurrentSurface = surf; scrn->CurrentMode = mode; } return EGL_TRUE; }
static fbSurface * Lookup_fbSurface(EGLSurface surf) { _EGLSurface *s = _eglLookupSurface(surf); return (fbSurface *) s; }
static struct xlib_egl_surface * lookup_surface(EGLSurface surf) { _EGLSurface *surface = _eglLookupSurface(surf); return (struct xlib_egl_surface *) surface; }
/** * Drivers will typically call this to do the error checking and * update the various IsBound and DeletePending flags. * Then, the driver will do its device-dependent Make-Current stuff. */ EGLBoolean _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d, EGLSurface r, EGLContext context) { _EGLThreadInfo *t = _eglGetCurrentThread(); _EGLContext *ctx = _eglLookupContext(context); _EGLSurface *draw = _eglLookupSurface(d); _EGLSurface *read = _eglLookupSurface(r); _EGLContext *oldContext = _eglGetCurrentContext(); _EGLSurface *oldDrawSurface = _eglGetCurrentSurface(EGL_DRAW); _EGLSurface *oldReadSurface = _eglGetCurrentSurface(EGL_READ); /* error checking */ if (ctx) { if (draw == NULL || read == NULL) { _eglError(EGL_BAD_MATCH, "eglMakeCurrent"); return EGL_FALSE; } if (draw->Config != ctx->Config) { _eglError(EGL_BAD_MATCH, "eglMakeCurrent"); return EGL_FALSE; } if (read->Config != ctx->Config) { _eglError(EGL_BAD_MATCH, "eglMakeCurrent"); return EGL_FALSE; } } /* * check if the old context or surfaces need to be deleted */ if (oldDrawSurface != NULL) { oldDrawSurface->IsBound = EGL_FALSE; if (oldDrawSurface->DeletePending) { /* make sure we don't try to rebind a deleted surface */ if (draw == oldDrawSurface || draw == oldReadSurface) { draw = NULL; } /* really delete surface now */ drv->API.DestroySurface(drv, dpy, oldDrawSurface->Handle); } } if (oldReadSurface != NULL && oldReadSurface != oldDrawSurface) { oldReadSurface->IsBound = EGL_FALSE; if (oldReadSurface->DeletePending) { /* make sure we don't try to rebind a deleted surface */ if (read == oldDrawSurface || read == oldReadSurface) { read = NULL; } /* really delete surface now */ drv->API.DestroySurface(drv, dpy, oldReadSurface->Handle); } } if (oldContext != NULL) { oldContext->IsBound = EGL_FALSE; if (oldContext->DeletePending) { /* make sure we don't try to rebind a deleted context */ if (ctx == oldContext) { ctx = NULL; } /* really delete context now */ drv->API.DestroyContext(drv, dpy, oldContext->Handle); } } if (ctx) { /* check read/draw again, in case we deleted them above */ if (draw == NULL || read == NULL) { _eglError(EGL_BAD_MATCH, "eglMakeCurrent"); return EGL_FALSE; } ctx->DrawSurface = draw; ctx->ReadSurface = read; ctx->IsBound = EGL_TRUE; draw->IsBound = EGL_TRUE; read->IsBound = EGL_TRUE; } t->CurrentContext = ctx; return EGL_TRUE; }