mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-31 08:21:59 +02:00
Gtk4Plugin: add drawing black fixes from Flatpak patch
This commit is contained in:
@@ -39,6 +39,7 @@ GST_DEBUG_CATEGORY (gst_debug_gtk_base_sink);
|
|||||||
#define DEFAULT_PAR_N 0
|
#define DEFAULT_PAR_N 0
|
||||||
#define DEFAULT_PAR_D 1
|
#define DEFAULT_PAR_D 1
|
||||||
#define DEFAULT_IGNORE_ALPHA TRUE
|
#define DEFAULT_IGNORE_ALPHA TRUE
|
||||||
|
#define DEFAULT_IGNORE_TEXTURES FALSE
|
||||||
|
|
||||||
static void gst_gtk_base_sink_finalize (GObject * object);
|
static void gst_gtk_base_sink_finalize (GObject * object);
|
||||||
static void gst_gtk_base_sink_set_property (GObject * object, guint prop_id,
|
static void gst_gtk_base_sink_set_property (GObject * object, guint prop_id,
|
||||||
@@ -70,6 +71,7 @@ enum
|
|||||||
PROP_FORCE_ASPECT_RATIO,
|
PROP_FORCE_ASPECT_RATIO,
|
||||||
PROP_PIXEL_ASPECT_RATIO,
|
PROP_PIXEL_ASPECT_RATIO,
|
||||||
PROP_IGNORE_ALPHA,
|
PROP_IGNORE_ALPHA,
|
||||||
|
PROP_IGNORE_TEXTURES,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define gst_gtk_base_sink_parent_class parent_class
|
#define gst_gtk_base_sink_parent_class parent_class
|
||||||
@@ -123,6 +125,11 @@ gst_gtk_base_sink_class_init (GstGtkBaseSinkClass * klass)
|
|||||||
DEFAULT_IGNORE_ALPHA, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
DEFAULT_IGNORE_ALPHA, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class, PROP_IGNORE_TEXTURES,
|
||||||
|
g_param_spec_boolean ("ignore-textures", "Ignore Textures",
|
||||||
|
"When enabled, textures will be ignored and not drawn",
|
||||||
|
DEFAULT_IGNORE_TEXTURES, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
gobject_class->finalize = gst_gtk_base_sink_finalize;
|
gobject_class->finalize = gst_gtk_base_sink_finalize;
|
||||||
|
|
||||||
gstelement_class->change_state = gst_gtk_base_sink_change_state;
|
gstelement_class->change_state = gst_gtk_base_sink_change_state;
|
||||||
@@ -143,6 +150,7 @@ gst_gtk_base_sink_init (GstGtkBaseSink * gtk_sink)
|
|||||||
gtk_sink->par_n = DEFAULT_PAR_N;
|
gtk_sink->par_n = DEFAULT_PAR_N;
|
||||||
gtk_sink->par_d = DEFAULT_PAR_D;
|
gtk_sink->par_d = DEFAULT_PAR_D;
|
||||||
gtk_sink->ignore_alpha = DEFAULT_IGNORE_ALPHA;
|
gtk_sink->ignore_alpha = DEFAULT_IGNORE_ALPHA;
|
||||||
|
gtk_sink->ignore_textures = DEFAULT_IGNORE_TEXTURES;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -221,6 +229,10 @@ gst_gtk_base_sink_get_widget (GstGtkBaseSink * gtk_sink)
|
|||||||
"ignore-alpha", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
"ignore-alpha", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
gtk_sink->bind_ignore_textures =
|
||||||
|
g_object_bind_property (gtk_sink, "ignore-textures", gtk_sink->widget,
|
||||||
|
"ignore-textures", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
||||||
|
|
||||||
/* Take the floating ref, other wise the destruction of the container will
|
/* Take the floating ref, other wise the destruction of the container will
|
||||||
* make this widget disappear possibly before we are done. */
|
* make this widget disappear possibly before we are done. */
|
||||||
gst_object_ref_sink (gtk_sink->widget);
|
gst_object_ref_sink (gtk_sink->widget);
|
||||||
@@ -268,6 +280,9 @@ gst_gtk_base_sink_get_property (GObject * object, guint prop_id,
|
|||||||
case PROP_IGNORE_ALPHA:
|
case PROP_IGNORE_ALPHA:
|
||||||
g_value_set_boolean (value, gtk_sink->ignore_alpha);
|
g_value_set_boolean (value, gtk_sink->ignore_alpha);
|
||||||
break;
|
break;
|
||||||
|
case PROP_IGNORE_TEXTURES:
|
||||||
|
g_value_set_boolean (value, gtk_sink->ignore_textures);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@@ -291,6 +306,9 @@ gst_gtk_base_sink_set_property (GObject * object, guint prop_id,
|
|||||||
case PROP_IGNORE_ALPHA:
|
case PROP_IGNORE_ALPHA:
|
||||||
gtk_sink->ignore_alpha = g_value_get_boolean (value);
|
gtk_sink->ignore_alpha = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
|
case PROP_IGNORE_TEXTURES:
|
||||||
|
gtk_sink->ignore_textures = g_value_get_boolean (value);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@@ -68,6 +68,9 @@ struct _GstGtkBaseSink
|
|||||||
gboolean ignore_alpha;
|
gboolean ignore_alpha;
|
||||||
GBinding *bind_ignore_alpha;
|
GBinding *bind_ignore_alpha;
|
||||||
|
|
||||||
|
gboolean ignore_textures;
|
||||||
|
GBinding *bind_ignore_textures;
|
||||||
|
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
gulong widget_destroy_id;
|
gulong widget_destroy_id;
|
||||||
gulong window_destroy_id;
|
gulong window_destroy_id;
|
||||||
|
@@ -34,6 +34,7 @@ GST_DEBUG_CATEGORY (gst_debug_gtk_base_widget);
|
|||||||
#define DEFAULT_PAR_N 0
|
#define DEFAULT_PAR_N 0
|
||||||
#define DEFAULT_PAR_D 1
|
#define DEFAULT_PAR_D 1
|
||||||
#define DEFAULT_IGNORE_ALPHA TRUE
|
#define DEFAULT_IGNORE_ALPHA TRUE
|
||||||
|
#define DEFAULT_IGNORE_TEXTURES FALSE
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@@ -41,6 +42,7 @@ enum
|
|||||||
PROP_FORCE_ASPECT_RATIO,
|
PROP_FORCE_ASPECT_RATIO,
|
||||||
PROP_PIXEL_ASPECT_RATIO,
|
PROP_PIXEL_ASPECT_RATIO,
|
||||||
PROP_IGNORE_ALPHA,
|
PROP_IGNORE_ALPHA,
|
||||||
|
PROP_IGNORE_TEXTURES,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -108,6 +110,9 @@ gtk_gst_base_widget_set_property (GObject * object, guint prop_id,
|
|||||||
case PROP_IGNORE_ALPHA:
|
case PROP_IGNORE_ALPHA:
|
||||||
gtk_widget->ignore_alpha = g_value_get_boolean (value);
|
gtk_widget->ignore_alpha = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
|
case PROP_IGNORE_TEXTURES:
|
||||||
|
gtk_widget->ignore_textures = g_value_get_boolean (value);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@@ -130,6 +135,9 @@ gtk_gst_base_widget_get_property (GObject * object, guint prop_id,
|
|||||||
case PROP_IGNORE_ALPHA:
|
case PROP_IGNORE_ALPHA:
|
||||||
g_value_set_boolean (value, gtk_widget->ignore_alpha);
|
g_value_set_boolean (value, gtk_widget->ignore_alpha);
|
||||||
break;
|
break;
|
||||||
|
case PROP_IGNORE_TEXTURES:
|
||||||
|
g_value_set_boolean (value, gtk_widget->ignore_textures);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@@ -460,6 +468,11 @@ gtk_gst_base_widget_class_init (GtkGstBaseWidgetClass * klass)
|
|||||||
"When enabled, alpha will be ignored and converted to black",
|
"When enabled, alpha will be ignored and converted to black",
|
||||||
DEFAULT_IGNORE_ALPHA, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
DEFAULT_IGNORE_ALPHA, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_klass, PROP_IGNORE_TEXTURES,
|
||||||
|
g_param_spec_boolean ("ignore-textures", "Ignore Textures",
|
||||||
|
"When enabled, textures will be ignored and not drawn",
|
||||||
|
DEFAULT_IGNORE_TEXTURES, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
#if defined(BUILD_FOR_GTK4)
|
#if defined(BUILD_FOR_GTK4)
|
||||||
widget_klass->measure = gtk_gst_base_widget_measure;
|
widget_klass->measure = gtk_gst_base_widget_measure;
|
||||||
#else
|
#else
|
||||||
@@ -478,6 +491,7 @@ gtk_gst_base_widget_init (GtkGstBaseWidget * widget)
|
|||||||
widget->par_n = DEFAULT_PAR_N;
|
widget->par_n = DEFAULT_PAR_N;
|
||||||
widget->par_d = DEFAULT_PAR_D;
|
widget->par_d = DEFAULT_PAR_D;
|
||||||
widget->ignore_alpha = DEFAULT_IGNORE_ALPHA;
|
widget->ignore_alpha = DEFAULT_IGNORE_ALPHA;
|
||||||
|
widget->ignore_textures = DEFAULT_IGNORE_TEXTURES;
|
||||||
|
|
||||||
gst_video_info_init (&widget->v_info);
|
gst_video_info_init (&widget->v_info);
|
||||||
gst_video_info_init (&widget->pending_v_info);
|
gst_video_info_init (&widget->pending_v_info);
|
||||||
|
@@ -50,6 +50,7 @@ struct _GtkGstBaseWidget
|
|||||||
gboolean force_aspect_ratio;
|
gboolean force_aspect_ratio;
|
||||||
gint par_n, par_d;
|
gint par_n, par_d;
|
||||||
gboolean ignore_alpha;
|
gboolean ignore_alpha;
|
||||||
|
gboolean ignore_textures;
|
||||||
|
|
||||||
gint display_width;
|
gint display_width;
|
||||||
gint display_height;
|
gint display_height;
|
||||||
|
@@ -62,7 +62,7 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
|||||||
|
|
||||||
struct _GtkGstGLWidgetPrivate
|
struct _GtkGstGLWidgetPrivate
|
||||||
{
|
{
|
||||||
gboolean initted;
|
gboolean initiated;
|
||||||
GstGLDisplay *display;
|
GstGLDisplay *display;
|
||||||
GdkGLContext *gdk_context;
|
GdkGLContext *gdk_context;
|
||||||
GstGLContext *other_context;
|
GstGLContext *other_context;
|
||||||
@@ -159,7 +159,7 @@ gtk_gst_gl_widget_init_redisplay (GtkGstGLWidget * gst_widget)
|
|||||||
priv->overlay_compositor =
|
priv->overlay_compositor =
|
||||||
gst_gl_overlay_compositor_new (priv->other_context);
|
gst_gl_overlay_compositor_new (priv->other_context);
|
||||||
|
|
||||||
priv->initted = TRUE;
|
priv->initiated = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -173,7 +173,7 @@ _redraw_texture (GtkGstGLWidget * gst_widget, guint tex)
|
|||||||
GstVideoRectangle src, dst, result;
|
GstVideoRectangle src, dst, result;
|
||||||
gint widget_width, widget_height, widget_scale;
|
gint widget_width, widget_height, widget_scale;
|
||||||
|
|
||||||
gl->ClearColor (0.0, 0.0, 0.0, 0.0);
|
gl->ClearColor (0.0, 0.0, 0.0, 1.0);
|
||||||
gl->Clear (GL_COLOR_BUFFER_BIT);
|
gl->Clear (GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
widget_scale = gtk_widget_get_scale_factor ((GtkWidget *) gst_widget);
|
widget_scale = gtk_widget_get_scale_factor ((GtkWidget *) gst_widget);
|
||||||
@@ -220,11 +220,19 @@ _draw_black (GstGLContext * context)
|
|||||||
{
|
{
|
||||||
const GstGLFuncs *gl = context->gl_vtable;
|
const GstGLFuncs *gl = context->gl_vtable;
|
||||||
|
|
||||||
gst_gl_insert_debug_marker (context, "no buffer. rendering black");
|
gst_gl_insert_debug_marker (context, "rendering black");
|
||||||
gl->ClearColor (0.0, 0.0, 0.0, 0.0);
|
gl->ClearColor (0.0, 0.0, 0.0, 1.0);
|
||||||
gl->Clear (GL_COLOR_BUFFER_BIT);
|
gl->Clear (GL_COLOR_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
_draw_black_with_gdk (GdkGLContext * gdk_context)
|
||||||
|
{
|
||||||
|
GST_DEBUG ("rendering empty frame with gdk context %p", gdk_context);
|
||||||
|
glClearColor (0.0, 0.0, 0.0, 1.0);
|
||||||
|
glClear (GL_COLOR_BUFFER_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gtk_gst_gl_widget_render (GtkGLArea * widget, GdkGLContext * context)
|
gtk_gst_gl_widget_render (GtkGLArea * widget, GdkGLContext * context)
|
||||||
{
|
{
|
||||||
@@ -233,15 +241,19 @@ gtk_gst_gl_widget_render (GtkGLArea * widget, GdkGLContext * context)
|
|||||||
|
|
||||||
GTK_GST_BASE_WIDGET_LOCK (widget);
|
GTK_GST_BASE_WIDGET_LOCK (widget);
|
||||||
|
|
||||||
if (!priv->context || !priv->other_context)
|
/* Draw black with GDK context when priv is not available yet.
|
||||||
|
GTK calls render with GDK context already active. */
|
||||||
|
if (!priv->context || !priv->other_context || base_widget->ignore_textures) {
|
||||||
|
_draw_black_with_gdk (context);
|
||||||
goto done;
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
gst_gl_context_activate (priv->other_context, TRUE);
|
gst_gl_context_activate (priv->other_context, TRUE);
|
||||||
|
|
||||||
if (!priv->initted)
|
if (!priv->initiated || !base_widget->negotiated) {
|
||||||
gtk_gst_gl_widget_init_redisplay (GTK_GST_GL_WIDGET (widget));
|
if (!priv->initiated)
|
||||||
|
gtk_gst_gl_widget_init_redisplay (GTK_GST_GL_WIDGET (widget));
|
||||||
|
|
||||||
if (!priv->initted || !base_widget->negotiated) {
|
|
||||||
_draw_black (priv->other_context);
|
_draw_black (priv->other_context);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user