From 9b6c93e904e0880dc276885dcad35ff6ed4ccfc2 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 14 Sep 2016 10:58:55 +0200 Subject: vo_opengl: drm: use new EGL context creation code --- video/out/opengl/context_drm_egl.c | 49 ++++++-------------------------------- wscript | 2 +- 2 files changed, 8 insertions(+), 43 deletions(-) diff --git a/video/out/opengl/context_drm_egl.c b/video/out/opengl/context_drm_egl.c index e613fca38a..f3c0c660be 100644 --- a/video/out/opengl/context_drm_egl.c +++ b/video/out/opengl/context_drm_egl.c @@ -30,6 +30,7 @@ #include #include "context.h" +#include "egl_helpers.h" #include "common/common.h" #include "video/out/drm_common.h" @@ -75,33 +76,7 @@ struct priv { struct vt_switcher vt_switcher; }; -static EGLConfig select_fb_config_egl(struct MPGLContext *ctx, bool es) -{ - struct priv *p = ctx->priv; - const EGLint attributes[] = { - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_RED_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_BLUE_SIZE, 8, - EGL_ALPHA_SIZE, 0, - EGL_DEPTH_SIZE, 1, - EGL_RENDERABLE_TYPE, es ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_BIT, - EGL_NONE - }; - EGLint config_count; - EGLConfig config; - if (!eglChooseConfig(p->egl.display, attributes, &config, 1, &config_count)) { - MP_FATAL(ctx->vo, "Failed to configure EGL.\n"); - return NULL; - } - if (!config_count) { - MP_FATAL(ctx->vo, "Could not find EGL configuration!\n"); - return NULL; - } - return config; -} - -static bool init_egl(struct MPGLContext *ctx, bool es) +static bool init_egl(struct MPGLContext *ctx, int flags) { struct priv *p = ctx->priv; MP_VERBOSE(ctx->vo, "Initializing EGL\n"); @@ -114,20 +89,10 @@ static bool init_egl(struct MPGLContext *ctx, bool es) MP_ERR(ctx->vo, "Failed to initialize EGL.\n"); return false; } - if (!eglBindAPI(es ? EGL_OPENGL_ES_API : EGL_OPENGL_API)) { - MP_ERR(ctx->vo, "Failed to set EGL API version.\n"); - return false; - } - EGLConfig config = select_fb_config_egl(ctx, es); - if (!config) { - MP_ERR(ctx->vo, "Failed to configure EGL.\n"); - return false; - } - p->egl.context = eglCreateContext(p->egl.display, config, EGL_NO_CONTEXT, NULL); - if (!p->egl.context) { - MP_ERR(ctx->vo, "Failed to create EGL context.\n"); - return false; - } + EGLConfig config; + if (!mpegl_create_context(p->egl.display, ctx->vo->log, flags, + &p->egl.context, &config)) + return -1; MP_VERBOSE(ctx->vo, "Initializing EGL surface\n"); p->egl.surface = eglCreateWindowSurface(p->egl.display, config, p->gbm.surface, NULL); if (p->egl.surface == EGL_NO_SURFACE) { @@ -339,7 +304,7 @@ static int drm_egl_init(struct MPGLContext *ctx, int flags) return -1; } - if (!init_egl(ctx, flags & VOFLAG_GLES)) { + if (!init_egl(ctx, flags)) { MP_ERR(ctx->vo, "Failed to setup EGL.\n"); return -1; } diff --git a/wscript b/wscript index 1e97e89980..e01ae81af6 100644 --- a/wscript +++ b/wscript @@ -846,7 +846,7 @@ video_output_features = [ }, { 'name': 'egl-helpers', 'desc': 'EGL helper functions', - 'deps_any': [ 'egl-x11', 'mali-fbdev', 'rpi', 'gl-wayland' ], + 'deps_any': [ 'egl-x11', 'mali-fbdev', 'rpi', 'gl-wayland', 'egl-drm' ], 'func': check_true } ] -- cgit v1.2.3