[vlc-commits] [Git][videolan/vlc][master] 3 commits: qt: fix inverted y-axis for the distance function in `SDFAARoundedTexture.frag`

Steve Lhomme (@robUx4) gitlab at videolan.org
Mon Sep 8 15:41:57 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
7b9d50ad by Fatih Uzunoglu at 2025-09-08T15:10:33+00:00
qt: fix inverted y-axis for the distance function in `SDFAARoundedTexture.frag`

This was not noticed before because the the radii used are always the same.

- - - - -
a47d9fb6 by Fatih Uzunoglu at 2025-09-08T15:10:33+00:00
qml: expose individual corner radii as properties in `ImageExt`

Since we are using a distance function which can work with
different radii, there is no reason to not allow them to be
configurable.

Note that `RoundedRectangleShadow` does not support different
corner radii at the moment, so be careful if there are shadows
for the image.

- - - - -
cf2350cc by Fatih Uzunoglu at 2025-09-08T15:10:33+00:00
qml: expose individual corner radii in `MediaCover`

- - - - -


4 changed files:

- modules/gui/qt/shaders/SDFAARoundedTexture.frag
- modules/gui/qt/shaders/SDFAARoundedTexture_cropsupport_bordersupport.frag
- modules/gui/qt/widgets/qml/ImageExt.qml
- modules/gui/qt/widgets/qml/MediaCover.qml


Changes:

=====================================
modules/gui/qt/shaders/SDFAARoundedTexture.frag
=====================================
@@ -88,6 +88,7 @@ void main()
     // Therefore, we have to normalize the coordinate for the distance
     // function to [0, 1]:
     vec2 normalCoord = vec2(1.0, 1.0) / (qt_SubRect_source.zw) * (qt_TexCoord0 - (qt_SubRect_source.zw + qt_SubRect_source.xy)) + vec2(1.0, 1.0);
+    normalCoord.y = (1.0 - normalCoord.y); // invert y-axis because texture coordinates have origin at the top
 
     vec2 p = (size.xy * ((2.0 * normalCoord) - 1)) / size.y;
     // Signed distance:


=====================================
modules/gui/qt/shaders/SDFAARoundedTexture_cropsupport_bordersupport.frag
=====================================
@@ -101,6 +101,7 @@ void main()
     // Therefore, we have to normalize the coordinate for the distance
     // function to [0, 1]:
     vec2 normalCoord = vec2(1.0, 1.0) / (qt_SubRect_source.zw) * (qt_TexCoord0 - (qt_SubRect_source.zw + qt_SubRect_source.xy)) + vec2(1.0, 1.0);
+    normalCoord.y = (1.0 - normalCoord.y); // invert y-axis because texture coordinates have origin at the top
 
     vec2 p = (size.xy * ((2.0 * normalCoord) - 1)) / size.y;
     // Signed distance:


=====================================
modules/gui/qt/widgets/qml/ImageExt.qml
=====================================
@@ -118,8 +118,13 @@ Item {
     fillMode: Image.PreserveAspectFit
 
     property real radius
+    property real radiusTopRight: radius
+    property real radiusTopLeft: radius
+    property real radiusBottomRight: radius
+    property real radiusBottomLeft: radius
+
     property alias backgroundColor: shaderEffect.backgroundColor
-    readonly property real effectiveRadius: shaderEffect.readyForVisibility ? radius : 0.0
+    readonly property real effectiveRadius: shaderEffect.readyForVisibility ? Math.max(radiusTopRight, radiusTopLeft, radiusBottomRight, radiusBottomLeft) : 0.0
     readonly property color effectiveBackgroundColor: shaderEffect.readyForVisibility ? backgroundColor : "transparent"
 
     // Border:
@@ -166,11 +171,14 @@ Item {
 
         // cullMode: ShaderEffect.BackFaceCulling // QTBUG-136611 (Layering breaks culling with OpenGL)
 
-        readonly property real radius: Math.min(1.0, Math.max(root.radius / (Math.min(width, height) / 2), 0.0))
-        readonly property real radiusTopRight: radius
-        readonly property real radiusBottomRight: radius
-        readonly property real radiusTopLeft: radius
-        readonly property real radiusBottomLeft: radius
+        function normalizeRadius(radius: real) : real {
+            return Math.min(1.0, Math.max(radius / (Math.min(width, height) / 2), 0.0))
+        }
+
+        readonly property real radiusTopRight: normalizeRadius(root.radiusTopRight)
+        readonly property real radiusBottomRight: normalizeRadius(root.radiusBottomRight)
+        readonly property real radiusTopLeft: normalizeRadius(root.radiusTopLeft)
+        readonly property real radiusBottomLeft: normalizeRadius(root.radiusBottomLeft)
 
         property color backgroundColor: "transparent"
 


=====================================
modules/gui/qt/widgets/qml/MediaCover.qml
=====================================
@@ -43,6 +43,10 @@ Item {
     // Aliases
 
     property alias radius: image.radius
+    property alias radiusTopRight: image.radiusTopRight
+    property alias radiusTopLeft: image.radiusTopLeft
+    property alias radiusBottomRight: image.radiusBottomRight
+    property alias radiusBottomLeft: image.radiusBottomLeft
 
     property alias color: image.backgroundColor
 
@@ -132,6 +136,10 @@ Item {
         anchors.fill: parent
 
         radius: root.radius
+        radiusTopRight: root.radiusTopRight
+        radiusTopLeft: root.radiusTopLeft
+        radiusBottomRight: root.radiusBottomRight
+        radiusBottomLeft: root.radiusBottomLeft
 
         backgroundColor: root.color
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/bab4f9848ea8a5573a60984128b1f7f51068c26e...cf2350cc06efa4d3cdafa0141ff2b2f30999ae5d

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/bab4f9848ea8a5573a60984128b1f7f51068c26e...cf2350cc06efa4d3cdafa0141ff2b2f30999ae5d
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