Merge branch 'cleanups' into 'master'

Misc. code cleanups

See merge request plymouth/plymouth!82
This commit is contained in:
Hans de Goede 2019-11-01 12:42:52 +00:00
commit d18086efcc
2 changed files with 36 additions and 95 deletions

View file

@ -168,8 +168,6 @@ struct _ply_renderer_backend
ply_renderer_plugin_interface_t *ply_renderer_backend_get_interface (void);
static bool open_input_source (ply_renderer_backend_t *backend,
ply_renderer_input_source_t *input_source);
static bool reset_scan_out_buffer_if_needed (ply_renderer_backend_t *backend,
ply_renderer_head_t *head);
static void flush_head (ply_renderer_backend_t *backend,
ply_renderer_head_t *head);
@ -933,6 +931,7 @@ destroy_backend (ply_renderer_backend_t *backend)
static void
activate (ply_renderer_backend_t *backend)
{
ply_renderer_head_t *head;
ply_list_node_t *node;
ply_trace ("taking master and scanning out");
@ -941,16 +940,10 @@ activate (ply_renderer_backend_t *backend)
drmSetMaster (backend->device_fd);
node = ply_list_get_first_node (backend->heads);
while (node != NULL) {
ply_list_node_t *next_node;
ply_renderer_head_t *head;
head = (ply_renderer_head_t *) ply_list_node_get_data (node);
next_node = ply_list_get_next_node (backend->heads, node);
/* Flush out any pending drawing to the buffer */
flush_head (backend, head);
node = next_node;
node = ply_list_get_next_node (backend->heads, node);
}
}
@ -1568,22 +1561,19 @@ handle_change_event (ply_renderer_backend_t *backend)
static bool
map_to_device (ply_renderer_backend_t *backend)
{
ply_renderer_head_t *head;
ply_list_node_t *node;
bool head_mapped;
head_mapped = false;
node = ply_list_get_first_node (backend->heads);
while (node != NULL) {
ply_list_node_t *next_node;
ply_renderer_head_t *head;
head = (ply_renderer_head_t *) ply_list_node_get_data (node);
next_node = ply_list_get_next_node (backend->heads, node);
if (ply_renderer_head_map (backend, head))
head_mapped = true;
node = next_node;
node = ply_list_get_next_node (backend->heads, node);
}
if (backend->terminal != NULL) {
@ -1601,19 +1591,14 @@ map_to_device (ply_renderer_backend_t *backend)
static void
unmap_from_device (ply_renderer_backend_t *backend)
{
ply_renderer_head_t *head;
ply_list_node_t *node;
node = ply_list_get_first_node (backend->heads);
while (node != NULL) {
ply_list_node_t *next_node;
ply_renderer_head_t *head;
head = (ply_renderer_head_t *) ply_list_node_get_data (node);
next_node = ply_list_get_next_node (backend->heads, node);
ply_renderer_head_unmap (backend, head);
node = next_node;
node = ply_list_get_next_node (backend->heads, node);
}
}
@ -1655,6 +1640,7 @@ static void
flush_head (ply_renderer_backend_t *backend,
ply_renderer_head_t *head)
{
ply_rectangle_t *area_to_flush;
ply_region_t *updated_region;
ply_list_t *areas_to_flush;
ply_list_node_t *node;
@ -1685,17 +1671,12 @@ flush_head (ply_renderer_backend_t *backend,
node = ply_list_get_first_node (areas_to_flush);
while (node != NULL) {
ply_list_node_t *next_node;
ply_rectangle_t *area_to_flush;
area_to_flush = (ply_rectangle_t *) ply_list_node_get_data (node);
next_node = ply_list_get_next_node (areas_to_flush, node);
ply_renderer_head_flush_area (head, area_to_flush, map_address);
dirty = true;
node = next_node;
node = ply_list_get_next_node (areas_to_flush, node);
}
if (dirty) {

View file

@ -683,21 +683,18 @@ load_views (ply_boot_splash_plugin_t *plugin)
{
ply_list_node_t *node;
bool view_loaded;
view_t *view;
view_loaded = false;
node = ply_list_get_first_node (plugin->views);
while (node != NULL) {
ply_list_node_t *next_node;
view_t *view;
view = ply_list_node_get_data (node);
next_node = ply_list_get_next_node (plugin->views, node);
if (view_load (view))
view_loaded = true;
node = next_node;
node = ply_list_get_next_node (plugin->views, node);
}
return view_loaded;
@ -719,18 +716,13 @@ static void
redraw_views (ply_boot_splash_plugin_t *plugin)
{
ply_list_node_t *node;
view_t *view;
node = ply_list_get_first_node (plugin->views);
while (node != NULL) {
ply_list_node_t *next_node;
view_t *view;
view = ply_list_node_get_data (node);
next_node = ply_list_get_next_node (plugin->views, node);
view_redraw (view);
node = next_node;
node = ply_list_get_next_node (plugin->views, node);
}
}
@ -738,20 +730,15 @@ static void
pause_views (ply_boot_splash_plugin_t *plugin)
{
ply_list_node_t *node;
view_t *view;
ply_trace ("pausing views");
node = ply_list_get_first_node (plugin->views);
while (node != NULL) {
ply_list_node_t *next_node;
view_t *view;
view = ply_list_node_get_data (node);
next_node = ply_list_get_next_node (plugin->views, node);
ply_pixel_display_pause_updates (view->display);
node = next_node;
node = ply_list_get_next_node (plugin->views, node);
}
}
@ -759,20 +746,15 @@ static void
unpause_views (ply_boot_splash_plugin_t *plugin)
{
ply_list_node_t *node;
view_t *view;
ply_trace ("unpausing views");
node = ply_list_get_first_node (plugin->views);
while (node != NULL) {
ply_list_node_t *next_node;
view_t *view;
view = ply_list_node_get_data (node);
next_node = ply_list_get_next_node (plugin->views, node);
ply_pixel_display_unpause_updates (view->display);
node = next_node;
node = ply_list_get_next_node (plugin->views, node);
}
}
@ -1270,6 +1252,9 @@ static void
start_end_animation (ply_boot_splash_plugin_t *plugin,
ply_trigger_t *trigger)
{
ply_list_node_t *node;
view_t *view;
if (!plugin->mode_settings[plugin->mode].use_animation) {
ply_trigger_pull (trigger, NULL);
return;
@ -1277,20 +1262,14 @@ start_end_animation (ply_boot_splash_plugin_t *plugin,
ply_trace ("starting end animation");
ply_list_node_t *node;
node = ply_list_get_first_node (plugin->views);
while (node != NULL) {
ply_list_node_t *next_node;
view_t *view;
ply_trigger_t *throbber_trigger;
view = ply_list_node_get_data (node);
next_node = ply_list_get_next_node (plugin->views, node);
ply_trigger_ignore_next_pull (trigger);
if (view->throbber != NULL) {
ply_trigger_t *throbber_trigger;
ply_trace ("stopping throbber");
view->end_trigger = trigger;
throbber_trigger = ply_trigger_new (NULL);
@ -1303,7 +1282,7 @@ start_end_animation (ply_boot_splash_plugin_t *plugin,
view_start_end_animation (view, trigger);
}
node = next_node;
node = ply_list_get_next_node (plugin->views, node);
}
ply_trigger_pull (trigger, NULL);
}
@ -1312,6 +1291,7 @@ static void
start_progress_animation (ply_boot_splash_plugin_t *plugin)
{
ply_list_node_t *node;
view_t *view;
if (plugin->is_animating)
return;
@ -1320,15 +1300,9 @@ start_progress_animation (ply_boot_splash_plugin_t *plugin)
node = ply_list_get_first_node (plugin->views);
while (node != NULL) {
ply_list_node_t *next_node;
view_t *view;
view = ply_list_node_get_data (node);
next_node = ply_list_get_next_node (plugin->views, node);
view_start_progress_animation (view);
node = next_node;
node = ply_list_get_next_node (plugin->views, node);
}
plugin->is_animating = true;
@ -1346,6 +1320,7 @@ static void
stop_animation (ply_boot_splash_plugin_t *plugin)
{
ply_list_node_t *node;
view_t *view;
assert (plugin != NULL);
assert (plugin->loop != NULL);
@ -1358,11 +1333,7 @@ stop_animation (ply_boot_splash_plugin_t *plugin)
node = ply_list_get_first_node (plugin->views);
while (node != NULL) {
ply_list_node_t *next_node;
view_t *view;
view = ply_list_node_get_data (node);
next_node = ply_list_get_next_node (plugin->views, node);
ply_progress_bar_hide (view->progress_bar);
if (view->progress_animation != NULL)
@ -1372,7 +1343,7 @@ stop_animation (ply_boot_splash_plugin_t *plugin)
if (view->end_animation != NULL)
ply_animation_stop (view->end_animation);
node = next_node;
node = ply_list_get_next_node (plugin->views, node);
}
}
@ -1709,15 +1680,12 @@ update_progress_animation (ply_boot_splash_plugin_t *plugin,
double percent_done)
{
ply_list_node_t *node;
view_t *view;
char buf[64];
node = ply_list_get_first_node (plugin->views);
while (node != NULL) {
ply_list_node_t *next_node;
view_t *view;
view = ply_list_node_get_data (node);
next_node = ply_list_get_next_node (plugin->views, node);
if (view->progress_animation != NULL)
ply_progress_animation_set_percent_done (view->progress_animation,
@ -1730,7 +1698,7 @@ update_progress_animation (ply_boot_splash_plugin_t *plugin,
view_show_message (view, buf);
}
node = next_node;
node = ply_list_get_next_node (plugin->views, node);
}
}
@ -1808,19 +1776,14 @@ show_prompt (ply_boot_splash_plugin_t *plugin,
int number_of_bullets)
{
ply_list_node_t *node;
view_t *view;
ply_trace ("showing prompt");
node = ply_list_get_first_node (plugin->views);
while (node != NULL) {
ply_list_node_t *next_node;
view_t *view;
view = ply_list_node_get_data (node);
next_node = ply_list_get_next_node (plugin->views, node);
view_show_prompt (view, prompt, entry_text, number_of_bullets);
node = next_node;
node = ply_list_get_next_node (plugin->views, node);
}
}
@ -1861,23 +1824,17 @@ static void
hide_prompt (ply_boot_splash_plugin_t *plugin)
{
ply_list_node_t *node;
view_t *view;
ply_trace ("hiding prompt");
node = ply_list_get_first_node (plugin->views);
while (node != NULL) {
ply_list_node_t *next_node;
view_t *view;
view = ply_list_node_get_data (node);
next_node = ply_list_get_next_node (plugin->views, node);
view_hide_prompt (view);
node = next_node;
node = ply_list_get_next_node (plugin->views, node);
}
}
static void
view_show_message (view_t *view,
const char *message)
@ -1905,15 +1862,18 @@ static void
show_message (ply_boot_splash_plugin_t *plugin,
const char *message)
{
ply_list_node_t *node;
view_t *view;
if (plugin->mode_settings[plugin->mode].suppress_messages) {
ply_trace ("Suppressing message '%s'", message);
return;
}
ply_trace ("Showing message '%s'", message);
ply_list_node_t *node;
node = ply_list_get_first_node (plugin->views);
while (node != NULL) {
view_show_message (ply_list_node_get_data (node), message);
view = ply_list_node_get_data (node);
view_show_message (view, message);
node = ply_list_get_next_node (plugin->views, node);
}
}