1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 21:42:51 -05:00

wallpaper: clamp max texture size

This commit is contained in:
bbedward
2025-12-12 11:17:28 -05:00
parent d6b9b72e9b
commit 32e6c1660f
2 changed files with 100 additions and 103 deletions

View File

@@ -79,10 +79,12 @@ Variants {
} }
Component.onCompleted: { Component.onCompleted: {
if (source) { if (!source) {
const formattedSource = source.startsWith("file://") ? source : "file://" + source; isInitialized = true;
setWallpaperImmediate(formattedSource); return;
} }
const formattedSource = source.startsWith("file://") ? source : "file://" + source;
setWallpaperImmediate(formattedSource);
isInitialized = true; isInitialized = true;
} }
@@ -93,22 +95,23 @@ Variants {
property bool useNextForEffect: false property bool useNextForEffect: false
onSourceChanged: { onSourceChanged: {
const isColor = source.startsWith("#"); if (!source || source.startsWith("#")) {
if (!source) {
setWallpaperImmediate(""); setWallpaperImmediate("");
} else if (isColor) { return;
setWallpaperImmediate("");
} else {
if (!isInitialized || !currentWallpaper.source) {
setWallpaperImmediate(source.startsWith("file://") ? source : "file://" + source);
isInitialized = true;
} else if (CompositorService.isNiri && SessionData.isSwitchingMode) {
setWallpaperImmediate(source.startsWith("file://") ? source : "file://" + source);
} else {
changeWallpaper(source.startsWith("file://") ? source : "file://" + source);
}
} }
const formattedSource = source.startsWith("file://") ? source : "file://" + source;
if (!isInitialized || !currentWallpaper.source) {
setWallpaperImmediate(formattedSource);
isInitialized = true;
return;
}
if (CompositorService.isNiri && SessionData.isSwitchingMode) {
setWallpaperImmediate(formattedSource);
return;
}
changeWallpaper(formattedSource);
} }
function setWallpaperImmediate(newSource) { function setWallpaperImmediate(newSource) {
@@ -120,15 +123,18 @@ Variants {
} }
function startTransition() { function startTransition() {
currentWallpaper.cache = true;
nextWallpaper.cache = true;
root.useNextForEffect = true; root.useNextForEffect = true;
root.effectActive = true; root.effectActive = true;
if (srcNext.scheduleUpdate) if (srcNext.scheduleUpdate)
srcNext.scheduleUpdate(); srcNext.scheduleUpdate();
Qt.callLater(() => { transitionDelayTimer.start();
transitionAnimation.start(); }
});
Timer {
id: transitionDelayTimer
interval: 16
repeat: false
onTriggered: transitionAnimation.start()
} }
function changeWallpaper(newPath) { function changeWallpaper(newPath) {
@@ -143,7 +149,6 @@ Variants {
currentWallpaper.source = nextWallpaper.source; currentWallpaper.source = nextWallpaper.source;
nextWallpaper.source = ""; nextWallpaper.source = "";
} }
if (!currentWallpaper.source) { if (!currentWallpaper.source) {
setWallpaperImmediate(newPath); setWallpaperImmediate(newPath);
return; return;
@@ -151,9 +156,8 @@ Variants {
nextWallpaper.source = newPath; nextWallpaper.source = newPath;
if (nextWallpaper.status === Image.Ready) { if (nextWallpaper.status === Image.Ready)
root.startTransition(); root.startTransition();
}
} }
Loader { Loader {
@@ -166,9 +170,9 @@ Variants {
} }
} }
property real screenScale: CompositorService.getScreenScale(modelData) readonly property int maxTextureSize: 8192
property int physicalWidth: Math.round(modelData.width * screenScale) property int textureWidth: Math.min(modelData.width, maxTextureSize)
property int physicalHeight: Math.round(modelData.height * screenScale) property int textureHeight: Math.min(modelData.height, maxTextureSize)
Image { Image {
id: currentWallpaper id: currentWallpaper
@@ -178,7 +182,7 @@ Variants {
asynchronous: true asynchronous: true
smooth: true smooth: true
cache: true cache: true
sourceSize: Qt.size(root.physicalWidth, root.physicalHeight) sourceSize: Qt.size(root.textureWidth, root.textureHeight)
fillMode: root.getFillMode(SessionData.isGreeterMode ? GreetdSettings.wallpaperFillMode : SettingsData.wallpaperFillMode) fillMode: root.getFillMode(SessionData.isGreeterMode ? GreetdSettings.wallpaperFillMode : SettingsData.wallpaperFillMode)
} }
@@ -189,8 +193,8 @@ Variants {
opacity: 0 opacity: 0
asynchronous: true asynchronous: true
smooth: true smooth: true
cache: false cache: true
sourceSize: Qt.size(root.physicalWidth, root.physicalHeight) sourceSize: Qt.size(root.textureWidth, root.textureHeight)
fillMode: root.getFillMode(SessionData.isGreeterMode ? GreetdSettings.wallpaperFillMode : SettingsData.wallpaperFillMode) fillMode: root.getFillMode(SessionData.isGreeterMode ? GreetdSettings.wallpaperFillMode : SettingsData.wallpaperFillMode)
onStatusChanged: { onStatusChanged: {
@@ -209,7 +213,7 @@ Variants {
live: root.effectActive live: root.effectActive
mipmap: false mipmap: false
recursive: false recursive: false
textureSize: root.effectActive ? Qt.size(root.physicalWidth, root.physicalHeight) : Qt.size(1, 1) textureSize: Qt.size(root.textureWidth, root.textureHeight)
} }
Rectangle { Rectangle {
@@ -265,19 +269,12 @@ Variants {
duration: 1000 duration: 1000
easing.type: Easing.InOutCubic easing.type: Easing.InOutCubic
onFinished: { onFinished: {
if (nextWallpaper.source && nextWallpaper.status === Image.Ready) { if (nextWallpaper.source && nextWallpaper.status === Image.Ready)
currentWallpaper.source = nextWallpaper.source; currentWallpaper.source = nextWallpaper.source;
}
root.useNextForEffect = false; root.useNextForEffect = false;
Qt.callLater(() => { nextWallpaper.source = "";
nextWallpaper.source = ""; root.transitionProgress = 0.0;
Qt.callLater(() => { root.effectActive = false;
root.effectActive = false;
currentWallpaper.cache = true;
nextWallpaper.cache = false;
root.transitionProgress = 0.0;
});
});
} }
} }
} }

View File

@@ -57,15 +57,11 @@ Variants {
} }
} }
onTransitionTypeChanged: { onTransitionTypeChanged: {
if (transitionType === "random") { if (transitionType !== "random") {
if (SessionData.includedTransitions.length === 0) {
actualTransitionType = "none";
} else {
actualTransitionType = SessionData.includedTransitions[Math.floor(Math.random() * SessionData.includedTransitions.length)];
}
} else {
actualTransitionType = transitionType; actualTransitionType = transitionType;
return;
} }
actualTransitionType = SessionData.includedTransitions.length === 0 ? "none" : SessionData.includedTransitions[Math.floor(Math.random() * SessionData.includedTransitions.length)];
} }
property real transitionProgress: 0 property real transitionProgress: 0
@@ -108,30 +104,33 @@ Variants {
} }
Component.onCompleted: { Component.onCompleted: {
if (source) { if (!source) {
const formattedSource = source.startsWith("file://") ? source : "file://" + source; isInitialized = true;
setWallpaperImmediate(formattedSource); return;
} }
const formattedSource = source.startsWith("file://") ? source : "file://" + source;
setWallpaperImmediate(formattedSource);
isInitialized = true; isInitialized = true;
} }
onSourceChanged: { onSourceChanged: {
const isColor = source.startsWith("#"); if (!source || source.startsWith("#")) {
if (!source) {
setWallpaperImmediate(""); setWallpaperImmediate("");
} else if (isColor) { return;
setWallpaperImmediate("");
} else {
if (!isInitialized || !currentWallpaper.source) {
setWallpaperImmediate(source.startsWith("file://") ? source : "file://" + source);
isInitialized = true;
} else if (CompositorService.isNiri && SessionData.isSwitchingMode) {
setWallpaperImmediate(source.startsWith("file://") ? source : "file://" + source);
} else {
changeWallpaper(source.startsWith("file://") ? source : "file://" + source);
}
} }
const formattedSource = source.startsWith("file://") ? source : "file://" + source;
if (!isInitialized || !currentWallpaper.source) {
setWallpaperImmediate(formattedSource);
isInitialized = true;
return;
}
if (CompositorService.isNiri && SessionData.isSwitchingMode) {
setWallpaperImmediate(formattedSource);
return;
}
changeWallpaper(formattedSource);
} }
function setWallpaperImmediate(newSource) { function setWallpaperImmediate(newSource) {
@@ -143,8 +142,6 @@ Variants {
} }
function startTransition() { function startTransition() {
currentWallpaper.cache = true;
nextWallpaper.cache = true;
currentWallpaper.layer.enabled = true; currentWallpaper.layer.enabled = true;
nextWallpaper.layer.enabled = true; nextWallpaper.layer.enabled = true;
root.useNextForEffect = true; root.useNextForEffect = true;
@@ -153,9 +150,14 @@ Variants {
srcCurrent.scheduleUpdate(); srcCurrent.scheduleUpdate();
if (srcNext.scheduleUpdate) if (srcNext.scheduleUpdate)
srcNext.scheduleUpdate(); srcNext.scheduleUpdate();
Qt.callLater(() => { transitionDelayTimer.start();
transitionAnimation.start(); }
});
Timer {
id: transitionDelayTimer
interval: 16
repeat: false
onTriggered: transitionAnimation.start()
} }
function changeWallpaper(newPath, force) { function changeWallpaper(newPath, force) {
@@ -163,23 +165,17 @@ Variants {
return; return;
if (!newPath || newPath.startsWith("#")) if (!newPath || newPath.startsWith("#"))
return; return;
if (root.transitioning || root.effectActive) { if (root.transitioning || root.effectActive) {
root.pendingWallpaper = newPath; root.pendingWallpaper = newPath;
return; return;
} }
if (!currentWallpaper.source) { if (!currentWallpaper.source) {
setWallpaperImmediate(newPath); setWallpaperImmediate(newPath);
return; return;
} }
if (root.transitionType === "random") { if (root.transitionType === "random") {
if (SessionData.includedTransitions.length === 0) { root.actualTransitionType = SessionData.includedTransitions.length === 0 ? "none" : SessionData.includedTransitions[Math.floor(Math.random() * SessionData.includedTransitions.length)];
root.actualTransitionType = "none";
} else {
root.actualTransitionType = SessionData.includedTransitions[Math.floor(Math.random() * SessionData.includedTransitions.length)];
}
} }
if (root.actualTransitionType === "none") { if (root.actualTransitionType === "none") {
@@ -187,21 +183,26 @@ Variants {
return; return;
} }
if (root.actualTransitionType === "wipe") { switch (root.actualTransitionType) {
case "wipe":
root.wipeDirection = Math.random() * 4; root.wipeDirection = Math.random() * 4;
} else if (root.actualTransitionType === "disc" || root.actualTransitionType === "pixelate" || root.actualTransitionType === "portal") { break;
case "disc":
case "pixelate":
case "portal":
root.discCenterX = Math.random(); root.discCenterX = Math.random();
root.discCenterY = Math.random(); root.discCenterY = Math.random();
} else if (root.actualTransitionType === "stripes") { break;
case "stripes":
root.stripesCount = Math.round(Math.random() * 20 + 4); root.stripesCount = Math.round(Math.random() * 20 + 4);
root.stripesAngle = Math.random() * 360; root.stripesAngle = Math.random() * 360;
break;
} }
nextWallpaper.source = newPath; nextWallpaper.source = newPath;
if (nextWallpaper.status === Image.Ready) { if (nextWallpaper.status === Image.Ready)
root.startTransition(); root.startTransition();
}
} }
Loader { Loader {
@@ -214,9 +215,9 @@ Variants {
} }
} }
property real screenScale: CompositorService.getScreenScale(modelData) readonly property int maxTextureSize: 8192
property int physicalWidth: Math.round(modelData.width * screenScale) property int textureWidth: Math.min(modelData.width, maxTextureSize)
property int physicalHeight: Math.round(modelData.height * screenScale) property int textureHeight: Math.min(modelData.height, maxTextureSize)
Image { Image {
id: currentWallpaper id: currentWallpaper
@@ -227,7 +228,7 @@ Variants {
asynchronous: true asynchronous: true
smooth: true smooth: true
cache: true cache: true
sourceSize: Qt.size(root.physicalWidth, root.physicalHeight) sourceSize: Qt.size(root.textureWidth, root.textureHeight)
fillMode: root.getFillMode(SettingsData.wallpaperFillMode) fillMode: root.getFillMode(SettingsData.wallpaperFillMode)
} }
@@ -239,8 +240,8 @@ Variants {
layer.enabled: false layer.enabled: false
asynchronous: true asynchronous: true
smooth: true smooth: true
cache: false cache: true
sourceSize: Qt.size(root.physicalWidth, root.physicalHeight) sourceSize: Qt.size(root.textureWidth, root.textureHeight)
fillMode: root.getFillMode(SettingsData.wallpaperFillMode) fillMode: root.getFillMode(SettingsData.wallpaperFillMode)
onStatusChanged: { onStatusChanged: {
@@ -263,7 +264,7 @@ Variants {
live: root.effectActive live: root.effectActive
mipmap: false mipmap: false
recursive: false recursive: false
textureSize: root.effectActive ? Qt.size(root.physicalWidth, root.physicalHeight) : Qt.size(1, 1) textureSize: Qt.size(root.textureWidth, root.textureHeight)
} }
ShaderEffectSource { ShaderEffectSource {
@@ -273,7 +274,7 @@ Variants {
live: root.effectActive live: root.effectActive
mipmap: false mipmap: false
recursive: false recursive: false
textureSize: root.effectActive ? Qt.size(root.physicalWidth, root.physicalHeight) : Qt.size(1, 1) textureSize: Qt.size(root.textureWidth, root.textureHeight)
} }
Rectangle { Rectangle {
@@ -297,8 +298,9 @@ Variants {
id: effectLoader id: effectLoader
anchors.fill: parent anchors.fill: parent
active: root.effectActive active: root.effectActive
sourceComponent: {
switch (root.actualTransitionType) { function getTransitionComponent(type) {
switch (type) {
case "fade": case "fade":
return fadeComp; return fadeComp;
case "wipe": case "wipe":
@@ -317,6 +319,8 @@ Variants {
return null; return null;
} }
} }
sourceComponent: getTransitionComponent(root.actualTransitionType)
} }
Component { Component {
@@ -491,17 +495,13 @@ Variants {
root.transitionProgress = 0.0; root.transitionProgress = 0.0;
currentWallpaper.layer.enabled = false; currentWallpaper.layer.enabled = false;
nextWallpaper.layer.enabled = false; nextWallpaper.layer.enabled = false;
currentWallpaper.cache = true;
nextWallpaper.cache = false;
root.effectActive = false; root.effectActive = false;
if (root.pendingWallpaper) { if (!root.pendingWallpaper)
var pending = root.pendingWallpaper; return;
root.pendingWallpaper = ""; var pending = root.pendingWallpaper;
Qt.callLater(() => { root.pendingWallpaper = "";
root.changeWallpaper(pending, true); Qt.callLater(() => root.changeWallpaper(pending, true));
});
}
} }
} }