mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
glshaderelement: implement on-demand create-shader signalling
One may not have an GstGLContext available or current in the thread where one would need to update the shader. Support this by signalling create-shader whenever the one-shot 'update-shader' is set to TRUE.
This commit is contained in:
parent
2882f6b90b
commit
608cf31a25
1 changed files with 22 additions and 29 deletions
|
@ -195,36 +195,36 @@ _new_shader (GstGLContext * context, struct shader_state *state)
|
||||||
return shader;
|
return shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
_set_compilation_state (struct shader_state *state)
|
||||||
|
{
|
||||||
|
gtk_label_set_text (GTK_LABEL (state->label),
|
||||||
|
state->shader_linked ? "Success" : "Failure");
|
||||||
|
|
||||||
|
return G_SOURCE_REMOVE;
|
||||||
|
}
|
||||||
|
|
||||||
static GstGLShader *
|
static GstGLShader *
|
||||||
_create_shader (GstElement * element, struct shader_state *state)
|
_create_shader (GstElement * element, struct shader_state *state)
|
||||||
{
|
{
|
||||||
GstGLContext *context;
|
GstGLContext *context;
|
||||||
GstGLShader *shader;
|
GstGLShader *shader, *new_shader;
|
||||||
|
|
||||||
g_object_get (G_OBJECT (element), "context", &context, NULL);
|
g_object_get (G_OBJECT (element), "context", &context, "shader", &shader,
|
||||||
|
NULL);
|
||||||
|
|
||||||
shader = _new_shader (context, state);
|
new_shader = _new_shader (context, state);
|
||||||
state->shader_linked = TRUE;
|
if (!shader && !new_shader)
|
||||||
|
g_warning ("Failed to create a shader!");
|
||||||
|
state->shader_linked = new_shader != NULL;
|
||||||
|
|
||||||
if (state->context)
|
if (shader)
|
||||||
gst_object_unref (state->context);
|
gst_object_unref (shader);
|
||||||
state->context = context;
|
gst_object_unref (context);
|
||||||
|
|
||||||
return shader;
|
g_main_context_invoke (NULL, (GSourceFunc) _set_compilation_state, state);
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
return new_shader;
|
||||||
_modify_shader (GstGLContext * context, struct shader_state *state)
|
|
||||||
{
|
|
||||||
GstGLShader *shader;
|
|
||||||
|
|
||||||
if (!(shader = _new_shader (context, state))) {
|
|
||||||
state->shader_linked = FALSE;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
state->shader_linked = TRUE;
|
|
||||||
|
|
||||||
g_object_set (state->shader, "shader", shader, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -232,18 +232,11 @@ _on_text_changed (GtkTextBuffer * text, struct text_view_state *state)
|
||||||
{
|
{
|
||||||
GtkTextIter start, end;
|
GtkTextIter start, end;
|
||||||
|
|
||||||
if (!state->state->context)
|
|
||||||
return;
|
|
||||||
|
|
||||||
gtk_text_buffer_get_bounds (text, &start, &end);
|
gtk_text_buffer_get_bounds (text, &start, &end);
|
||||||
if (state->str)
|
if (state->str)
|
||||||
g_free (state->str);
|
g_free (state->str);
|
||||||
state->str = gtk_text_buffer_get_text (text, &start, &end, FALSE);
|
state->str = gtk_text_buffer_get_text (text, &start, &end, FALSE);
|
||||||
gst_gl_context_thread_add (state->state->context,
|
g_object_set (state->state->shader, "update-shader", TRUE, NULL);
|
||||||
(GstGLContextThreadFunc) _modify_shader, state->state);
|
|
||||||
|
|
||||||
gtk_label_set_text (GTK_LABEL (state->state->label),
|
|
||||||
state->state->shader_linked ? "Success" : "Failure");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
|
|
Loading…
Reference in a new issue