From: Charlie Brej Date: Mon, 20 Jul 2009 14:10:49 +0000 (+0100) Subject: [script] Sort the sprites so they are drawn in the correct order X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0f880745d168c51bb9c138df744ebab1f2f0c53d;p=thirdparty%2Fplymouth.git [script] Sort the sprites so they are drawn in the correct order Sorting is done using the Z parameter. The higher the closer to the front and the more above the others. --- diff --git a/src/plugins/splash/script/script-lib-sprite.c b/src/plugins/splash/script/script-lib-sprite.c index c0a9bba4..a0366353 100644 --- a/src/plugins/splash/script/script-lib-sprite.c +++ b/src/plugins/splash/script/script-lib-sprite.c @@ -38,12 +38,6 @@ #define STRINGIFY_VAR script_lib_sprite_string #include "script-lib-sprite.string" -static void draw_area (script_lib_sprite_data_t *data, - int x, - int y, - int width, - int height); - static void sprite_free (script_obj_t *obj) { sprite_t *sprite = obj->data.native.object_data; @@ -347,10 +341,20 @@ script_lib_sprite_data_t *script_lib_sprite_setup (script_state_t *state, return data; } +static int +sprite_compare_z(void *data_a, void *data_b) +{ + sprite_t *sprite_a = data_a; + sprite_t *sprite_b = data_b; + return sprite_a->z - sprite_b->z; +} + void script_lib_sprite_refresh (script_lib_sprite_data_t *data) { ply_list_node_t *node; - + + ply_list_sort (data->sprite_list, &sprite_compare_z); + node = ply_list_get_first_node (data->sprite_list); if (data->full_refresh) @@ -364,6 +368,7 @@ void script_lib_sprite_refresh (script_lib_sprite_data_t *data) screen_area.width, screen_area.height); data->full_refresh = false; + return; } while (node) {