From c7b4e2c49dc0334c4a9f815f29ebd8ae89e0dbd5 Mon Sep 17 00:00:00 2001 From: bbedward Date: Thu, 25 Sep 2025 23:33:57 -0400 Subject: [PATCH] wrap shaders in a loader --- Modules/WallpaperBackground.qml | 342 +++++++++++++++++--------------- 1 file changed, 179 insertions(+), 163 deletions(-) diff --git a/Modules/WallpaperBackground.qml b/Modules/WallpaperBackground.qml index 8df55da5..c707d12f 100644 --- a/Modules/WallpaperBackground.qml +++ b/Modules/WallpaperBackground.qml @@ -77,7 +77,6 @@ LazyLoader { monitor: modelData.name } - Component.onDestruction: { weProc.stop() } @@ -116,8 +115,10 @@ LazyLoader { } function changeWallpaper(newPath, force) { - if (!force && newPath === currentWallpaper.source) return - if (!newPath || newPath.startsWith("#")) return + if (!force && newPath === currentWallpaper.source) + return + if (!newPath || newPath.startsWith("#")) + return if (root.transitioning) { transitionAnimation.stop() @@ -163,7 +164,6 @@ LazyLoader { } } - Loader { anchors.fill: parent active: !root.source || root.isColorSource @@ -212,15 +212,14 @@ LazyLoader { fillMode: Image.PreserveAspectCrop onStatusChanged: { - if (status !== Image.Ready) return + if (status !== Image.Ready) + return if (root.actualTransitionType === "none") { currentWallpaper.source = source nextWallpaper.source = "" root.transitionProgress = 0.0 } else { - currentWallpaper.layer.enabled = true - layer.enabled = true visible = true if (!root.transitioning) { transitionAnimation.start() @@ -229,166 +228,185 @@ LazyLoader { } } - ShaderEffect { - id: fadeShader + Loader { + id: effectLoader anchors.fill: parent - visible: root.actualTransitionType === "fade" && (root.hasCurrent || root.booting) - - property variant source1: root.hasCurrent ? currentWallpaper : transparentSource - property variant source2: nextWallpaper - property real progress: root.transitionProgress - property real fillMode: root.fillMode - property vector4d fillColor: root.fillColor - property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width) - property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height) - property real imageWidth2: Math.max(1, source2.sourceSize.width) - property real imageHeight2: Math.max(1, source2.sourceSize.height) - property real screenWidth: modelData.width - property real screenHeight: modelData.height - - fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_fade.frag.qsb") + active: root.actualTransitionType !== "none" && (root.hasCurrent || root.booting) + sourceComponent: { + switch (root.actualTransitionType) { + case "fade": + return fadeComp + case "wipe": + return wipeComp + case "disc": + return discComp + case "stripes": + return stripesComp + case "iris bloom": + return irisComp + case "pixelate": + return pixelateComp + case "portal": + return portalComp + default: + return null + } + } } - ShaderEffect { - id: wipeShader - anchors.fill: parent - visible: root.actualTransitionType === "wipe" && (root.hasCurrent || root.booting) - - property variant source1: root.hasCurrent ? currentWallpaper : transparentSource - property variant source2: nextWallpaper - property real progress: root.transitionProgress - property real smoothness: root.edgeSmoothness - property real direction: root.wipeDirection - property real fillMode: root.fillMode - property vector4d fillColor: root.fillColor - property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width) - property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height) - property real imageWidth2: Math.max(1, source2.sourceSize.width) - property real imageHeight2: Math.max(1, source2.sourceSize.height) - property real screenWidth: modelData.width - property real screenHeight: modelData.height - - fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_wipe.frag.qsb") + Component { + id: fadeComp + ShaderEffect { + anchors.fill: parent + property variant source1: root.hasCurrent ? currentWallpaper : transparentSource + property variant source2: nextWallpaper + property real progress: root.transitionProgress + property real fillMode: root.fillMode + property vector4d fillColor: root.fillColor + property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width) + property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height) + property real imageWidth2: Math.max(1, source2.sourceSize.width) + property real imageHeight2: Math.max(1, source2.sourceSize.height) + property real screenWidth: modelData.width + property real screenHeight: modelData.height + fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_fade.frag.qsb") + } } - ShaderEffect { - id: discShader - anchors.fill: parent - visible: root.actualTransitionType === "disc" && (root.hasCurrent || root.booting) - - property variant source1: root.hasCurrent ? currentWallpaper : transparentSource - property variant source2: nextWallpaper - property real progress: root.transitionProgress - property real smoothness: root.edgeSmoothness - property real aspectRatio: root.width / root.height - property real centerX: root.discCenterX - property real centerY: root.discCenterY - property real fillMode: root.fillMode - property vector4d fillColor: root.fillColor - property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width) - property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height) - property real imageWidth2: Math.max(1, source2.sourceSize.width) - property real imageHeight2: Math.max(1, source2.sourceSize.height) - property real screenWidth: modelData.width - property real screenHeight: modelData.height - - fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_disc.frag.qsb") + Component { + id: wipeComp + ShaderEffect { + anchors.fill: parent + property variant source1: root.hasCurrent ? currentWallpaper : transparentSource + property variant source2: nextWallpaper + property real progress: root.transitionProgress + property real smoothness: root.edgeSmoothness + property real direction: root.wipeDirection + property real fillMode: root.fillMode + property vector4d fillColor: root.fillColor + property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width) + property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height) + property real imageWidth2: Math.max(1, source2.sourceSize.width) + property real imageHeight2: Math.max(1, source2.sourceSize.height) + property real screenWidth: modelData.width + property real screenHeight: modelData.height + fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_wipe.frag.qsb") + } } - ShaderEffect { - id: stripesShader - anchors.fill: parent - visible: root.actualTransitionType === "stripes" && (root.hasCurrent || root.booting) - - property variant source1: root.hasCurrent ? currentWallpaper : transparentSource - property variant source2: nextWallpaper - property real progress: root.transitionProgress - property real smoothness: root.edgeSmoothness - property real aspectRatio: root.width / root.height - property real stripeCount: root.stripesCount - property real angle: root.stripesAngle - property real fillMode: root.fillMode - property vector4d fillColor: root.fillColor - property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width) - property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height) - property real imageWidth2: Math.max(1, source2.sourceSize.width) - property real imageHeight2: Math.max(1, source2.sourceSize.height) - property real screenWidth: modelData.width - property real screenHeight: modelData.height - - fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_stripes.frag.qsb") + Component { + id: discComp + ShaderEffect { + anchors.fill: parent + property variant source1: root.hasCurrent ? currentWallpaper : transparentSource + property variant source2: nextWallpaper + property real progress: root.transitionProgress + property real smoothness: root.edgeSmoothness + property real aspectRatio: root.width / root.height + property real centerX: root.discCenterX + property real centerY: root.discCenterY + property real fillMode: root.fillMode + property vector4d fillColor: root.fillColor + property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width) + property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height) + property real imageWidth2: Math.max(1, source2.sourceSize.width) + property real imageHeight2: Math.max(1, source2.sourceSize.height) + property real screenWidth: modelData.width + property real screenHeight: modelData.height + fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_disc.frag.qsb") + } } - ShaderEffect { - id: irisBloomShader - anchors.fill: parent - visible: root.actualTransitionType === "iris bloom" && (root.hasCurrent || root.booting) - - property variant source1: root.hasCurrent ? currentWallpaper : transparentSource - property variant source2: nextWallpaper - property real progress: root.transitionProgress - property real smoothness: root.edgeSmoothness - property real centerX: 0.5 - property real centerY: 0.5 - property real aspectRatio: root.width / root.height - property real fillMode: root.fillMode - property vector4d fillColor: root.fillColor - property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width) - property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height) - property real imageWidth2: Math.max(1, source2.sourceSize.width) - property real imageHeight2: Math.max(1, source2.sourceSize.height) - property real screenWidth: modelData.width - property real screenHeight: modelData.height - - fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_iris_bloom.frag.qsb") + Component { + id: stripesComp + ShaderEffect { + anchors.fill: parent + property variant source1: root.hasCurrent ? currentWallpaper : transparentSource + property variant source2: nextWallpaper + property real progress: root.transitionProgress + property real smoothness: root.edgeSmoothness + property real aspectRatio: root.width / root.height + property real stripeCount: root.stripesCount + property real angle: root.stripesAngle + property real fillMode: root.fillMode + property vector4d fillColor: root.fillColor + property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width) + property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height) + property real imageWidth2: Math.max(1, source2.sourceSize.width) + property real imageHeight2: Math.max(1, source2.sourceSize.height) + property real screenWidth: modelData.width + property real screenHeight: modelData.height + fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_stripes.frag.qsb") + } } - ShaderEffect { - id: pixelateShader - anchors.fill: parent - visible: root.actualTransitionType === "pixelate" && (root.hasCurrent || root.booting) - - property variant source1: root.hasCurrent ? currentWallpaper : transparentSource - property variant source2: nextWallpaper - property real progress: root.transitionProgress - property real smoothness: root.edgeSmoothness // controls starting block size - property real fillMode: root.fillMode - property vector4d fillColor: root.fillColor - property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width) - property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height) - property real imageWidth2: Math.max(1, source2.sourceSize.width) - property real imageHeight2: Math.max(1, source2.sourceSize.height) - property real screenWidth: modelData.width - property real screenHeight: modelData.height - property real centerX: root.discCenterX - property real centerY: root.discCenterY - property real aspectRatio: root.width / root.height - - fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_pixelate.frag.qsb") + Component { + id: irisComp + ShaderEffect { + anchors.fill: parent + property variant source1: root.hasCurrent ? currentWallpaper : transparentSource + property variant source2: nextWallpaper + property real progress: root.transitionProgress + property real smoothness: root.edgeSmoothness + property real centerX: 0.5 + property real centerY: 0.5 + property real aspectRatio: root.width / root.height + property real fillMode: root.fillMode + property vector4d fillColor: root.fillColor + property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width) + property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height) + property real imageWidth2: Math.max(1, source2.sourceSize.width) + property real imageHeight2: Math.max(1, source2.sourceSize.height) + property real screenWidth: modelData.width + property real screenHeight: modelData.height + fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_iris_bloom.frag.qsb") + } } - ShaderEffect { - id: portalShader - anchors.fill: parent - visible: root.actualTransitionType === "portal" && (root.hasCurrent || root.booting) + Component { + id: pixelateComp + ShaderEffect { + anchors.fill: parent + property variant source1: root.hasCurrent ? currentWallpaper : transparentSource + property variant source2: nextWallpaper + property real progress: root.transitionProgress + property real smoothness: root.edgeSmoothness + property real fillMode: root.fillMode + property vector4d fillColor: root.fillColor + property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width) + property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height) + property real imageWidth2: Math.max(1, source2.sourceSize.width) + property real imageHeight2: Math.max(1, source2.sourceSize.height) + property real screenWidth: modelData.width + property real screenHeight: modelData.height + property real centerX: root.discCenterX + property real centerY: root.discCenterY + property real aspectRatio: root.width / root.height + fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_pixelate.frag.qsb") + } + } - property variant source1: root.hasCurrent ? currentWallpaper : transparentSource - property variant source2: nextWallpaper - property real progress: root.transitionProgress - property real smoothness: root.edgeSmoothness - property real aspectRatio: root.width / root.height - property real centerX: root.discCenterX - property real centerY: root.discCenterY - property real fillMode: root.fillMode - property vector4d fillColor: root.fillColor - property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width) - property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height) - property real imageWidth2: Math.max(1, source2.sourceSize.width) - property real imageHeight2: Math.max(1, source2.sourceSize.height) - property real screenWidth: modelData.width - property real screenHeight: modelData.height - - fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_portal.frag.qsb") + Component { + id: portalComp + ShaderEffect { + anchors.fill: parent + property variant source1: root.hasCurrent ? currentWallpaper : transparentSource + property variant source2: nextWallpaper + property real progress: root.transitionProgress + property real smoothness: root.edgeSmoothness + property real aspectRatio: root.width / root.height + property real centerX: root.discCenterX + property real centerY: root.discCenterY + property real fillMode: root.fillMode + property vector4d fillColor: root.fillColor + property real imageWidth1: Math.max(1, root.hasCurrent ? source1.sourceSize.width : modelData.width) + property real imageHeight1: Math.max(1, root.hasCurrent ? source1.sourceSize.height : modelData.height) + property real imageWidth2: Math.max(1, source2.sourceSize.width) + property real imageHeight2: Math.max(1, source2.sourceSize.height) + property real screenWidth: modelData.width + property real screenHeight: modelData.height + fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wp_portal.frag.qsb") + } } NumberAnimation { @@ -401,16 +419,14 @@ LazyLoader { easing.type: Easing.InOutCubic onFinished: { Qt.callLater(() => { - if (nextWallpaper.source && nextWallpaper.status === Image.Ready && !nextWallpaper.source.toString().startsWith("#")) { - currentWallpaper.source = nextWallpaper.source - } - nextWallpaper.source = "" - nextWallpaper.visible = false - currentWallpaper.visible = root.actualTransitionType === "none" - currentWallpaper.layer.enabled = false - nextWallpaper.layer.enabled = false - root.transitionProgress = 0.0 - }) + if (nextWallpaper.source && nextWallpaper.status === Image.Ready && !nextWallpaper.source.toString().startsWith("#")) { + currentWallpaper.source = nextWallpaper.source + } + nextWallpaper.source = "" + nextWallpaper.visible = false + currentWallpaper.visible = root.actualTransitionType === "none" + root.transitionProgress = 0.0 + }) } } }