Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
b19ddcc9 by Fatih Uzunoglu at 2025-02-02T10:18:44+00:00
qml: do not let qt to create implicit layer in artist top banner
Here, Qt wants to create a layer because when source is `QQuickImage`,
`QGfxSourceProxy(ME)` checks its fill mode and source size.
In this case, we need to tell Qt that we don't need a layer here, as
we are doing the mapping as we want but Qt currently does not offer
a way to tell that and simply tries to decide itself: "If needed,
MultiEffect will internally generate a ShaderEffectSource as the
texture source"
Using the static texture for the blur source has also the advantage
of applying blur only once because the source would not get updated
constantly due to size change. With clipping, we can simply adjust
the viewport without needing to update the blur.
Unfortunately we can not do this with older Qt versions, because if
the source image changes fill mode from stretch or to stretch where
it is fed to a blur effect, the effect either causes crash (layering
needed to not needed, so Tile -> Stretch) or does not work (layering
not needed to needed, so Stretch -> Tile).
- - - - -
1 changed file:
- modules/gui/qt/medialibrary/qml/ArtistTopBanner.qml
Changes:
=====================================
modules/gui/qt/medialibrary/qml/ArtistTopBanner.qml
=====================================
@@ -62,7 +62,18 @@ FocusScope {
sourceSize: artist.cover ?
Qt.size(Helpers.alignUp(Screen.desktopAvailableWidth, 32), 0)
: undefined
mipmap: !!artist.cover
- fillMode: artist.cover ? Image.PreserveAspectCrop : Image.Tile
+ // Fill mode is stretch when blur effect is used, otherwise an
implicit layer is created.
+ // Having the fill mode stretch does not have a side effect here,
because source size
+ // is still calculated as to preserve the aspect ratio as height is
left empty (0) and the
+ // image is not shown stretched because it is invisible when blur
effect is used:
+ // "If only one dimension of the size is set to greater than 0, the
other dimension is
+ // set in proportion to preserve the source image's aspect ratio.
(The fillMode is
+ // independent of this.)". Unfortunately with old Qt versions we can
not do this
+ // because it does not seem to create a layer when fill mode (tiling
is wanted)
+ // is changed at a later point.
+ fillMode: artist.cover ? ((visible || (MainCtx.qtVersion() <
MainCtx.qtVersionCheck(6, 5, 0))) ? Image.PreserveAspectCrop : Image.Stretch)
+ : Image.Tile
+
visible: layer.enabled
cache: (source === VLCStyle.noArtArtist)
@@ -72,10 +83,42 @@ FocusScope {
layer.textureSize: Qt.size(width * .75, height * .75)
}
- Widgets.BlurEffect {
+ Item {
anchors.fill: background
- source: background
- radius: VLCStyle.dp(4, VLCStyle.scale)
+
+ // The texture is big, and the blur item should only draw the portion
of it.
+ // If the blur effect creates an implicit layer, it properly adjusts
the
+ // area that it needs to cover. However, as we don't want an additional
+ // layer that keeps getting updated every time the size changes, we
feed
+ // the whole static texture. For that reason, we need clipping because
+ // the blur effect is applied to the whole texture and shown as whole:
+ clip: !blurEffect.sourceNeedsLayering
+
+ visible: !background.visible && (GraphicsInfo.shaderType ===
GraphicsInfo.RhiShader)
+
+ // This blur effect does not create an implicit layer that is updated
+ // each time the size changes. The source texture is static, so the
blur
+ // is applied only once and we adjust the viewport through the parent
item
+ // with clipping.
+ Widgets.BlurEffect {
+ id: blurEffect
+
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: parent.left
+ anchors.right: parent.right
+
+ // If source image is tiled, layering is necessary:
+ readonly property bool sourceNeedsLayering: (background.fillMode
!== Image.Stretch) ||
+ (MainCtx.qtVersion() <
MainCtx.qtVersionCheck(6, 5, 0))
+
+ readonly property real aspectRatio: (background.implicitHeight /
background.implicitWidth)
+
+ height: sourceNeedsLayering ? background.height : (aspectRatio *
width)
+
+ source: background
+
+ radius: VLCStyle.dp(4, VLCStyle.scale)
+ }
}
Rectangle {
View it on GitLab:
https://code.videolan.org/videolan/vlc/-/commit/b19ddcc9d25416295d43bf5e91e9e8c04f94ee33
--
View it on GitLab:
https://code.videolan.org/videolan/vlc/-/commit/b19ddcc9d25416295d43bf5e91e9e8c04f94ee33
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits