summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Waters <matthew@centricular.com>2016-02-26 08:34:11 +1100
committerMatthew Waters <matthew@centricular.com>2016-02-26 10:59:04 +1100
commitabec124f6946e9fe0635dc53d729b3c2d92be9a9 (patch)
tree22fa3b290d7d01cabbcc2c7495635e097b595360
parenta50e4bcadffe4b815d0754f68e240a3aa20556eb (diff)
glcontext: add a method to add a context to another share group
Intended for use with wrapped contexts that are created shared with gst's gl contexts in order to manage the internal sharegroup state correctly. e.g. with caopengllayer (which is used in glimagesink and caopengllayersink on OS X), we create a CGL context from the gst context and the sharing state was not being correctly set on either GL context and gst_gl_context_is_shared() was always returning FALSE. With 11fb4fff80b63b9d67a731d4bb238b6c0a29d774 only flushing with multiple shared contexts, the required flush was not occuring causing screen corruption or stuttering. Note: this didn't affect GST_GL_API=opengl pipelines https://bugzilla.gnome.org/show_bug.cgi?id=762620
-rw-r--r--gst-libs/gst/gl/cocoa/gstglcaopengllayer.m1
-rw-r--r--gst-libs/gst/gl/gstglcontext.c29
-rw-r--r--gst-libs/gst/gl/gstglcontext.h1
3 files changed, 30 insertions, 1 deletions
diff --git a/gst-libs/gst/gl/cocoa/gstglcaopengllayer.m b/gst-libs/gst/gl/cocoa/gstglcaopengllayer.m
index cc82c3c2c..a11700d24 100644
--- a/gst-libs/gst/gl/cocoa/gstglcaopengllayer.m
+++ b/gst-libs/gst/gl/cocoa/gstglcaopengllayer.m
@@ -126,6 +126,7 @@ _context_ready (gpointer data)
}
gst_gl_context_activate (self->draw_context, TRUE);
+ gst_gl_context_set_shared_with (self->draw_context, self->gst_gl_context);
if (!gst_gl_context_fill_info (self->draw_context, &error)) {
GST_ERROR ("failed to fill wrapped context information: %s", error->message);
return NULL;
diff --git a/gst-libs/gst/gl/gstglcontext.c b/gst-libs/gst/gl/gstglcontext.c
index 88526bde2..2c208edd0 100644
--- a/gst-libs/gst/gl/gstglcontext.c
+++ b/gst-libs/gst/gl/gstglcontext.c
@@ -1617,11 +1617,38 @@ gboolean
gst_gl_context_is_shared (GstGLContext * context)
{
g_return_val_if_fail (GST_IS_GL_CONTEXT (context), FALSE);
- g_return_val_if_fail (context->priv->alive, FALSE);
+ if (GST_IS_GL_WRAPPED_CONTEXT (context))
+ g_return_val_if_fail (context->priv->active_thread, FALSE);
+ else
+ g_return_val_if_fail (context->priv->alive, FALSE);
return _context_share_group_is_shared (context->priv->sharegroup);
}
+/**
+ * gst_gl_context_set_shared_with:
+ * @context: a wrapped #GstGLContext
+ * @share: another #GstGLContext
+ *
+ * Will internally set @context as shared with @share
+ *
+ * Since: 1.8
+ */
+void
+gst_gl_context_set_shared_with (GstGLContext * context, GstGLContext * share)
+{
+ g_return_if_fail (GST_IS_GL_CONTEXT (context));
+ g_return_if_fail (GST_IS_GL_CONTEXT (share));
+ g_return_if_fail (!gst_gl_context_is_shared (context));
+ /* XXX: may be a little too strict */
+ g_return_if_fail (GST_IS_GL_WRAPPED_CONTEXT (context));
+
+ if (context->priv->sharegroup)
+ _context_share_group_unref (context->priv->sharegroup);
+ context->priv->sharegroup =
+ _context_share_group_ref (share->priv->sharegroup);
+}
+
static GstGLAPI
gst_gl_wrapped_context_get_gl_api (GstGLContext * context)
{
diff --git a/gst-libs/gst/gl/gstglcontext.h b/gst-libs/gst/gl/gstglcontext.h
index 64464aa2c..4d917323d 100644
--- a/gst-libs/gst/gl/gstglcontext.h
+++ b/gst-libs/gst/gl/gstglcontext.h
@@ -149,6 +149,7 @@ guintptr gst_gl_context_get_current_gl_context (GstGLPlatform platform)
GstGLAPI gst_gl_context_get_current_gl_api (GstGLPlatform platform, guint *major, guint *minor);
gboolean gst_gl_context_is_shared (GstGLContext * context);
+void gst_gl_context_set_shared_with (GstGLContext * context, GstGLContext * share);
gboolean gst_gl_context_fill_info (GstGLContext * context, GError ** error);