🔧 Tweak kwin build process

This commit is contained in:
Simon Schneegans
2022-06-10 13:57:21 +02:00
parent 192719739c
commit d08c318b7d
9 changed files with 77 additions and 60 deletions
+30 -8
View File
@@ -41,15 +41,34 @@ generate() {
mkdir -p "$BUILD_DIR/$DIR_NAME/contents/config" mkdir -p "$BUILD_DIR/$DIR_NAME/contents/config"
mkdir -p "$BUILD_DIR/$DIR_NAME/contents/ui" mkdir -p "$BUILD_DIR/$DIR_NAME/contents/ui"
# Copy the config and ui files. # Copy the config file if it exists.
cp "$DIR_NAME/main.xml" "$BUILD_DIR/$DIR_NAME/contents/config" if [ -f "$DIR_NAME/main.xml" ]; then
cp "$DIR_NAME/config.ui" "$BUILD_DIR/$DIR_NAME/contents/ui" cp "$DIR_NAME/main.xml" "$BUILD_DIR/$DIR_NAME/contents/config"
fi
perl -pe "s/%LOAD_CONFIG%/$(tr '/' '\f' < "$DIR_NAME/loadConfig.js")/g;" \ # Copy the ui file if it exists.
main.js.in | tr '\f' '/' > "$BUILD_DIR/$DIR_NAME/contents/code/main.js" if [ -f "$DIR_NAME/config.ui" ]; then
cp "$DIR_NAME/config.ui" "$BUILD_DIR/$DIR_NAME/contents/ui"
fi
perl -pi -e "s/%EFFECT_CLASS%/$EFFECT_CLASS/g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
perl -pi -e "s/%SHADER_NAME%/$1/g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js" ON_SETTINGS_CHANGE=""
ON_ANIMATION_BEGIN=""
if [ -f "$DIR_NAME/onSettingsChanged.js" ]; then
ON_SETTINGS_CHANGE=$(tr '/' '\f' < "$DIR_NAME/onSettingsChanged.js")
fi
if [ -f "$DIR_NAME/onAnimationBegin.js" ]; then
ON_ANIMATION_BEGIN=$(tr '/' '\f' < "$DIR_NAME/onAnimationBegin.js")
fi
cp main.js.in "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
perl -pi -e "s/%ON_SETTINGS_CHANGE%/$ON_SETTINGS_CHANGE/g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
perl -pi -e "s/%ON_ANIMATION_BEGIN%/$ON_ANIMATION_BEGIN/g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
perl -pi -e "s/%EFFECT_CLASS%/$EFFECT_CLASS/g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
perl -pi -e "s/%SHADER_NAME%/$1/g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
perl -pi -e "s/\f/\//g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
cp metadata.desktop.in "$BUILD_DIR/$DIR_NAME/metadata.desktop" cp metadata.desktop.in "$BUILD_DIR/$DIR_NAME/metadata.desktop"
perl -pi -e "s/%ICON%/$1/g;" "$BUILD_DIR/$DIR_NAME/metadata.desktop" perl -pi -e "s/%ICON%/$1/g;" "$BUILD_DIR/$DIR_NAME/metadata.desktop"
@@ -75,9 +94,12 @@ generate() {
cat "../resources/shaders/common.glsl" cat "../resources/shaders/common.glsl"
cat "../resources/shaders/$1.frag" cat "../resources/shaders/$1.frag"
} > "$BUILD_DIR/$DIR_NAME/contents/shaders/$1.frag" } > "$BUILD_DIR/$DIR_NAME/contents/shaders/$1.frag"
# If clang-format is installed, try to beauty the code a bit.
} }
generate "tv" "TV Effect" "Make windows close like turning off a TV"
generate "energize-a" "Energize A" "Beam your windows away" generate "energize-a" "Energize A" "Beam your windows away"
generate "energize-b" "Energize B" "Using different transporter technology results in an alternative visual effect" generate "energize-b" "Energize B" "Using different transporter technology results in an alternative visual effect"
generate "hexagon" "Hexagon" "With glowing lines and hexagon-shaped tiles, this effect looks very sci-fi"
generate "tv" "TV Effect" "Make windows close like turning off a TV"
# generate "fire" "Fire" "Make windows burn" # generate "fire" "Fire" "Make windows burn"
@@ -1,5 +0,0 @@
loadConfig() {
this.duration = animationTime(effect.readConfig('Duration', 1000));
effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
}
@@ -0,0 +1,6 @@
// This part is automatically included in the effect's source during the build process.
// The code below is called whenever the user changes something in the configuration of
// the effect.
effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
@@ -1,5 +0,0 @@
loadConfig() {
this.duration = animationTime(effect.readConfig('Duration', 1000));
effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
}
@@ -0,0 +1,6 @@
// This part is automatically included in the effect's source during the build process.
// The code below is called whenever the user changes something in the configuration of
// the effect.
effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
-4
View File
@@ -1,4 +0,0 @@
loadConfig() {
this.duration = animationTime(effect.readConfig('Duration', 1000));
effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
}
@@ -0,0 +1,5 @@
// This part is automatically included in the effect's source during the build process.
// The code below is called whenever the user changes something in the configuration of
// the effect.
effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
+20 -19
View File
@@ -30,7 +30,12 @@ class %EFFECT_CLASS% {
this.loadConfig(); this.loadConfig();
} }
%LOAD_CONFIG% loadConfig() {
this.duration = animationTime(effect.readConfig('Duration', 1000));
effect.setUniform(this.shader, 'uDuration', this.duration * 0.001);
%ON_SETTINGS_CHANGE%
}
static isScaleWindow(window) { static isScaleWindow(window) {
// We don't want to animate most of plasmashell's windows, yet, some // We don't want to animate most of plasmashell's windows, yet, some
@@ -95,6 +100,11 @@ class %EFFECT_CLASS% {
return; return;
} }
this.setupForcedRoles(window); this.setupForcedRoles(window);
effect.setUniform(this.shader, 'uForOpening', 1.0);
%ON_ANIMATION_BEGIN%
window.scaleInAnimation = animate({ window.scaleInAnimation = animate({
window: window, window: window,
curve: QEasingCurve.Linear, curve: QEasingCurve.Linear,
@@ -103,16 +113,9 @@ class %EFFECT_CLASS% {
{ {
type: Effect.ShaderUniform, type: Effect.ShaderUniform,
fragmentShader: this.shader, fragmentShader: this.shader,
uniform: "forOpening", uniform: "uProgress",
from: 1.0, from: 0.0,
to: 1.0 to: 1.0
},
{
type: Effect.ShaderUniform,
fragmentShader: this.shader,
uniform: "uDuration",
from: this.duration * 0.001,
to: this.duration * 0.001
} }
] ]
}); });
@@ -136,6 +139,11 @@ class %EFFECT_CLASS% {
delete window.scaleInAnimation; delete window.scaleInAnimation;
} }
this.setupForcedRoles(window); this.setupForcedRoles(window);
effect.setUniform(this.shader, 'uForOpening', 0.0);
%ON_ANIMATION_BEGIN%
window.scaleOutAnimation = animate({ window.scaleOutAnimation = animate({
window: window, window: window,
curve: QEasingCurve.Linear, curve: QEasingCurve.Linear,
@@ -144,16 +152,9 @@ class %EFFECT_CLASS% {
{ {
type: Effect.ShaderUniform, type: Effect.ShaderUniform,
fragmentShader: this.shader, fragmentShader: this.shader,
uniform: "forOpening", uniform: "uProgress",
from: 0.0, from: 0.0,
to: 0.0 to: 1.0
},
{
type: Effect.ShaderUniform,
fragmentShader: this.shader,
uniform: "uDuration",
from: this.duration * 0.001,
to: this.duration * 0.001
} }
] ]
}); });
+10 -19
View File
@@ -33,23 +33,22 @@
// vec4 getInputColor(vec2 coords) // vec4 getInputColor(vec2 coords)
// void setOutputColor(vec4 outColor) // void setOutputColor(vec4 outColor)
uniform bool uForOpening;
uniform float uProgress;
uniform float uDuration;
#if defined(KWIN) // -------------------------------------------------------------------- #if defined(KWIN) // --------------------------------------------------------------------
uniform float forOpening;
uniform sampler2D sampler; uniform sampler2D sampler;
uniform float uDuration;
uniform int textureWidth; uniform int textureWidth;
uniform int textureHeight; uniform int textureHeight;
uniform float animationProgress;
in vec2 texcoord0; in vec2 texcoord0;
out vec4 fragColor; out vec4 fragColor;
vec2 uSize = vec2(textureWidth, textureHeight); vec2 uSize = vec2(textureWidth, textureHeight);
bool uForOpening = forOpening == 1.0; vec2 iTexCoord = vec2(texcoord0.x, 1.0 - texcoord0.y);
vec2 iTexCoord = vec2(texcoord0.x, 1.0 - texcoord0.y); float uPadding = 0.0;
float uProgress = animationProgress;
float uPadding = 0.0;
vec4 getInputColor(vec2 coords) { vec4 getInputColor(vec2 coords) {
vec4 color = texture2D(sampler, vec2(coords.x, 1.0 - coords.y)); vec4 color = texture2D(sampler, vec2(coords.x, 1.0 - coords.y));
@@ -67,20 +66,15 @@ void setOutputColor(vec4 outColor) {
#elif defined(KWIN_LEGACY) // ----------------------------------------------------------- #elif defined(KWIN_LEGACY) // -----------------------------------------------------------
uniform float forOpening;
uniform sampler2D sampler; uniform sampler2D sampler;
uniform float uDuration;
uniform int textureWidth; uniform int textureWidth;
uniform int textureHeight; uniform int textureHeight;
uniform float animationProgress;
varying vec2 texcoord0; varying vec2 texcoord0;
vec2 uSize = vec2(textureWidth, textureHeight); vec2 uSize = vec2(textureWidth, textureHeight);
bool uForOpening = forOpening == 1.0; vec2 iTexCoord = vec2(texcoord0.x, 1.0 - texcoord0.y);
vec2 iTexCoord = vec2(texcoord0.x, 1.0 - texcoord0.y); float uPadding = 0.0;
float uProgress = animationProgress;
float uPadding = 0.0;
vec4 getInputColor(vec2 coords) { vec4 getInputColor(vec2 coords) {
vec4 color = texture2D(sampler, vec2(coords.x, 1.0 - coords.y)); vec4 color = texture2D(sampler, vec2(coords.x, 1.0 - coords.y));
@@ -99,10 +93,7 @@ void setOutputColor(vec4 outColor) {
#else // GNOME -------------------------------------------------------------------------- #else // GNOME --------------------------------------------------------------------------
// On GNOME, the uniforms are just normal uniforms. // On GNOME, the uniforms are just normal uniforms.
uniform bool uForOpening;
uniform sampler2D uTexture; uniform sampler2D uTexture;
uniform float uProgress;
uniform float uDuration;
uniform vec2 uSize; uniform vec2 uSize;
uniform float uPadding; uniform float uPadding;