[785/906] egl: Use EGL_KHR_surfaceless_context instead of creating a useless surface if available

This commit is contained in:
Sebastian Dröge 2013-07-24 13:34:20 +02:00 committed by Matthew Waters
parent 2952b923aa
commit ba1403fdd4

View file

@ -108,6 +108,8 @@ gst_gl_egl_create_context (EGLDisplay display, EGLNativeWindowType window,
EGLint context_attrib[3]; EGLint context_attrib[3];
EGLint majorVersion; EGLint majorVersion;
EGLint minorVersion; EGLint minorVersion;
const gchar *egl_exts;
gboolean need_surface = TRUE;
egl = g_slice_new0 (GstGLEGL); egl = g_slice_new0 (GstGLEGL);
@ -196,12 +198,13 @@ gst_gl_egl_create_context (EGLDisplay display, EGLNativeWindowType window,
goto failure; goto failure;
} }
egl_exts = eglQueryString (egl->egl_display, EGL_EXTENSIONS);
if (window) { if (window && FALSE) {
egl->egl_surface = egl->egl_surface =
eglCreateWindowSurface (egl->egl_display, egl->egl_config, window, eglCreateWindowSurface (egl->egl_display, egl->egl_config, window,
NULL); NULL);
} else { } else if (!gst_gl_check_extension ("EGL_KHR_surfaceless_context", egl_exts)) {
EGLint surface_attrib[7]; EGLint surface_attrib[7];
gint j = 0; gint j = 0;
@ -218,15 +221,21 @@ gst_gl_egl_create_context (EGLDisplay display, EGLNativeWindowType window,
egl->egl_surface = egl->egl_surface =
eglCreatePbufferSurface (egl->egl_display, egl->egl_config, eglCreatePbufferSurface (egl->egl_display, egl->egl_config,
surface_attrib); surface_attrib);
} else {
egl->egl_surface = EGL_NO_SURFACE;
need_surface = FALSE;
} }
if (need_surface) {
if (egl->egl_surface != EGL_NO_SURFACE) { if (egl->egl_surface != EGL_NO_SURFACE) {
GST_INFO ("surface created"); GST_INFO ("surface created");
} else { } else {
g_set_error (error, GST_GL_WINDOW_ERROR, GST_GL_WINDOW_ERROR_FAILED, g_set_error (error, GST_GL_WINDOW_ERROR, GST_GL_WINDOW_ERROR_FAILED,
"Failed to create window surface: %s", gst_gl_egl_get_error_string ()); "Failed to create window surface: %s",
gst_gl_egl_get_error_string ());
goto failure; goto failure;
} }
}
gst_gl_egl_activate (egl, TRUE); gst_gl_egl_activate (egl, TRUE);