From ca67a460eed4247c551b97e37590a02f65121759 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Thu, 5 Apr 2018 16:05:12 +1000 Subject: [PATCH] meson: add build files for the qml plugin Tested on linux with X11/wayland and semi-tested on Windows. Windows crashes on item destruction however this is better than nothing. Fix up some win32 build issues on the way with mismatched {} and G_STMT_{START,END} --- ext/meson.build | 2 +- ext/qt/gstqtglutility.cc | 12 +- ext/qt/meson.build | 123 ++++++++++++++++++ tests/examples/meson.build | 2 +- tests/examples/qt/meson.build | 2 + tests/examples/qt/qmlsink/CMakeLists.txt | 2 +- tests/examples/qt/qmlsink/meson.build | 19 +++ tests/examples/qt/qmlsink/play.pro | 2 +- .../qt/qmlsink/{qml.qrc => qmlsink.qrc} | 0 tests/examples/qt/qmlsrc/grabqml.pro | 2 +- tests/examples/qt/qmlsrc/meson.build | 19 +++ .../qt/qmlsrc/{qml.qrc => qmlsrc.qrc} | 0 12 files changed, 175 insertions(+), 10 deletions(-) create mode 100644 ext/qt/meson.build create mode 100644 tests/examples/qt/meson.build create mode 100644 tests/examples/qt/qmlsink/meson.build rename tests/examples/qt/qmlsink/{qml.qrc => qmlsink.qrc} (100%) create mode 100644 tests/examples/qt/qmlsrc/meson.build rename tests/examples/qt/qmlsrc/{qml.qrc => qmlsrc.qrc} (100%) diff --git a/ext/meson.build b/ext/meson.build index 52eb4c7485..dd1d316374 100644 --- a/ext/meson.build +++ b/ext/meson.build @@ -14,7 +14,7 @@ endif subdir('libpng') subdir('mpg123') subdir('raw1394') -# FIXME: subdir('qt') +subdir('qt') subdir('pulse') subdir('shout2') subdir('soup') diff --git a/ext/qt/gstqtglutility.cc b/ext/qt/gstqtglutility.cc index cc84c8340c..82f4983a45 100644 --- a/ext/qt/gstqtglutility.cc +++ b/ext/qt/gstqtglutility.cc @@ -48,6 +48,8 @@ #endif #endif +#include + #define GST_CAT_DEFAULT qt_gl_utils_debug GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT); @@ -204,12 +206,12 @@ gst_qt_get_gl_wrapcontext (GstGLDisplay * display, GST_ERROR ("cannot wrap qt OpenGL context"); return FALSE; } - + (void) platform; (void) gl_api; (void) gl_handle; - gst_gl_context_activate (*wrap_glcontext, TRUE); + gst_gl_context_activate(*wrap_glcontext, TRUE); if (!gst_gl_context_fill_info (*wrap_glcontext, &error)) { GST_ERROR ("failed to retrieve qt context info: %s", error->message); g_object_unref (*wrap_glcontext); @@ -242,7 +244,7 @@ gst_qt_get_gl_wrapcontext (GstGLDisplay * display, wglMakeCurrent (device, 0); gst_object_unref (window); if (!gst_gl_context_create (*context, *wrap_glcontext, &error)) { - GST_ERROR ("%p failed to create shared GL context: %s", this, error->message); + GST_ERROR ("failed to create shared GL context: %s", error->message); g_object_unref (*context); *context = NULL; g_object_unref (*wrap_glcontext); @@ -251,10 +253,10 @@ gst_qt_get_gl_wrapcontext (GstGLDisplay * display, return FALSE; } wglMakeCurrent (device, (HGLRC) gl_handle); - } + } G_STMT_END; #endif gst_gl_context_activate (*wrap_glcontext, FALSE); - } G_STMT_END; + } return TRUE; } diff --git a/ext/qt/meson.build b/ext/qt/meson.build new file mode 100644 index 0000000000..754dc5a1d7 --- /dev/null +++ b/ext/qt/meson.build @@ -0,0 +1,123 @@ +sources = [ + 'gstplugin.cc', + 'gstqsgtexture.cc', + 'gstqtglutility.cc', + 'gstqtsink.cc', + 'gstqtsrc.cc', + 'qtitem.cc', + 'qtwindow.cc', +] + +moc_headers = [ + 'qtitem.h', + 'qtwindow.h', + 'gstqsgtexture.h', +] + +if have_cxx and build_gstgl + qt5_mod = import('qt5') + qt5qml_dep = dependency('qt5', modules : ['Core', 'Gui', 'Qml', 'Quick'], required: false) + + # FIXME Add a way to get that information out of the qt5 module + moc = find_program('moc-qt5', required : false) + if qt5qml_dep.found() and moc.found() + optional_deps = [] + qt_defines = [] + have_qpa_include = false + have_qt_windowing = false + + # Attempt to find the QPA header either through pkg-config (preferred) or qmake + # This semi-matches what meson does internally with the qt5 module + # FIXME Add a way to get some of this information out of the qt5 module + if not have_qpa_include + qt5core_dep = dependency('Qt5Core', required: false) + if qt5core_dep.found() and qt5core_dep.type_name() == 'pkgconfig' + qt_version = qt5core_dep.version() + qt_include_dir = qt5core_dep.get_pkgconfig_variable('includedir') + qpa_include_path = join_paths(qt_include_dir, 'QtGui', qt_version, 'QtGui') + if cxx.has_header('qpa/qplatformnativeinterface.h', + dependencies : qt5core_dep, + args : '-I' + qpa_include_path) + qt_defines += '-DHAVE_QT_QPA_HEADER' + qt_defines += '-I' + qpa_include_path + have_qpa_include = true + message('Found QPA header using pkg-config') + endif + endif + endif + if not have_qpa_include + qmake = find_program('qmake') + if qmake.found() + qt_version = run_command(qmake, '-query', 'QT_VERSION').stdout().strip() + qt_include_dir = run_command(qmake, '-query', 'QT_INSTALL_HEADERS').stdout().strip() + qpa_include_path = join_paths(qt_include_dir, 'QtGui', qt_version, 'QtGui') + if cxx.has_header('qpa/qplatformnativeinterface.h', + args : '-I' + qpa_include_path) + qt_defines += '-DHAVE_QT_QPA_HEADER' + qt_defines += '-I' + qpa_include_path + have_qpa_include = true + message('Found QPA header using qmake') + endif + endif + endif + + # Try to come up with all the platform/winsys combinations that will work + + if gst_gl_have_window_x11 and gst_gl_have_platform_glx + qt5x11extras = dependency('qt5', modules : ['X11Extras'], required : false) + if qt5x11extras.found() + optional_deps += qt5x11extras + qt_defines += ['-DHAVE_QT_X11'] + have_qt_windowing = true + endif + endif + + if gst_gl_have_platform_egl + if have_qpa_include + if gst_gl_have_window_wayland + qt5waylandextras = dependency('qt5', modules : ['WaylandClient'], required : false) + if qt5waylandextras.found() + optional_deps += qt5waylandextras + qt_defines += ['-DHAVE_QT_WAYLAND'] + have_qt_windowing = true + endif + endif + if gst_gl_have_window_android + # FIXME: untested + qt5androidextras = dependency('qt5', modules : ['AndroidExtras'], required : false) + if qt5androidextras.found() + optional_deps += qt5androidextras + # also uses the HAVE_QT_EGLFS define below + have_qt_windowing = true + endif + endif + endif + qt_defines += ['-DHAVE_QT_EGLFS'] + have_qt_windowing = true + endif + + if gst_gl_have_platform_wgl and gst_gl_have_window_win32 + # for wglMakeCurrent() + opengl32_dep = cc.find_library('opengl32', required : false) + if opengl32_dep.found() + qt_defines += ['-DHAVE_QT_WIN32'] + optional_deps += opengl32_dep + have_qt_windowing = true + endif + endif + + # FIXME: OSX/iOS definitions + + if have_qt_windowing + # Build it! + moc_files = qt5_mod.preprocess(moc_headers : moc_headers) + library('gstqmlgl', sources, moc_files, + cpp_args : gst_plugins_good_args + qt_defines, + link_args : noseh_link_args, + include_directories: [configinc, libsinc], + dependencies : [glib_deps, gst_dep, gstvideo_dep, gstgl_dep, qt5qml_dep, optional_deps], + install: true, + install_dir : plugins_install_dir) + endif + endif +endif diff --git a/tests/examples/meson.build b/tests/examples/meson.build index 19f9a0defa..d96ca32f6a 100644 --- a/tests/examples/meson.build +++ b/tests/examples/meson.build @@ -2,7 +2,7 @@ subdir('audiofx') subdir('cairo') #FIXME: subdir('gtk') subdir('level') -#FIXME: subdir('qt') +subdir('qt') subdir('rtp') subdir('rtsp') subdir('shapewipe') diff --git a/tests/examples/qt/meson.build b/tests/examples/qt/meson.build new file mode 100644 index 0000000000..3fa08cfa2c --- /dev/null +++ b/tests/examples/qt/meson.build @@ -0,0 +1,2 @@ +subdir('qmlsink') +subdir('qmlsrc') diff --git a/tests/examples/qt/qmlsink/CMakeLists.txt b/tests/examples/qt/qmlsink/CMakeLists.txt index 02b0e11ea6..6005f66ceb 100644 --- a/tests/examples/qt/qmlsink/CMakeLists.txt +++ b/tests/examples/qt/qmlsink/CMakeLists.txt @@ -14,7 +14,7 @@ find_package(Qt5Qml REQUIRED) find_package(Qt5Quick REQUIRED) set (SRC_LIST main.cpp) -qt5_add_resources(RESOURCES qml.qrc) +qt5_add_resources(RESOURCES qmlsink.qrc) link_directories(${GSTREAMER_LIBRARY_DIRS}) include_directories (${GSTREAMER_INCLUDE_DIRS}) add_executable(qml-example ${SRC_LIST} ${RESOURCES}) diff --git a/tests/examples/qt/qmlsink/meson.build b/tests/examples/qt/qmlsink/meson.build new file mode 100644 index 0000000000..d1f3f4d4b1 --- /dev/null +++ b/tests/examples/qt/qmlsink/meson.build @@ -0,0 +1,19 @@ +sources = [ + 'main.cpp', +] + +if have_cxx and build_gstgl and gstgl_dep.found() + qt5_mod = import('qt5') + qt5qml_deps = dependency('qt5', modules : ['Core', 'Gui', 'Widgets', 'Qml', 'Quick'], required: false) + + # FIXME Add a way to get that information out of the qt5 module + moc = find_program('moc-qt5', required : false) + if qt5qml_deps.found() and moc.found() + qt_preprocessed = qt5_mod.preprocess(qresources : 'qmlsink.qrc') + executable('qmlsink', sources, qt_preprocessed, + dependencies : [gst_dep, qt5qml_deps], + c_args : gst_plugins_good_args, + include_directories : [configinc], + install: false) + endif +endif diff --git a/tests/examples/qt/qmlsink/play.pro b/tests/examples/qt/qmlsink/play.pro index 374e40297a..9ecaf87b12 100644 --- a/tests/examples/qt/qmlsink/play.pro +++ b/tests/examples/qt/qmlsink/play.pro @@ -14,7 +14,7 @@ INCLUDEPATH += ../lib SOURCES += main.cpp -RESOURCES += qml.qrc +RESOURCES += qmlsink.qrc # Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH = diff --git a/tests/examples/qt/qmlsink/qml.qrc b/tests/examples/qt/qmlsink/qmlsink.qrc similarity index 100% rename from tests/examples/qt/qmlsink/qml.qrc rename to tests/examples/qt/qmlsink/qmlsink.qrc diff --git a/tests/examples/qt/qmlsrc/grabqml.pro b/tests/examples/qt/qmlsrc/grabqml.pro index 374e40297a..9c97c670a4 100644 --- a/tests/examples/qt/qmlsrc/grabqml.pro +++ b/tests/examples/qt/qmlsrc/grabqml.pro @@ -14,7 +14,7 @@ INCLUDEPATH += ../lib SOURCES += main.cpp -RESOURCES += qml.qrc +RESOURCES += qmlsrc.qrc # Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH = diff --git a/tests/examples/qt/qmlsrc/meson.build b/tests/examples/qt/qmlsrc/meson.build new file mode 100644 index 0000000000..df7f94f0e8 --- /dev/null +++ b/tests/examples/qt/qmlsrc/meson.build @@ -0,0 +1,19 @@ +sources = [ + 'main.cpp', +] + +if have_cxx and build_gstgl and gstgl_dep.found() + qt5_mod = import('qt5') + qt5qml_deps = dependency('qt5', modules : ['Core', 'Gui', 'Widgets', 'Qml', 'Quick'], required: false) + + # FIXME Add a way to get that information out of the qt5 module + moc = find_program('moc-qt5', required : false) + if qt5qml_deps.found() and moc.found() + qt_preprocessed = qt5_mod.preprocess(qresources : 'qmlsrc.qrc') + executable('qmlsrc', sources, qt_preprocessed, + dependencies : [gst_dep, qt5qml_deps], + c_args : gst_plugins_good_args, + include_directories : [configinc], + install: false) + endif +endif diff --git a/tests/examples/qt/qmlsrc/qml.qrc b/tests/examples/qt/qmlsrc/qmlsrc.qrc similarity index 100% rename from tests/examples/qt/qmlsrc/qml.qrc rename to tests/examples/qt/qmlsrc/qmlsrc.qrc