diff --git a/app/qml/ApplicationSettings.qml b/app/qml/ApplicationSettings.qml index 9c97946..350bc41 100644 --- a/app/qml/ApplicationSettings.qml +++ b/app/qml/ApplicationSettings.qml @@ -99,7 +99,7 @@ Item{ // FONTS ////////////////////////////////////////////////////////////////// - signal terminalFontChanged(string fontSource, int pixelSize, int lineSpacing, size virtualCharSize) + signal terminalFontChanged(string fontSource, int pixelSize, int lineSpacing, real screenScaling) Loader{ id: fontManager @@ -117,17 +117,17 @@ Item{ } signal fontScalingChanged - property var fontScalingList: fontManager.item.fontScalingList - property var fontScalingIndexes: [5,1,1] + property var fontScalingList: [0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5] + property int fontScalingIndex: 5 function setScalingIndex(newScaling){ - fontScalingIndexes[rasterization] = newScaling; + fontScalingIndex = newScaling; fontScalingChanged(); handleFontChanged(); } function getScalingIndex(){ - return fontScalingIndexes[rasterization]; + return fontScalingIndex; } property var fontIndexes: [0,0,0] @@ -136,14 +136,14 @@ Item{ function handleFontChanged(){ if(!fontManager.item) return; fontManager.item.selectedFontIndex = fontIndexes[rasterization]; - fontManager.item.selectedScalingIndex = fontScalingIndexes[rasterization]; + fontManager.item.scaling = fontScalingList[fontScalingIndex]; var fontSource = fontManager.item.source; var pixelSize = fontManager.item.pixelSize; var lineSpacing = fontManager.item.lineSpacing; - var virtualCharSize = fontManager.item.virtualCharSize; + var screenScaling = fontManager.item.screenScaling; - terminalFontChanged(fontSource, pixelSize, lineSpacing, virtualCharSize); + terminalFontChanged(fontSource, pixelSize, lineSpacing, screenScaling); } // FRAMES ///////////////////////////////////////////////////////////////// @@ -164,7 +164,7 @@ Item{ fps: fps, window_scaling: window_scaling, show_terminal_size: show_terminal_size, - fontScalingIndexes: fontScalingIndexes, + fontScalingIndex: fontScalingIndex, fontIndexes: fontIndexes, frameReflections: _frameReflections, showMenubar: showMenubar @@ -231,7 +231,7 @@ Item{ window_scaling = settings.window_scaling !== undefined ? settings.window_scaling : window_scaling fontIndexes = settings.fontIndexes !== undefined ? settings.fontIndexes : fontIndexes - fontScalingIndexes = settings.fontScalingIndexes !== undefined ? settings.fontScalingIndexes : fontScalingIndexes + fontScalingIndex = settings.fontScalingIndex !== undefined ? settings.fontScalingIndex : fontScalingIndex _frameReflections = settings.frameReflections !== undefined ? settings.frameReflections : _frameReflections; diff --git a/app/qml/FontPixels.qml b/app/qml/FontPixels.qml index b6debbd..4c0afbd 100644 --- a/app/qml/FontPixels.qml +++ b/app/qml/FontPixels.qml @@ -22,50 +22,50 @@ import QtQuick 2.2 Item{ property int selectedFontIndex - property int selectedScalingIndex + property real scaling property alias fontlist: fontlist property var _font: fontlist.get(selectedFontIndex) - property var _scaling: fontScalingList[selectedScalingIndex] property var source: _font.source - property var fontScalingList: [0.75, 1.0, 1.25, 1.50, 1.75, 2.0, 2.25, 2.5] - property int pixelSize: _font.pixelSize * _scaling - property int lineSpacing: (_font.pixelSize / _font.virtualCharHeight) * _font.lineSpacing - property size virtualCharSize: Qt.size(_font.virtualCharWidth, - _font.virtualCharHeight) + property int pixelSize: _font.pixelSize + property int lineSpacing: _font.lineSpacing + property real screenScaling: scaling * _font.baseScaling ListModel{ id: fontlist + ListElement{ + text: "Commodore PET 2Y (1977)" + source: "fonts/1977-commodore-pet/COMMODORE_PET_2y.ttf" + lineSpacing: 2 + pixelSize: 16 + baseScaling: 3.0 + } ListElement{ text: "Commodore PET (1977)" source: "fonts/1977-commodore-pet/COMMODORE_PET.ttf" lineSpacing: 2 - virtualCharWidth: 8 - virtualCharHeight: 8 - pixelSize: 32 + pixelSize: 8 + baseScaling: 4.0 } ListElement{ text: "Apple ][ (1977)" source: "fonts/1977-apple2/PrintChar21.ttf" lineSpacing: 2 - virtualCharWidth: 7 - virtualCharHeight: 8 - pixelSize: 32 + pixelSize: 8 + baseScaling: 4.0 } ListElement{ text: "Atari 400-800 (1979)" source: "fonts/1979-atari-400-800/ATARI400800_original.TTF" lineSpacing: 3 - virtualCharWidth: 8 - virtualCharHeight: 8 - pixelSize: 32 + pixelSize: 8 + baseScaling: 4.0 } ListElement{ text: "Commodore 64 (1982)" source: "fonts/1982-commodore64/C64_User_Mono_v1.0-STYLE.ttf" lineSpacing: 3 - virtualCharWidth: 8 - virtualCharHeight: 8 - pixelSize: 32 + pixelSize: 8 + baseScaling: 4.0 } } } diff --git a/app/qml/FontScanlines.qml b/app/qml/FontScanlines.qml index 361c1be..4c0afbd 100644 --- a/app/qml/FontScanlines.qml +++ b/app/qml/FontScanlines.qml @@ -22,16 +22,13 @@ import QtQuick 2.2 Item{ property int selectedFontIndex - property int selectedScalingIndex + property real scaling property alias fontlist: fontlist property var _font: fontlist.get(selectedFontIndex) - property var _scaling: fontScalingList[selectedScalingIndex] property var source: _font.source - property var fontScalingList: [0.75, 1.0, 1.25, 1.50, 1.75, 2.0, 2.25, 2.50] - property int pixelSize: _font.pixelSize * _scaling - property int lineSpacing: (_font.pixelSize / _font.virtualCharHeight) * _font.lineSpacing - property size virtualCharSize: Qt.size(_font.virtualCharWidth, - _font.virtualCharHeight) + property int pixelSize: _font.pixelSize + property int lineSpacing: _font.lineSpacing + property real screenScaling: scaling * _font.baseScaling ListModel{ id: fontlist @@ -39,41 +36,36 @@ Item{ text: "Commodore PET 2Y (1977)" source: "fonts/1977-commodore-pet/COMMODORE_PET_2y.ttf" lineSpacing: 2 - virtualCharWidth: 4 - virtualCharHeight: 8 - pixelSize: 32 + pixelSize: 16 + baseScaling: 3.0 } ListElement{ text: "Commodore PET (1977)" source: "fonts/1977-commodore-pet/COMMODORE_PET.ttf" lineSpacing: 2 - virtualCharWidth: 8 - virtualCharHeight: 8 - pixelSize: 32 + pixelSize: 8 + baseScaling: 4.0 } ListElement{ text: "Apple ][ (1977)" source: "fonts/1977-apple2/PrintChar21.ttf" lineSpacing: 2 - virtualCharWidth: 8 - virtualCharHeight: 8 - pixelSize: 32 + pixelSize: 8 + baseScaling: 4.0 } ListElement{ text: "Atari 400-800 (1979)" source: "fonts/1979-atari-400-800/ATARI400800_original.TTF" lineSpacing: 3 - virtualCharWidth: 8 - virtualCharHeight: 8 - pixelSize: 32 + pixelSize: 8 + baseScaling: 4.0 } ListElement{ text: "Commodore 64 (1982)" source: "fonts/1982-commodore64/C64_User_Mono_v1.0-STYLE.ttf" lineSpacing: 3 - virtualCharWidth: 8 - virtualCharHeight: 8 - pixelSize: 32 + pixelSize: 8 + baseScaling: 4.0 } } } diff --git a/app/qml/Fonts.qml b/app/qml/Fonts.qml index 9acd11e..621251a 100644 --- a/app/qml/Fonts.qml +++ b/app/qml/Fonts.qml @@ -22,14 +22,13 @@ import QtQuick 2.2 Item{ property int selectedFontIndex - property int selectedScalingIndex + property real scaling property alias fontlist: fontlist property var source: fontlist.get(selectedFontIndex).source property var _font: fontlist.get(selectedFontIndex) - property var _scaling: fontScalingList[selectedScalingIndex] - property var fontScalingList: [0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5] - property int pixelSize: _font.pixelSize * _scaling + property int pixelSize: _font.pixelSize * scaling property int lineSpacing: pixelSize * _font.lineSpacing + property real screenScaling: 1.0 //In this configuration lineSpacing is proportional to pixelSize. diff --git a/app/qml/PreprocessedTerminal.qml b/app/qml/PreprocessedTerminal.qml index e2754aa..d6bbd0c 100644 --- a/app/qml/PreprocessedTerminal.qml +++ b/app/qml/PreprocessedTerminal.qml @@ -26,7 +26,19 @@ import org.crt.konsole 0.1 Item{ id: terminalContainer - property variant theSource: finalSource + + //Frame displacement properties. This makes the terminal the same size of the texture. + property real dtop: frame.item.displacementTop + property real dleft:frame.item.displacementLeft + property real dright: frame.item.displacementRight + property real dbottom: frame.item.displacementBottom + + anchors.leftMargin: dleft + anchors.rightMargin: dright + anchors.topMargin: dtop + anchors.bottomMargin: dbottom + + property variant theSource: mBlur !== 0 ? blurredSourceLoader.item : kterminalSource property variant bloomSource: bloomSourceLoader.item property variant rasterizationSource: rasterizationEffectSource property variant staticNoiseSource: staticNoiseSource @@ -45,11 +57,6 @@ Item{ property real _minBlurCoefficient: 0.70 property real _maxBlurCoefficient: 0.90 - property size virtualPxSize: Qt.size(1,1) - property size virtual_resolution: Qt.size(width / virtualPxSize.width, height / virtualPxSize.height) - property real deltay: 0.5 / virtual_resolution.height - property real deltax: 0.5 / virtual_resolution.width - property real mBloom: shadersettings.bloom_strength property int mScanlines: shadersettings.rasterization onMScanlinesChanged: restartBlurredSource() @@ -60,9 +67,8 @@ Item{ onMBlurChanged: restartBlurredSource() function restartBlurredSource(){ - if(!blurredSource) return; - blurredSource.live = true; - livetimer.restart() + if(!blurredSourceLoader.item) return; + blurredSourceLoader.item.restartBlurSource(); } function pasteClipboard(){ kterminal.pasteClipboard(); @@ -73,7 +79,8 @@ Item{ KTerminal { id: kterminal - anchors.fill: parent + width: parent.width + height: parent.height colorScheme: "cool-retro-term" @@ -89,30 +96,15 @@ Item{ FontLoader{ id: fontLoader } Text{id: fontMetrics; text: "B"; visible: false} - function getPaintedSize(pixelSize){ - fontMetrics.font.family = fontLoader.name; - fontMetrics.font.pixelSize = pixelSize; - return Qt.size(fontMetrics.paintedWidth, fontMetrics.paintedHeight); - } - function isValid(size){ - return size.width >= 0 && size.height >= 0; - } - function handleFontChange(fontSource, pixelSize, lineSpacing, virtualCharSize){ + function handleFontChange(fontSource, pixelSize, lineSpacing, screenScaling){ fontLoader.source = fontSource; - font.pixelSize = pixelSize * shadersettings.window_scaling; + font.pixelSize = pixelSize; font.family = fontLoader.name; - var paintedSize = getPaintedSize(pixelSize); - var charSize = isValid(virtualCharSize) - ? virtualCharSize - : Qt.size(paintedSize.width / 2, paintedSize.height / 2); + width = Qt.binding(function() {return Math.floor(terminalContainer.width / screenScaling);}); + height = Qt.binding(function() {return Math.floor(terminalContainer.height / screenScaling);}); - var virtualPxSize = Qt.size((paintedSize.width / charSize.width) * shadersettings.window_scaling, - (paintedSize.height / charSize.height) * shadersettings.window_scaling) - - terminalContainer.virtualPxSize = virtualPxSize; - - setLineSpacing(lineSpacing * shadersettings.window_scaling); + setLineSpacing(lineSpacing); restartBlurredSource(); } Component.onCompleted: { @@ -157,116 +149,121 @@ Item{ var coord = correctDistortion(mouse.x, mouse.y); kterminal.mouseReleaseEvent(coord, mouse.button, mouse.modifiers); } - onPositionChanged: { - var coord = correctDistortion(mouse.x, mouse.y); - kterminal.mouseMoveEvent(coord, mouse.button, mouse.buttons, mouse.modifiers); - } - - //Frame displacement properties - property real dtop: frame.item.displacementTop - property real dleft:frame.item.displacementLeft - property real dright: frame.item.displacementRight - property real dbottom: frame.item.displacementBottom + onPositionChanged: { + var coord = correctDistortion(mouse.x, mouse.y); + kterminal.mouseMoveEvent(coord, mouse.button, mouse.buttons, mouse.modifiers); + } function correctDistortion(x, y){ x = x / width; y = y / height; - x = (-dleft + x * (width + dleft + dright)) / width - y = (-dtop + y * (height + dtop + dbottom)) / height - var cc = Qt.size(0.5 - x, 0.5 - y); var distortion = (cc.height * cc.height + cc.width * cc.width) * shadersettings.screen_distortion; - return Qt.point((x - cc.width * (1+distortion) * distortion) * width, - (y - cc.height * (1+distortion) * distortion) * height) + return Qt.point((x - cc.width * (1+distortion) * distortion) * kterminal.width, + (y - cc.height * (1+distortion) * distortion) * kterminal.height) } } ShaderEffectSource{ - id: source + id: kterminalSource sourceItem: kterminal hideSource: true - smooth: false - } - ShaderEffectSource{ - id: blurredSource - sourceItem: blurredterminal - recursive: true + smooth: mScanlines == shadersettings.no_rasterization + wrapMode: ShaderEffectSource.ClampToEdge live: false - hideSource: true + signal sourceUpdate - smooth: false - antialiasing: false - - Timer{ - id: livetimer - running: true - onRunningChanged: running ? - timeManager.onTimeChanged.connect(blurredSource.scheduleUpdate) : - timeManager.onTimeChanged.disconnect(blurredSource.scheduleUpdate) - - Component.onCompleted: kterminal.updatedImage.connect(restart); + Connections{ + target: kterminal + onUpdatedImage:{ + kterminalSource.scheduleUpdate(); + kterminalSource.sourceUpdate(); + } } } - ShaderEffectSource{ - id: finalSource - sourceItem: blurredterminal - sourceRect: frame.sourceRect - hideSource: true + Loader{ + id: blurredSourceLoader + active: mBlur !== 0 + + sourceComponent: ShaderEffectSource{ + id: _blurredSourceEffect + sourceItem: blurredTerminalLoader.item + recursive: true + live: false + hideSource: true + wrapMode: kterminalSource.wrapMode + + smooth: mScanlines == shadersettings.no_rasterization + + function restartBlurSource(){ + livetimer.restart(); + } + + Timer{ + id: livetimer + running: true + onRunningChanged: { + running ? + timeBinding.target = timeManager : + timeBinding.target = null + } + } + Connections{ + id: timeBinding + target: timeManager + onTimeChanged: { + _blurredSourceEffect.scheduleUpdate(); + } + } + Connections{ + target: kterminalSource + onSourceUpdate:{ + livetimer.restart(); + } + } + } } - ShaderEffect { - id: blurredterminal - anchors.fill: parent - property variant source: source - property variant blurredSource: (mBlur !== 0) ? blurredSource : undefined - property real blurCoefficient: (1.0 - motionBlurCoefficient) * fpsAttenuation - property size virtual_resolution: parent.virtual_resolution - property size delta: Qt.size((mScanlines == shadersettings.pixel_rasterization ? deltax : 0), - mScanlines != shadersettings.no_rasterization ? deltay : 0) - blending: false - fragmentShader: - "uniform lowp float qt_Opacity;" + - "uniform lowp sampler2D source;" + - "uniform highp vec2 delta;" + + Loader{ + id: blurredTerminalLoader + anchors.fill: kterminal + active: mBlur !== 0 - "varying highp vec2 qt_TexCoord0; + sourceComponent: ShaderEffect { + property variant txt_source: kterminalSource + property variant blurredSource: blurredSourceLoader.item + property real blurCoefficient: (1.0 - motionBlurCoefficient) * fpsAttenuation - uniform highp vec2 virtual_resolution;" + + blending: false - (mBlur !== 0 ? - "uniform lowp sampler2D blurredSource; - uniform lowp float blurCoefficient;" - : "") + + fragmentShader: + "uniform lowp float qt_Opacity;" + + "uniform lowp sampler2D txt_source;" + - "float rgb2grey(vec3 v){ - return dot(v, vec3(0.21, 0.72, 0.04)); - }" + + "varying highp vec2 qt_TexCoord0; - "void main() {" + - "vec2 coords = qt_TexCoord0;" + - (mScanlines != shadersettings.no_rasterization ? " - coords.y = floor(virtual_resolution.y * coords.y) / virtual_resolution.y;" + - (mScanlines == shadersettings.pixel_rasterization ? " - coords.x = floor(virtual_resolution.x * coords.x) / virtual_resolution.x;" : "") - : "") + - "coords = coords + delta;" + + uniform lowp sampler2D blurredSource; + uniform highp float blurCoefficient;" + - "vec4 color = texture2D(source, coords) * 256.0; - color.a = rgb2grey(color.rgb);" + + "float rgb2grey(vec3 v){ + return dot(v, vec3(0.21, 0.72, 0.04)); + }" + - (mBlur !== 0 ? - "vec4 blur_color = texture2D(blurredSource, coords) * 256.0;" + - "blur_color.a = blur_color.a - blur_color.a * blurCoefficient;" + - "color = step(1.0, color.a) * color + step(color.a, 1.0) * blur_color;" - : "") + + "void main() {" + + "vec2 coords = qt_TexCoord0;" + + "vec3 color = texture2D(txt_source, coords).rgb * 256.0;" + + "vec3 blur_color = texture2D(blurredSource, coords).rgb * 256.0;" + + "blur_color = blur_color - blur_color * blurCoefficient;" + + "color = step(vec3(1.0), color) * color + step(color, vec3(1.0)) * blur_color;" + - "gl_FragColor = floor(color) / 256.0;" + - "}" + "gl_FragColor = vec4(floor(color) / 256.0, 1.0);" + + "}" - onStatusChanged: if (log) console.log(log) //Print warning messages + onStatusChanged: if (log) console.log(log) //Print warning messages + } } /////////////////////////////////////////////////////////////////////////// // EFFECTS ////////////////////////////////////////////////////////////// @@ -291,7 +288,6 @@ Item{ sourceComponent: ShaderEffectSource{ sourceItem: bloomEffectLoader.item hideSource: true - sourceRect: frame.sourceRect smooth: false } } @@ -301,7 +297,8 @@ Item{ ShaderEffect { id: staticNoiseEffect anchors.fill: parent - property size virtual_resolution: terminalContainer.virtual_resolution + property real element_size: shadersettings.rasterization == shadersettings.no_rasterization ? 2 : 1 + property size virtual_resolution: Qt.size(kterminal.width / element_size, kterminal.height / element_size) blending: false @@ -332,9 +329,9 @@ Item{ return mix(s, n, inter.y); }" + - "void main() {" + - "gl_FragColor.a = smoothNoise(qt_TexCoord0 * virtual_resolution);" + - "}" + "void main() {" + + "gl_FragColor.a = smoothNoise(qt_TexCoord0 * virtual_resolution);" + + "}" onStatusChanged: if (log) console.log(log) //Print warning messages } @@ -345,33 +342,37 @@ Item{ wrapMode: ShaderEffectSource.Repeat smooth: true hideSource: true - //format: ShaderEffectSource.Alpha } // RASTERIZATION ////////////////////////////////////////////////////////// - ShaderEffect{ - id: rasterizationContainer - width: frame.sourceRect.width - height: frame.sourceRect.height - property size offset: Qt.size(width - rasterizationEffect.width, height - rasterizationEffect.height) - property size txtRes: Qt.size(width, height) + ShaderEffect { + id: rasterizationEffect + width: parent.width + height: parent.height + property size virtual_resolution: Qt.size(kterminal.width, kterminal.height) blending: false fragmentShader: - "uniform lowp float qt_Opacity; - uniform highp vec2 offset; - uniform highp vec2 txtRes;" + + "uniform lowp float qt_Opacity;" + - "varying highp vec2 qt_TexCoord0;" + + "varying highp vec2 qt_TexCoord0; + uniform highp vec2 virtual_resolution; + + highp float getScanlineIntensity(vec2 coords) { + highp float result = 1.0;" + + + (mScanlines != shadersettings.no_rasterization ? + "result *= abs(sin(coords.y * virtual_resolution.y * "+Math.PI+"));" : "") + + (mScanlines == shadersettings.pixel_rasterization ? + "result *= abs(sin(coords.x * virtual_resolution.x * "+Math.PI+"));" : "") + " + + return result; + }" + "void main() {" + - "float color = 1.0; - color *= smoothstep(0.0, offset.x / txtRes.x, qt_TexCoord0.x); - color *= smoothstep(0.0, offset.y / txtRes.y, qt_TexCoord0.y); - color *= smoothstep(0.0, offset.x / txtRes.x, 1.0 - qt_TexCoord0.x); - color *= smoothstep(0.0, offset.y / txtRes.y, 1.0 - qt_TexCoord0.y);" + + "highp float color = getScanlineIntensity(qt_TexCoord0);" + "float distance = length(vec2(0.5) - qt_TexCoord0);" + "color = mix(color, 0.0, 1.2 * distance * distance);" + @@ -379,48 +380,13 @@ Item{ "gl_FragColor.a = color;" + "}" - ShaderEffect { - id: rasterizationEffect - width: terminalContainer.width - height: terminalContainer.height - anchors.centerIn: parent - property size virtual_resolution: terminalContainer.virtual_resolution - - blending: false - - fragmentShader: - "uniform lowp float qt_Opacity;" + - - "varying highp vec2 qt_TexCoord0; - uniform highp vec2 virtual_resolution; - - float getScanlineIntensity(vec2 coords) { - float result = 1.0;" + - (mScanlines != shadersettings.no_rasterization ? - "result *= abs(sin(coords.y * virtual_resolution.y * "+Math.PI+"));" : "") + - (mScanlines == shadersettings.pixel_rasterization ? - "result *= abs(sin(coords.x * virtual_resolution.x * "+Math.PI+"));" : "") + " - return result; - }" + - - "void main() {" + - "float color = getScanlineIntensity(qt_TexCoord0);" + - - "float distance = length(vec2(0.5) - qt_TexCoord0);" + - "color = mix(color, 0.0, 1.2 * distance * distance);" + - - "gl_FragColor.a = color;" + - "}" - - onStatusChanged: if (log) console.log(log) //Print warning messages - } onStatusChanged: if (log) console.log(log) //Print warning messages } ShaderEffectSource{ id: rasterizationEffectSource - sourceItem: rasterizationContainer + sourceItem: rasterizationEffect hideSource: true smooth: true - //format: ShaderEffectSource.Alpha + wrapMode: ShaderEffectSource.Repeat } } diff --git a/app/qml/ShaderTerminal.qml b/app/qml/ShaderTerminal.qml index 531d91e..dc30bbd 100644 --- a/app/qml/ShaderTerminal.qml +++ b/app/qml/ShaderTerminal.qml @@ -21,6 +21,7 @@ import QtQuick 2.2 import QtGraphicalEffects 1.0 + ShaderEffect { property color font_color: shadersettings.font_color property color background_color: shadersettings.background_color @@ -28,11 +29,8 @@ ShaderEffect { property variant bloomSource: terminal.bloomSource property variant rasterizationSource: terminal.rasterizationSource property variant noiseSource: terminal.staticNoiseSource - property size txt_Size: Qt.size(frame.sourceRect.width, frame.sourceRect.height) property real bloom_strength: shadersettings.bloom_strength * 2.5 - property int rasterization: shadersettings.rasterization - property real jitter: shadersettings.jitter * 0.007 property real noise_strength: shadersettings.noise_strength @@ -40,7 +38,6 @@ ShaderEffect { property real glowing_line_strength: shadersettings.glowing_line_strength property real chroma_color: shadersettings.chroma_color; - property real saturation_color: shadersettings.saturation_color; property real rgb_shift: shadersettings.rgb_shift * 0.2 @@ -49,10 +46,10 @@ ShaderEffect { property bool frameReflections: shadersettings.frameReflections - property real disp_top: frame.item.displacementTop * shadersettings.window_scaling - property real disp_bottom: frame.item.displacementBottom * shadersettings.window_scaling - property real disp_left: frame.item.displacementLeft * shadersettings.window_scaling - property real disp_right: frame.item.displacementRight * shadersettings.window_scaling + property real disp_top: frame.item.displacementTop / height + property real disp_bottom: frame.item.displacementBottom / height + property real disp_left: frame.item.displacementLeft / width + property real disp_right: frame.item.displacementRight / width property real screen_brightness: shadersettings.brightness * 1.5 + 0.5 @@ -88,7 +85,11 @@ ShaderEffect { uniform highp mat4 qt_Matrix; uniform highp float time; uniform sampler2D randomFunctionSource; - uniform highp vec2 txt_Size; + + uniform highp float disp_left; + uniform highp float disp_right; + uniform highp float disp_top; + uniform highp float disp_bottom; attribute highp vec4 qt_Vertex; attribute highp vec2 qt_MultiTexCoord0; @@ -103,8 +104,8 @@ ShaderEffect { uniform lowp float horizontal_sincronization;" : "") + " void main() { - qt_TexCoord0.x = -"+str(disp_left)+"/txt_Size.x + qt_MultiTexCoord0.x / ((txt_Size.x -("+str(disp_left+disp_right)+")) / txt_Size.x);" + " - qt_TexCoord0.y = -"+str(disp_top)+"/txt_Size.y + qt_MultiTexCoord0.y / ((txt_Size.y -("+str(disp_top+disp_bottom)+")) / txt_Size.y);" + " + qt_TexCoord0.x = (qt_MultiTexCoord0.x - disp_left) / (1.0 - disp_left - disp_right); + qt_TexCoord0.y = (qt_MultiTexCoord0.y - disp_top) / (1.0 - disp_top - disp_bottom); vec2 coords = vec2(fract(time/(1024.0*2.0)), fract(time/(1024.0*1024.0)));" + (brightness_flickering !== 0.0 ? " brightness = 1.0 + (texture2D(randomFunctionSource, coords).g - 0.5) * brightness_flickering;" @@ -123,7 +124,6 @@ ShaderEffect { uniform sampler2D source; uniform highp float qt_Opacity; uniform highp float time; - uniform highp vec2 txt_Size; varying highp vec2 qt_TexCoord0; uniform highp vec4 font_color; @@ -136,7 +136,7 @@ ShaderEffect { uniform lowp float bloom_strength;" : "") + (noise_strength !== 0 ? " uniform highp float noise_strength;" : "") + - (noise_strength !== 0 || jitter !== 0 ? " + (noise_strength !== 0 || jitter !== 0 || rgb_shift ? " uniform lowp sampler2D noiseSource;" : "") + (screen_distorsion !== 0 ? " uniform highp float screen_distorsion;" : "") + @@ -175,10 +175,6 @@ ShaderEffect { :" vec2 coords = qt_TexCoord0;") + - (frameReflections ? " - vec2 inside = step(0.0, coords) - step(1.0, coords); - coords = abs(mod(floor(coords), 2.0) - fract(coords)) * clamp(inside.x + inside.y, 0.0, 1.0);" : "") + - (horizontal_sincronization !== 0 ? " float h_distortion = 0.5 * sin(time*0.001 + coords.y*10.0*fract(time/10.0)); h_distortion += 0.5 * cos(time*0.04 + 0.03 + coords.y*50.0*fract(time/10.0 + 0.4)); @@ -202,36 +198,38 @@ ShaderEffect { (glowing_line_strength !== 0 ? " color += randomPass(coords) * glowing_line_strength;" : "") + + + "vec3 txt_color = texture2D(source, txt_coords).rgb; + float greyscale_color = rgb2grey(txt_color) + color;" + + (chroma_color !== 0 ? (rgb_shift !== 0 ? " float rgb_noise = abs(texture2D(noiseSource, vec2(fract(time/(1024.0 * 256.0)), fract(time/(1024.0*1024.0)))).a - 0.5); - vec4 realBackColor = texture2D(source, txt_coords); - vec2 rcolor = texture2D(source, txt_coords + vec2(0.1, 0.0) * rgb_shift * rgb_noise).ra; - vec2 bcolor = texture2D(source, txt_coords - vec2(0.1, 0.0) * rgb_shift * rgb_noise).ba; - realBackColor.r = rcolor.x; - realBackColor.b = bcolor.x; - realBackColor.a = 0.33 * (realBackColor.a + rcolor.y + bcolor.y);" - : - "vec4 realBackColor = texture2D(source, txt_coords);") + + float rcolor = texture2D(source, txt_coords + vec2(0.1, 0.0) * rgb_shift * rgb_noise).r; + float bcolor = texture2D(source, txt_coords - vec2(0.1, 0.0) * rgb_shift * rgb_noise).b; + txt_color.r = rcolor; + txt_color.b = bcolor; + greyscale_color = 0.33 * (rcolor + bcolor);" : "") + - "vec4 mixedColor = mix(font_color, realBackColor * font_color, chroma_color);" + - - "vec4 finalBackColor = mix(background_color, mixedColor, realBackColor.a);" + - "vec3 finalColor = mix(finalBackColor, font_color, color).rgb;" + "vec3 mixedColor = mix(font_color.rgb, txt_color * font_color.rgb, chroma_color); + vec3 finalBackColor = mix(background_color.rgb, mixedColor, greyscale_color); + vec3 finalColor = mix(finalBackColor, font_color.rgb, color).rgb;" : - "color += texture2D(source, txt_coords).a;" + - "vec3 finalColor = mix(background_color, font_color, color).rgb;" - ) + + "vec3 finalColor = mix(background_color.rgb, font_color.rgb, greyscale_color);") + "finalColor *= texture2D(rasterizationSource, coords).a;" + (bloom_strength !== 0 ? - "vec3 bloomColor = texture2D(bloomSource, coords).rgb;" + + "vec4 bloomFullColor = texture2D(bloomSource, coords); + vec3 bloomColor = bloomFullColor.rgb; + vec2 minBound = step(vec2(0.0), coords); + vec2 maxBound = step(coords, vec2(1.0)); + float bloomAlpha = bloomFullColor.a * minBound.x * minBound.y * maxBound.x * maxBound.y;" + (chroma_color !== 0 ? "bloomColor = font_color.rgb * mix(vec3(rgb2grey(bloomColor)), bloomColor, chroma_color);" : "bloomColor = font_color.rgb * rgb2grey(bloomColor);") + - "finalColor += bloomColor * bloom_strength;" + "finalColor += bloomColor * bloom_strength * bloomAlpha;" : "") + (brightness_flickering !== 0 ? " diff --git a/app/qml/frames/BlackRoughFrame.qml b/app/qml/frames/BlackRoughFrame.qml index 7bc688a..8661cd7 100644 --- a/app/qml/frames/BlackRoughFrame.qml +++ b/app/qml/frames/BlackRoughFrame.qml @@ -7,22 +7,19 @@ TerminalFrame{ anchors.fill: parent addedWidth: 200 addedHeight: 370 - borderLeft: 148 - borderRight: 148 - borderTop: 232 - borderBottom: 232 + borderLeft: 170 + borderRight: 170 + borderTop: 250 + borderBottom: 250 imageSource: "../images/black-frame.png" normalsSource: "../images/black-frame-normals.png" - rectX: 20 - rectY: 20 - distortionCoefficient: 1.9 - displacementLeft: 70.0 - displacementTop: 55.0 - displacementRight: 50.0 - displacementBottom: 38.0 + displacementLeft: 80.0 + displacementTop: 65.0 + displacementRight: 80.0 + displacementBottom: 65.0 shaderString: "FrameShader.qml" } diff --git a/app/qml/frames/NoFrame.qml b/app/qml/frames/NoFrame.qml index 806e437..e594158 100644 --- a/app/qml/frames/NoFrame.qml +++ b/app/qml/frames/NoFrame.qml @@ -12,9 +12,6 @@ TerminalFrame{ borderTop: 0 borderBottom: 0 - rectX: 15 - rectY: 15 - displacementLeft: 0 displacementTop: 0 displacementRight: 0 diff --git a/app/qml/frames/WhiteSimpleFrame.qml b/app/qml/frames/WhiteSimpleFrame.qml index 207e869..0231c40 100644 --- a/app/qml/frames/WhiteSimpleFrame.qml +++ b/app/qml/frames/WhiteSimpleFrame.qml @@ -14,15 +14,12 @@ TerminalFrame{ imageSource: "../images/screen-frame.png" normalsSource: "../images/screen-frame-normals.png" - rectX: 15 - rectY: 15 - distortionCoefficient: 1.5 - displacementLeft: 45 - displacementTop: 40 - displacementRight: 38.0 - displacementBottom: 28.0 + displacementLeft: 55 + displacementTop: 50 + displacementRight: 55 + displacementBottom: 50 shaderString: "FrameShader.qml" } diff --git a/app/qml/frames/utils/TerminalFrame.qml b/app/qml/frames/utils/TerminalFrame.qml index 3c0b9b1..0232702 100644 --- a/app/qml/frames/utils/TerminalFrame.qml +++ b/app/qml/frames/utils/TerminalFrame.qml @@ -15,10 +15,6 @@ Item{ property string normalsSource property string shaderString - //Value used to create the rect used to add the border to the texture - property real rectX - property real rectY - //Values used to displace the texture in the screen. Used to make reflections correct. property real displacementLeft property real displacementTop @@ -27,11 +23,6 @@ Item{ property real distortionCoefficient - property rect sourceRect: Qt.rect(-rectX * shadersettings.window_scaling, - -rectY * shadersettings.window_scaling, - terminal.width + 2*rectX * shadersettings.window_scaling, - terminal.height + 2*rectY * shadersettings.window_scaling) - BorderImage{ id: frameimage anchors.centerIn: parent diff --git a/app/qml/main.qml b/app/qml/main.qml index 9de405d..4071404 100644 --- a/app/qml/main.qml +++ b/app/qml/main.qml @@ -83,7 +83,7 @@ ApplicationWindow{ text: qsTr("Zoom In") shortcut: "Ctrl++" onTriggered: { - var oldScaling = shadersettings.fontScalingIndexes[shadersettings.rasterization]; + var oldScaling = shadersettings.fontScalingIndex; var maxScalingIndex = shadersettings.fontScalingList.length - 1; shadersettings.setScalingIndex(Math.min(oldScaling + 1, maxScalingIndex)); } @@ -93,7 +93,7 @@ ApplicationWindow{ text: qsTr("Zoom Out") shortcut: "Ctrl+-" onTriggered: { - var oldScaling = shadersettings.fontScalingIndexes[shadersettings.rasterization]; + var oldScaling = shadersettings.fontScalingIndex; shadersettings.setScalingIndex(Math.max(oldScaling - 1, 0)); } } @@ -148,23 +148,17 @@ ApplicationWindow{ width: parent.width * shadersettings.window_scaling height: parent.height * shadersettings.window_scaling scale: 1.0 / shadersettings.window_scaling - smooth: false - antialiasing: false opacity: shadersettings.windowOpacity * 0.3 + 0.7 Loader{ id: frame anchors.fill: parent - - property rect sourceRect: item.sourceRect - z: 2.1 source: shadersettings.frame_source } PreprocessedTerminal{ id: terminal anchors.fill: parent - anchors.margins: 30 } ShaderTerminal{ id: shadercontainer diff --git a/konsole-qml-plugin/src/TerminalDisplay.cpp b/konsole-qml-plugin/src/TerminalDisplay.cpp index ffa3d58..484207f 100644 --- a/konsole-qml-plugin/src/TerminalDisplay.cpp +++ b/konsole-qml-plugin/src/TerminalDisplay.cpp @@ -1996,7 +1996,7 @@ void KTerminalDisplay::calcGeometry() _contentHeight = height() - 2 * DEFAULT_TOP_MARGIN + /* mysterious */ 1; // ensure that display is always at least one column wide - _columns = qMax(1, qRound(_contentWidth / _fontWidth)); + _columns = qMax(1, qFloor(_contentWidth / _fontWidth)); _usedColumns = qMin(_usedColumns,_columns); // ensure that display is always at least one line high @@ -2265,7 +2265,7 @@ void KTerminalDisplay::drawCursor(QPainter* painter, bool& invertCharacterColor) { QRectF cursorRect = rect; - cursorRect.setHeight(_fontHeight - _lineSpacing - 1); + cursorRect.setHeight(_fontHeight - _lineSpacing); if (!_cursorBlinking) { @@ -2280,8 +2280,8 @@ void KTerminalDisplay::drawCursor(QPainter* painter, // it is draw entirely inside 'rect' int penWidth = qMax(1,painter->pen().width()); - painter->drawRect(cursorRect.adjusted( penWidth/2, - penWidth/2, + painter->drawRect(cursorRect.adjusted( penWidth/2 + penWidth%2, + penWidth/2 + penWidth%2, - penWidth/2 - penWidth%2, - penWidth/2 - penWidth%2)); if ( hasFocus() )