diff options
author | Marek Olšák <[email protected]> | 2016-03-03 15:59:48 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2016-04-20 12:18:47 +0200 |
commit | b6eda708431b91a3b568da0efac845c08cb36796 (patch) | |
tree | 4d80c1559be8195b4f2cbd5b0b3cf1bc7414fc29 /src/egl/main | |
parent | 5e9ed261ed8ec211ba9bf5aa58d50078304583ff (diff) |
egl: implement EGL part of interop interface (v2)
v2: - use const
Diffstat (limited to 'src/egl/main')
-rw-r--r-- | src/egl/main/eglapi.c | 72 | ||||
-rw-r--r-- | src/egl/main/eglapi.h | 9 |
2 files changed, 81 insertions, 0 deletions
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 64ffe92be43..eb612c00f64 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -88,6 +88,7 @@ #include <string.h> #include "c99_compat.h" #include "c11/threads.h" +#include "GL/mesa_glinterop.h" #include "eglcompiler.h" #include "eglglobals.h" @@ -1912,3 +1913,74 @@ eglGetProcAddress(const char *procname) RETURN_EGL_SUCCESS(NULL, ret); } + +static int +_eglLockDisplayInterop(EGLDisplay dpy, EGLContext context, + _EGLDisplay **disp, _EGLDriver **drv, + _EGLContext **ctx) +{ + + *disp = _eglLockDisplay(dpy); + if (!*disp || !(*disp)->Initialized || !(*disp)->Driver) { + if (*disp) + _eglUnlockDisplay(*disp); + return MESA_GLINTEROP_INVALID_DISPLAY; + } + + *drv = (*disp)->Driver; + + *ctx = _eglLookupContext(context, *disp); + if (!*ctx || + ((*ctx)->ClientAPI != EGL_OPENGL_API && + (*ctx)->ClientAPI != EGL_OPENGL_ES_API)) { + _eglUnlockDisplay(*disp); + return MESA_GLINTEROP_INVALID_CONTEXT; + } + + return MESA_GLINTEROP_SUCCESS; +} + +GLAPI int GLAPIENTRY +MesaGLInteropEGLQueryDeviceInfo(EGLDisplay dpy, EGLContext context, + mesa_glinterop_device_info *out) +{ + _EGLDisplay *disp; + _EGLDriver *drv; + _EGLContext *ctx; + int ret; + + ret = _eglLockDisplayInterop(dpy, context, &disp, &drv, &ctx); + if (ret != MESA_GLINTEROP_SUCCESS) + return ret; + + if (drv->API.GLInteropQueryDeviceInfo) + ret = drv->API.GLInteropQueryDeviceInfo(disp, ctx, out); + else + ret = MESA_GLINTEROP_UNSUPPORTED; + + _eglUnlockDisplay(disp); + return ret; +} + +GLAPI int GLAPIENTRY +MesaGLInteropEGLExportObject(EGLDisplay dpy, EGLContext context, + const mesa_glinterop_export_in *in, + mesa_glinterop_export_out *out) +{ + _EGLDisplay *disp; + _EGLDriver *drv; + _EGLContext *ctx; + int ret; + + ret = _eglLockDisplayInterop(dpy, context, &disp, &drv, &ctx); + if (ret != MESA_GLINTEROP_SUCCESS) + return ret; + + if (drv->API.GLInteropExportObject) + ret = drv->API.GLInteropExportObject(disp, ctx, in, out); + else + ret = MESA_GLINTEROP_UNSUPPORTED; + + _eglUnlockDisplay(disp); + return ret; +} diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h index 3f6d3c27a52..58327fd1015 100644 --- a/src/egl/main/eglapi.h +++ b/src/egl/main/eglapi.h @@ -42,6 +42,9 @@ extern "C" { typedef void (*_EGLProc)(void); struct wl_display; +typedef struct _mesa_glinterop_device_info mesa_glinterop_device_info; +typedef struct _mesa_glinterop_export_in mesa_glinterop_export_in; +typedef struct _mesa_glinterop_export_out mesa_glinterop_export_out; /** * The API dispatcher jumps through these functions @@ -188,6 +191,12 @@ struct _egl_api EGLBoolean (*ExportDMABUFImageMESA)(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, EGLint *fds, EGLint *strides, EGLint *offsets); + + int (*GLInteropQueryDeviceInfo)(_EGLDisplay *dpy, _EGLContext *ctx, + mesa_glinterop_device_info *out); + int (*GLInteropExportObject)(_EGLDisplay *dpy, _EGLContext *ctx, + const mesa_glinterop_export_in *in, + mesa_glinterop_export_out *out); }; |