static gboolean reset_context (GstVaapiDisplayEGL * display, EGLContext gl_context) { EglConfig *config; EglContext *ctx; egl_object_replace (&display->egl_context, NULL); if (gl_context != EGL_NO_CONTEXT) ctx = egl_context_new_wrapped (display->egl_display, gl_context); else { config = egl_config_new (display->egl_display, display->gles_version, GST_VIDEO_FORMAT_RGB); if (!config) return FALSE; ctx = egl_context_new (display->egl_display, config, NULL); egl_object_unref (config); } if (!ctx) return FALSE; egl_object_replace (&display->egl_context, ctx); egl_object_unref (ctx); return TRUE; }
static gboolean egl_window_init (EglWindow * window, EglContext * ctx, gpointer native_window) { EGLSurface gl_surface; window->context = egl_context_new (ctx->display, ctx->config, ctx); if (!window->context) return FALSE; ctx = window->context; gl_surface = eglCreateWindowSurface (ctx->display->base.handle.p, ctx->config->base.handle.p, (EGLNativeWindowType) native_window, NULL); if (!gl_surface) return FALSE; window->surface = egl_surface_new_wrapped (ctx->display, gl_surface); if (!window->surface) goto error_create_surface; window->base.handle.p = gl_surface; window->base.is_wrapped = FALSE; egl_context_set_surface (ctx, window->surface); return TRUE; /* ERRORS */ error_create_surface: GST_ERROR ("failed to create EGL wrapper surface"); eglDestroySurface (ctx->display->base.handle.p, gl_surface); return FALSE; }