From 1aaaf1d39d67dfb08238fa4ec6e01d35569e2138 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Thu, 6 May 2010 12:59:54 -0400 Subject: [PATCH] [two-step] Add new ProgressFunction config option We've historically used a expontial function for boot up, to make it "feel" faster. This equation was invented by Will Woods. Making progress linear with boot up is also useful though. This commit makes it configurable. --- src/plugins/splash/two-step/plugin.c | 45 +++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/src/plugins/splash/two-step/plugin.c b/src/plugins/splash/two-step/plugin.c index 48f4a7c5..41ea3887 100644 --- a/src/plugins/splash/two-step/plugin.c +++ b/src/plugins/splash/two-step/plugin.c @@ -73,6 +73,11 @@ typedef enum { PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY } ply_boot_splash_display_type_t; +typedef enum { + PROGRESS_FUNCTION_TYPE_WWOODS, + PROGRESS_FUNCTION_TYPE_LINEAR, +} progress_function_t; + typedef struct { ply_boot_splash_plugin_t *plugin; @@ -106,6 +111,8 @@ struct _ply_boot_splash_plugin uint32_t background_start_color; uint32_t background_end_color; + progress_function_t progress_function; + ply_trigger_t *idle_trigger; ply_trigger_t *stop_trigger; @@ -411,6 +418,7 @@ create_plugin (ply_key_file_t *key_file) char *transition; char *transition_duration; char *color; + char *progress_function; srand ((int) ply_get_timestamp ()); plugin = calloc (1, sizeof (ply_boot_splash_plugin_t)); @@ -483,6 +491,27 @@ create_plugin (ply_key_file_t *key_file) free (color); + progress_function = ply_key_file_get_value (key_file, "two-step", "ProgressFunction"); + + if (progress_function != NULL) + { + if (strcmp (progress_function, "wwoods") == 0) + { + ply_trace ("Using wwoods progress function"); + plugin->progress_function = PROGRESS_FUNCTION_TYPE_WWOODS; + } + else if (strcmp (progress_function, "linear") == 0) + { + ply_trace ("Using linear progress function"); + plugin->progress_function = PROGRESS_FUNCTION_TYPE_LINEAR; + } + else + { + ply_trace ("unknown progress function %s, defaulting to linear", progress_function); + plugin->progress_function = PROGRESS_FUNCTION_TYPE_LINEAR; + } + } + plugin->views = ply_list_new (); return plugin; @@ -892,11 +921,19 @@ on_boot_progress (ply_boot_splash_plugin_t *plugin, double total_duration; percent_done *= (1 / SHOW_ANIMATION_PERCENT); - total_duration = duration / percent_done; - /* Fun made-up smoothing function to make the growth asymptotic: - * fraction(time,estimate)=1-2^(-(time^1.45)/estimate) */ - percent_done = 1.0 - pow (2.0, -pow (duration, 1.45) / total_duration) * (1.0 - percent_done); + switch (plugin->progress_function) + { + /* Fun made-up smoothing function to make the growth asymptotic: + * fraction(time,estimate)=1-2^(-(time^1.45)/estimate) */ + case PROGRESS_FUNCTION_TYPE_WWOODS: + total_duration = duration / percent_done; + percent_done = 1.0 - pow (2.0, -pow (duration, 1.45) / total_duration) * (1.0 - percent_done); + break; + + case PROGRESS_FUNCTION_TYPE_LINEAR: + break; + } update_progress_animation (plugin, percent_done); }