[vlc-commits] [Git][videolan/vlc][master] 5 commits: qml: add `Helpers::denominatorForFloat()`
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Sat Apr 4 18:46:10 UTC 2026
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
92eb32cd by Fatih Uzunoglu at 2026-04-04T20:17:06+02:00
qml: add `Helpers::denominatorForFloat()`
- - - - -
b7095e6e by Fatih Uzunoglu at 2026-04-04T20:17:06+02:00
qml: introduce `pixelAlignedForDPR` property in `PartialEffect`
When the visual size is supposed to match 1:1 the sampled
texture size, we can not afford to have deviation due to
fractions. QML items may have fractional size, and on top
of that the display scale may be fractional.
- - - - -
a9db7f45 by Fatih Uzunoglu at 2026-04-04T20:17:06+02:00
qml: disable linear filtering in source visual in `PartialEffect`
- - - - -
9502705b by Fatih Uzunoglu at 2026-04-04T20:17:06+02:00
qml: expose default value of `blending` in `PartialEffect`
- - - - -
e37307ab by Fatih Uzunoglu at 2026-04-04T20:17:06+02:00
qml: provide type annotation in `Helpers::{alignUp,alignDown}()`
- - - - -
2 changed files:
- modules/gui/qt/util/qml/Helpers.qml
- modules/gui/qt/widgets/qml/PartialEffect.qml
Changes:
=====================================
modules/gui/qt/util/qml/Helpers.qml
=====================================
@@ -71,14 +71,32 @@ QtObject {
return (Math.abs(a - b) < Number.EPSILON)
}
- function alignUp(a, b) {
+ function alignUp(a, b : int) {
return Math.ceil(a / b) * b
}
- function alignDown(a, b) {
+ function alignDown(a, b : int) {
return Math.floor(a / b) * b
}
+ // Currently only supports .25, .5, .75
+ function denominatorForFloat(number) : int {
+ const fraction = number % 1
+
+ if (fraction === 0)
+ return 1
+ else if (compareFloat(fraction, 0.25))
+ return 4
+ else if (compareFloat(fraction, 0.50))
+ return 2
+ else if (compareFloat(fraction, 0.75))
+ return 4
+ else {
+ console.error("Can not find denominator for number", number, "!")
+ return 1
+ }
+ }
+
function isSortedIntegerArrayConsecutive(array) {
for (let i = 1; i < array.length; ++i) {
if ((array[i] - array[i - 1]) !== 1)
=====================================
modules/gui/qt/widgets/qml/PartialEffect.qml
=====================================
@@ -57,8 +57,35 @@ Item {
// Enable blending if source or the effect is not opaque.
// This comes with a performance penalty.
+ blending: false
+
property alias blending: sourceProxy.blending
+ // Display scale may be a fractional size, but textures can not. Pixel aligned
+ // aligns the visual size to the nearest multiple of number, depending on
+ // the window/screen fraction, so that the layer texture can be displayed
+ // without stretching. For example, if the display scale is 1.25, the
+ // visual size would be aligned up to the nearest multiple of 4. Note that
+ // using this property is going to make the visual to deviate from the
+ // size intended, which may increase greatly depending on the fraction
+ // of the display scale. Also note that if the QML item size is fractional
+ // itself, it is ceiled regardless of the display scale or this property.
+ // This setting applies to both the source and the effect visuals, but
+ // is only relevant for the source visual if `sourceVisualRect` is
+ // provided.
+ property bool pixelAlignedForDPR: true
+
+ property real _eDPR: MainCtx.effectiveDevicePixelRatio(Window.window) || 1.0
+ readonly property int _alignNumber: pixelAlignedForDPR ? Helpers.denominatorForFloat(_eDPR) : 1
+
+ Connections {
+ target: MainCtx
+
+ function onIntfDevicePixelRatioChanged() {
+ root._eDPR = MainCtx.effectiveDevicePixelRatio(root.Window.window) || 1.0
+ }
+ }
+
// This item displays the item with the rect denoted by effectRect
// being transparent (only when blending is set):
ShaderEffect {
@@ -66,10 +93,10 @@ Item {
x: root.sourceVisualRect.x
y: root.sourceVisualRect.y
- width: useSubTexture ? root.sourceVisualRect.width : parent.width
- height: useSubTexture ? root.sourceVisualRect.height : parent.height
+ width: useSubTexture ? Helpers.alignUp(root.sourceVisualRect.width, root._alignNumber) : parent.width
+ height: useSubTexture ? Helpers.alignUp(root.sourceVisualRect.height, root._alignNumber) : parent.height
- blending: false
+ smooth: false
// WARNING: Switching the source should be fine, but old Qt (Qt 6.2.13) seems to break the interface
// in this case. The indirection does not use sub-rect if it is not relevant, so in this
@@ -100,10 +127,10 @@ Item {
// If the effect is in a isolated inner area, filtering is necessary. Otherwise, we can simply
// use sub-texturing for the source itself as well (we already use sub-texture for the effect area).
- textureSubRect: (sourceProxy.useSubTexture) ? Qt.rect(root.sourceVisualRect.x * textureProviderIndirection.eDPR,
- root.sourceVisualRect.y * textureProviderIndirection.eDPR,
- root.sourceVisualRect.width * textureProviderIndirection.eDPR,
- root.sourceVisualRect.height * textureProviderIndirection.eDPR) : undefined
+ textureSubRect: (sourceProxy.useSubTexture) ? Qt.rect(sourceProxy.x * root._eDPR,
+ sourceProxy.y * root._eDPR,
+ sourceProxy.width * root._eDPR,
+ sourceProxy.height * root._eDPR) : undefined
}
}
@@ -117,27 +144,17 @@ Item {
x: effectRect.x
y: effectRect.y
- width: effectRect.width
- height: effectRect.height
+ width: Helpers.alignUp(effectRect.width, root._alignNumber)
+ height: Helpers.alignUp(effectRect.height, root._alignNumber)
readonly property Item sourceItem: source?.sourceItem ?? source
property rect effectRect
- property real eDPR: MainCtx.effectiveDevicePixelRatio(Window.window)
-
- textureSubRect: Qt.rect(effectRect.x * textureProviderIndirection.eDPR,
- effectRect.y * textureProviderIndirection.eDPR,
- effectRect.width * textureProviderIndirection.eDPR,
- effectRect.height * textureProviderIndirection.eDPR)
-
- Connections {
- target: MainCtx
-
- function onIntfDevicePixelRatioChanged() {
- textureProviderIndirection.eDPR = MainCtx.effectiveDevicePixelRatio(textureProviderIndirection.Window.window)
- }
- }
+ textureSubRect: Qt.rect(x * root._eDPR,
+ y * root._eDPR,
+ width * root._eDPR,
+ height * root._eDPR)
readonly property bool effectAcceptsSourceRect: (typeof root.effect?.sourceRect !== "undefined") // typeof `rect` is "object"
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/32d2be351e6808ad444ab5158a48da56158f0c2a...e37307ab3ca1d41bf9b7098d24a9eb265de14a5d
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/32d2be351e6808ad444ab5158a48da56158f0c2a...e37307ab3ca1d41bf9b7098d24a9eb265de14a5d
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list