From 06d9f302c2c6649a955fc3601f65d3d06a2e3ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Mon, 31 May 2021 18:07:37 +0200 Subject: [PATCH] Revert "sink: Use g_main_context_invoke_full for drawing" Not much benefit from using this function and unlike g_idle_add_full it does not allow to skip a frame when previous one was not finished (slow HW). This reverts commit f8a7abe1959946116aa993f34ba892c3da08e6e0. --- lib/gst/clapper/gtk4/gtkclapperglwidget.c | 13 +++++++------ lib/gst/clapper/gtk4/gtkclapperglwidget.h | 4 +++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/gst/clapper/gtk4/gtkclapperglwidget.c b/lib/gst/clapper/gtk4/gtkclapperglwidget.c index 5e949343..7f592249 100644 --- a/lib/gst/clapper/gtk4/gtkclapperglwidget.c +++ b/lib/gst/clapper/gtk4/gtkclapperglwidget.c @@ -284,6 +284,7 @@ static gboolean _queue_draw (GtkClapperGLWidget * clapper_widget) { GTK_CLAPPER_GL_WIDGET_LOCK (clapper_widget); + clapper_widget->draw_id = 0; if (clapper_widget->pending_resize) { clapper_widget->pending_resize = FALSE; @@ -750,8 +751,8 @@ gtk_clapper_gl_widget_finalize (GObject * object) if (priv->display) gst_object_unref (priv->display); - if (clapper_widget->app_context) - g_main_context_unref (clapper_widget->app_context); + if (clapper_widget->draw_id) + g_source_remove (clapper_widget->draw_id); gst_buffer_replace (&clapper_widget->pending_buffer, NULL); gst_buffer_replace (&clapper_widget->buffer, NULL); @@ -802,9 +803,10 @@ gtk_clapper_gl_widget_set_buffer (GtkClapperGLWidget * clapper_widget, gst_buffer_replace (&clapper_widget->pending_buffer, buffer); - g_main_context_invoke_full (clapper_widget->app_context, - G_PRIORITY_DEFAULT - 10, (GSourceFunc) _queue_draw, - g_object_ref (clapper_widget), g_object_unref); + if (!clapper_widget->draw_id) { + clapper_widget->draw_id = g_idle_add_full (G_PRIORITY_DEFAULT, + (GSourceFunc) _queue_draw, clapper_widget, NULL); + } GTK_CLAPPER_GL_WIDGET_UNLOCK (clapper_widget); } @@ -957,7 +959,6 @@ gtk_clapper_gl_widget_init (GtkClapperGLWidget * clapper_widget) clapper_widget->par_n = DEFAULT_PAR_N; clapper_widget->par_d = DEFAULT_PAR_D; clapper_widget->ignore_textures = DEFAULT_IGNORE_TEXTURES; - clapper_widget->app_context = g_main_context_ref_thread_default (); clapper_widget->last_pos_x = 0; clapper_widget->last_pos_y = 0; diff --git a/lib/gst/clapper/gtk4/gtkclapperglwidget.h b/lib/gst/clapper/gtk4/gtkclapperglwidget.h index ee733712..bce9539e 100644 --- a/lib/gst/clapper/gtk4/gtkclapperglwidget.h +++ b/lib/gst/clapper/gtk4/gtkclapperglwidget.h @@ -69,7 +69,6 @@ struct _GtkClapperGLWidget GstBuffer *pending_buffer; GstBuffer *buffer; GstVideoInfo v_info; - GMainContext *app_context; /* resize */ gboolean pending_resize; @@ -85,6 +84,9 @@ struct _GtkClapperGLWidget GtkEventController *key_controller; GtkEventController *motion_controller; GtkGesture *click_gesture; + + /* Pending draw idles callback */ + guint draw_id; }; struct _GtkClapperGLWidgetClass