From bc5d65928f444c66986e28e60eeb97cf04ca7351 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Mon, 17 Jun 2013 19:45:27 +1000 Subject: [PATCH] [716/906] wayland: properly choose EGL_RENDERABLE_TYPE based on the gl api we chose --- gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c | 69 +++++++++++++++-------- gst-libs/gst/gl/x11/gstglwindow_x11_egl.c | 7 ++- 2 files changed, 51 insertions(+), 25 deletions(-) diff --git a/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c b/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c index cbe5c61..ad0d603 100644 --- a/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c +++ b/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c @@ -363,31 +363,53 @@ error: return FALSE; } + +static gboolean +_gst_gl_window_wayland_egl_choose_config (GstGLWindowWaylandEGL * window_egl, + GError ** error) +{ + EGLint numConfigs; + gint i = 0; + EGLint config_attrib[20]; + + config_attrib[i++] = EGL_SURFACE_TYPE; + config_attrib[i++] = EGL_WINDOW_BIT; + config_attrib[i++] = EGL_RENDERABLE_TYPE; + if (window_egl->gl_api & GST_GL_API_GLES2) + config_attrib[i++] = EGL_OPENGL_ES2_BIT; + else + config_attrib[i++] = EGL_OPENGL_BIT; + config_attrib[i++] = EGL_DEPTH_SIZE; + config_attrib[i++] = 16; + config_attrib[i++] = EGL_NONE; + + if (eglChooseConfig (window_egl->egl_display, config_attrib, + &window_egl->egl_config, 1, &numConfigs)) + GST_INFO ("config set: %ld, %ld", (gulong) window_egl->egl_config, + (gulong) numConfigs); + else { + g_set_error (error, GST_GL_WINDOW_ERROR, GST_GL_WINDOW_ERROR_WRONG_CONFIG, + "Failed to set window configuration: %s", WlEGLErrorString ()); + goto failure; + } + + return TRUE; + +failure: + return FALSE; +} + gboolean gst_gl_window_wayland_egl_create_context (GstGLWindow * window, GstGLAPI gl_api, guintptr external_gl_context, GError ** error) { GstGLWindowWaylandEGL *window_egl = GST_GL_WINDOW_WAYLAND_EGL (window); - EGLint config_attrib[] = { - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_RED_SIZE, 1, - EGL_GREEN_SIZE, 1, - EGL_BLUE_SIZE, 1, - EGL_ALPHA_SIZE, 1, - EGL_DEPTH_SIZE, 1, - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - EGL_NONE - }; - - EGLint context_attrib[] = { - EGL_CONTEXT_CLIENT_VERSION, 2, - EGL_NONE - }; + EGLint context_attrib[3]; + gint i = 0; EGLint majorVersion; EGLint minorVersion; - EGLint numConfigs; if (!_setup_wayland (window_egl, error)) return FALSE; @@ -445,18 +467,19 @@ gst_gl_window_wayland_egl_create_context (GstGLWindow * window, window_egl->gl_api = GST_GL_API_GLES2; } - if (eglChooseConfig (window_egl->egl_display, config_attrib, - &window_egl->egl_config, 1, &numConfigs)) - GST_DEBUG ("config set: %ld, %ld", (gulong) window_egl->egl_config, - (gulong) numConfigs); - else { - g_set_error (error, GST_GL_WINDOW_ERROR, GST_GL_WINDOW_ERROR_WRONG_CONFIG, - "Failed to set window configuration: %s", WlEGLErrorString ()); + if (!_gst_gl_window_wayland_egl_choose_config (window_egl, error)) { + g_assert (error == NULL || *error != NULL); goto failure; } GST_DEBUG ("about to create gl context"); + if (window_egl->gl_api & GST_GL_API_GLES2) { + context_attrib[i++] = EGL_CONTEXT_CLIENT_VERSION; + context_attrib[i++] = 2; + } + context_attrib[i++] = EGL_NONE; + window_egl->egl_context = eglCreateContext (window_egl->egl_display, window_egl->egl_config, (EGLContext) external_gl_context, context_attrib); diff --git a/gst-libs/gst/gl/x11/gstglwindow_x11_egl.c b/gst-libs/gst/gl/x11/gstglwindow_x11_egl.c index e8af671..e21158a 100644 --- a/gst-libs/gst/gl/x11/gstglwindow_x11_egl.c +++ b/gst-libs/gst/gl/x11/gstglwindow_x11_egl.c @@ -108,7 +108,7 @@ gst_gl_window_x11_egl_choose_format (GstGLWindowX11 * window_x11, } static gboolean -gst_gl_window_x11_egl_choose_config (GstGLWindowX11EGL * window_egl, +_gst_gl_window_x11_egl_choose_config (GstGLWindowX11EGL * window_egl, GError ** error) { EGLint numConfigs; @@ -215,7 +215,10 @@ gst_gl_window_x11_egl_create_context (GstGLWindowX11 * window_x11, window_egl->gl_api = GST_GL_API_GLES2; } - gst_gl_window_x11_egl_choose_config (window_egl, error); + if (!_gst_gl_window_x11_egl_choose_config (window_egl, error)) { + g_assert (error == NULL || *error != NULL); + goto failure; + } window_egl->egl_surface = eglCreateWindowSurface (window_egl->egl_display, window_egl->egl_config, -- 2.7.4