diff --git a/gst-libs/gst/gl/cocoa/gstglcaopengllayer.m b/gst-libs/gst/gl/cocoa/gstglcaopengllayer.m index cc82c3c2c6..a11700d245 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 88526bde27..2c208edd09 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 64464aa2c3..4d917323d4 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);