mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-01 06:01:04 +00:00
glwindow: fix racy resize updates
Take locks around resize handling and marshall all resizes to the windowing thread by default.
This commit is contained in:
parent
b29d61b88e
commit
b887db1efe
1 changed files with 29 additions and 20 deletions
|
@ -147,12 +147,15 @@ gst_gl_window_error_quark (void)
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_gl_window_default_open (GstGLWindow * window, GError ** error)
|
gst_gl_window_default_open (GstGLWindow * window, GError ** error)
|
||||||
{
|
{
|
||||||
|
g_main_context_push_thread_default (window->main_context);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_gl_window_default_close (GstGLWindow * window)
|
gst_gl_window_default_close (GstGLWindow * window)
|
||||||
{
|
{
|
||||||
|
g_main_context_pop_thread_default (window->main_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -511,11 +514,7 @@ gst_gl_window_default_run (GstGLWindow * window)
|
||||||
{
|
{
|
||||||
GstGLWindowPrivate *priv = window->priv;
|
GstGLWindowPrivate *priv = window->priv;
|
||||||
|
|
||||||
g_main_context_push_thread_default (window->main_context);
|
|
||||||
|
|
||||||
g_main_loop_run (priv->loop);
|
g_main_loop_run (priv->loop);
|
||||||
|
|
||||||
g_main_context_pop_thread_default (window->main_context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -890,10 +889,12 @@ void
|
||||||
gst_gl_window_get_surface_dimensions (GstGLWindow * window, guint * width,
|
gst_gl_window_get_surface_dimensions (GstGLWindow * window, guint * width,
|
||||||
guint * height)
|
guint * height)
|
||||||
{
|
{
|
||||||
|
GST_GL_WINDOW_LOCK (window);
|
||||||
if (width)
|
if (width)
|
||||||
*width = window->priv->surface_width;
|
*width = window->priv->surface_width;
|
||||||
if (height)
|
if (height)
|
||||||
*height = window->priv->surface_height;
|
*height = window->priv->surface_height;
|
||||||
|
GST_GL_WINDOW_UNLOCK (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -958,6 +959,7 @@ gst_gl_window_set_render_rectangle (GstGLWindow * window, gint x, gint y,
|
||||||
g_return_val_if_fail (GST_IS_GL_WINDOW (window), FALSE);
|
g_return_val_if_fail (GST_IS_GL_WINDOW (window), FALSE);
|
||||||
window_class = GST_GL_WINDOW_GET_CLASS (window);
|
window_class = GST_GL_WINDOW_GET_CLASS (window);
|
||||||
|
|
||||||
|
GST_GL_WINDOW_LOCK (window);
|
||||||
/* When x/y is smaller then reset the render rectangle */
|
/* When x/y is smaller then reset the render rectangle */
|
||||||
if (x < 0 || y < 0) {
|
if (x < 0 || y < 0) {
|
||||||
x = y = 0;
|
x = y = 0;
|
||||||
|
@ -965,12 +967,16 @@ gst_gl_window_set_render_rectangle (GstGLWindow * window, gint x, gint y,
|
||||||
height = window->priv->surface_height;
|
height = window->priv->surface_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x < 0 || y < 0 || width <= 0 || height <= 0)
|
if (x < 0 || y < 0 || width <= 0 || height <= 0) {
|
||||||
|
GST_GL_WINDOW_UNLOCK (window);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (window_class->set_render_rectangle)
|
if (window_class->set_render_rectangle)
|
||||||
ret = window_class->set_render_rectangle (window, x, y, width, height);
|
ret = window_class->set_render_rectangle (window, x, y, width, height);
|
||||||
|
|
||||||
|
GST_GL_WINDOW_UNLOCK (window);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1004,8 +1010,18 @@ _on_resize (gpointer data)
|
||||||
{
|
{
|
||||||
struct resize_data *resize = data;
|
struct resize_data *resize = data;
|
||||||
|
|
||||||
resize->window->resize (resize->window->resize_data, resize->width,
|
GST_GL_WINDOW_LOCK (resize->window);
|
||||||
resize->height);
|
|
||||||
|
if (resize->window->resize)
|
||||||
|
resize->window->resize (resize->window->resize_data, resize->width,
|
||||||
|
resize->height);
|
||||||
|
|
||||||
|
resize->window->priv->surface_width = resize->width;
|
||||||
|
resize->window->priv->surface_height = resize->height;
|
||||||
|
|
||||||
|
GST_GL_WINDOW_UNLOCK (resize->window);
|
||||||
|
|
||||||
|
resize->window->queue_resize = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1019,22 +1035,15 @@ _on_resize (gpointer data)
|
||||||
void
|
void
|
||||||
gst_gl_window_resize (GstGLWindow * window, guint width, guint height)
|
gst_gl_window_resize (GstGLWindow * window, guint width, guint height)
|
||||||
{
|
{
|
||||||
|
struct resize_data resize = { 0, };
|
||||||
|
|
||||||
g_return_if_fail (GST_IS_GL_WINDOW (window));
|
g_return_if_fail (GST_IS_GL_WINDOW (window));
|
||||||
|
|
||||||
if (window->resize) {
|
resize.window = window;
|
||||||
struct resize_data resize = { 0, };
|
resize.width = width;
|
||||||
|
resize.height = height;
|
||||||
|
|
||||||
resize.window = window;
|
gst_gl_window_send_message (window, (GstGLWindowCB) _on_resize, &resize);
|
||||||
resize.width = width;
|
|
||||||
resize.height = height;
|
|
||||||
|
|
||||||
gst_gl_window_send_message (window, (GstGLWindowCB) _on_resize, &resize);
|
|
||||||
}
|
|
||||||
|
|
||||||
window->priv->surface_width = width;
|
|
||||||
window->priv->surface_height = height;
|
|
||||||
|
|
||||||
window->queue_resize = FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue