[vlc-commits] [Git][videolan/vlc][master] 2 commits: qt: relax made current assertions in `CompositorX11UISurface`
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Tue Mar 25 05:24:16 UTC 2025
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
3257b2e4 by Fatih Uzunoglu at 2025-03-25T05:08:47+00:00
qt: relax made current assertions in `CompositorX11UISurface`
Rather than having an assertion regarding the context became current,
we can simply early return in these functions. If the context could
not be made current, it is likely that we are in some sort of
transitional phase and `resizeFbo()` would be called later when the
state is stable either directly or indirectly.
`render()`, on the other is periodically called anyway. It should
be fine to simply return early instead of triggering assertion
failure. When the context can be made current, it can do its job.
- - - - -
99162581 by Fatih Uzunoglu at 2025-03-25T05:08:47+00:00
qt: make context current before calling `::createFbo()` and `::destroyFbo()` in `CompositorX11UISurface`
The reason these methods don't make the context current themselves is because
they are called together in `resizeFbo()` where the context is already made
current. This makes it possible to make current once instead of twice (with
accompanying done current in these methods).
- - - - -
2 changed files:
- modules/gui/qt/maininterface/compositor_x11_uisurface.cpp
- modules/gui/qt/maininterface/compositor_x11_uisurface.hpp
Changes:
=====================================
modules/gui/qt/maininterface/compositor_x11_uisurface.cpp
=====================================
@@ -89,8 +89,21 @@ CompositorX11UISurface::CompositorX11UISurface(QWindow* window, QScreen* screen)
if (m_context)
{
- connect(m_uiWindow, &QQuickWindow::sceneGraphInitialized, this, &CompositorX11UISurface::createFbo);
- connect(m_uiWindow, &QQuickWindow::sceneGraphInvalidated, this, &CompositorX11UISurface::destroyFbo);
+ connect(m_uiWindow, &QQuickWindow::sceneGraphInitialized, this, [this]() {
+ assert(m_context);
+ const bool ret = m_context->makeCurrent(this);
+ assert(ret); // initial fbo creation must succeed
+ createFbo();
+ m_context->doneCurrent();
+ });
+ connect(m_uiWindow, &QQuickWindow::sceneGraphInvalidated, this, [this]() {
+ assert(m_context);
+ if (Q_LIKELY(m_context->makeCurrent(this)))
+ {
+ destroyFbo();
+ m_context->doneCurrent();
+ }
+ });
}
connect(m_uiWindow, &QQuickWindow::beforeRendering, this, &CompositorX11UISurface::beforeRendering);
@@ -204,15 +217,16 @@ void CompositorX11UISurface::destroyFbo()
}
}
-void CompositorX11UISurface::render()
+bool CompositorX11UISurface::render()
{
if (!isExposed())
- return;
+ return false;
if (m_context)
{
const bool current = m_context->makeCurrent(this);
- assert(current);
+ if (!current)
+ return false;
m_uiRenderControl->beginFrame();
}
@@ -250,6 +264,8 @@ void CompositorX11UISurface::render()
emit m_uiWindow->frameSwapped();
emit updated();
+
+ return true;
}
void CompositorX11UISurface::updateSizes()
@@ -411,18 +427,21 @@ bool CompositorX11UISurface::eventFilter(QObject*, QEvent *event)
return false;
}
-void CompositorX11UISurface::resizeFbo()
+bool CompositorX11UISurface::resizeFbo()
{
if (m_rootItem)
{
const bool current = m_context->makeCurrent(this);
- assert(current);
+ if (!current)
+ return false;
destroyFbo();
createFbo();
m_context->doneCurrent();
updateSizes();
render();
+ return true;
}
+ return false;
}
void CompositorX11UISurface::applyNvidiaWorkaround(QSurfaceFormat &format)
=====================================
modules/gui/qt/maininterface/compositor_x11_uisurface.hpp
=====================================
@@ -57,7 +57,7 @@ public:
explicit CompositorX11UISurface(QWindow* window, QScreen *screen = nullptr);
~CompositorX11UISurface();
- virtual void render();
+ virtual bool render();
bool handleWindowEvent(QEvent *event);
@@ -89,9 +89,12 @@ protected:
void updateSizes();
+ // WARNING: The OpenGL context must be made current against this window before calling these methods:
void createFbo();
void destroyFbo();
- void resizeFbo();
+
+ // NOTE: This method attempts to make the OpenGL context current against this window:
+ bool resizeFbo();
private:
static void applyNvidiaWorkaround(QSurfaceFormat& format);
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d1a0dc704013ddc6a0337518fc22b6b8d98016c3...99162581a3fc00a9d3f9917ad4fd2bedf649a6ce
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d1a0dc704013ddc6a0337518fc22b6b8d98016c3...99162581a3fc00a9d3f9917ad4fd2bedf649a6ce
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