vlc | branch: master | Pierre Lamot <pie...@videolabs.io> | Wed Aug 12 13:54:23 2020 +0200| [5e8452d7d0f3f87e778148b4e5bf069f09d3cd42] | committer: Pierre Lamot
qt: distinguish enabled from video embed in video surface > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5e8452d7d0f3f87e778148b4e5bf069f09d3cd42 --- modules/gui/qt/maininterface/compositor_dcomp.cpp | 5 +++-- modules/gui/qt/maininterface/compositor_win7.cpp | 2 ++ modules/gui/qt/maininterface/main_interface.cpp | 8 ++++---- modules/gui/qt/maininterface/videosurface.cpp | 20 ++++++++++++++++---- modules/gui/qt/maininterface/videosurface.hpp | 9 ++++++--- 5 files changed, 31 insertions(+), 13 deletions(-) diff --git a/modules/gui/qt/maininterface/compositor_dcomp.cpp b/modules/gui/qt/maininterface/compositor_dcomp.cpp index 0738488dd3..ca4b45038a 100644 --- a/modules/gui/qt/maininterface/compositor_dcomp.cpp +++ b/modules/gui/qt/maininterface/compositor_dcomp.cpp @@ -58,6 +58,7 @@ int CompositorDirectComposition::window_enable(struct vout_window_t * p_wnd, con try { that->m_qmlVideoSurfaceProvider->enable(p_wnd); + that->m_qmlVideoSurfaceProvider->setVideoEmbed(true); HR(that->m_rootVisual->AddVisual(that->m_videoVisual.Get(), FALSE, that->m_uiVisual.Get()), "add video visual to root"); HR(that->m_dcompDevice->Commit(), "commit"); } @@ -74,6 +75,7 @@ void CompositorDirectComposition::window_disable(struct vout_window_t * p_wnd) CompositorDirectComposition* that = static_cast<CompositorDirectComposition*>(p_wnd->sys); try { + that->m_qmlVideoSurfaceProvider->setVideoEmbed(false); that->m_qmlVideoSurfaceProvider->disable(); that->m_videoWindowHandler->disable(); msg_Dbg(that->m_intf, "window_disable"); @@ -208,7 +210,6 @@ MainInterface* CompositorDirectComposition::makeMainInterface() m_videoWindowHandler = std::make_unique<VideoWindowHandler>(m_intf, m_rootWindow); m_videoWindowHandler->setWindow( m_rootWindow->windowHandle() ); - HR(m_dcompDevice->CreateTargetForHwnd((HWND)m_rootWindow->windowHandle()->winId(), TRUE, &m_dcompTarget), "create target"); HR(m_dcompDevice->CreateVisual(&m_rootVisual), "create root visual"); HR(m_dcompTarget->SetRoot(m_rootVisual.Get()), "set root visual"); @@ -232,7 +233,7 @@ MainInterface* CompositorDirectComposition::makeMainInterface() m_qmlVideoSurfaceProvider = std::make_unique<VideoSurfaceProvider>(); m_rootWindow->setVideoSurfaceProvider(m_qmlVideoSurfaceProvider.get()); - connect(m_qmlVideoSurfaceProvider.get(), &VideoSurfaceProvider::hasVideoChanged, + connect(m_qmlVideoSurfaceProvider.get(), &VideoSurfaceProvider::hasVideoEmbedChanged, m_interfaceWindowHandler, &InterfaceWindowHandlerWin32::onVideoEmbedChanged); connect(m_rootWindow, &MainInterface::requestInterfaceMaximized, diff --git a/modules/gui/qt/maininterface/compositor_win7.cpp b/modules/gui/qt/maininterface/compositor_win7.cpp index c7ee0e2f9b..7a262ad60e 100644 --- a/modules/gui/qt/maininterface/compositor_win7.cpp +++ b/modules/gui/qt/maininterface/compositor_win7.cpp @@ -31,12 +31,14 @@ int CompositorWin7::window_enable(struct vout_window_t * p_wnd, const vout_windo CompositorWin7* that = static_cast<CompositorWin7*>(p_wnd->sys); msg_Dbg(that->m_intf, "window_enable"); that->m_qmlVideoSurfaceProvider->enable(p_wnd); + that->m_qmlVideoSurfaceProvider->setVideoEmbed(true); return VLC_SUCCESS; } void CompositorWin7::window_disable(struct vout_window_t * p_wnd) { CompositorWin7* that = static_cast<CompositorWin7*>(p_wnd->sys); + that->m_qmlVideoSurfaceProvider->setVideoEmbed(false); that->m_qmlVideoSurfaceProvider->disable(); that->m_videoWindowHandler->disable(); msg_Dbg(that->m_intf, "window_disable"); diff --git a/modules/gui/qt/maininterface/main_interface.cpp b/modules/gui/qt/maininterface/main_interface.cpp index 287cee774d..d59c6b6abc 100644 --- a/modules/gui/qt/maininterface/main_interface.cpp +++ b/modules/gui/qt/maininterface/main_interface.cpp @@ -416,19 +416,19 @@ void MainInterface::setInterfaceAlwaysOnTop( bool on_top ) bool MainInterface::hasEmbededVideo() const { - return m_videoSurfaceProvider && m_videoSurfaceProvider->hasVideo(); + return m_videoSurfaceProvider && m_videoSurfaceProvider->hasVideoEmbed(); } void MainInterface::setVideoSurfaceProvider(VideoSurfaceProvider* videoSurfaceProvider) { if (m_videoSurfaceProvider) - disconnect(m_videoSurfaceProvider, &VideoSurfaceProvider::hasVideoChanged, this, &MainInterface::hasEmbededVideoChanged); + disconnect(m_videoSurfaceProvider, &VideoSurfaceProvider::hasVideoEmbedChanged, this, &MainInterface::hasEmbededVideoChanged); m_videoSurfaceProvider = videoSurfaceProvider; if (m_videoSurfaceProvider) - connect(m_videoSurfaceProvider, &VideoSurfaceProvider::hasVideoChanged, + connect(m_videoSurfaceProvider, &VideoSurfaceProvider::hasVideoEmbedChanged, this, &MainInterface::hasEmbededVideoChanged, Qt::QueuedConnection); - emit hasEmbededVideoChanged(m_videoSurfaceProvider && m_videoSurfaceProvider->hasVideo()); + emit hasEmbededVideoChanged(m_videoSurfaceProvider && m_videoSurfaceProvider->hasVideoEmbed()); } VideoSurfaceProvider* MainInterface::getVideoSurfaceProvider() const diff --git a/modules/gui/qt/maininterface/videosurface.cpp b/modules/gui/qt/maininterface/videosurface.cpp index b69e4a3b52..de74872145 100644 --- a/modules/gui/qt/maininterface/videosurface.cpp +++ b/modules/gui/qt/maininterface/videosurface.cpp @@ -25,12 +25,17 @@ VideoSurfaceProvider::VideoSurfaceProvider(QObject* parent) { } -bool VideoSurfaceProvider::hasVideo() +bool VideoSurfaceProvider::isEnabled() { QMutexLocker lock(&m_voutlock); return m_voutWindow != nullptr; } +bool VideoSurfaceProvider::hasVideoEmbed() const +{ + return m_videoEmbed; +} + void VideoSurfaceProvider::enable(vout_window_t* voutWindow) { assert(voutWindow); @@ -38,16 +43,23 @@ void VideoSurfaceProvider::enable(vout_window_t* voutWindow) QMutexLocker lock(&m_voutlock); m_voutWindow = voutWindow; } - emit hasVideoChanged(true); + emit videoEnabledChanged(true); } void VideoSurfaceProvider::disable() { + setVideoEmbed(false); { QMutexLocker lock(&m_voutlock); m_voutWindow = nullptr; } - emit hasVideoChanged(false); + emit videoEnabledChanged(false); +} + +void VideoSurfaceProvider::setVideoEmbed(bool embed) +{ + m_videoEmbed = embed; + emit hasVideoEmbedChanged(embed); } void VideoSurfaceProvider::onWindowClosed() @@ -270,7 +282,7 @@ QSGNode*VideoSurface::updatePaintNode(QSGNode* oldNode, QQuickItem::UpdatePaintN connect(this, &VideoSurface::keyPressed, m_provider, &VideoSurfaceProvider::onKeyPressed); connect(this, &VideoSurface::surfaceSizeChanged, m_provider, &VideoSurfaceProvider::onSurfaceSizeChanged); - connect(m_provider, &VideoSurfaceProvider::hasVideoChanged, this, &VideoSurface::onProviderVideoChanged); + connect(m_provider, &VideoSurfaceProvider::hasVideoEmbedChanged, this, &VideoSurface::onProviderVideoChanged); onSurfaceSizeChanged(); } diff --git a/modules/gui/qt/maininterface/videosurface.hpp b/modules/gui/qt/maininterface/videosurface.hpp index 5ff2cd4814..a3b70daa5a 100644 --- a/modules/gui/qt/maininterface/videosurface.hpp +++ b/modules/gui/qt/maininterface/videosurface.hpp @@ -32,15 +32,17 @@ public: VideoSurfaceProvider(QObject* parent = nullptr); virtual ~VideoSurfaceProvider() {} - bool hasVideo(); - void enable(vout_window_t* voutWindow); void disable(); + bool isEnabled(); + void setVideoEmbed(bool embed); + bool hasVideoEmbed() const; signals: void ctxChanged(QmlMainContext*); - bool hasVideoChanged(bool); + bool videoEnabledChanged(bool); + bool hasVideoEmbedChanged(bool); public slots: void onWindowClosed(); @@ -55,6 +57,7 @@ public slots: protected: QMutex m_voutlock; vout_window_t* m_voutWindow = nullptr; + bool m_videoEmbed = false; }; _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits