[vlc-commits] [Git][videolan/vlc][master] 3 commits: qt: move the dcomp check in CompositorDirectComposition::init()

Steve Lhomme (@robUx4) gitlab at videolan.org
Sat Jun 8 13:18:28 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
1e43b9ee by Steve Lhomme at 2024-06-08T14:46:20+02:00
qt: move the dcomp check in CompositorDirectComposition::init()

We can refuse to initialize from here. It will try the next in the compositorList list.

- - - - -
f6df83c0 by Steve Lhomme at 2024-06-08T14:46:20+02:00
qt: remove preInit() that always returns true

- - - - -
7c212192 by Steve Lhomme at 2024-06-08T14:46:39+02:00
qt: check the qt platform matches before checking for dcomp

- - - - -


13 changed files:

- modules/gui/qt/maininterface/compositor.cpp
- modules/gui/qt/maininterface/compositor.hpp
- modules/gui/qt/maininterface/compositor_dcomp.cpp
- modules/gui/qt/maininterface/compositor_dcomp.hpp
- modules/gui/qt/maininterface/compositor_dummy.cpp
- modules/gui/qt/maininterface/compositor_dummy.hpp
- modules/gui/qt/maininterface/compositor_wayland.cpp
- modules/gui/qt/maininterface/compositor_wayland.hpp
- modules/gui/qt/maininterface/compositor_win7.cpp
- modules/gui/qt/maininterface/compositor_win7.hpp
- modules/gui/qt/maininterface/compositor_x11.cpp
- modules/gui/qt/maininterface/compositor_x11.hpp
- modules/gui/qt/qt.cpp


Changes:

=====================================
modules/gui/qt/maininterface/compositor.cpp
=====================================
@@ -53,29 +53,23 @@ static Compositor* instanciateCompositor(qt_intf_t *p_intf) {
     return new T(p_intf);
 }
 
-template<typename T>
-static bool preInit(qt_intf_t *p_intf) {
-    return T::preInit(p_intf);
-}
-
 struct {
     const char* name;
     Compositor* (*instantiate)(qt_intf_t *p_intf);
-    bool (*preInit)(qt_intf_t *p_intf);
 } static compositorList[] = {
 #ifdef _WIN32
 #ifdef HAVE_DCOMP_H
-    {"dcomp", &instanciateCompositor<CompositorDirectComposition>, &preInit<CompositorDirectComposition> },
+    {"dcomp", &instanciateCompositor<CompositorDirectComposition> },
 #endif
-    {"win7", &instanciateCompositor<CompositorWin7>, &preInit<CompositorWin7> },
+    {"win7", &instanciateCompositor<CompositorWin7> },
 #endif
 #ifdef QT_HAS_WAYLAND_COMPOSITOR
-    {"wayland", &instanciateCompositor<CompositorWayland>, &preInit<CompositorWayland> },
+    {"wayland", &instanciateCompositor<CompositorWayland> },
 #endif
 #ifdef QT_HAS_X11_COMPOSITOR
-    {"x11", &instanciateCompositor<CompositorX11>, &preInit<CompositorX11> },
+    {"x11", &instanciateCompositor<CompositorX11> },
 #endif
-    {"dummy", &instanciateCompositor<CompositorDummy>, &preInit<CompositorDummy> }
+    {"dummy", &instanciateCompositor<CompositorDummy> }
 };
 
 CompositorFactory::CompositorFactory(qt_intf_t *p_intf, const char* compositor)
@@ -84,19 +78,6 @@ CompositorFactory::CompositorFactory(qt_intf_t *p_intf, const char* compositor)
 {
 }
 
