From 2b9eca8724fe6c5e0f6a4438cd398b5978283131 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Thu, 11 May 2023 12:48:42 -0700 Subject: modules/*: remove use of static default setups There was a time when it made sense for context creates needing setups but not receiving them to still be functional with some sane defaults. But with recursive settings, we really shouldn't ever have orphaned nested module uses unreachable by a proper setup. So let's just get rid of this fallback, and exclusively rely on the baked setups provided by the .setup() methods. They still have preferred defaults, and the proper setup production machinery is what should be responsible for applying those at runtime where they may also be overridden or otherwise influenced. --- src/modules/blinds/blinds.c | 9 --------- src/modules/checkers/checkers.c | 12 ------------ src/modules/drizzle/drizzle.c | 8 -------- src/modules/flui2d/flui2d.c | 11 ----------- src/modules/moire/moire.c | 8 -------- src/modules/pixbounce/pixbounce.c | 5 ----- src/modules/rkt/rkt.c | 5 ----- src/modules/rtv/rtv.c | 12 ------------ src/modules/shapes/shapes.c | 8 -------- src/modules/sparkler/sparkler.c | 5 ----- src/modules/stars/stars.c | 7 ------- src/modules/strobe/strobe.c | 8 -------- src/modules/submit/submit.c | 5 ----- src/modules/swarm/swarm.c | 7 ------- src/modules/voronoi/voronoi.c | 10 ---------- 15 files changed, 120 deletions(-) diff --git a/src/modules/blinds/blinds.c b/src/modules/blinds/blinds.c index 6a0639b..7b2f7ac 100644 --- a/src/modules/blinds/blinds.c +++ b/src/modules/blinds/blinds.c @@ -42,19 +42,10 @@ typedef struct blinds_context_t { } blinds_context_t; -static blinds_setup_t blinds_default_setup = { - .count = BLINDS_DEFAULT_COUNT, - .orientation = BLINDS_DEFAULT_ORIENTATION, -}; - - static til_module_context_t * blinds_create_context(const til_module_t *module, til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup) { blinds_context_t *ctxt; - if (!setup) - setup = &blinds_default_setup.til_setup; - ctxt = til_module_context_new(module, sizeof(blinds_context_t), stream, seed, ticks, n_cpus, path); if (!ctxt) return NULL; diff --git a/src/modules/checkers/checkers.c b/src/modules/checkers/checkers.c index a2a767d..19c1232 100644 --- a/src/modules/checkers/checkers.c +++ b/src/modules/checkers/checkers.c @@ -70,23 +70,11 @@ typedef struct checkers_context_t { } checkers_context_t; -static checkers_setup_t checkers_default_setup = { - .size = CHECKERS_DEFAULT_SIZE, - .pattern = CHECKERS_DEFAULT_PATTERN, - .dynamics = CHECKERS_DEFAULT_DYNAMICS, - .rate = CHECKERS_DEFAULT_DYNAMICS_RATE, - .color = CHECKERS_DEFAULT_COLOR, -}; - - static til_module_context_t * checkers_create_context(const til_module_t *module, til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup) { size_t size = sizeof(checkers_context_t); checkers_context_t *ctxt; - if (!setup) - setup = &checkers_default_setup.til_setup; - if (((checkers_setup_t *)setup)->fill_module) size += sizeof(til_module_context_t *) * n_cpus; diff --git a/src/modules/drizzle/drizzle.c b/src/modules/drizzle/drizzle.c index 8a5607f..d91af01 100644 --- a/src/modules/drizzle/drizzle.c +++ b/src/modules/drizzle/drizzle.c @@ -68,11 +68,6 @@ typedef struct drizzle_context_t { drizzle_setup_t setup; } drizzle_context_t; -static drizzle_setup_t drizzle_default_setup = { - .viscosity = DEFAULT_VISCOSITY, - .style = DEFAULT_STYLE, -}; - /* convert a color into a packed, 32-bit rgb pixel value (taken from libs/ray/ray_color.h) */ static inline uint32_t color_to_uint32(v3f_t color) { @@ -100,9 +95,6 @@ static til_module_context_t * drizzle_create_context(const til_module_t *module, { drizzle_context_t *ctxt; - if (!setup) - setup = &drizzle_default_setup.til_setup; - ctxt = til_module_context_new(module, sizeof(drizzle_context_t), stream, seed, ticks, n_cpus, path); if (!ctxt) return NULL; diff --git a/src/modules/flui2d/flui2d.c b/src/modules/flui2d/flui2d.c index f8e25d3..af25549 100644 --- a/src/modules/flui2d/flui2d.c +++ b/src/modules/flui2d/flui2d.c @@ -215,14 +215,6 @@ typedef struct flui2d_context_t { #define FLUI2D_DEFAULT_DECAY .0001 -static flui2d_setup_t flui2d_default_setup = { - .viscosity = FLUI2D_DEFAULT_VISCOSITY, - .diffusion = FLUI2D_DEFAULT_DIFFUSION, - .decay = FLUI2D_DEFAULT_DECAY, - .emitters = FLUI2D_DEFAULT_EMITTERS, -}; - - /* gamma correction derived from libs/ray/ray_gamma.[ch] */ static uint8_t gamma_table[1024]; @@ -262,9 +254,6 @@ static til_module_context_t * flui2d_create_context(const til_module_t *module, static int initialized; flui2d_context_t *ctxt; - if (!setup) - setup = &flui2d_default_setup.til_setup; - ctxt = til_module_context_new(module, sizeof(flui2d_context_t), stream, seed, ticks, n_cpus, path); if (!ctxt) return NULL; diff --git a/src/modules/moire/moire.c b/src/modules/moire/moire.c index f7d0f3b..27d48d9 100644 --- a/src/modules/moire/moire.c +++ b/src/modules/moire/moire.c @@ -42,18 +42,10 @@ typedef struct moire_context_t { moire_center_t centers[]; } moire_context_t; -static moire_setup_t moire_default_setup = { - .n_centers = MOIRE_DEFAULT_CENTERS, -}; - - static til_module_context_t * moire_create_context(const til_module_t *module, til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup) { moire_context_t *ctxt; - if (!setup) - setup = &moire_default_setup.til_setup; - ctxt = til_module_context_new(module, sizeof(moire_context_t) + ((moire_setup_t *)setup)->n_centers * sizeof(moire_center_t), stream, seed, ticks, n_cpus, path); if (!ctxt) return NULL; diff --git a/src/modules/pixbounce/pixbounce.c b/src/modules/pixbounce/pixbounce.c index 6f7502c..79826ce 100644 --- a/src/modules/pixbounce/pixbounce.c +++ b/src/modules/pixbounce/pixbounce.c @@ -27,11 +27,6 @@ typedef struct pixbounce_setup_t { pixbounce_pixmaps_t pixmap; } pixbounce_setup_t; -static pixbounce_setup_t pixbounce_default_setup = { - .pixmap_size = DEFAULT_PIXMAP_SIZE, - .pixmap = DEFAULT_PIXMAP -}; - typedef struct pixbounce_pixmap_t { int width, height; int pix_map[34*35]; diff --git a/src/modules/rkt/rkt.c b/src/modules/rkt/rkt.c index 6947fbb..6e5d016 100644 --- a/src/modules/rkt/rkt.c +++ b/src/modules/rkt/rkt.c @@ -46,17 +46,12 @@ typedef struct rkt_setup_t { unsigned short port; } rkt_setup_t; -static rkt_setup_t rkt_default_setup = { .seq_module_name = "compose" }; - static til_module_context_t * rkt_create_context(const til_module_t *module, til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup) { rkt_context_t *ctxt; const til_module_t *seq_module; - if (!setup) - setup = &rkt_default_setup.til_setup; - seq_module = til_lookup_module(((rkt_setup_t *)setup)->seq_module_name); if (!seq_module) return NULL; diff --git a/src/modules/rtv/rtv.c b/src/modules/rtv/rtv.c index 82720b6..b48fa6b 100644 --- a/src/modules/rtv/rtv.c +++ b/src/modules/rtv/rtv.c @@ -72,15 +72,6 @@ static void rtv_render_fragment(til_module_context_t *context, til_stream_t *str static void rtv_finish_frame(til_module_context_t *context, til_stream_t *stream, unsigned ticks, til_fb_fragment_t **fragment_ptr); static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup); -static rtv_setup_t rtv_default_setup = { - .duration = RTV_DURATION_SECS, - .context_duration = RTV_CONTEXT_DURATION_SECS, - .snow_duration = RTV_SNOW_DURATION_SECS, - .caption_duration = RTV_CAPTION_DURATION_SECS, - .snow_module = RTV_DEFAULT_SNOW_MODULE, - .channels = { NULL }, /* NULL == "all" */ -}; - static til_module_t rtv_none_module = {}; til_module_t rtv_module = { @@ -234,9 +225,6 @@ static til_module_context_t * rtv_create_context(const til_module_t *module, til const til_module_t **modules; size_t n_modules, n_channels = 0; - if (!setup) - setup = &rtv_default_setup.til_setup; - til_get_modules(&modules, &n_modules); /* how many modules are in the setup? */ diff --git a/src/modules/shapes/shapes.c b/src/modules/shapes/shapes.c index e0f020a..053e917 100644 --- a/src/modules/shapes/shapes.c +++ b/src/modules/shapes/shapes.c @@ -93,18 +93,10 @@ typedef struct shapes_context_t { } shapes_context_t; -static shapes_setup_t shapes_default_setup = { - .type = SHAPES_DEFAULT_TYPE, -}; - - static til_module_context_t * shapes_create_context(const til_module_t *module, til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup) { shapes_context_t *ctxt; - if (!setup) - setup = &shapes_default_setup.til_setup; - ctxt = til_module_context_new(module, sizeof(shapes_context_t), stream, seed, ticks, n_cpus, path); if (!ctxt) return NULL; diff --git a/src/modules/sparkler/sparkler.c b/src/modules/sparkler/sparkler.c index 50815e9..c071617 100644 --- a/src/modules/sparkler/sparkler.c +++ b/src/modules/sparkler/sparkler.c @@ -33,15 +33,10 @@ typedef struct sparkler_context_t { extern particle_ops_t simple_ops; -static sparkler_setup_t sparkler_default_setup; - static til_module_context_t * sparkler_create_context(const til_module_t *module, til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup) { sparkler_context_t *ctxt; - if (!setup) - setup = &sparkler_default_setup.til_setup; - ctxt = til_module_context_new(module, sizeof(sparkler_context_t), stream, seed, ticks, n_cpus, path); if (!ctxt) return NULL; diff --git a/src/modules/stars/stars.c b/src/modules/stars/stars.c index 8dc18b8..51bb1c9 100644 --- a/src/modules/stars/stars.c +++ b/src/modules/stars/stars.c @@ -60,10 +60,6 @@ typedef struct stars_setup_t { float rot_adj; } stars_setup_t; -static stars_setup_t stars_default_setup = { - .rot_adj = DEFAULT_ROT_ADJ, -}; - float get_random_unit_coord(unsigned *seed) { return (((float)rand_r(seed)/(float)RAND_MAX)*2.0)-1.0; @@ -76,9 +72,6 @@ static til_module_context_t * stars_create_context(const til_module_t *module, t float z; struct points* p_ptr = NULL; - if (!setup) - setup = &stars_default_setup.til_setup; - ctxt = til_module_context_new(module, sizeof(stars_context_t), stream, seed, ticks, n_cpus, path); if (!ctxt) return NULL; diff --git a/src/modules/strobe/strobe.c b/src/modules/strobe/strobe.c index fa245f7..4d56045 100644 --- a/src/modules/strobe/strobe.c +++ b/src/modules/strobe/strobe.c @@ -35,18 +35,10 @@ typedef struct strobe_context_t { } strobe_context_t; -static strobe_setup_t strobe_default_setup = { - .period = STROBE_DEFAULT_PERIOD, -}; - - static til_module_context_t * strobe_create_context(const til_module_t *module, til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, char *path, til_setup_t *setup) { strobe_context_t *ctxt; - if (!setup) - setup = &strobe_default_setup.til_setup; - ctxt = til_module_context_new(module, sizeof(strobe_context_t), stream, seed, ticks, n_cpus, path); if (!ctxt) return NULL; diff --git a/src/modules/submit/submit.c b/src/modules/submit/submit.c index 285ef92..ea0a56d 100644 --- a/src/modules/submit/submit.c +++ b/src/modules/submit/submit.c @@ -64,8 +64,6 @@ typedef struct submit_setup_t { unsigned bilerp:1; } submit_setup_t; -static submit_setup_t submit_default_setup; - /* convert a color into a packed, 32-bit rgb pixel value (taken from libs/ray/ray_color.h) */ static inline uint32_t color_to_uint32(color_t color) { uint32_t pixel; @@ -271,9 +269,6 @@ static til_module_context_t * submit_create_context(const til_module_t *module, { submit_context_t *ctxt; - if (!setup) - setup = &submit_default_setup.til_setup; - ctxt = til_module_context_new(module, sizeof(submit_context_t), stream, seed, ticks, n_cpus, path); if (!ctxt) return NULL; diff --git a/src/modules/swarm/swarm.c b/src/modules/swarm/swarm.c index adb8df8..8883197 100644 --- a/src/modules/swarm/swarm.c +++ b/src/modules/swarm/swarm.c @@ -65,10 +65,6 @@ typedef struct swarm_context_t { #define SWARM_ZCONST 4.f #define SWARM_DEFAULT_STYLE SWARM_DRAW_STYLE_LINES -static swarm_setup_t swarm_default_setup = { - .draw_style = SWARM_DEFAULT_STYLE, -}; - static inline float randf(unsigned *seed, float min, float max) { @@ -185,9 +181,6 @@ static til_module_context_t * swarm_create_context(const til_module_t *module, t { swarm_context_t *ctxt; - if (!setup) - setup = &swarm_default_setup.til_setup; - ctxt = til_module_context_new(module, sizeof(swarm_context_t) + sizeof(*(ctxt->boids)) * SWARM_SIZE, stream, seed, ticks, n_cpus, path); if (!ctxt) return NULL; diff --git a/src/modules/voronoi/voronoi.c b/src/modules/voronoi/voronoi.c index 209310d..56cbe0c 100644 --- a/src/modules/voronoi/voronoi.c +++ b/src/modules/voronoi/voronoi.c @@ -56,13 +56,6 @@ typedef struct voronoi_context_t { #define VORONOI_DEFAULT_RANDOMIZE 0 -static voronoi_setup_t voronoi_default_setup = { - .n_cells = VORONOI_DEFAULT_N_CELLS, - .dirty = VORONOI_DEFAULT_DIRTY, - .randomize = VORONOI_DEFAULT_RANDOMIZE, -}; - - static void voronoi_randomize(voronoi_context_t *ctxt) { float inv_rand_max= 1.f / (float)RAND_MAX; @@ -84,9 +77,6 @@ static til_module_context_t * voronoi_create_context(const til_module_t *module, { voronoi_context_t *ctxt; - if (!setup) - setup = &voronoi_default_setup.til_setup; - ctxt = til_module_context_new(module, sizeof(voronoi_context_t) + ((voronoi_setup_t *)setup)->n_cells * sizeof(voronoi_cell_t), stream, seed, ticks, n_cpus, path); if (!ctxt) return NULL; -- cgit v1.2.3