homescreens/folio: Improve performance of wallpaper blur, and enable by default

Fixes https://invent.kde.org/plasma/plasma-mobile/-/issues/306

I added a ShaderEffectSource in between so that the blur only samples the wallpaper when necessary

I also switched to FastBlur which seems to be much, much faster than MultiEffect on the PinePhone.

From testing, this made the performance about on-par with no blur at all.
This commit is contained in:
Devin Lin 2024-03-06 13:04:25 -05:00
parent ec5a112da2
commit ca55def5eb
2 changed files with 19 additions and 14 deletions

View file

@ -170,7 +170,7 @@ void FolioSettings::load()
m_delegateIconSize = m_applet->config().readEntry("delegateIconSize", 48); m_delegateIconSize = m_applet->config().readEntry("delegateIconSize", 48);
m_showFavouritesBarBackground = m_applet->config().readEntry("showFavoritesBarBackground", true); m_showFavouritesBarBackground = m_applet->config().readEntry("showFavoritesBarBackground", true);
m_pageTransitionEffect = static_cast<PageTransitionEffect>(m_applet->config().readEntry("pageTransitionEffect", (int)SlideTransition)); m_pageTransitionEffect = static_cast<PageTransitionEffect>(m_applet->config().readEntry("pageTransitionEffect", (int)SlideTransition));
m_showWallpaperBlur = m_applet->config().readEntry("showWallpaperBlur", false); m_showWallpaperBlur = m_applet->config().readEntry("showWallpaperBlur", true);
Q_EMIT homeScreenRowsChanged(); Q_EMIT homeScreenRowsChanged();
Q_EMIT homeScreenColumnsChanged(); Q_EMIT homeScreenColumnsChanged();

View file

@ -5,6 +5,7 @@ import QtQuick
import QtQuick.Window import QtQuick.Window
import QtQuick.Layouts import QtQuick.Layouts
import QtQuick.Effects import QtQuick.Effects
import Qt5Compat.GraphicalEffects
import org.kde.kirigami 2.20 as Kirigami import org.kde.kirigami 2.20 as Kirigami
@ -35,23 +36,27 @@ ContainmentItem {
anchors.fill: parent anchors.fill: parent
sourceComponent: Item { sourceComponent: Item {
// HACK: wallpaper (to enforce same dimensions that blur uses) id: wallpaper
MultiEffect { anchors.fill: parent
blurEnabled: true
blur: 0.0 // only take samples from wallpaper when we need the blur for performance
blurMax: 0.0 ShaderEffectSource {
autoPaddingEnabled: false id: controlledWallpaperSource
source: Plasmoid.wallpaperGraphicsObject
anchors.fill: parent anchors.fill: parent
sourceItem: Plasmoid.wallpaperGraphicsObject
live: blur.visible
hideSource: false
visible: false
} }
// wallpaper blur // wallpaper blur
MultiEffect { // we attempted to use MultiEffect in the past, but it had very poor performance on the PinePhone
blurEnabled: true FastBlur {
blur: 1.0 id: blur
blurMax: 50 radius: 50
autoPaddingEnabled: false cached: true
source: Plasmoid.wallpaperGraphicsObject source: controlledWallpaperSource
anchors.fill: parent anchors.fill: parent
visible: opacity > 0 visible: opacity > 0
opacity: Math.min(1, opacity: Math.min(1,