diff --git a/kwin/build.sh b/kwin/build.sh index 190c0dd..95550c2 100755 --- a/kwin/build.sh +++ b/kwin/build.sh @@ -48,6 +48,16 @@ generate() { echo "" cat "../resources/shaders/common.glsl" cat "../resources/shaders/$1.frag" + } > "${BUILD_DIR}/kwin4_effect_$1/contents/shaders/$1_core.frag" + + { + echo "#version 100" + echo "#define KWIN_LEGACY" + echo "" + echo "// This file is automatically generated during the build process." + echo "" + cat "../resources/shaders/common.glsl" + cat "../resources/shaders/$1.frag" } > "${BUILD_DIR}/kwin4_effect_$1/contents/shaders/$1.frag" } diff --git a/kwin/main.js.in b/kwin/main.js.in index a0d96c6..426def2 100755 --- a/kwin/main.js.in +++ b/kwin/main.js.in @@ -1,8 +1,7 @@ /* - KWin - the KDE window manager - This file is part of the KDE project. + This file is part of the Burn-My-Windows project. - SPDX-FileCopyrightText: 2018, 2021, 2022 Vlad Zahorodnii , Martin Flöser , Simon Schneegans + SPDX-FileCopyrightText: 2018, 2021, 2022 Vlad Zahorodnii , Martin Flöser , Simon Schneegans SPDX-License-Identifier: GPL-3.0-or-later */ @@ -26,7 +25,7 @@ class Effect { effects.windowClosed.connect(this.slotWindowClosed.bind(this)); effects.windowDataChanged.connect(this.slotWindowDataChanged.bind(this)); - this.shader = effect.addShader(Effect.MapTexture, "%NICK%.frag"); + this.shader = effect.addFragmentShader(Effect.MapTexture, "%NICK%.frag"); this.loadConfig(); } @@ -109,7 +108,7 @@ class Effect { animations: [ { type: Effect.ShaderUniform, - shader: this.shader, + fragmentShader: this.shader, uniform: "uForOpening", from: 1.0, to: 1.0 @@ -143,7 +142,7 @@ class Effect { animations: [ { type: Effect.ShaderUniform, - shader: this.shader, + fragmentShader: this.shader, uniform: "uForOpening", from: 0.0, to: 0.0 diff --git a/kwin/metadata.desktop.in b/kwin/metadata.desktop.in index c975bed..25dc34c 100755 --- a/kwin/metadata.desktop.in +++ b/kwin/metadata.desktop.in @@ -6,7 +6,7 @@ Comment=%DESCRIPTION% Type=Service X-KDE-ServiceTypes=KWin/Effect,KCModule X-KDE-PluginInfo-Author=Vlad Zahorodnii, Martin Flöser, Simon Schneegans -X-KDE-PluginInfo-Email=vlad.zahorodnii@kde.org, mgraesslin@kde.org +X-KDE-PluginInfo-Email=vlad.zahorodnii@kde.org, mgraesslin@kde.org, code@simonschneegans.de X-KDE-PluginInfo-Name=kwin4_effect_%NICK% X-KDE-PluginInfo-Version=1 X-KDE-PluginInfo-Category=Window Open/Close Animation diff --git a/resources/shaders/common.glsl b/resources/shaders/common.glsl index 46e6d5c..6a2dc8f 100644 --- a/resources/shaders/common.glsl +++ b/resources/shaders/common.glsl @@ -17,31 +17,60 @@ // --------------------------------------------------------------------- standard uniforms -// uForOpening: True if a window-open animation is ongoing, false otherwise. -// uTexture: Contains the texture of the window. -// uProgress: A value which transitions from 0 to 1 during the entire animation. -// uTime: A steadily increasing value in seconds. -// uSize: The size of uTexture in pixels. -// uPadding: The empty area around the actual window (e.g. where the shadow is drawn). +// Each shader can access these standard uniforms: -#ifdef KWIN +// bool uForOpening: True if a window-open animation is ongoing, false otherwise. +// sampler2D uTexture: Contains the texture of the window. +// float uProgress: A value which transitions from 0 to 1 during the animation. +// float uTime: A steadily increasing value in seconds. +// vec2 uSize: The size of uTexture in pixels. +// float uPadding: The empty area around the actual window (e.g. where the shadow +// is drawn). For now, this will only be set on GNOME. -uniform bool uForOpening; -uniform sampler2D uTexture; +// Furthermore, there is the global input "vec2 iTexCoord" and the output "vec4 oColor". + +#ifdef KWIN // -------------------------------------------------------------------------- + +uniform float forOpening; +uniform sampler2D sampler; +uniform float textureWidth; +uniform float textureHeight; uniform float animationProgress; -// uniform float uTime; -// uniform vec2 uSize; -// uniform float uPadding; + +vec2 uSize = vec2(textureWidth, textureHeight); +bool uForOpening = forOpening == 1.0; in vec2 texcoord0; out vec4 fragColor; +#define uTexture sampler; #define uProgress animationProgress +#define uPadding 0.0 #define iTexCoord texcoord0 #define oColor fragColor -#else +#elif KWIN_LEGACY // -------------------------------------------------------------------- +uniform float forOpening; +uniform sampler2D sampler; +uniform float textureWidth; +uniform float textureHeight; +uniform float animationProgress; + +vec2 uSize = vec2(textureWidth, textureHeight); +bool uForOpening = forOpening == 1.0; + +varying vec2 texcoord0; + +#define uTexture sampler; +#define uProgress animationProgress +#define uPadding 0.0 +#define iTexCoord texcoord0 +#define oColor gl_fragColor + +#else // GNOME -------------------------------------------------------------------------- + +// On GNOME, the uniforms are just normal uniforms. uniform bool uForOpening; uniform sampler2D uTexture; uniform float uProgress; @@ -49,10 +78,11 @@ uniform float uTime; uniform vec2 uSize; uniform float uPadding; +// On GNOME, we set iTexCoord and oColor to be aliases for the cogl variables. #define iTexCoord cogl_tex_coord_in[0] #define oColor cogl_color_out -#endif +#endif // ------------------------------------------------------------------------------- // ----------------------------------------------------------------- compositing operators