shift-shell/components/mobileshell/qml/homescreen/BlurEffect.qml
Micah Stanley d4eaf693c6 Folio/Halcyon: Expand Background Blur Effect using a MaskLayer
This merge request expands upon the folio and halcyon background blur effects, making the folio background blur include the backgrounds of folder icons, the favorites bar, and wallpaper selector, and for halcyon, it now includes the folder icons, app library, search, and wallpaper selector. To accomplish this, a mask layer plugin was created to easily attach to these elements. This way, we can use a `OpacityMask` to cut out from the existing blur layer, thus hopefully keeping the performance cost low. And with my limited testing, it does at least seems to run about the same on my oneplus 6t, though it is not really a low end device, so I can not fairly judge the impact for something slower (eg. PinePhone). To be on the safe side, a third option was also added to the folio settings, allowing for the ability to toggle back to the old functionality if needed.

![Screenshot_20250613_135521](/uploads/d5aa81d6589b61fbba675e4a6e621b55/Screenshot_20250613_135521.png)
![Screenshot_20250613_135536](/uploads/bd726459a131f736e2711ced3fe90d4f/Screenshot_20250613_135536.png)
![Screenshot_20250613_135505](/uploads/c603627b4e65d4b956a1e0b6463d28f3/Screenshot_20250613_135505.png)
![Screenshot_20250627_093729](/uploads/e5f1ad672361c2b9bae23e57905336eb/Screenshot_20250627_093729.png)
2025-06-27 14:27:30 -04:00

90 lines
3 KiB
QML

// SPDX-FileCopyrightText: 2023-2025 Devin Lin <devin@kde.org>
// SPDX-FileCopyrightText: 2025 Micah Stanley <stanleymicah@proton.me>
// SPDX-License-Identifier: LGPL-2.0-or-later
import QtQuick
import QtQuick.Layouts
import Qt5Compat.GraphicalEffects
Loader {
id: root
property Item sourceLayer
property Item maskSourceLayer
// this value is used to switch between blurring the whole wallpaper or just behind the mask areas
property real fullBlur: 1
// gets multiplied against the screen size to set the texture size
readonly property real blurTextureQuality: 0.5
readonly property var textureSize: Qt.size(Math.round(root.width * root.blurTextureQuality), Math.round(root.height * root.blurTextureQuality))
readonly property int fastBlurRadius: 42
sourceComponent: Item {
// only take samples from wallpaper when we need the blur for performance
ShaderEffectSource {
id: controlledWallpaperSource
anchors.fill: parent
// this layer will be blurred, so it looks fine to have a lower texture quality to help with performance
textureSize: root.textureSize
hideSource: false
opacity: root.fullBlur
visible: opacity > 0
// wallpaper blur
// we attempted to use MultiEffect in the past, but it had very poor performance on the PinePhone
sourceItem: FastBlur {
height: controlledWallpaperSource.textureSize.height
width: controlledWallpaperSource.textureSize.width
cached: true
radius: root.fastBlurRadius
source: ShaderEffectSource {
anchors.fill: parent
textureSize: controlledWallpaperSource.textureSize
sourceItem: root.sourceLayer
hideSource: false
}
}
}
// load in the layer mask so we can utilize it with the OpacityMask
Item {
id: blurMask
anchors.fill: parent
layer.enabled: true
layer.smooth: true
opacity: 0
Loader {
asynchronous: true
active: root.maskSourceLayer != null && root.fullBlur != 1
anchors.fill: parent
sourceComponent: maskSource
property Component maskSource: Item {
ShaderEffectSource {
anchors.fill: parent
sourceItem: root.maskSourceLayer
hideSource: false
live: true
}
}
}
}
// here we utilize the mask on the blur layer so we can blur behind the some homescreen items
OpacityMask {
anchors.fill: parent
source: controlledWallpaperSource
maskSource: blurMask
visible: opacity > 0 && root.maskSourceLayer != null
}
}
}