Protect against multiple calls to start/stop animation.
This prevents crashes if the user presses escape when
the animation is already stopped, and prevents
super fast animations if --show-splash gets called twice
in a row.
double start_time;
double now;
+
+ uint32_t is_animating : 1;
};
ply_boot_splash_plugin_t *
assert (plugin != NULL);
assert (plugin->loop != NULL);
+ if (plugin->is_animating)
+ return;
+
ply_event_loop_watch_for_timeout (plugin->loop,
1.0 / FRAMES_PER_SECOND,
(ply_event_loop_timeout_handler_t)
plugin->start_time = ply_get_timestamp ();
draw_background (plugin, NULL);
+
+ plugin->is_animating = true;
}
static void
assert (plugin != NULL);
assert (plugin->loop != NULL);
+ if (!plugin->is_animating)
+ return;
+
+ plugin->is_animating = false;
+
for (i = 0; i < 10; i++)
{
ply_frame_buffer_fill_with_hex_color_at_opacity (plugin->frame_buffer,
ply_text_pulser_t *pulser;
uint32_t keyboard_input_is_hidden : 1;
+ uint32_t is_animating : 1;
};
void hide_splash_screen (ply_boot_splash_plugin_t *plugin,
ply_event_loop_t *loop);
assert (plugin != NULL);
assert (plugin->loop != NULL);
+ if (plugin->is_animating)
+ return;
+
ply_window_set_color_hex_value (plugin->window,
PLY_WINDOW_COLOR_BROWN,
PLYMOUTH_BACKGROUND_END_COLOR);
plugin->window,
window_width / 2.0 - width / 2.0,
window_height / 2.0 - height / 2.0);
+
+ plugin->is_animating = true;
}
static void
assert (plugin != NULL);
assert (plugin->loop != NULL);
+ if (!plugin->is_animating)
+ return;
+
+ plugin->is_animating = false;
+
ply_text_pulser_stop (plugin->pulser);
}
uint32_t root_is_mounted : 1;
uint32_t is_visible : 1;
+ uint32_t is_animating : 1;
};
static void detach_from_event_loop (ply_boot_splash_plugin_t *plugin);
assert (plugin != NULL);
assert (plugin->loop != NULL);
+ if (plugin->is_animating)
+ return;
+
ply_frame_buffer_get_size (plugin->frame_buffer, &area);
plugin->now = ply_get_timestamp ();
on_timeout (plugin);
ply_window_draw_area (plugin->window, area.x, area.y, area.width, area.height);
+ plugin->is_animating = true;
}
static void
assert (plugin != NULL);
assert (plugin->loop != NULL);
+ if (!plugin->is_animating)
+ return;
+
+ plugin->is_animating = false;
+
if (plugin->loop != NULL)
{
ply_event_loop_stop_watching_for_timeout (plugin->loop,
free_sprite (sprite);
}
ply_list_remove_all_nodes (plugin->sprites);
-
}
static void
uint32_t root_is_mounted : 1;
uint32_t is_visible : 1;
+ uint32_t is_animating : 1;
};
static void detach_from_event_loop (ply_boot_splash_plugin_t *plugin);
assert (plugin != NULL);
assert (plugin->loop != NULL);
+ if (plugin->is_animating)
+ return;
+
draw_background (plugin, NULL);
draw_logo (plugin);
ply_progress_bar_show (plugin->progress_bar,
plugin->window,
0, area.height - ply_progress_bar_get_height (plugin->progress_bar));
+
+ plugin->is_animating = true;
}
static void
assert (plugin != NULL);
assert (plugin->loop != NULL);
+ if (!plugin->is_animating)
+ return;
+
+ plugin->is_animating = false;
+
ply_progress_bar_hide (plugin->progress_bar);
ply_throbber_stop (plugin->throbber, trigger);
ply_text_progress_bar_t *progress_bar;
uint32_t keyboard_input_is_hidden : 1;
+ uint32_t is_animating : 1;
};
void hide_splash_screen (ply_boot_splash_plugin_t *plugin,
ply_event_loop_t *loop);
assert (plugin != NULL);
assert (plugin->loop != NULL);
+ if (plugin->is_animating)
+ return;
+
ply_window_set_color_hex_value (plugin->window,
PLY_WINDOW_COLOR_BLACK,
0x000000);
ply_text_progress_bar_show (plugin->progress_bar,
plugin->window);
+
+ plugin->is_animating = true;
}
static void
assert (plugin != NULL);
assert (plugin->loop != NULL);
+ if (!plugin->is_animating)
+ return;
+
+ plugin->is_animating = false;
+
+
ply_text_progress_bar_hide (plugin->progress_bar);
}