glcontext: add public swap_buffers function
authorMatthew Waters <matthew@centricular.com>
Sun, 21 May 2017 10:03:01 +0000 (12:03 +0200)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 9 Dec 2017 19:32:28 +0000 (19:32 +0000)
That simply calls the implementation

gst-libs/gst/gl/android/gstglwindow_android_egl.c
gst-libs/gst/gl/cocoa/gstglcontext_cocoa.m
gst-libs/gst/gl/eagl/gstglwindow_eagl.m
gst-libs/gst/gl/gstglcontext.c
gst-libs/gst/gl/gstglcontext.h
gst-libs/gst/gl/gstglwindow.c
gst-libs/gst/gl/viv-fb/gstglwindow_viv_fb_egl.c
gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c
gst-libs/gst/gl/win32/gstglwindow_win32.c
gst-libs/gst/gl/x11/gstglwindow_x11.c

index 4e7ded8..2f4d80a 100644 (file)
@@ -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);
 }
index 1869be4..9e2f1e4 100644 (file)
@@ -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)
 {
 }
 
index 4923260..d98cb84 100644 (file)
@@ -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);
 
index 3ef068c..db35dc7 100644 (file)
@@ -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)
 {
index adc3a21..031b612 100644 (file)
@@ -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);
index e7947bf..a282b4a 100644 (file)
@@ -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);
 }
index 8ce25ee..621c90a 100644 (file)
@@ -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);
 }
index 7d99a55..45f9336 100644 (file)
@@ -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);
index 8d33ea4..324954e 100644 (file)
@@ -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;
index 0c83539..63bc0e8 100644 (file)
@@ -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);
 }