From 1b94fb6b22a4f065cac7e1591978ae1df7f4011e Mon Sep 17 00:00:00 2001 From: Filippo Scognamiglio Date: Wed, 2 Apr 2014 22:07:37 +0200 Subject: [PATCH] Introducing terminal scaling for performance reasons on old PCs. --- app/ShaderSettings.qml | 9 ++++++++- app/Terminal.qml | 4 ++-- app/app.qmlproject.user | 2 +- app/frames/BlackRoughFrame.qml | 5 ++++- app/frames/NoFrame.qml | 5 ++++- app/frames/WhiteSimpleFrame.qml | 5 ++++- app/main.qml | 27 +++++++++++++++------------ 7 files changed, 38 insertions(+), 19 deletions(-) diff --git a/app/ShaderSettings.qml b/app/ShaderSettings.qml index 85dd22e..b36b255 100644 --- a/app/ShaderSettings.qml +++ b/app/ShaderSettings.qml @@ -25,9 +25,16 @@ Item{ property real ambient_light: 0.2 property real contrast: 0.8 - property real brightness: 0.5 + //Scaling of the preprocessed terminal with respect to the window. + property real terminal_scaling: 1.0 + + //Scaling of the whole window + property real window_scaling: 1.0 + + property real total_scaling: terminal_scaling * window_scaling + function mix(c1, c2, alpha){ return Qt.rgba(c1.r * alpha + c2.r * (1-alpha), c1.g * alpha + c2.g * (1-alpha), diff --git a/app/Terminal.qml b/app/Terminal.qml index 989652e..b7919cf 100644 --- a/app/Terminal.qml +++ b/app/Terminal.qml @@ -31,7 +31,6 @@ Item{ property real motionBlurCoefficient: (_minBlurCoefficient)*mBlur + (_maxBlurCoefficient)*(1.0-mBlur) property real _minBlurCoefficient: 0.015 property real _maxBlurCoefficient: 0.10 - anchors.fill: parent //Force reload of the blursource when settings change onScanlinesChanged: restartBlurredSource() @@ -74,7 +73,8 @@ Item{ onUpdatedImage: {blurredSource.live = true;livetimer.restart();} Component.onCompleted: { - font.pointSize = shadersettings.font.pixelSize * shadersettings.font_scaling; + var scaling_factor = shadersettings.font_scaling * shadersettings.terminal_scaling * shadersettings.window_scaling; + font.pointSize = shadersettings.font.pixelSize * scaling_factor; font.family = shadersettings.font.name; setLineSpacing(shadersettings.font.lineSpacing); forceActiveFocus(); diff --git a/app/app.qmlproject.user b/app/app.qmlproject.user index 8a025ba..6e1302e 100644 --- a/app/app.qmlproject.user +++ b/app/app.qmlproject.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/app/frames/BlackRoughFrame.qml b/app/frames/BlackRoughFrame.qml index 211cb97..50425cc 100644 --- a/app/frames/BlackRoughFrame.qml +++ b/app/frames/BlackRoughFrame.qml @@ -14,7 +14,10 @@ TerminalFrame{ borderBottom: 232 imageSource: "../images/black-frame.png" normalsSource: "../images/black-frame-normals.png" - sourceRect: Qt.rect(-80, -90, terminal.width + 160, terminal.height + 180) + sourceRect: Qt.rect(-80 * shadersettings.total_scaling, + -90 * shadersettings.total_scaling, + terminal.width + 160 * shadersettings.total_scaling, + terminal.height + 180 * shadersettings.total_scaling) shaderString: "FrameShader.qml" } diff --git a/app/frames/NoFrame.qml b/app/frames/NoFrame.qml index 5cbf386..58a0806 100644 --- a/app/frames/NoFrame.qml +++ b/app/frames/NoFrame.qml @@ -12,7 +12,10 @@ TerminalFrame{ borderTop: 116 borderBottom: 116 imageSource: "../images/screen-frame.png" - sourceRect: Qt.rect(-65, -75, terminal.width + 130, terminal.height + 150) + sourceRect: Qt.rect(-65 * shadersettings.total_scaling, + -75 * shadersettings.total_scaling, + terminal.width + 130 * shadersettings.total_scaling, + terminal.height + 150 * shadersettings.total_scaling) shaderString: "NoFrameShader.qml" } diff --git a/app/frames/WhiteSimpleFrame.qml b/app/frames/WhiteSimpleFrame.qml index 085052c..7434a63 100644 --- a/app/frames/WhiteSimpleFrame.qml +++ b/app/frames/WhiteSimpleFrame.qml @@ -13,7 +13,10 @@ TerminalFrame{ borderBottom: 116 imageSource: "../images/screen-frame.png" normalsSource: "../images/screen-frame-normals.png" - sourceRect: Qt.rect(-65, -75, terminal.width + 130, terminal.height + 150) + sourceRect: Qt.rect(-65 * shadersettings.total_scaling, + -75 * shadersettings.total_scaling, + terminal.width + 130 * shadersettings.total_scaling, + terminal.height + 150 * shadersettings.total_scaling) shaderString: "FrameShader.qml" } diff --git a/app/main.qml b/app/main.qml index 418c02e..192af8e 100644 --- a/app/main.qml +++ b/app/main.qml @@ -67,10 +67,21 @@ ApplicationWindow{ } } + Loader{ + id: frame + property rect sourceRect: item.sourceRect + anchors.fill: parent + z: 2.1 + source: shadersettings.frame_source + } + Item{ id: maincontainer - anchors.fill: parent - clip: true + anchors.centerIn: parent + 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" @@ -94,22 +105,14 @@ ApplicationWindow{ } Terminal{ id: terminal - width: parent.width - height: parent.height + width: parent.width * shadersettings.terminal_scaling + height: parent.height * shadersettings.terminal_scaling } ShaderEffectSource{ id: theSource sourceItem: terminal sourceRect: frame.sourceRect } - Loader{ - id: frame - property rect sourceRect: item.sourceRect - - anchors.fill: parent - z: 2.1 - source: shadersettings.frame_source - } ShaderManager{ id: shadercontainer anchors.fill: parent