diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2019-05-07 17:41:51 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2019-05-07 17:41:51 -0700 |
commit | e46a14e914fe8eaa7087154cf32cb9c86c0aa023 (patch) | |
tree | 0a0f4c54946eed4fb694642f650f1e104a7865c6 /src/stage.c | |
parent | 53959d40924628f1ebae3e7d524318eb212de4bf (diff) |
libstage: use dll.h for linked lists, rm list.h
Diffstat (limited to 'src/stage.c')
-rw-r--r-- | src/stage.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/stage.c b/src/stage.c index 6ded8a5..b35abda 100644 --- a/src/stage.c +++ b/src/stage.c @@ -17,12 +17,13 @@ #include <stdlib.h> #include <string.h> -#include "list.h" +#include <dll_h/dll.h> + #include "stage.h" struct stage_node_t { - list_head_t nodes; + dll_t nodes; char name[STAGE_NODE_NAME_MAX]; float alpha; /* alpha for the texture when composited */ unsigned active:1; /* node is active */ @@ -35,8 +36,8 @@ struct stage_node_t { struct stage_t { - list_head_t layers[STAGE_LAYERS_MAX]; - float alpha; /* alpha to apply to all nodes */ + dll_t layers[STAGE_LAYERS_MAX]; + float alpha; /* alpha to apply to all nodes */ }; @@ -84,7 +85,7 @@ stage_node_t * stage_node_new(stage_t *stage, int layer, const char *name, void if (!node) return NULL; - list_add_tail(&node->nodes, &stage->layers[layer]); + (void) dll_pre(&node->nodes, &stage->layers[layer]); return node; } @@ -117,7 +118,7 @@ void stage_node_replace(const stage_t *stage, stage_node_t *node, const char *na stage_node_t * stage_node_free(stage_t *stage, stage_node_t *node) { if (node) { - list_del(&node->nodes); + (void) dll_del(&node->nodes); node_free(stage, node); } @@ -151,8 +152,8 @@ void stage_node_set_locked(const stage_t *stage, stage_node_t *node, int locked) void stage_node_set_layer(stage_t *stage, stage_node_t *node, int layer) { /* TODO: assert layer sanity */ - list_del(&node->nodes); - list_add_tail(&node->nodes, &stage->layers[layer]); + (void) dll_del(&node->nodes); + (void) dll_pre(&node->nodes, &stage->layers[layer]); } @@ -167,7 +168,7 @@ stage_t * stage_new(void) return NULL; for (i = 0; i < STAGE_LAYERS_MAX; i++) - INIT_LIST_HEAD(&stage->layers[i]); + (void) dll_init(&stage->layers[i]); return stage; } @@ -179,7 +180,7 @@ static void _stage_clear(stage_t *stage, int force) int i; for (i = 0; i < STAGE_LAYERS_MAX; i++) { - list_for_each_entry_safe(node, _node, &stage->layers[i], nodes) { + DLL_FOR_EACH_ENTRY_SAFE(&stage->layers[i], node, _node, stage_node_t, nodes) { if (force || !node->locked) stage_node_free(stage, node); } @@ -245,11 +246,11 @@ void stage_get_alpha(stage_t *stage, float *res_alpha) } -static void render_nodes(const stage_t *stage, const list_head_t *head) +static void render_nodes(const stage_t *stage, const dll_t *nodes) { stage_node_t *node; - list_for_each_entry(node, head, nodes) { + DLL_FOR_EACH_ENTRY(nodes, node, stage_node_t, nodes) { if (!node->active) continue; @@ -280,7 +281,7 @@ stage_node_t * stage_node_lookup_name(const stage_t *stage, const char *name) int i; for (i = 0; i < STAGE_LAYERS_MAX; i++) { - list_for_each_entry(node, &stage->layers[i], nodes) { + DLL_FOR_EACH_ENTRY(&stage->layers[i], node, stage_node_t, nodes) { if (!strncmp(node->name, name, sizeof(node->name))) return node; } |