From cf21e7948f37952159efc4dbd6fe7daf305ad8e4 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Tue, 11 Jul 2017 14:26:25 -0400 Subject: glamor: Factor out glamor_egl_make_current Signed-off-by: Adam Jackson --- glamor/glamor_egl.c | 20 ++++++++++++++++++++ glamor/glamor_egl.h | 4 ++++ hw/xfree86/glamor_egl/xf86glamoregl.c | 19 ------------------- hw/xwayland/xwayland-glamor.c | 15 ++------------- 4 files changed, 26 insertions(+), 32 deletions(-) diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c index d88e5f197..3b70e78ad 100644 --- a/glamor/glamor_egl.c +++ b/glamor/glamor_egl.c @@ -23,6 +23,7 @@ #include "dix-config.h" #include "glamor_egl.h" +#include "glamor_context.h" /* * Create an EGLDisplay from a native display type. This is a little quirky @@ -50,3 +51,22 @@ glamor_egl_get_display(EGLint type, void *native) /* Welp, everything is awful. */ return eglGetDisplay(native); } + +void +glamor_egl_make_current(struct glamor_context *glamor_ctx) +{ + /* There's only a single global dispatch table in Mesa. EGL, GLX, + * and AIGLX's direct dispatch table manipulation don't talk to + * each other. We need to set the context to NULL first to avoid + * EGL's no-op context change fast path when switching back to + * EGL. + */ + eglMakeCurrent(glamor_ctx->display, EGL_NO_SURFACE, + EGL_NO_SURFACE, EGL_NO_CONTEXT); + + if (!eglMakeCurrent(glamor_ctx->display, + EGL_NO_SURFACE, EGL_NO_SURFACE, + glamor_ctx->ctx)) { + FatalError("Failed to make EGL context current\n"); + } +} diff --git a/glamor/glamor_egl.h b/glamor/glamor_egl.h index 094e4914a..63779611c 100644 --- a/glamor/glamor_egl.h +++ b/glamor/glamor_egl.h @@ -30,8 +30,12 @@ #define MESA_EGL_NO_X11_HEADERS #include #include +#include "glamor.h" EGLDisplay glamor_egl_get_display(EGLint type, void *native); +void +glamor_egl_make_current(struct glamor_context *glamor_ctx); + #endif diff --git a/hw/xfree86/glamor_egl/xf86glamoregl.c b/hw/xfree86/glamor_egl/xf86glamoregl.c index 1ac9ff347..3795ac21d 100644 --- a/hw/xfree86/glamor_egl/xf86glamoregl.c +++ b/hw/xfree86/glamor_egl/xf86glamoregl.c @@ -72,25 +72,6 @@ glamor_egl_get_screen_private(ScrnInfoPtr scrn) scrn->privates[xf86GlamorEGLPrivateIndex].ptr; } -static void -glamor_egl_make_current(struct glamor_context *glamor_ctx) -{ - /* There's only a single global dispatch table in Mesa. EGL, GLX, - * and AIGLX's direct dispatch table manipulation don't talk to - * each other. We need to set the context to NULL first to avoid - * EGL's no-op context change fast path when switching back to - * EGL. - */ - eglMakeCurrent(glamor_ctx->display, EGL_NO_SURFACE, - EGL_NO_SURFACE, EGL_NO_CONTEXT); - - if (!eglMakeCurrent(glamor_ctx->display, - EGL_NO_SURFACE, EGL_NO_SURFACE, - glamor_ctx->ctx)) { - FatalError("Failed to make EGL context current\n"); - } -} - static int glamor_get_flink_name(int fd, int handle, int *name) { diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c index cef798491..60d13d67a 100644 --- a/hw/xwayland/xwayland-glamor.c +++ b/hw/xwayland/xwayland-glamor.c @@ -47,17 +47,6 @@ struct xwl_pixmap { unsigned int texture; }; -static void -xwl_glamor_egl_make_current(struct glamor_context *glamor_ctx) -{ - eglMakeCurrent(glamor_ctx->display, EGL_NO_SURFACE, - EGL_NO_SURFACE, EGL_NO_CONTEXT); - if (!eglMakeCurrent(glamor_ctx->display, - EGL_NO_SURFACE, EGL_NO_SURFACE, - glamor_ctx->ctx)) - FatalError("Failed to make EGL context current\n"); -} - static uint32_t drm_format_for_depth(int depth) { @@ -98,7 +87,7 @@ glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx) glamor_ctx->ctx = xwl_screen->egl_context; glamor_ctx->display = xwl_screen->egl_display; - glamor_ctx->make_current = xwl_glamor_egl_make_current; + glamor_ctx->make_current = glamor_egl_make_current; xwl_screen->glamor_ctx = glamor_ctx; @@ -128,7 +117,7 @@ xwl_glamor_create_pixmap_for_bo(ScreenPtr screen, struct gbm_bo *bo, int depth) if (lastGLContext != xwl_screen->glamor_ctx) { lastGLContext = xwl_screen->glamor_ctx; - xwl_glamor_egl_make_current(xwl_screen->glamor_ctx); + glamor_egl_make_current(xwl_screen->glamor_ctx); } xwl_pixmap->bo = bo; -- cgit v1.2.3