From dec948dc805611eeb2ed0ad970864953ad19da22 Mon Sep 17 00:00:00 2001 From: Erik Reider <35975961+ErikReider@users.noreply.github.com> Date: Fri, 26 Jan 2024 19:46:13 +0100 Subject: [PATCH] Moved easing functions into their own file --- include/sway/desktop/fx_renderer/animation_utils.h | 10 ++++++++++ sway/desktop/fx_renderer/animation_utils.c | 12 ++++++++++++ sway/desktop/output.c | 10 +--------- sway/meson.build | 1 + 4 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 include/sway/desktop/fx_renderer/animation_utils.h create mode 100644 sway/desktop/fx_renderer/animation_utils.c diff --git a/include/sway/desktop/fx_renderer/animation_utils.h b/include/sway/desktop/fx_renderer/animation_utils.h new file mode 100644 index 00000000..63e3b487 --- /dev/null +++ b/include/sway/desktop/fx_renderer/animation_utils.h @@ -0,0 +1,10 @@ +#ifndef ANIMATION_UTILS_H +#define ANIMATION_UTILS_H + +double lerp (double a, double b, double t); + +double ease_out_cubic (double t); + +// TODO: Add more easing functions in the future like ease_in and ease_in_out, etc... + +#endif diff --git a/sway/desktop/fx_renderer/animation_utils.c b/sway/desktop/fx_renderer/animation_utils.c new file mode 100644 index 00000000..9c64897a --- /dev/null +++ b/sway/desktop/fx_renderer/animation_utils.c @@ -0,0 +1,12 @@ +#include + +#include "sway/desktop/fx_renderer/animation_utils.h" + +double lerp (double a, double b, double t) { + return a * (1.0 - t) + b * t; +} + +double ease_out_cubic (double t) { + double p = t - 1; + return pow(p, 3) + 1; +} diff --git a/sway/desktop/output.c b/sway/desktop/output.c index cae31412..481079d1 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -19,6 +19,7 @@ #include "config.h" #include "log.h" #include "sway/config.h" +#include "sway/desktop/fx_renderer/animation_utils.h" #include "sway/desktop/transaction.h" #include "sway/input/input-manager.h" #include "sway/input/seat.h" @@ -1108,15 +1109,6 @@ void handle_output_power_manager_set_mode(struct wl_listener *listener, apply_output_config(oc, output); } -static double lerp (double a, double b, double t) { - return a * (1.0 - t) + b * t; -} - -static double ease_out_cubic (double t) { - double p = t - 1; - return pow(p, 3) + 1; -} - struct workspace_scroll workspace_scroll_get_default() { return (struct workspace_scroll) { .percent = 0, diff --git a/sway/meson.build b/sway/meson.build index 8ccdb20d..481b1d0f 100644 --- a/sway/meson.build +++ b/sway/meson.build @@ -20,6 +20,7 @@ sway_sources = files( 'desktop/fx_renderer/fx_stencilbuffer.c', 'desktop/fx_renderer/fx_texture.c', 'desktop/fx_renderer/matrix.c', + 'desktop/fx_renderer/animation_utils.c', 'desktop/idle_inhibit_v1.c', 'desktop/layer_shell.c', 'desktop/output.c',