[vlc-commits] [Git][videolan/vlc][master] 4 commits: qt: call `::create()` also for offscreen quick window in `CompositorX11`
Steve Lhomme (@robUx4)
gitlab at videolan.org
Thu Dec 18 11:03:58 UTC 2025
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
56c42613 by Fatih Uzunoglu at 2025-12-18T10:35:56+00:00
qt: call `::create()` also for offscreen quick window in `CompositorX11`
- - - - -
a1c6dfb5 by Fatih Uzunoglu at 2025-12-18T10:35:56+00:00
qt: introduce `MainCtx::windowHasDepthBuffer(const QWindow*)`
- - - - -
8e488b31 by Fatih Uzunoglu at 2025-12-18T10:35:56+00:00
qml: introduce `defaultCompensationFactor` in `RoundedRectangleShadow`
- - - - -
3cd86f0c by Fatih Uzunoglu at 2025-12-18T10:35:56+00:00
qml: disable clipping if there is depth buffer with csd shadows
We can make use of the depth buffer here, which is better than
clipping because we don't need to spend effort on clipping
anything since the content pixels will not be painted in the
shadow area as the shadow pixels obscure the content pixels.
On top of that, if early-z is applicable, the fragment shader
for the content pixels that are obscured by the quasi-opaque
shadow will not be executed.
- - - - -
4 changed files:
- modules/gui/qt/maininterface/compositor_x11.cpp
- modules/gui/qt/maininterface/mainctx.hpp
- modules/gui/qt/maininterface/qml/MainInterface.qml
- modules/gui/qt/widgets/qml/RoundedRectangleShadow.qml
Changes:
=====================================
modules/gui/qt/maininterface/compositor_x11.cpp
=====================================
@@ -208,6 +208,8 @@ bool CompositorX11::makeMainInterface(MainCtx* mainCtx, std::function<void (QQui
CompositorVideo::Flags flags = CompositorVideo::CAN_SHOW_PIP | HAS_ACRYLIC;
if (m_renderWindow->supportExtendedFrame())
flags |= CompositorVideo::HAS_EXTENDED_FRAME;
+ assert(m_qmlView->getOffscreenWindow());
+ m_qmlView->getOffscreenWindow()->create();
if (!commonGUICreate(m_renderWindow.get(), m_qmlView.get(), flags))
return false;
=====================================
modules/gui/qt/maininterface/mainctx.hpp
=====================================
@@ -331,6 +331,14 @@ public:
return 0.0;
}
+ Q_INVOKABLE static bool windowHasDepthBuffer(const QWindow* window)
+ {
+ assert(window);
+ // Make sure window has been initialized before (such as `::create()` was called):
+ assert(window->handle());
+ return window->format().depthBufferSize() > 0;
+ }
+
Q_INVOKABLE virtual bool platformHandlesResizeWithCSD() const { return false; };
Q_INVOKABLE virtual bool platformHandlesTitleBarButtonsWithCSD() const { return false; };
Q_INVOKABLE virtual bool platformHandlesShadowsWithCSD() const { return false; };
=====================================
modules/gui/qt/maininterface/qml/MainInterface.qml
=====================================
@@ -269,7 +269,8 @@ Item {
id: stackView
anchors.fill: parent
focus: true
- clip: _extendedFrameVisible
+ // If there is depth buffer, clipping is not necessary:
+ clip: _extendedFrameVisible && !effect.hasDepthBuffer
pageModel: _pageModel
@@ -319,20 +320,30 @@ Item {
Widgets.RoundedRectangleShadow {
id: effect
parent: g_mainInterface
- hollow: Window.window && (Window.window.color.a < 1.0) // the interface may be translucent if the window has backdrop blur
- blending: false // stacked below everything, no need for blending even though it is not opaque
+ hollow: (z >= 0) || (Window.window && (Window.window.color.a < 1.0)) // the interface may be translucent if the window has backdrop blur
+ // No need for blending, even if this is above everything (when there is depth buffer). This item does not need to be blended in the scene
+ // graph. The system compositor is still going to respect the transparency when compositing the window. By disabling blending, this is treated
+ // as opaque in the scene graph by the renderer, which makes it possible to not use a clip node for the content due to depth test (since
+ // this item is quasi-opaque, the content pixels obscured by the shadow pixels are not painted), and at the same time not spend effort on
+ // blending. Note that this optimization relies on hollow mode that discards the inner pixels, so the actual content area is still painted.
+ blending: false
visible: _extendedFrameVisible && !MainCtx.platformHandlesShadowsWithCSD()
- opacity: 0.5
+ color: Qt.rgba(0.0, 0.0, 0.0, 0.5) // sg opacity < 1.0 force enables blending, so we adjust the color instead
+
+ // If there is depth buffer, we enable hollow mode. The inner area is discarded, so we can do this:
+ z: hasDepthBuffer ? 99 : -1
+
+ readonly property bool hasDepthBuffer: (Window.window && MainCtx.windowHasDepthBuffer(Window.window))
// Blur radius can not be greater than (margin / compensationFactor), as in that case it would need bigger
// size than the window to compensate. If you want bigger blur radius, either decrease the compensation
// factor which can lead to visible clipping, or increase the window extended margin:
- property real activeBlurRadius: (MainCtx.windowExtendedMargin / effect.compensationFactor)
+ blurRadius: (MainCtx.windowExtendedMargin / effect.compensationFactor)
- blurRadius: MainCtx.intfMainWindow.active ? activeBlurRadius
- : (activeBlurRadius / 2.0)
+ compensationFactor: MainCtx.intfMainWindow.active ? (defaultCompensationFactor)
+ : (defaultCompensationFactor * 2)
- Behavior on blurRadius {
+ Behavior on compensationFactor {
// FIXME: Use UniformAnimator instead
NumberAnimation {
duration: VLCStyle.duration_veryShort
=====================================
modules/gui/qt/widgets/qml/RoundedRectangleShadow.qml
=====================================
@@ -59,7 +59,9 @@ ShaderEffect {
// Increase the compensation factor if clipping occurs, but make it as small as possible
// to prevent overlapping shadows (breaks batching) and to decrease the shader coverage:
- property real compensationFactor: 2.0
+ property real compensationFactor: defaultCompensationFactor
+
+ readonly property real defaultCompensationFactor: 2.0
// Do not paint in the non-compensated inner area - only makes sense if there is compensation:
property bool hollow: false
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/08403d9383faefb93d16319726fe756f9fdf6108...3cd86f0c90ee367a307b4d19802675c82ea5020b
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/08403d9383faefb93d16319726fe756f9fdf6108...3cd86f0c90ee367a307b4d19802675c82ea5020b
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