1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-02 03:28:28 -04:00

media: throttle frame rate of media-related animations

port 1.5

related #2869
This commit is contained in:
bbedward
2026-07-15 12:57:25 -04:00
parent bf408f8d00
commit cdaedad969
4 changed files with 53 additions and 37 deletions
+36 -24
View File
@@ -358,38 +358,50 @@ BasePill {
onTextChanged: { onTextChanged: {
scrollOffset = 0; scrollOffset = 0;
textShift = 0; textShift = 0;
scrollTimer.reset();
textChangeAnimation.restart(); textChangeAnimation.restart();
} }
SequentialAnimation { // Timer stepping, not NumberAnimation — a running animation commits frames every vsync (#2863)
id: scrollAnimation Timer {
id: scrollTimer
readonly property real maxOffset: Math.max(0, mediaText.implicitWidth - textContainer.width + 5)
property int direction: 1
property int holdTicks: 33
interval: 60
repeat: true
running: mediaText.needsScrolling && textContainer.visible && mediaText.onScreen && root._isPlaying running: mediaText.needsScrolling && textContainer.visible && mediaText.onScreen && root._isPlaying
loops: Animation.Infinite
onStopped: mediaText.scrollOffset = 0
PauseAnimation { function reset() {
duration: 2000 mediaText.scrollOffset = 0;
direction = 1;
holdTicks = 33;
} }
NumberAnimation { onRunningChanged: {
target: mediaText if (!running)
property: "scrollOffset" reset();
from: 0
to: mediaText.implicitWidth - textContainer.width + 5
duration: Math.max(1000, (mediaText.implicitWidth - textContainer.width + 5) * 60)
easing.type: Easing.Linear
} }
onTriggered: {
PauseAnimation { if (holdTicks > 0) {
duration: 2000 holdTicks--;
} return;
}
NumberAnimation { const next = mediaText.scrollOffset + direction;
target: mediaText if (next >= maxOffset) {
property: "scrollOffset" mediaText.scrollOffset = maxOffset;
to: 0 direction = -1;
duration: Math.max(1000, (mediaText.implicitWidth - textContainer.width + 5) * 60) holdTicks = 33;
easing.type: Easing.Linear return;
}
if (next <= 0) {
mediaText.scrollOffset = 0;
direction = 1;
holdTicks = 33;
return;
}
mediaText.scrollOffset = next;
} }
} }
+6 -10
View File
@@ -182,16 +182,12 @@ Item {
} }
} }
FrameAnimation { // Timer, not FrameAnimation — a running animation commits frames every vsync (#2863)
running: blobEffect.visible Timer {
property real pending: 0 running: blobEffect.visible && root.onScreen
onTriggered: { interval: 33
pending += frameTime; repeat: true
if (pending < 0.03) onTriggered: root.stepBlob(0.033)
return;
root.stepBlob(Math.min(pending, 0.05));
pending = 0;
}
} }
ShaderEffect { ShaderEffect {
+4
View File
@@ -147,6 +147,10 @@ Item {
trackColor: MediaAccentService.accentTrack trackColor: MediaAccentService.accentTrack
actualProgressColor: MediaAccentService.accentSubtle actualProgressColor: MediaAccentService.accentSubtle
isPlaying: activePlayer && activePlayer.playbackState === MprisPlaybackState.Playing isPlaying: activePlayer && activePlayer.playbackState === MprisPlaybackState.Playing
onFrameTicked: {
if (!root.isSeeking)
activePlayer.positionChanged();
}
MouseArea { MouseArea {
id: waveMouseArea id: waveMouseArea
+7 -3
View File
@@ -50,11 +50,15 @@ Item {
fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wave_progress.frag.qsb") fragmentShader: Qt.resolvedUrl("../Shaders/qsb/wave_progress.frag.qsb")
} }
signal frameTicked
FrameAnimation { FrameAnimation {
running: root.visible && (root.isPlaying || root.currentAmp > 0) running: root.visible && (root.isPlaying || root.currentAmp > 0) && (root.Window.window?.visible ?? false)
onTriggered: { onTriggered: {
if (root.isPlaying) if (!root.isPlaying)
root.phase += 0.03 * frameTime * 60; return;
root.phase = (root.phase + 0.03 * frameTime * 60) % 6.28318530718;
root.frameTicked();
} }
} }
} }