1
0
mirror of https://github.com/Swordfish90/cool-retro-term.git synced 2025-04-19 01:00:47 +01:00

Unload burnin effect when not in use.

This commit is contained in:
Filippo Scognamiglio 2018-11-08 18:21:33 +01:00
parent 92e82c203f
commit 2ec21f5eba

View File

@ -2,10 +2,10 @@ import QtQuick 2.0
import "utils.js" as Utils import "utils.js" as Utils
Item { Loader {
id: burnInEffect id: burnInEffect
readonly property alias source: burnInEffectSource property ShaderEffectSource source: item ? item.source : null
property real lastUpdate: 0 property real lastUpdate: 0
property real prevLastUpdate: 0 property real prevLastUpdate: 0
@ -16,10 +16,12 @@ Item {
property real _minBurnInFadeTime: 160 property real _minBurnInFadeTime: 160
property real _maxBurnInFadeTime: 1600 property real _maxBurnInFadeTime: 1600
active: appSettings.burnIn !== 0
function completelyUpdate() { function completelyUpdate() {
prevLastUpdate = lastUpdate; prevLastUpdate = lastUpdate;
lastUpdate = timeManager.time; lastUpdate = timeManager.time;
burnInEffectSource.scheduleUpdate(); item.source.scheduleUpdate();
} }
function restartBlurSource(){ function restartBlurSource(){
@ -28,9 +30,24 @@ Item {
completelyUpdate() completelyUpdate()
} }
sourceComponent: Item {
property alias source: burnInEffectSource
property int burnInScaling: scaleTexture * appSettings.burnInQuality
width: appSettings.lowResolutionFont
? kterminal.width * Math.max(1, burnInScaling)
: kterminal.width * scaleTexture * appSettings.burnInQuality
height: appSettings.lowResolutionFont
? kterminal.height * Math.max(1, burnInScaling)
: kterminal.height * scaleTexture * appSettings.burnInQuality
ShaderEffectSource { ShaderEffectSource {
id: burnInEffectSource id: burnInEffectSource
anchors.fill: parent
sourceItem: burnInShaderEffect sourceItem: burnInShaderEffect
live: false live: false
recursive: true recursive: true
@ -63,21 +80,13 @@ Item {
ShaderEffect { ShaderEffect {
id: burnInShaderEffect id: burnInShaderEffect
property int burnInScaling: scaleTexture * appSettings.burnInQuality
width: appSettings.lowResolutionFont
? kterminal.width * Math.max(1, burnInScaling)
: kterminal.width * scaleTexture * appSettings.burnInQuality
height: appSettings.lowResolutionFont
? kterminal.height * Math.max(1, burnInScaling)
: kterminal.height * scaleTexture * appSettings.burnInQuality
property variant txt_source: kterminalSource property variant txt_source: kterminalSource
property variant burnInSource: burnInEffectSource property variant burnInSource: burnInEffectSource
property real burnInTime: burnInFadeTime property real burnInTime: burnInFadeTime
property alias lastUpdate: burnInEffect.lastUpdate property real lastUpdate: burnInEffect.lastUpdate
property alias prevLastUpdate: burnInEffect.prevLastUpdate property real prevLastUpdate: burnInEffect.prevLastUpdate
anchors.fill: parent
blending: false blending: false
@ -105,7 +114,7 @@ Item {
"void main() { "void main() {
vec2 coords = qt_TexCoord0; vec2 coords = qt_TexCoord0;
vec3 txtColor = texture2D(txt_source, coords).rgb * 0.70; vec3 txtColor = texture2D(txt_source, coords).rgb * 0.5;
vec4 accColor = texture2D(burnInSource, coords); vec4 accColor = texture2D(burnInSource, coords);
float prevMask = accColor.a; float prevMask = accColor.a;
@ -124,3 +133,4 @@ Item {
onStatusChanged: if (log) console.log(log) //Print warning messages onStatusChanged: if (log) console.log(log) //Print warning messages
} }
} }
}