qt: don't always activate/deactivate our GstGLContext
authorMatthew Waters <matthew@centricular.com>
Tue, 25 Feb 2020 10:47:14 +0000 (21:47 +1100)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 18 Mar 2020 11:22:39 +0000 (11:22 +0000)
Techincally it is enough to activate at the beginning and then forget.

ext/qt/gstqsgtexture.cc
ext/qt/qtitem.cc

index 2b314e0..a05d26e 100644 (file)
@@ -99,8 +99,6 @@ GstQSGTexture::bind ()
   if (!this->qt_context_)
     return;
 
-  gst_gl_context_activate (this->qt_context_, TRUE);
-
   if (!this->buffer_)
     goto out;
   if (GST_VIDEO_INFO_FORMAT (&this->v_info) == GST_VIDEO_FORMAT_UNKNOWN)
@@ -174,8 +172,6 @@ out:
 
     funcs->glBindTexture (GL_TEXTURE_2D, this->dummy_tex_id_);
   }
-
-  gst_gl_context_activate (this->qt_context_, FALSE);
 }
 
 /* can be called from any thread */
index 3839aa9..62c28a5 100644 (file)
@@ -199,7 +199,9 @@ QtGLVideoItem::updatePaintNode(QSGNode * oldNode,
   GstQSGTexture *tex;
 
   g_mutex_lock (&this->priv->lock);
-  gst_gl_context_activate (this->priv->other_context, TRUE);
+
+  if (gst_gl_context_get_current() == NULL)
+    gst_gl_context_activate (this->priv->other_context, TRUE);
 
   GST_TRACE ("%p updatePaintNode", this);
 
@@ -238,7 +240,6 @@ QtGLVideoItem::updatePaintNode(QSGNode * oldNode,
 
   texNode->setRect (QRectF (result.x, result.y, result.w, result.h));
 
-  gst_gl_context_activate (this->priv->other_context, FALSE);
   g_mutex_unlock (&this->priv->lock);
 
   return texNode;