From: Ray Strode Date: Fri, 25 Oct 2013 20:24:47 +0000 (-0400) Subject: two-step: introduce delayed startup X-Git-Tag: 0.9.0~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=17976ac53807d93d9e240e85fe0e1e8ea3fab730;p=thirdparty%2Fplymouth.git two-step: introduce delayed startup Many machines these days can boot in 5 seconds or less. In those cases, there's little point in showing a boot splash. This commit introduces a StartupDelay option to the two step plugin to prevent it from displaying anything for a few seconds. --- diff --git a/src/plugins/splash/two-step/plugin.c b/src/plugins/splash/two-step/plugin.c index f48b41e1..5dca355f 100644 --- a/src/plugins/splash/two-step/plugin.c +++ b/src/plugins/splash/two-step/plugin.c @@ -92,6 +92,8 @@ typedef struct ply_rectangle_t box_area, lock_area, watermark_area; ply_trigger_t *end_trigger; ply_image_t *background_image; + + uint32_t is_blank : 1; } view_t; struct _ply_boot_splash_plugin @@ -126,6 +128,9 @@ struct _ply_boot_splash_plugin ply_trigger_t *idle_trigger; ply_trigger_t *stop_trigger; + double start_time; + double startup_delay; + uint32_t root_is_mounted : 1; uint32_t is_visible : 1; uint32_t is_animating : 1; @@ -167,6 +172,7 @@ view_new (ply_boot_splash_plugin_t *plugin, view->label = ply_label_new (); view->message_label = ply_label_new (); + view->is_blank = true; return view; } @@ -521,6 +527,7 @@ create_plugin (ply_key_file_t *key_file) { ply_boot_splash_plugin_t *plugin; char *image_dir, *image_path; + char *startup_delay; char *alignment; char *transition; char *transition_duration; @@ -530,6 +537,8 @@ create_plugin (ply_key_file_t *key_file) srand ((int) ply_get_timestamp ()); plugin = calloc (1, sizeof (ply_boot_splash_plugin_t)); + plugin->start_time = ply_get_timestamp (); + image_dir = ply_key_file_get_value (key_file, "two-step", "ImageDir"); ply_trace ("Using '%s' as working directory", image_dir); @@ -560,6 +569,13 @@ create_plugin (ply_key_file_t *key_file) plugin->animation_dir = image_dir; + startup_delay = ply_key_file_get_value (key_file, "two-step", "StartupDelay"); + if (startup_delay != NULL) + plugin->startup_delay = strtod (startup_delay, NULL); + else + plugin->startup_delay = 5.0; + free (startup_delay); + alignment = ply_key_file_get_value (key_file, "two-step", "HorizontalAlignment"); if (alignment != NULL) plugin->animation_horizontal_alignment = strtod (alignment, NULL); @@ -903,6 +919,35 @@ on_draw (view_t *view, plugin = view->plugin; + if (plugin->mode == PLY_BOOT_SPLASH_MODE_BOOT_UP) + { + double now; + + now = ply_get_timestamp (); + + if (now - plugin->start_time < plugin->startup_delay) + return; + + if (view->is_blank) + { + ply_rectangle_t clip_area; + + x = 0; + y = 0; + width = ply_pixel_display_get_width (view->display); + height = ply_pixel_display_get_height (view->display); + + clip_area.x = 0; + clip_area.y = 0; + clip_area.width = width; + clip_area.height = height; + ply_pixel_buffer_pop_clip_area (pixel_buffer); + ply_pixel_buffer_push_clip_area (pixel_buffer, + &clip_area); + view->is_blank = false; + } + } + draw_background (view, pixel_buffer, x, y, width, height); ply_pixel_buffer_get_size (pixel_buffer, &screen_area);