diff --git a/gst-libs/gst/gl/android/gstglwindow_android_egl.c b/gst-libs/gst/gl/android/gstglwindow_android_egl.c index 4e7ded80ab..2f4d80aff4 100644 --- a/gst-libs/gst/gl/android/gstglwindow_android_egl.c +++ b/gst-libs/gst/gl/android/gstglwindow_android_egl.c @@ -107,7 +107,6 @@ draw_cb (gpointer data) GstGLWindow *window = GST_GL_WINDOW (window_egl); GstGLContext *context = gst_gl_window_get_context (window); GstGLContextEGL *context_egl = GST_GL_CONTEXT_EGL (context); - GstGLContextClass *context_class = GST_GL_CONTEXT_GET_CLASS (context); if (context_egl->egl_surface) { gint width, height; @@ -128,7 +127,7 @@ draw_cb (gpointer data) if (window->draw) window->draw (window->draw_data); - context_class->swap_buffers (context); + gst_gl_context_swap_buffers (context); gst_object_unref (context); } diff --git a/gst-libs/gst/gl/cocoa/gstglcontext_cocoa.m b/gst-libs/gst/gl/cocoa/gstglcontext_cocoa.m index 1869be4da1..9e2f1e4f53 100644 --- a/gst-libs/gst/gl/cocoa/gstglcontext_cocoa.m +++ b/gst-libs/gst/gl/cocoa/gstglcontext_cocoa.m @@ -34,7 +34,7 @@ static guintptr gst_gl_context_cocoa_get_gl_context (GstGLContext * window); static gboolean gst_gl_context_cocoa_activate (GstGLContext * context, gboolean activate); static GstGLAPI gst_gl_context_cocoa_get_gl_api (GstGLContext * context); static GstGLPlatform gst_gl_context_cocoa_get_gl_platform (GstGLContext * context); -static void gst_gl_context_cocoa_swap_buffer (GstGLContext * context); +static void gst_gl_context_cocoa_swap_buffers (GstGLContext * context); #define GST_GL_CONTEXT_COCOA_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_TYPE_GL_CONTEXT_COCOA, GstGLContextCocoaPrivate)) @@ -53,7 +53,7 @@ gst_gl_context_cocoa_class_init (GstGLContextCocoaClass * klass) g_type_class_add_private (klass, sizeof (GstGLContextCocoaPrivate)); context_class->swap_buffers = - GST_DEBUG_FUNCPTR (gst_gl_context_cocoa_swap_buffer); + GST_DEBUG_FUNCPTR (gst_gl_context_cocoa_swap_buffers); context_class->destroy_context = GST_DEBUG_FUNCPTR (gst_gl_context_cocoa_destroy_context); context_class->create_context = @@ -290,7 +290,7 @@ error: } static void -gst_gl_context_cocoa_swap_buffer (GstGLContext * context) +gst_gl_context_cocoa_swap_buffers (GstGLContext * context) { } diff --git a/gst-libs/gst/gl/eagl/gstglwindow_eagl.m b/gst-libs/gst/gl/eagl/gstglwindow_eagl.m index 4923260ff3..d98cb84c2e 100644 --- a/gst-libs/gst/gl/eagl/gstglwindow_eagl.m +++ b/gst-libs/gst/gl/eagl/gstglwindow_eagl.m @@ -183,7 +183,6 @@ draw_cb (gpointer data) GstGLWindow *window = GST_GL_WINDOW (window_eagl); GstGLContext *context = gst_gl_window_get_context (window); GstGLContextEagl *eagl_context = GST_GL_CONTEXT_EAGL (context); - GstGLContextClass *context_class = GST_GL_CONTEXT_GET_CLASS (context); if (window_eagl->priv->view) { CGSize size; @@ -210,7 +209,7 @@ draw_cb (gpointer data) if (window->draw) window->draw (window->draw_data); - context_class->swap_buffers (context); + gst_gl_context_swap_buffers (context); gst_gl_context_eagl_finish_draw (eagl_context); diff --git a/gst-libs/gst/gl/gstglcontext.c b/gst-libs/gst/gl/gstglcontext.c index 3ef068cafe..db35dc7bc2 100644 --- a/gst-libs/gst/gl/gstglcontext.c +++ b/gst-libs/gst/gl/gstglcontext.c @@ -1767,6 +1767,25 @@ gst_gl_context_get_gl_platform_version (GstGLContext * context, gint * major, context_class->get_gl_platform_version (context, major, minor); } +/** + * gst_gl_context_swap_buffers: + * @context: a #GstGLContext + * + * Swap the front and back buffers on the window attached to @context. + * This will display the frame on the next refresh cycle. + */ +void +gst_gl_context_swap_buffers (GstGLContext * context) +{ + GstGLContextClass *context_class; + + g_return_if_fail (GST_IS_GL_CONTEXT (context)); + context_class = GST_GL_CONTEXT_GET_CLASS (context); + g_return_if_fail (context_class->swap_buffers != NULL); + + context_class->swap_buffers (context); +} + static GstGLAPI gst_gl_wrapped_context_get_gl_api (GstGLContext * context) { diff --git a/gst-libs/gst/gl/gstglcontext.h b/gst-libs/gst/gl/gstglcontext.h index adc3a2182e..031b612870 100644 --- a/gst-libs/gst/gl/gstglcontext.h +++ b/gst-libs/gst/gl/gstglcontext.h @@ -164,6 +164,8 @@ GST_EXPORT guintptr gst_gl_context_get_gl_context (GstGLContext *context); GST_EXPORT gboolean gst_gl_context_can_share (GstGLContext * context, GstGLContext *other_context); +GST_EXPORT +void gst_gl_context_swap_buffers (GstGLContext * context); GST_EXPORT gboolean gst_gl_context_create (GstGLContext *context, GstGLContext *other_context, GError ** error); diff --git a/gst-libs/gst/gl/gstglwindow.c b/gst-libs/gst/gl/gstglwindow.c index e7947bf048..a282b4a24c 100644 --- a/gst-libs/gst/gl/gstglwindow.c +++ b/gst-libs/gst/gl/gstglwindow.c @@ -395,7 +395,6 @@ draw_cb (gpointer data) { GstGLWindow *window = GST_GL_WINDOW (data); GstGLContext *context = gst_gl_window_get_context (window); - GstGLContextClass *context_class = GST_GL_CONTEXT_GET_CLASS (context); if (window->queue_resize) { guint width, height; @@ -407,8 +406,7 @@ draw_cb (gpointer data) if (window->draw) window->draw (window->draw_data); - if (context_class->swap_buffers) - context_class->swap_buffers (context); + gst_gl_context_swap_buffers (context); gst_object_unref (context); } diff --git a/gst-libs/gst/gl/viv-fb/gstglwindow_viv_fb_egl.c b/gst-libs/gst/gl/viv-fb/gstglwindow_viv_fb_egl.c index 8ce25eed38..621c90acc8 100644 --- a/gst-libs/gst/gl/viv-fb/gstglwindow_viv_fb_egl.c +++ b/gst-libs/gst/gl/viv-fb/gstglwindow_viv_fb_egl.c @@ -165,7 +165,6 @@ draw_cb (gpointer data) GstGLWindowVivFBEGL *window_egl = data; GstGLWindow *window = GST_GL_WINDOW (window_egl); GstGLContext *context = gst_gl_window_get_context (window); - GstGLContextClass *context_class = GST_GL_CONTEXT_GET_CLASS (context); const GstGLFuncs *gl; gint viewport_dim[4]; @@ -189,7 +188,7 @@ draw_cb (gpointer data) if (window->draw) window->draw (window->draw_data); - context_class->swap_buffers (context); + gst_gl_context_swap_buffers (context); gst_object_unref (context); } diff --git a/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c b/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c index 7d99a55610..45f93361ad 100644 --- a/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c +++ b/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c @@ -486,7 +486,6 @@ draw_cb (gpointer data) GstGLWindowWaylandEGL *window_egl = data; GstGLWindow *window = GST_GL_WINDOW (window_egl); GstGLContext *context = gst_gl_window_get_context (window); - GstGLContextClass *context_class = GST_GL_CONTEXT_GET_CLASS (context); create_surfaces (window_egl); @@ -503,7 +502,7 @@ draw_cb (gpointer data) if (window->draw) window->draw (window->draw_data); - context_class->swap_buffers (context); + gst_gl_context_swap_buffers (context); if (window_egl->window.subsurface) wl_subsurface_set_desync (window_egl->window.subsurface); diff --git a/gst-libs/gst/gl/win32/gstglwindow_win32.c b/gst-libs/gst/gl/win32/gstglwindow_win32.c index 8d33ea443e..324954e587 100644 --- a/gst-libs/gst/gl/win32/gstglwindow_win32.c +++ b/gst-libs/gst/gl/win32/gstglwindow_win32.c @@ -408,12 +408,10 @@ window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) } else if (GetProp (hWnd, "gl_window")) { GstGLWindow *window; GstGLContext *context; - GstGLContextClass *context_class; window_win32 = GST_GL_WINDOW_WIN32 (GetProp (hWnd, "gl_window")); window = GST_GL_WINDOW (window_win32); context = gst_gl_window_get_context (window); - context_class = GST_GL_CONTEXT_GET_CLASS (context); g_assert (window_win32->internal_win_id == hWnd); @@ -433,7 +431,7 @@ window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) PAINTSTRUCT ps; BeginPaint (hWnd, &ps); window->draw (window->draw_data); - context_class->swap_buffers (context); + gst_gl_context_swap_buffers (context); EndPaint (hWnd, &ps); } break; diff --git a/gst-libs/gst/gl/x11/gstglwindow_x11.c b/gst-libs/gst/gl/x11/gstglwindow_x11.c index 0c83539731..63bc0e8136 100644 --- a/gst-libs/gst/gl/x11/gstglwindow_x11.c +++ b/gst-libs/gst/gl/x11/gstglwindow_x11.c @@ -358,7 +358,7 @@ _context_draw (GstGLContext * context, GstGLWindow * window) GstGLContextClass *context_class = GST_GL_CONTEXT_GET_CLASS (context); window->draw (window->draw_data); - context_class->swap_buffers (context); + gst_gl_context_swap_buffers (context); gst_object_unref (context); }