mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
qmlglsrc: use glBlitFramebuffer to copy texture for GLES3.0
If support glBlitFrameBuffer, use it for texture copy instead of glCopyTexImage2D https://bugzilla.gnome.org/show_bug.cgi?id=777078
This commit is contained in:
parent
1c12c21653
commit
afa9c57a52
2 changed files with 50 additions and 1 deletions
|
@ -67,6 +67,8 @@ struct _QtGLWindowPrivate
|
|||
GstGLDisplay *display;
|
||||
GstGLContext *other_context;
|
||||
|
||||
GLuint fbo;
|
||||
|
||||
/* frames that qmlview rendered in its gl thread */
|
||||
quint64 frames_rendered;
|
||||
quint64 start;
|
||||
|
@ -121,6 +123,8 @@ QtGLWindow::QtGLWindow ( QWindow * parent, QQuickWindow *src ) :
|
|||
else
|
||||
connect (source, SIGNAL(sceneGraphInitialized()), this, SLOT(onSceneGraphInitialized()), Qt::DirectConnection);
|
||||
|
||||
connect (source, SIGNAL(sceneGraphInvalidated()), this, SLOT(onSceneGraphInvalidated()), Qt::DirectConnection);
|
||||
|
||||
GST_DEBUG ("%p init Qt Window", this->priv->display);
|
||||
}
|
||||
|
||||
|
@ -224,7 +228,23 @@ QtGLWindow::afterRendering()
|
|||
this->source->renderTargetId(), dst_tex, width,height);
|
||||
|
||||
gl->BindTexture (GL_TEXTURE_2D, dst_tex);
|
||||
gl->CopyTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, width, height, 0);
|
||||
if (gl->BlitFramebuffer) {
|
||||
gl->BindFramebuffer (GL_DRAW_FRAMEBUFFER, this->priv->fbo);
|
||||
gl->FramebufferTexture2D (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
||||
GL_TEXTURE_2D, dst_tex, 0);
|
||||
|
||||
ret = gst_gl_context_check_framebuffer_status (context);
|
||||
if (!ret) {
|
||||
GST_ERROR ("FBO errors");
|
||||
goto errors;
|
||||
}
|
||||
gl->ReadBuffer (GL_COLOR_ATTACHMENT0);
|
||||
gl->BlitFramebuffer (0, 0, width, height,
|
||||
0, 0, width, height,
|
||||
GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
} else {
|
||||
gl->CopyTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, width, height, 0);
|
||||
}
|
||||
|
||||
GST_DEBUG ("rendering finished");
|
||||
|
||||
|
@ -268,10 +288,38 @@ QtGLWindow::onSceneGraphInitialized()
|
|||
this->priv->initted = gst_qt_get_gl_wrapcontext (this->priv->display,
|
||||
&this->priv->other_context, NULL);
|
||||
|
||||
if (this->priv->initted && this->priv->other_context) {
|
||||
const GstGLFuncs *gl;
|
||||
|
||||
gst_gl_context_activate (this->priv->other_context, TRUE);
|
||||
gl = this->priv->other_context->gl_vtable;
|
||||
|
||||
gl->GenFramebuffers (1, &this->priv->fbo);
|
||||
|
||||
gst_gl_context_activate (this->priv->other_context, FALSE);
|
||||
}
|
||||
|
||||
GST_DEBUG ("%p created wrapped GL context %" GST_PTR_FORMAT, this,
|
||||
this->priv->other_context);
|
||||
}
|
||||
|
||||
void
|
||||
QtGLWindow::onSceneGraphInvalidated()
|
||||
{
|
||||
GST_DEBUG ("scene graph invalidated");
|
||||
|
||||
if (this->priv->fbo && this->priv->other_context) {
|
||||
const GstGLFuncs *gl;
|
||||
|
||||
gst_gl_context_activate (this->priv->other_context, TRUE);
|
||||
gl = this->priv->other_context->gl_vtable;
|
||||
|
||||
gl->DeleteFramebuffers (1, &this->priv->fbo);
|
||||
|
||||
gst_gl_context_activate (this->priv->other_context, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
QtGLWindow::getGeometry(int * width, int * height)
|
||||
{
|
||||
|
|
|
@ -48,6 +48,7 @@ private Q_SLOTS:
|
|||
void beforeRendering ();
|
||||
void afterRendering ();
|
||||
void onSceneGraphInitialized ();
|
||||
void onSceneGraphInvalidated ();
|
||||
void aboutToQuit();
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue