From 343eef58944dc56025e66aafd6e6f7b30df9d9af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Fri, 13 May 2022 11:38:20 +0200 Subject: [PATCH] plugin: Add GL support for Windows OS Add support for both WGL and EGL on Win32 --- .../importers/gstclapperglbaseimporter.c | 42 ++++++++++++++++++- .../importers/gstclapperglbaseimporter.h | 3 ++ lib/gst/plugin/importers/meson.build | 8 ++++ 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/lib/gst/plugin/importers/gstclapperglbaseimporter.c b/lib/gst/plugin/importers/gstclapperglbaseimporter.c index 8859685a..252a8447 100644 --- a/lib/gst/plugin/importers/gstclapperglbaseimporter.c +++ b/lib/gst/plugin/importers/gstclapperglbaseimporter.c @@ -38,10 +38,14 @@ #if GST_CLAPPER_GL_BASE_IMPORTER_HAVE_X11_GLX #include #endif -#if GST_CLAPPER_GL_BASE_IMPORTER_HAVE_X11_EGL +#if GST_CLAPPER_GL_BASE_IMPORTER_HAVE_X11_EGL || GST_CLAPPER_GL_BASE_IMPORTER_HAVE_WIN32_EGL #include #endif +#if GST_CLAPPER_GL_BASE_IMPORTER_HAVE_WIN32 +#include +#endif + #if GST_CLAPPER_GL_BASE_IMPORTER_HAVE_MACOS #include #endif @@ -155,6 +159,24 @@ retrieve_gl_context_on_main (GstClapperGLBaseImporter *self) #endif #endif +#if GST_CLAPPER_GL_BASE_IMPORTER_HAVE_WIN32 + if (GDK_IS_WIN32_DISPLAY (gdk_display)) { +#if GST_CLAPPER_GL_BASE_IMPORTER_HAVE_WIN32_EGL + gpointer display_ptr = gdk_win32_display_get_egl_display (gdk_display); + if (display_ptr) { + self->gst_display = (GstGLDisplay *) + gst_gl_display_egl_new_with_egl_display (display_ptr); + } +#endif +#if GST_CLAPPER_GL_BASE_IMPORTER_HAVE_WIN32_WGL + if (!self->gst_display) { + self->gst_display = + gst_gl_display_new_with_type (GST_GL_DISPLAY_TYPE_WIN32); + } + } +#endif +#endif + #if GST_CLAPPER_GL_BASE_IMPORTER_HAVE_MACOS if (GDK_IS_MACOS_DISPLAY (gdk_display)) { self->gst_display = @@ -176,7 +198,8 @@ retrieve_gl_context_on_main (GstClapperGLBaseImporter *self) } #endif #if GST_CLAPPER_GL_BASE_IMPORTER_HAVE_X11_EGL - if (GST_IS_GL_DISPLAY_EGL (self->gst_display)) { + if (GST_IS_GL_DISPLAY_EGL (self->gst_display) + && GDK_IS_X11_DISPLAY (gdk_display)) { platform = GST_GL_PLATFORM_EGL; GST_INFO_OBJECT (self, "Using EGL on x11"); goto have_display; @@ -189,6 +212,21 @@ retrieve_gl_context_on_main (GstClapperGLBaseImporter *self) goto have_display; } #endif +#if GST_CLAPPER_GL_BASE_IMPORTER_HAVE_WIN32_EGL + if (GST_IS_GL_DISPLAY_EGL (self->gst_display) + && GDK_IS_WIN32_DISPLAY (gdk_display)) { + platform = GST_GL_PLATFORM_EGL; + GST_INFO_OBJECT (self, "Using EGL on Win32"); + goto have_display; + } +#endif +#if GST_CLAPPER_GL_BASE_IMPORTER_HAVE_WIN32_WGL + if (gst_gl_display_get_handle_type (self->gst_display) == GST_GL_DISPLAY_TYPE_WIN32) { + platform = GST_GL_PLATFORM_WGL; + GST_INFO_OBJECT (self, "Using WGL on Win32"); + goto have_display; + } +#endif #if GST_CLAPPER_GL_BASE_IMPORTER_HAVE_MACOS if (gst_gl_display_get_handle_type (self->gst_display) == GST_GL_DISPLAY_TYPE_COCOA) { platform = GST_GL_PLATFORM_CGL; diff --git a/lib/gst/plugin/importers/gstclapperglbaseimporter.h b/lib/gst/plugin/importers/gstclapperglbaseimporter.h index 65383768..ee44e9e1 100644 --- a/lib/gst/plugin/importers/gstclapperglbaseimporter.h +++ b/lib/gst/plugin/importers/gstclapperglbaseimporter.h @@ -41,6 +41,9 @@ G_BEGIN_DECLS #define GST_CLAPPER_GL_BASE_IMPORTER_HAVE_X11 (GST_GL_HAVE_WINDOW_X11 && defined (GDK_WINDOWING_X11)) #define GST_CLAPPER_GL_BASE_IMPORTER_HAVE_X11_GLX (GST_CLAPPER_GL_BASE_IMPORTER_HAVE_X11 && GST_GL_HAVE_PLATFORM_GLX) #define GST_CLAPPER_GL_BASE_IMPORTER_HAVE_X11_EGL (GST_CLAPPER_GL_BASE_IMPORTER_HAVE_X11 && GST_GL_HAVE_PLATFORM_EGL) +#define GST_CLAPPER_GL_BASE_IMPORTER_HAVE_WIN32 (GST_GL_HAVE_WINDOW_WIN32 && defined (GDK_WINDOWING_WIN32)) +#define GST_CLAPPER_GL_BASE_IMPORTER_HAVE_WIN32_WGL (GST_CLAPPER_GL_BASE_IMPORTER_HAVE_WIN32 && GST_GL_HAVE_PLATFORM_WGL) +#define GST_CLAPPER_GL_BASE_IMPORTER_HAVE_WIN32_EGL (GST_CLAPPER_GL_BASE_IMPORTER_HAVE_WIN32 && GST_GL_HAVE_PLATFORM_EGL) #define GST_CLAPPER_GL_BASE_IMPORTER_HAVE_MACOS (GST_GL_HAVE_WINDOW_COCOA && defined (GDK_WINDOWING_MACOS) && GST_GL_HAVE_PLATFORM_CGL) typedef struct _GstClapperGLBaseImporter GstClapperGLBaseImporter; diff --git a/lib/gst/plugin/importers/meson.build b/lib/gst/plugin/importers/meson.build index de5e3d66..d6121611 100644 --- a/lib/gst/plugin/importers/meson.build +++ b/lib/gst/plugin/importers/meson.build @@ -46,6 +46,14 @@ if gst_gl_have_window_wayland and gst_gl_have_platform_egl endif endif +if gst_gl_have_window_win32 and (gst_gl_have_platform_egl or gst_gl_have_platform_wgl) + gtk_win32_dep = dependency('gtk4-win32', required: false) + if gtk_win32_dep.found() + gst_plugin_gl_base_deps += gtk_win32_dep + have_gtk_gl_windowing = true + endif +endif + if gst_gl_have_window_cocoa and gst_gl_have_platform_cgl gtk_macos_dep = dependency('gtk4-macos', required: false) if gtk_macos_dep.found()