[vlc-commits] [Git][videolan/vlc][master] qt: add possibility to disable anti-aliasing in SDFAARoundedTexture.frag
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Tue Dec 24 08:25:29 UTC 2024
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
3bb16e5b by Fatih Uzunoglu at 2024-12-24T08:12:39+00:00
qt: add possibility to disable anti-aliasing in SDFAARoundedTexture.frag
Although this adds the possibility, due to lacking build system support
I do not manually create a new file that defines `ANTIALIASING` but
rather use it unconditionally in both `SDFAARoundedTexture.frag` and
`SDFAARoundedTexture_cropsupport.frag` and override the antialiasing
property as readonly true.
When the build system supports defines for the shaders, we can start
respecting `antialiasing` and revert the readonly attribute.
- - - - -
3 changed files:
- modules/gui/qt/shaders/SDFAARoundedTexture.frag
- modules/gui/qt/shaders/SDFAARoundedTexture_cropsupport.frag
- modules/gui/qt/widgets/qml/RoundImage.qml
Changes:
=====================================
modules/gui/qt/shaders/SDFAARoundedTexture.frag
=====================================
@@ -1,5 +1,7 @@
#version 440
+#define ANTIALIASING
+
/*****************************************************************************
* Copyright (C) 2024 VLC authors and VideoLAN
*
@@ -113,7 +115,12 @@ void main()
// Soften the outline, as recommended by the Valve paper, using smoothstep:
// "Improved Alpha-Tested Magnification for Vector Textures and Special Effects"
// NOTE: The whole texel is multiplied, because of premultiplied alpha.
- texel *= 1.0 - smoothstep(softEdgeMin, softEdgeMax, dist);
+#ifdef ANTIALIASING
+ float factor = smoothstep(softEdgeMin, softEdgeMax, dist);
+#else
+ float factor = step(0.0, dist);
+#endif
+ texel *= 1.0 - factor;
fragColor = texel * qt_Opacity;
}
=====================================
modules/gui/qt/shaders/SDFAARoundedTexture_cropsupport.frag
=====================================
@@ -12,6 +12,8 @@
// for maintenance purposes. IF YOU EDIT THIS FILE, MAKE SURE TO DO THE
// SAME IN SDFAARoundedTexture.frag.
+#define ANTIALIASING
+
/*****************************************************************************
* Copyright (C) 2024 VLC authors and VideoLAN
*
@@ -125,7 +127,12 @@ void main()
// Soften the outline, as recommended by the Valve paper, using smoothstep:
// "Improved Alpha-Tested Magnification for Vector Textures and Special Effects"
// NOTE: The whole texel is multiplied, because of premultiplied alpha.
- texel *= 1.0 - smoothstep(softEdgeMin, softEdgeMax, dist);
+#ifdef ANTIALIASING
+ float factor = smoothstep(softEdgeMin, softEdgeMax, dist);
+#else
+ float factor = step(0.0, dist);
+#endif
+ texel *= 1.0 - factor;
fragColor = texel * qt_Opacity;
}
=====================================
modules/gui/qt/widgets/qml/RoundImage.qml
=====================================
@@ -26,6 +26,13 @@ Item {
implicitWidth: image.implicitWidth
implicitHeight: image.implicitHeight
+ // Override QQuickItem's antialiasing as readonly.
+ // FIXME: The shader can be generated without
+ // the define that enables antialiasing.
+ // It should be done when the build system
+ // starts supporting shader defines.
+ readonly property bool antialiasing: true
+
asynchronous: true
property alias asynchronous: image.asynchronous
@@ -106,6 +113,8 @@ Item {
blending: true
+ antialiasing: root.antialiasing
+
// FIXME: Culling seems to cause issues, such as when the view is layered due to
// fading edge effec, this is most likely a Qt bug.
// cullMode: ShaderEffect.BackFaceCulling
@@ -168,5 +177,7 @@ Item {
// We can use clipping as QQuickImage suggests with
// PreserveAspectCrop in that case:
clip: (GraphicsInfo.shaderType !== GraphicsInfo.RhiShader) && (fillMode === Image.PreserveAspectCrop)
+
+ antialiasing: root.antialiasing
}
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/3bb16e5b14fb9ca05d061d9eb95fbf8a0d411bc8
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/3bb16e5b14fb9ca05d061d9eb95fbf8a0d411bc8
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