[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,14 +221,20 @@ 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 (egl->egl_surface != EGL_NO_SURFACE) { if (need_surface) {
GST_INFO ("surface created"); if (egl->egl_surface != EGL_NO_SURFACE) {
} else { GST_INFO ("surface created");
g_set_error (error, GST_GL_WINDOW_ERROR, GST_GL_WINDOW_ERROR_FAILED, } else {
"Failed to create window surface: %s", gst_gl_egl_get_error_string ()); g_set_error (error, GST_GL_WINDOW_ERROR, GST_GL_WINDOW_ERROR_FAILED,
goto failure; "Failed to create window surface: %s",
gst_gl_egl_get_error_string ());
goto failure;
}
} }
gst_gl_egl_activate (egl, TRUE); gst_gl_egl_activate (egl, TRUE);