1
0
mirror of https://github.com/Swordfish90/cool-retro-term.git synced 2025-01-18 20:20:45 +00:00

Merge pull request #212 from Swordfish90/fast-burnin-3

Improved burnin. This is a very important optimizatoin for mesa linux ma...
This commit is contained in:
Filippo Scognamiglio 2015-01-19 17:17:21 +00:00
commit e379f05aca
3 changed files with 26 additions and 17 deletions

View File

@ -44,11 +44,13 @@ Item{
anchors.topMargin: frame.displacementTop * appSettings.windowScaling
anchors.bottomMargin: frame.displacementBottom * appSettings.windowScaling
//The blur effect has to take into account the framerate
property real mBlur: Math.sqrt(appSettings.burnIn)
property real motionBlurCoefficient: Utils.lint(_minBlurCoefficient, _maxBlurCoefficient, mBlur)
property real _minBlurCoefficient: 0.2
property real _maxBlurCoefficient: 0.02
//Parameters for the burnIn effect.
property real burnIn: appSettings.burnIn
property real fps: appSettings.fps !== 0 ? appSettings.fps : 60
property real burnInFadeTime: Utils.lint(_minBurnInFadeTime, _maxBurnInFadeTime, burnIn)
property real motionBlurCoefficient: 1.0 / (fps * burnInFadeTime)
property real _minBurnInFadeTime: 0.16
property real _maxBurnInFadeTime: 1.6
property size terminalSize: kterminal.terminalSize
property size fontMetrics: kterminal.fontMetrics
@ -228,13 +230,15 @@ Item{
Loader{
id: blurredSourceLoader
asynchronous: true
active: mBlur !== 0
active: burnIn !== 0
sourceComponent: ShaderEffectSource{
property bool updateBurnIn: false
id: _blurredSourceEffect
sourceItem: blurredTerminalLoader.item
recursive: true
live: true
live: false
hideSource: true
wrapMode: kterminalSource.wrapMode
@ -244,6 +248,13 @@ Item{
livetimer.restart();
}
// This updates the burnin synched with the timer.
Connections {
target: updateBurnIn ? mainShader : null
ignoreUnknownSignals: false
onTimeChanged: _blurredSourceEffect.scheduleUpdate();
}
Timer{
id: livetimer
@ -251,14 +262,15 @@ Item{
// We multiply 1.1 to have a little bit of margin over the theoretical value.
// This solution is not extremely clean, but it's probably the best to avoid measuring fps.
interval: (1 / motionBlurCoefficient) * 60 * 1.1
interval: burnInFadeTime * 1000 * 1.1
running: true
onTriggered: _blurredSourceEffect.live = false;
onTriggered: _blurredSourceEffect.updateBurnIn = false;
}
Connections{
target: kterminal
onImagePainted:{
_blurredSourceEffect.live = true;
_blurredSourceEffect.scheduleUpdate();
_blurredSourceEffect.updateBurnIn = true;
livetimer.restart();
}
}
@ -289,7 +301,7 @@ Item{
? kterminal.height * Math.max(1, burnInScaling)
: kterminal.height * scaleTexture * appSettings.burnInQuality
active: mBlur !== 0
active: burnIn !== 0
asynchronous: true
sourceComponent: ShaderEffect {

View File

@ -26,8 +26,6 @@ ShaderEffect {
property ShaderEffectSource blurredSource
property ShaderEffectSource bloomSource
property real liveBlur: blurredSource && blurredSource.live ? 1.0 : 0.0
property color fontColor: appSettings.fontColor
property color backgroundColor: appSettings.backgroundColor
property real bloom: appSettings.bloom * 2.5
@ -162,8 +160,7 @@ ShaderEffect {
uniform highp sampler2D bloomSource;
uniform lowp float bloom;" : "") +
(burnIn !== 0 ? "
uniform sampler2D blurredSource;
uniform lowp float liveBlur;" : "") +
uniform sampler2D blurredSource;" : "") +
(staticNoise !== 0 ? "
uniform highp float staticNoise;" : "") +
(((staticNoise !== 0 || jitter !== 0 || rbgShift)
@ -269,7 +266,7 @@ ShaderEffect {
"vec3 txt_color = texture2D(source, txt_coords).rgb;" +
(burnIn !== 0 ? "
vec4 txt_blur = liveBlur * texture2D(blurredSource, txt_coords);
vec4 txt_blur = texture2D(blurredSource, txt_coords);
txt_color = txt_color + txt_blur.rgb * txt_blur.a;"
: "") +

@ -1 +1 @@
Subproject commit 4b3fd2729bac10a8e292bcf027737509d10e9c74
Subproject commit dbf93d175c66ab9d6cdbf42443569d4a1c83c5b2