From bbd9b2f58a2d2d01c32135e37cb373d9aeb4ba31 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Thu, 25 Sep 2008 17:45:30 -0400 Subject: [PATCH] Interpolate stored boot time with default time This is so we get a smooth progress bar after /var/lib/plymouth/boot-duration is read. --- src/ply-boot-splash.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/ply-boot-splash.c b/src/ply-boot-splash.c index eb29eb1d..2e47c61f 100644 --- a/src/ply-boot-splash.c +++ b/src/ply-boot-splash.c @@ -18,6 +18,7 @@ * 02111-1307, USA. * * Written by: Ray Strode + * Soeren Sandmann */ #include "config.h" #include "ply-boot-splash.h" @@ -205,14 +206,26 @@ static void ply_boot_splash_update_progress (ply_boot_splash_t *splash) { double time_in_seconds; + double default_percentage; double percentage; assert (splash != NULL); time_in_seconds = ply_get_timestamp () - splash->start_time; - percentage = CLAMP (time_in_seconds / splash->boot_duration, - 0.0, 1.0); + default_percentage = time_in_seconds / DEFAULT_BOOT_DURATION; + percentage = time_in_seconds / splash->boot_duration; + + /* We intepolate the percentage between the real percentage (based + * on what's stored on disk) with the default percentage (based on + * a 60 second boot time) + * + * This is because we initially assume 60 seconds until / is mounted, + * and we don't want any large jumps + */ + percentage = percentage * percentage + default_percentage * (1.0 - percentage); + + percentage = CLAMP (percentage, 0.0, 1.0); if (splash->plugin_interface->on_boot_progress != NULL) splash->plugin_interface->on_boot_progress (splash->plugin, -- 2.47.3