-bool CompositorFactory::preInit()
-{
-    for (; m_compositorIndex < ARRAY_SIZE(compositorList); m_compositorIndex++)
-    {
-        if (m_compositorName == "auto" || m_compositorName == compositorList[m_compositorIndex].name)
-        {
-            if (compositorList[m_compositorIndex].preInit(m_intf))
-                return true;
-        }
-    }
-    return false;
-}
-
 Compositor* CompositorFactory::createCompositor()
 {
     for (; m_compositorIndex < ARRAY_SIZE(compositorList); m_compositorIndex++)


=====================================
modules/gui/qt/maininterface/compositor.hpp
=====================================
@@ -173,9 +173,6 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(CompositorVideo::Flags)
  *
  * the usual scenario is:
  *
- *   - call to preInit that will try to preInit compositors from list until we find
- *     a matching candidate
- *
  *   - start Qt main loop
  *
  *   - call to createCompositor to instantiate the compositor, if it fails it will
@@ -186,18 +183,6 @@ public:
 
     CompositorFactory(qt_intf_t *p_intf, const char* compositor = "auto");
 
-    /**
-     * @brief preInit will check whether a compositor can be used, before starting Qt,
-     * each candidate may perform some basic checks and can setup Qt environment variable if required
-     *
-     * @note if a compositor return true on preinit but fails to initialize afterwards, next
-     * compositor in chain will be initialized without the preinit phaze (as Qt will be already started)
-     * this might lead to an unstable configuration if incompatible operations are done in the preInit phase
-     *
-     * @return true if a compositor can be instantiated
-     */
-    bool preInit();
-
     /**
      * @brief createCompositor will instantiate a compositor
      *


=====================================
modules/gui/qt/maininterface/compositor_dcomp.cpp
=====================================
@@ -109,13 +109,19 @@ CompositorDirectComposition::~CompositorDirectComposition()
     destroyMainInterface();
 }
 
-bool CompositorDirectComposition::preInit(qt_intf_t *intf)
+bool CompositorDirectComposition::init()
 {
 #if !defined(QRhiD3D11_ACTIVE) && !defined(QRhiD3D12_ACTIVE)
-    msg_Warn(intf, "compositor_dcomp was not built with D3D11 or D3D12 headers. It will not work.");
+    msg_Warn(m_intf, "compositor_dcomp was not built with D3D11 or D3D12 headers. It will not work.");
     return false;
 #endif
 
+    {
+        const QString& platformName = qApp->platformName();
+        if (!(platformName == QLatin1String("windows") || platformName == QLatin1String("direct2d")))
+            return false;
+    }
+
     QSystemLibrary dcomplib(QLatin1String("dcomp"));
 
     typedef HRESULT (__stdcall *DCompositionCreateDeviceFuncPtr)(
@@ -128,24 +134,13 @@ bool CompositorDirectComposition::preInit(qt_intf_t *intf)
     Microsoft::WRL::ComPtr<IDCompositionDevice> device;
     if (!func || FAILED(func(nullptr, IID_PPV_ARGS(&device))))
     {
-        msg_Warn(intf, "Can not create DCompositionDevice. CompositorDirectComposition will not work.");
+        msg_Warn(m_intf, "Can not create DCompositionDevice. CompositorDirectComposition will not work.");
         return false;
     }
 
     return true;
 }
 
-bool CompositorDirectComposition::init()
-{
-    {
-        const QString& platformName = qApp->platformName();
-        if (!(platformName == QLatin1String("windows") || platformName == QLatin1String("direct2d")))
-            return false;
-    }
-
-    return true;
-}
-
 void CompositorDirectComposition::setup()
 {
     assert(m_quickView);


=====================================
modules/gui/qt/maininterface/compositor_dcomp.hpp
=====================================
@@ -48,7 +48,6 @@ public:
     CompositorDirectComposition(qt_intf_t *p_intf, QObject* parent = nullptr);
     ~CompositorDirectComposition();
 
-    static bool preInit(qt_intf_t *);
     bool init() override;
 
     bool makeMainInterface(MainCtx*) override;


=====================================
modules/gui/qt/maininterface/compositor_dummy.cpp
=====================================
@@ -33,11 +33,6 @@ CompositorDummy::~CompositorDummy()
 {
 }
 
-bool CompositorDummy::preInit(qt_intf_t *)
-{
-    return true;
-}
-
 bool CompositorDummy::init()
 {
     return true;


=====================================
modules/gui/qt/maininterface/compositor_dummy.hpp
=====================================
@@ -38,7 +38,6 @@ public:
     CompositorDummy(qt_intf_t *p_intf, QObject* parent = nullptr);
     virtual ~CompositorDummy();
 
-    static bool preInit(qt_intf_t*);
     bool init() override;
 
     bool makeMainInterface(MainCtx*) override;


=====================================
modules/gui/qt/maininterface/compositor_wayland.cpp
=====================================
@@ -61,11 +61,6 @@ CompositorWayland::~CompositorWayland()
     }
 }
 
-bool CompositorWayland::preInit(qt_intf_t *)
-{
-    return true;
-}
-
 bool CompositorWayland::init()
 {
     QPlatformNativeInterface* native = QGuiApplication::platformNativeInterface();


=====================================
modules/gui/qt/maininterface/compositor_wayland.hpp
=====================================
@@ -42,7 +42,6 @@ public:
     CompositorWayland(qt_intf_t *p_intf, QObject* parent = nullptr);
     virtual ~CompositorWayland();
 
-    static bool preInit(qt_intf_t*);
     bool init() override;
 
     bool makeMainInterface(MainCtx*) override;


=====================================
modules/gui/qt/maininterface/compositor_win7.cpp
=====================================
@@ -50,11 +50,6 @@ CompositorWin7::~CompositorWin7()
 {
 }
 
-bool CompositorWin7::preInit(qt_intf_t *p_intf)
-{
-    return true;
-}
-
 bool CompositorWin7::init()
 {
     {


=====================================
modules/gui/qt/maininterface/compositor_win7.hpp
=====================================
@@ -47,7 +47,6 @@ public:
 
     virtual ~CompositorWin7();
 
-    static bool preInit(qt_intf_t *p_intf);
     bool init() override;
 
     bool makeMainInterface(MainCtx*) override;


=====================================
modules/gui/qt/maininterface/compositor_x11.cpp
=====================================
@@ -62,11 +62,6 @@ CompositorX11::~CompositorX11()
         xcb_disconnect(m_conn);
 }
 
-bool CompositorX11::preInit(qt_intf_t*)
-{
-    return true;
-}
-
 static bool checkExtensionPresent(qt_intf_t* intf, xcb_connection_t *conn, const char* extension)
 {
     bool ret = queryExtension(conn, extension, nullptr, nullptr);


=====================================
modules/gui/qt/maininterface/compositor_x11.hpp
=====================================
@@ -38,7 +38,6 @@ public:
     explicit CompositorX11(qt_intf_t *p_intf, QObject *parent = nullptr);
     virtual ~CompositorX11();
 
-    static bool preInit(qt_intf_t *);
     bool init() override;
 
     bool makeMainInterface(MainCtx*) override;


=====================================
modules/gui/qt/qt.cpp
=====================================
@@ -859,8 +859,6 @@ static void *Thread( void *obj )
     vlc::CompositorFactory compositorFactory(p_intf, compositor);
     free(compositor);
 
-    compositorFactory.preInit();
-
     // at the moment, the vout is created in another thread than the rendering thread
     QApplication::setAttribute( Qt::AA_DontCheckOpenGLContextThreadAffinity );
     QQuickWindow::setDefaultAlphaBuffer(true);



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d812b75331506a99b4a7a807037097752f2a78be...7c2121922da7d6d112588e43cffd836511a03561

-- 
This project does not include diff previews in email notifications.
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d812b75331506a99b4a7a807037097752f2a78be...7c2121922da7d6d112588e43cffd836511a03561
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list