2021-06-30 22:49:03 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (c) 2013-2021 "Filippo Scognamiglio"
|
|
|
|
* https://github.com/Swordfish90/cool-retro-term
|
|
|
|
*
|
|
|
|
* This file is part of cool-retro-term.
|
|
|
|
*
|
|
|
|
* cool-retro-term is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*******************************************************************************/
|
2018-11-07 22:36:51 +01:00
|
|
|
import QtQuick 2.0
|
|
|
|
|
|
|
|
import "utils.js" as Utils
|
|
|
|
|
2018-11-08 18:21:33 +01:00
|
|
|
Loader {
|
2018-11-07 22:36:51 +01:00
|
|
|
id: burnInEffect
|
|
|
|
|
2018-11-08 18:21:33 +01:00
|
|
|
property ShaderEffectSource source: item ? item.source : null
|
2018-11-07 22:36:51 +01:00
|
|
|
|
|
|
|
property real lastUpdate: 0
|
|
|
|
property real prevLastUpdate: 0
|
|
|
|
|
|
|
|
property real delay: (1.0 / appSettings.fps) * 1000
|
|
|
|
property real burnIn: appSettings.burnIn
|
|
|
|
property real burnInFadeTime: 1 / Utils.lint(_minBurnInFadeTime, _maxBurnInFadeTime, burnIn)
|
2019-01-09 19:01:11 +01:00
|
|
|
property real _minBurnInFadeTime: appSettings.minBurnInFadeTime
|
|
|
|
property real _maxBurnInFadeTime: appSettings.maxBurnInFadeTime
|
2018-11-07 22:36:51 +01:00
|
|
|
|
2019-01-09 19:01:11 +01:00
|
|
|
active: appSettings.useFastBurnIn && appSettings.burnIn !== 0
|
|
|
|
|
|
|
|
anchors.fill: parent
|
2018-11-08 18:21:33 +01:00
|
|
|
|
2018-11-07 22:36:51 +01:00
|
|
|
function completelyUpdate() {
|
|
|
|
prevLastUpdate = lastUpdate;
|
|
|
|
lastUpdate = timeManager.time;
|
2018-11-08 18:21:33 +01:00
|
|
|
item.source.scheduleUpdate();
|
2018-11-07 22:36:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function restartBlurSource(){
|
2018-11-21 18:18:18 +01:00
|
|
|
prevLastUpdate = timeManager.time;
|
|
|
|
lastUpdate = prevLastUpdate;
|
|
|
|
completelyUpdate();
|
2018-11-07 22:36:51 +01:00
|
|
|
}
|
|
|
|
|
2018-11-08 18:21:33 +01:00
|
|
|
sourceComponent: Item {
|
|
|
|
property alias source: burnInEffectSource
|
2018-11-07 22:36:51 +01:00
|
|
|
|
2018-11-08 18:21:33 +01:00
|
|
|
ShaderEffectSource {
|
|
|
|
id: burnInEffectSource
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
sourceItem: burnInShaderEffect
|
|
|
|
live: false
|
|
|
|
recursive: true
|
|
|
|
hideSource: true
|
2018-12-16 22:30:03 +01:00
|
|
|
wrapMode: ShaderEffectSource.ClampToEdge
|
2018-11-07 22:36:51 +01:00
|
|
|
|
2018-11-08 18:21:33 +01:00
|
|
|
format: ShaderEffectSource.RGBA
|
2018-12-17 19:06:49 +01:00
|
|
|
smooth: true
|
2018-11-21 18:18:18 +01:00
|
|
|
|
2018-11-08 18:21:33 +01:00
|
|
|
visible: false
|
2018-11-07 22:36:51 +01:00
|
|
|
|
2018-11-08 18:21:33 +01:00
|
|
|
Connections {
|
|
|
|
target: kterminal
|
2022-01-03 18:43:07 +01:00
|
|
|
|
|
|
|
function onImagePainted() {
|
|
|
|
completelyUpdate()
|
|
|
|
}
|
2018-11-08 18:21:33 +01:00
|
|
|
}
|
|
|
|
// Restart blurred source settings change.
|
|
|
|
Connections{
|
|
|
|
target: appSettings
|
2022-01-03 18:43:07 +01:00
|
|
|
|
|
|
|
function onBurnInChanged() {
|
|
|
|
burnInEffect.restartBlurSource()
|
|
|
|
}
|
|
|
|
|
|
|
|
function onTerminalFontChanged() {
|
|
|
|
burnInEffect.restartBlurSource()
|
|
|
|
}
|
|
|
|
|
|
|
|
function onRasterizationChanged() {
|
|
|
|
burnInEffect.restartBlurSource()
|
|
|
|
}
|
|
|
|
|
|
|
|
function onBurnInQualityChanged() {
|
|
|
|
burnInEffect.restartBlurSource()
|
|
|
|
}
|
2018-11-08 18:21:33 +01:00
|
|
|
}
|
2018-11-07 22:36:51 +01:00
|
|
|
|
2018-11-08 18:21:33 +01:00
|
|
|
Connections {
|
|
|
|
target: kterminalScrollbar
|
2022-01-03 18:43:07 +01:00
|
|
|
|
|
|
|
function onOpacityChanged() {
|
|
|
|
completelyUpdate()
|
|
|
|
}
|
2018-11-08 18:21:33 +01:00
|
|
|
}
|
|
|
|
}
|
2018-11-07 22:36:51 +01:00
|
|
|
|
2021-07-03 16:14:02 +02:00
|
|
|
ShaderLibrary {
|
|
|
|
id: shaderLibrary
|
|
|
|
}
|
|
|
|
|
2018-11-08 18:21:33 +01:00
|
|
|
ShaderEffect {
|
|
|
|
id: burnInShaderEffect
|
2018-11-07 22:36:51 +01:00
|
|
|
|
2018-11-08 18:21:33 +01:00
|
|
|
property variant txt_source: kterminalSource
|
|
|
|
property variant burnInSource: burnInEffectSource
|
|
|
|
property real burnInTime: burnInFadeTime
|
|
|
|
property real lastUpdate: burnInEffect.lastUpdate
|
|
|
|
property real prevLastUpdate: burnInEffect.prevLastUpdate
|
2018-11-07 22:36:51 +01:00
|
|
|
|
2018-11-08 18:21:33 +01:00
|
|
|
anchors.fill: parent
|
|
|
|
blending: false
|
2018-11-07 22:36:51 +01:00
|
|
|
|
2018-11-08 18:21:33 +01:00
|
|
|
fragmentShader:
|
|
|
|
"#ifdef GL_ES
|
|
|
|
precision mediump float;
|
|
|
|
#endif\n" +
|
2018-11-07 22:36:51 +01:00
|
|
|
|
2018-11-08 18:21:33 +01:00
|
|
|
"uniform lowp float qt_Opacity;" +
|
|
|
|
"uniform lowp sampler2D txt_source;" +
|
2018-11-07 22:36:51 +01:00
|
|
|
|
2018-11-08 18:21:33 +01:00
|
|
|
"varying highp vec2 qt_TexCoord0;
|
2018-11-07 22:36:51 +01:00
|
|
|
|
2018-11-08 18:21:33 +01:00
|
|
|
uniform lowp sampler2D burnInSource;
|
|
|
|
uniform highp float burnInTime;
|
2018-11-07 22:36:51 +01:00
|
|
|
|
2018-11-08 18:21:33 +01:00
|
|
|
uniform highp float lastUpdate;
|
2018-11-07 22:36:51 +01:00
|
|
|
|
2018-11-08 18:21:33 +01:00
|
|
|
uniform highp float prevLastUpdate;" +
|
|
|
|
|
2021-07-03 16:14:02 +02:00
|
|
|
shaderLibrary.rgb2grey +
|
2018-11-08 18:21:33 +01:00
|
|
|
|
|
|
|
"void main() {
|
|
|
|
vec2 coords = qt_TexCoord0;
|
2018-11-07 22:36:51 +01:00
|
|
|
|
2018-11-08 18:26:27 +01:00
|
|
|
vec3 txtColor = texture2D(txt_source, coords).rgb;
|
2018-11-08 18:21:33 +01:00
|
|
|
vec4 accColor = texture2D(burnInSource, coords);
|
|
|
|
|
|
|
|
float prevMask = accColor.a;
|
2018-12-18 23:03:52 +01:00
|
|
|
float currMask = rgb2grey(txtColor);
|
2018-11-08 18:21:33 +01:00
|
|
|
|
2018-11-09 21:06:13 +01:00
|
|
|
highp float blurDecay = clamp((lastUpdate - prevLastUpdate) * burnInTime, 0.0, 1.0);
|
|
|
|
blurDecay = max(0.0, blurDecay - prevMask);
|
2018-11-08 18:21:33 +01:00
|
|
|
vec3 blurColor = accColor.rgb - vec3(blurDecay);
|
2018-11-09 21:06:13 +01:00
|
|
|
vec3 color = max(blurColor, txtColor);
|
2018-11-08 18:21:33 +01:00
|
|
|
|
|
|
|
gl_FragColor = vec4(color, currMask);
|
|
|
|
}
|
|
|
|
"
|
|
|
|
|
|
|
|
onStatusChanged: if (log) console.log(log) //Print warning messages
|
|
|
|
}
|
2018-11-07 22:36:51 +01:00
|
|
|
}
|
|
|
|
}
|