diff options
author | Christian Hergert <christian@hergert.me> | 2022-02-16 21:27:10 -0800 |
---|---|---|
committer | Christian Hergert <christian@hergert.me> | 2022-02-16 21:31:20 -0800 |
commit | 7ec9c5181d69625b58781c1eca84d9a1a1cc20de (patch) | |
tree | e2742195ee1db250589b68dfdc52c140304ce888 /modules | |
parent | 9c1a66518b929255019e3ce56e27662296c891fa (diff) | |
download | gtk+-7ec9c5181d69625b58781c1eca84d9a1a1cc20de.tar.gz |
media: support OpenGL-based video playback on macOS
If we have GStreamer on macOS we likely have support for CGL to get an
OpenGL context we can use. This provides the missing pieces to get
accelerated video playback in gtk4-widget-factory working.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/media/gtkgstsink.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/modules/media/gtkgstsink.c b/modules/media/gtkgstsink.c index c2708da148..529952fffc 100644 --- a/modules/media/gtkgstsink.c +++ b/modules/media/gtkgstsink.c @@ -48,6 +48,10 @@ #include <gst/gl/egl/gstgldisplay_egl.h> #endif +#ifdef GDK_WINDOWING_MACOS +#include <gdk/macos/gdkmacos.h> +#endif + #include <gst/gl/gstglfuncs.h> enum { @@ -497,6 +501,29 @@ gtk_gst_sink_initialize_gl (GtkGstSink *self) } else #endif +#if defined(GST_GL_HAVE_PLATFORM_CGL) && defined(GDK_WINDOWING_MACOS) + if (GDK_IS_MACOS_DISPLAY (display)) + { + platform = GST_GL_PLATFORM_CGL; + + GST_DEBUG_OBJECT (self, "got CGL on macOS!"); + + gl_api = gst_gl_context_get_current_gl_api (platform, NULL, NULL); + gl_handle = gst_gl_context_get_current_gl_context (platform); + + if (gl_handle) + { + self->gst_display = gst_gl_display_new (); + self->gst_app_context = gst_gl_context_new_wrapped (self->gst_display, gl_handle, platform, gl_api); + } + else + { + GST_ERROR_OBJECT (self, "Failed to get handle from GdkGLContext, not using macOS CGL"); + return FALSE; + } + } + else +#endif #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)) { |