[meta-freescale] [PATCH 2/4] gstreamer1.0-plugins-bad: Add i.mx specific code about qmlglplugin
Yuqing Zhu
carol.zhu at nxp.com
Thu May 25 22:32:05 PDT 2017
*Add FB and X11 support for qml gl plugins
*Use Render-to-texture for texture copy since
we use direct viv for GPU download
Signed-off-by: Yuqing Zhu <carol.zhu at nxp.com>
---
.../0008-qmlglplugin-Add-i.mx-specific-code.patch | 203 +++++++++++++++++++++
.../gstreamer1.0-plugins-bad_1.10.%.bbappend | 1 +
2 files changed, 204 insertions(+)
create mode 100755 recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad/0008-qmlglplugin-Add-i.mx-specific-code.patch
diff --git a/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad/0008-qmlglplugin-Add-i.mx-specific-code.patch b/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad/0008-qmlglplugin-Add-i.mx-specific-code.patch
new file mode 100755
index 0000000..c5e1775
--- /dev/null
+++ b/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad/0008-qmlglplugin-Add-i.mx-specific-code.patch
@@ -0,0 +1,203 @@
+From 2afb646ca0cb911a7735ed5512ebc4a8f02ad052 Mon Sep 17 00:00:00 2001
+From: Haihua Hu <jared.hu at nxp.com>
+Date: Mon, 14 Nov 2016 14:34:47 +0800
+Subject: [PATCH 19/24] qmlglplugin: Add i.mx specific code
+
+1.Add FB and X11 support for qml gl plugins
+2.Use Render-to-texture for texture copy since we use direct viv
+ for GPU download.
+
+Upstream-Status: Inappropriate [i.MX specific]
+
+Signed-off-by: Haihua Hu <jared.hu at nxp.com>
+---
+ configure.ac | 9 +++++++--
+ ext/qt/gstqtglutility.cc | 17 +++++++++++++---
+ ext/qt/qtwindow.cc | 50 +++++++++++++++++++++++++++++++++++++++++++++++-
+ ext/qt/qtwindow.h | 1 +
+ 4 files changed, 71 insertions(+), 6 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 0876a14..a4cc878 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -2967,12 +2967,12 @@ AG_GST_CHECK_FEATURE(QT, [Qt elements], qt, [
+ HAVE_QT="yes"
+ HAVE_QT_WINDOWING="no"
+ QT_VERSION="`$PKG_CONFIG --modversion Qt5Core`"
+- QPA_INCLUDE_PATH=`$PKG_CONFIG --variable=includedir Qt5Core`/QtGui/${QT_VERSION}/QtGui
++ QPA_INCLUDE_PATH=${STAGING_INCDIR}/../../`$PKG_CONFIG --variable=includedir Qt5Core`/QtGui/${QT_VERSION}/QtGui
+ AS_IF([test -f "$QPA_INCLUDE_PATH/qpa/qplatformnativeinterface.h"], [
+ QT_CFLAGS="$QT_CFLAGS -I$QPA_INCLUDE_PATH"
+ HAVE_QT_QPA_HEADER="yes"
+ ], [AC_MSG_NOTICE([Cannot find QPA])])
+- if test "x$GST_GL_HAVE_WINDOW_X11" = "x1" -a "x$GST_GL_HAVE_PLATFORM_GLX" = "x1"; then
++ if test "x$GST_GL_HAVE_WINDOW_X11" = "x1" -a "x$GST_GL_HAVE_PLATFORM_EGL" = "x1"; then
+ PKG_CHECK_MODULES(QT_X11, Qt5X11Extras, [
+ AC_DEFINE([HAVE_QT_X11], [], [Define if Qt X11 integration is installed])
+ QT_CFLAGS="$QT_CFLAGS $QT_X11_CFLAGS"
+@@ -3032,6 +3032,11 @@ AG_GST_CHECK_FEATURE(QT, [Qt elements], qt, [
+ HAVE_QT_WINDOWING="yes"
+ fi
+ fi
++ if test "x$GST_GL_HAVE_WINDOW_FB" = "x1" -a "x$GST_GL_HAVE_PLATFORM_EGL" = "x1"; then
++ QT_CFLAGS="$QT_CFLAGS"
++ QT_LIBS="$QT_LIBS"
++ HAVE_QT_WINDOWING="yes"
++ fi
+ if test "x$HAVE_QT_WINDOWING" = "xno"; then
+ AC_MSG_WARN([Could not find any Qt Windowing integration])
+ HAVE_QT="no"
+diff --git a/ext/qt/gstqtglutility.cc b/ext/qt/gstqtglutility.cc
+index 4d6d318..c85465f 100644
+--- a/ext/qt/gstqtglutility.cc
++++ b/ext/qt/gstqtglutility.cc
+@@ -25,10 +25,10 @@
+ #include "gstqtglutility.h"
+ #include <QtGui/QGuiApplication>
+
+-#if GST_GL_HAVE_WINDOW_X11 && GST_GL_HAVE_PLATFORM_GLX && defined (HAVE_QT_X11)
++#if GST_GL_HAVE_WINDOW_X11 && GST_GL_HAVE_PLATFORM_EGL && defined (HAVE_QT_X11)
+ #include <QX11Info>
+ #include <gst/gl/x11/gstgldisplay_x11.h>
+-#include <gst/gl/x11/gstglcontext_glx.h>
++#include <gst/gl/egl/gstglcontext_egl.h>
+ #endif
+
+ #if GST_GL_HAVE_WINDOW_WAYLAND && GST_GL_HAVE_PLATFORM_EGL && defined (HAVE_QT_WAYLAND)
+@@ -45,6 +45,12 @@
+ #include <gst/gl/coaoa/gstgldisplay_cocoa.h>
+ #endif
+
++#if GST_GL_HAVE_WINDOW_FB
++#define LINUX
++#define EGL_API_FB
++#include <gst/gl/fb/gstgldisplay_fb.h>
++#endif
++
+ #define GST_CAT_DEFAULT qt_gl_utils_debug
+ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
+
+@@ -121,7 +127,7 @@ gst_qt_get_gl_wrapcontext (GstGLDisplay * display,
+
+ #if GST_GL_HAVE_WINDOW_X11 && defined (HAVE_QT_X11)
+ if (GST_IS_GL_DISPLAY_X11 (display)) {
+- platform = GST_GL_PLATFORM_GLX;
++ platform = GST_GL_PLATFORM_EGL;
+ }
+ #endif
+ #if GST_GL_HAVE_WINDOW_WAYLAND && defined (HAVE_QT_WAYLAND)
+@@ -134,6 +140,11 @@ gst_qt_get_gl_wrapcontext (GstGLDisplay * display,
+ platform = GST_GL_PLATFORM_EGL;
+ }
+ #endif
++#if GST_GL_HAVE_WINDOW_FB
++ if (GST_IS_GL_DISPLAY_FB (display)) {
++ platform = GST_GL_PLATFORM_EGL;
++ }
++#endif
+ if (platform == 0) {
+ #if GST_GL_HAVE_WINDOW_COCOA && GST_GL_HAVE_PLATFORM_COCOA && defined (HAVE_QT_MAC)
+ platform = GST_GL_PLATFORM_CGL;
+diff --git a/ext/qt/qtwindow.cc b/ext/qt/qtwindow.cc
+index c3fd564..3d96751 100644
+--- a/ext/qt/qtwindow.cc
++++ b/ext/qt/qtwindow.cc
+@@ -66,6 +66,9 @@ struct _QtGLWindowPrivate
+ GstGLDisplay *display;
+ GstGLContext *other_context;
+
++ /* used for direct viv renderTarget */
++ GLuint fbo;
++
+ /* frames that qmlview rendered in its gl thread */
+ guint64 frames_rendered;
+ };
+@@ -118,6 +121,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);
+ }
+
+@@ -210,8 +215,23 @@ QtGLWindow::afterRendering()
+ GST_DEBUG ("qml render target id %d, render to tex %d %dX%d",
+ this->source->renderTargetId(), dst_tex, width,height);
+
++ gl->BindFramebuffer (GL_DRAW_FRAMEBUFFER, this->priv->fbo);
+ gl->BindTexture (GL_TEXTURE_2D, dst_tex);
+- gl->CopyTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, width, height, 0);
++ 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 );
++
++ //gl->CopyTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, width, height, 0);
+
+ GST_DEBUG ("rendering finished");
+
+@@ -250,10 +270,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)
+ {
+diff --git a/ext/qt/qtwindow.h b/ext/qt/qtwindow.h
+index 5820e77..8cb5a2c 100644
+--- a/ext/qt/qtwindow.h
++++ b/ext/qt/qtwindow.h
+@@ -48,6 +48,7 @@ private Q_SLOTS:
+ void beforeRendering ();
+ void afterRendering ();
+ void onSceneGraphInitialized ();
++ void onSceneGraphInvalidated ();
+ void aboutToQuit();
+
+ private:
+--
+1.9.1
+
diff --git a/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.10.%.bbappend b/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.10.%.bbappend
index 7d852d8..0a25c4d 100644
--- a/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.10.%.bbappend
+++ b/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.10.%.bbappend
@@ -15,6 +15,7 @@ SRC_URI_append_imxgpu2d = " \
file://0005-glcolorconvert-convert-YUV-to-RGB-use-directviv.patch \
file://0006-glwindow-work-around-for-no-frame-when-imxplayer-use.patch \
file://0007-glcolorconvert-fix-MRT-cannot-work-in-GLES3.0.patch \
+ file://0008-qmlglplugin-Add-i.mx-specific-code.patch \
"
--
1.9.1
More information about the meta-freescale
mailing list