From e1b8dc0d92c10e712e67116cbc218af71fa12837 Mon Sep 17 00:00:00 2001 From: Filippo Scognamiglio Date: Thu, 3 Apr 2014 18:44:23 +0200 Subject: [PATCH] It is now possible to set fps to save some cpu and battery. --- app/SettingsWindow.qml | 26 ++++++++++++++++++++++++++ app/ShaderSettings.qml | 5 +++++ app/Terminal.qml | 7 +++++-- app/main.qml | 4 ++-- 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/app/SettingsWindow.qml b/app/SettingsWindow.qml index d664f5a..258d201 100644 --- a/app/SettingsWindow.qml +++ b/app/SettingsWindow.qml @@ -150,6 +150,32 @@ ApplicationWindow { // } } } + GroupBox{ + title: qsTr("Performace") + Layout.fillWidth: true + Layout.columnSpan: 2 + anchors.left: parent.left + anchors.right: parent.right + RowLayout{ + Layout.columnSpan: 2 + anchors.left: parent.left + anchors.right: parent.right + Text{text: "Animation FPS"} + Slider{ + Layout.fillWidth: true + id: slider + stepSize: 1 + maximumValue: 60 + minimumValue: 0 + onValueChanged: shadersettings.fps = value; + value: shadersettings.fps + } + Text{ + id: textfield + text: slider.value + } + } + } } } diff --git a/app/ShaderSettings.qml b/app/ShaderSettings.qml index 37028d8..b00c950 100644 --- a/app/ShaderSettings.qml +++ b/app/ShaderSettings.qml @@ -35,6 +35,8 @@ Item{ property real window_scaling: 1.0 property real total_scaling: terminal_scaling * window_scaling + property real fps: 60 + function mix(c1, c2, alpha){ return Qt.rgba(c1.r * alpha + c2.r * (1-alpha), c1.g * alpha + c2.g * (1-alpha), @@ -162,6 +164,8 @@ Item{ console.log(profilename + settings); settings = JSON.parse(settings); + fps = settings.fps !== undefined ? settings.fps: fps + contrast = settings.contrast !== undefined ? settings.contrast : contrast; brightness = settings.brightness !== undefined ? settings.brightness : brightness @@ -189,6 +193,7 @@ Item{ function storeCurrentSettings(){ var settings = { + fps: fps, ambient_light : ambient_light, brightness : brightness, contrast : contrast, diff --git a/app/Terminal.qml b/app/Terminal.qml index 87f2b5d..7279ecc 100644 --- a/app/Terminal.qml +++ b/app/Terminal.qml @@ -25,12 +25,15 @@ import org.kde.konsole 0.1 Item{ id: terminalContainer - property real mBloom: shadersettings.bloom_strength + //The blur effect has to take into account the framerate + property real fpsAttenuation: shadersettings.fps / 60 property real mBlur: shadersettings.motion_blur - property real motionBlurCoefficient: (_minBlurCoefficient)*mBlur + (_maxBlurCoefficient)*(1.0-mBlur) + property real motionBlurCoefficient: ((_minBlurCoefficient)*mBlur + (_maxBlurCoefficient)*(1.0-mBlur)) / fpsAttenuation property real _minBlurCoefficient: 0.015 property real _maxBlurCoefficient: 0.10 + property real mBloom: shadersettings.bloom_strength + //Force reload of the blursource when settings change onMBloomChanged: restartBlurredSource() diff --git a/app/main.qml b/app/main.qml index 192af8e..335a164 100644 --- a/app/main.qml +++ b/app/main.qml @@ -81,7 +81,7 @@ ApplicationWindow{ width: parent.width * shadersettings.window_scaling height: parent.height * shadersettings.window_scaling scale: 1.0 / shadersettings.window_scaling - clip: false + Image{ id: randtexture source: "frames/images/randfunction.png" @@ -99,7 +99,7 @@ ApplicationWindow{ id: timetimer property real time: 0 onTriggered: time += interval - interval: 16 + interval: Math.round(1000 / shadersettings.fps) running: true repeat: true }