mirror of
https://gitlab.freedesktop.org/plymouth/plymouth.git
synced 2026-05-08 22:58:17 +02:00
[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.
This commit is contained in:
parent
4da25e407c
commit
1aaaf1d39d
1 changed files with 41 additions and 4 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue