[gtk/gst.gl.win32: 6/6] gtkgstsink.c: Support EGL on Windows as well
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gst.gl.win32: 6/6] gtkgstsink.c: Support EGL on Windows as well
- Date: Mon, 17 May 2021 08:52:10 +0000 (UTC)
commit e46cbee52fef59c8343ef63328f4e2db66ead9ca
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Mon May 17 16:04:53 2021 +0800
gtkgstsink.c: Support EGL on Windows as well
Add support to look for and use the EGL context in Windows if it was activated
instead of desktop OpenGL
modules/media/gtkgstsink.c | 36 +++++++++++++++++++++++-------------
1 file changed, 23 insertions(+), 13 deletions(-)
---
diff --git a/modules/media/gtkgstsink.c b/modules/media/gtkgstsink.c
index a08e4646c7..91ce989188 100644
--- a/modules/media/gtkgstsink.c
+++ b/modules/media/gtkgstsink.c
@@ -42,7 +42,7 @@
#include <gst/gl/wayland/gstgldisplay_wayland.h>
#endif
-#if GST_GL_HAVE_WINDOW_WIN32 && GST_GL_HAVE_PLATFORM_WGL && defined (GDK_WINDOWING_WIN32)
+#if GST_GL_HAVE_WINDOW_WIN32 && (GST_GL_HAVE_PLATFORM_WGL || GST_GL_HAVE_PLATFORM_EGL) && defined
(GDK_WINDOWING_WIN32)
#include <gdk/win32/gdkwin32.h>
#include <epoxy/wgl.h>
#endif
@@ -353,11 +353,18 @@ gtk_gst_sink_show_frame (GstVideoSink *vsink,
return GST_FLOW_OK;
}
-#if GST_GL_HAVE_WINDOW_WIN32 && GST_GL_HAVE_PLATFORM_WGL && defined (GDK_WINDOWING_WIN32)
-#define HANDLE_EXTERNAL_WGL_MAKE_CURRENT epoxy_handle_external_wglMakeCurrent()
+#if GST_GL_HAVE_WINDOW_WIN32 && (GST_GL_HAVE_PLATFORM_WGL || GST_GL_HAVE_PLATFORM_EGL) && defined
(GDK_WINDOWING_WIN32)
+#define HANDLE_EXTERNAL_WGL_MAKE_CURRENT(ctx) handle_wgl_makecurrent(ctx)
#define DEACTIVATE_WGL_CONTEXT(ctx) deactivate_gdk_wgl_context(ctx)
#define REACTIVATE_WGL_CONTEXT(ctx) reactivate_gdk_wgl_context(ctx)
+static void
+handle_wgl_makecurrent (GdkGLContext *ctx)
+{
+ if (!gdk_gl_context_get_use_es (ctx))
+ epoxy_handle_external_wglMakeCurrent();
+}
+
static void
deactivate_gdk_wgl_context (GdkGLContext *ctx)
{
@@ -375,7 +382,7 @@ reactivate_gdk_wgl_context (GdkGLContext *ctx)
gdk_gl_context_make_current (ctx);
}
#else
-#define HANDLE_EXTERNAL_WGL_MAKE_CURRENT
+#define HANDLE_EXTERNAL_WGL_MAKE_CURRENT(ctx)
#define DEACTIVATE_WGL_CONTEXT(ctx)
#define REACTIVATE_WGL_CONTEXT(ctx)
#endif
@@ -391,7 +398,7 @@ gtk_gst_sink_initialize_gl (GtkGstSink *self)
display = gdk_gl_context_get_display (self->gdk_context);
- HANDLE_EXTERNAL_WGL_MAKE_CURRENT;
+ HANDLE_EXTERNAL_WGL_MAKE_CURRENT (self->gdk_context);
gdk_gl_context_make_current (self->gdk_context);
#ifdef HAVE_GST_X11_SUPPORT
@@ -459,16 +466,19 @@ gtk_gst_sink_initialize_gl (GtkGstSink *self)
}
else
#endif
-#if GST_GL_HAVE_WINDOW_WIN32 && GST_GL_HAVE_PLATFORM_WGL && defined (GDK_WINDOWING_WIN32)
- if (GDK_IS_WIN32_DISPLAY (display) &&
- !gdk_gl_context_get_use_es (self->gdk_context))
+#if GST_GL_HAVE_WINDOW_WIN32 && (GST_GL_HAVE_PLATFORM_WGL || GST_GL_HAVE_PLATFORM_EGL) && defined
(GDK_WINDOWING_WIN32)
+ if (GDK_IS_WIN32_DISPLAY (display))
{
- platform = GST_GL_PLATFORM_WGL;
+ gboolean is_gles = gdk_gl_context_get_use_es (self->gdk_context);
+ const gchar *gl_type = is_gles ? "EGL" : "WGL";
+
+ platform = is_gles ? GST_GL_PLATFORM_EGL : GST_GL_PLATFORM_WGL;
- GST_DEBUG_OBJECT (self, "got WGL on Win32!");
+ GST_DEBUG_OBJECT (self, "got %s on Win32!", gl_type);
gl_api = gst_gl_context_get_current_gl_api (platform, NULL, NULL);
gl_handle = gst_gl_context_get_current_gl_context (platform);
+ g_message ("GL Type: %s", gl_api == GST_GL_API_OPENGL3 ? "wgl" : "egl");
if (gl_handle)
{
@@ -477,7 +487,7 @@ gtk_gst_sink_initialize_gl (GtkGstSink *self)
}
else
{
- GST_ERROR_OBJECT (self, "Failed to get handle from GdkGLContext, not using WGL");
+ GST_ERROR_OBJECT (self, "Failed to get handle from GdkGLContext, not using %s", gl_type);
return;
}
}
@@ -498,7 +508,7 @@ gtk_gst_sink_initialize_gl (GtkGstSink *self)
g_clear_error (&error);
g_clear_object (&self->gst_app_context);
g_clear_object (&self->gst_display);
- HANDLE_EXTERNAL_WGL_MAKE_CURRENT;
+ HANDLE_EXTERNAL_WGL_MAKE_CURRENT (self->gdk_context);;
return;
}
else
@@ -515,7 +525,7 @@ gtk_gst_sink_initialize_gl (GtkGstSink *self)
g_clear_object (&self->gst_display);
}
- HANDLE_EXTERNAL_WGL_MAKE_CURRENT;
+ HANDLE_EXTERNAL_WGL_MAKE_CURRENT (self->gdk_context);
REACTIVATE_WGL_CONTEXT (self->gdk_context);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]