[vlc-commits] [Git][videolan/vlc][master] qml: slight refactor frosted glass effect

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sun Jan 2 18:15:20 UTC 2022



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
1d32cd03 by Fatih Uzunoglu at 2022-01-02T17:08:40+00:00
qml: slight refactor frosted glass effect

- - - - -


4 changed files:

- modules/gui/qt/player/qml/MiniPlayer.qml
- modules/gui/qt/playlist/qml/PlaylistListView.qml
- modules/gui/qt/widgets/qml/FrostedGlassEffect.qml
- modules/gui/qt/widgets/qml/OverlayMenu.qml


Changes:

=====================================
modules/gui/qt/player/qml/MiniPlayer.qml
=====================================
@@ -68,10 +68,12 @@ FocusScope {
 
     Widgets.FrostedGlassEffect {
         id: effect
-        anchors.fill: controlBar
+        anchors.fill: parent
 
-        source: mainContent
-        sourceRect: Qt.rect(root.x, root.y, root.width, root.height)
+        sourceRect: Qt.rect(root.x,
+                            root.y,
+                            root.width,
+                            root.height)
 
         tint: VLCStyle.colors.lowerBanner
     }


=====================================
modules/gui/qt/playlist/qml/PlaylistListView.qml
=====================================
@@ -139,7 +139,7 @@ Control {
             bottomPadding: VLCStyle.margin_large + root.bottomPadding
 
             itemParent: listView
-            backgroundItem: contentItem
+            effectSource: contentItem
         }
     }
 


=====================================
modules/gui/qt/widgets/qml/FrostedGlassEffect.qml
=====================================
@@ -24,88 +24,72 @@ import "qrc:///style/"
 Rectangle {
     id: effect
 
-    property var source
-    property var sourceRect: undefined
+    property alias source: effectSource.sourceItem
+    property alias sourceRect: effectSource.sourceRect
+    property alias recursive: effectSource.recursive
+    property alias blurRadius: blurEffect.radius
+    property alias tint: effect.color
 
-    property bool active: true
-
-    color: tint
-
-    property color tint: VLCStyle.colors.topBanner
     property real tintStrength: 0.7
     property real noiseStrength: 0.02
     property real exclusionStrength: 0.09
 
-    Item {
-        anchors.fill: parent
-
-        layer.enabled: effect.active
-        layer.effect: Item {
-
-            FastBlur {
-                id: effect1
-                anchors.fill: parent
-
-                source: ShaderEffectSource {
-                    sourceItem: effect.source
-                    sourceRect: !!effect.sourceRect ? effect.sourceRect : effect.mapToItem(effect.source, Qt.rect(effect.x, effect.y, effect.width, effect.height))
-                    visible: false
-                }
-
-                radius: 64
-                visible: false
-            }
+    FastBlur {
+        id: blurEffect
 
-            ShaderEffect {
-                id: effect2
-
-                property var source: ShaderEffectSource {
-                    sourceItem: effect1
-                    visible: true
-                }
-
-                anchors.fill: parent
-
-                visible: true
+        anchors.fill: parent
 
-                property color tint: effect.tint
-                property real  tintStrength: effect.tintStrength
-                property real  noiseStrength: effect.noiseStrength
-                property real  exclusionStrength: effect.exclusionStrength
+        source: ShaderEffectSource {
+            id: effectSource
+            sourceItem: effect.source
+            sourceRect: effect.mapToItem(effect.source,
+                                         effect.x,
+                                         effect.y,
+                                         effect.width,
+                                         effect.height)
+            visible: false
+            samples: 0
+        }
 
-                fragmentShader: "
-                    uniform lowp sampler2D source; // this item
-                    varying highp vec2 qt_TexCoord0;
+        radius: 64
 
-                    uniform lowp vec4  tint;
+        layer.enabled: true
+        layer.effect: ShaderEffect {
+            readonly property color tint: effect.tint
+            readonly property real tintStrength: effect.tintStrength
+            readonly property real noiseStrength: effect.noiseStrength
+            readonly property real exclusionStrength: effect.exclusionStrength
 
-                    uniform lowp float exclusionStrength;
-                    uniform lowp float noiseStrength;
-                    uniform lowp float tintStrength;
+            fragmentShader: "
+                uniform lowp sampler2D source; // this item
+                varying highp vec2 qt_TexCoord0;
 
+                uniform lowp vec4  tint;
 
-                    mediump float rand(highp vec2 co){
-                        return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
-                    }
+                uniform lowp float exclusionStrength;
+                uniform lowp float noiseStrength;
+                uniform lowp float tintStrength;
 
+                mediump float rand(highp vec2 co){
+                    return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
+                }
 
-                    mediump vec4 exclude(mediump vec4 src, mediump vec4 dst)
-                    {
-                        return src + dst - 2.0 * src * dst;
-                    }
+                mediump vec4 exclude(mediump vec4 src, mediump vec4 dst)
+                {
+                    return src + dst - 2.0 * src * dst;
+                }
 
-                    void main() {
-                       mediump float r = rand(qt_TexCoord0) - 0.5;
-                       mediump vec4 noise = vec4(r,r,r,1.0) * noiseStrength;
-                       mediump vec4 blured  = texture2D(source, qt_TexCoord0);
+                void main() {
+                   mediump float r = rand(qt_TexCoord0) - 0.5;
+                   mediump vec4 noise = vec4(r,r,r,1.0) * noiseStrength;
+                   mediump vec4 blured  = texture2D(source, qt_TexCoord0);
 
-                       mediump vec4 exclColor = vec4(exclusionStrength, exclusionStrength, exclusionStrength, 0.0);
+                   mediump vec4 exclColor = vec4(exclusionStrength, exclusionStrength, exclusionStrength, 0.0);
 
-                       blured = exclude(blured, exclColor);
+                   blured = exclude(blured, exclColor);
 
-                       gl_FragColor = mix(blured, tint, tintStrength) + noise;
-                    }"
-            }
+                   gl_FragColor = mix(blured, tint, tintStrength) + noise;
+                }"
         }
     }
 }


=====================================
modules/gui/qt/widgets/qml/OverlayMenu.qml
=====================================
@@ -57,7 +57,7 @@ Item {
     }
 
     /* required */ property var itemParent
-    /* required */ property var backgroundItem
+    property alias effectSource: effect.source
 
     visible: false
 
@@ -116,12 +116,12 @@ Item {
         }
 
         FrostedGlassEffect {
-            source: backgroundItem
-
+            id: effect
             anchors.fill: parent
 
-            readonly property point overlayPos: backgroundItem.mapFromItem(root, parentItem.x, parentItem.y)
-            sourceRect: Qt.rect(overlayPos.x, overlayPos.y, width, height)
+            source: backgroundItem
+
+            color: VLCStyle.colors.topBanner
 
             tintStrength: 0.0
             exclusionStrength: 0.1



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/1d32cd031232ef1e1afba996028727bff0683f2f

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/1d32cd031232ef1e1afba996028727bff0683f2f
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list