From 9c6575344bbba510836de9a3222d779434cb67f7 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sun, 3 Dec 2023 21:54:58 -0800 Subject: modules/spokes: get rid of spokes_context_t et al This isn't actually needed just for the settings now that til_module_context_t.setup always has a reference to the baked setup, and always gets created even if there's no bespoke context created. --- src/modules/spokes/spokes.c | 39 ++++----------------------------------- 1 file changed, 4 insertions(+), 35 deletions(-) (limited to 'src/modules/spokes') diff --git a/src/modules/spokes/spokes.c b/src/modules/spokes/spokes.c index 2b5fbe3..16e8900 100644 --- a/src/modules/spokes/spokes.c +++ b/src/modules/spokes/spokes.c @@ -16,13 +16,6 @@ #define SPOKES_DEFAULT_TWIST 0.0625 #define SPOKES_DEFAULT_THICKNESS 3 -typedef struct spokes_context_t { - til_module_context_t til_module_context; - int iterations; - float twist; - int thickness; -} spokes_context_t; - typedef struct spokes_setup_t { til_setup_t til_setup; unsigned iterations; @@ -137,10 +130,10 @@ static void spokes_render_fragment(til_module_context_t *context, til_stream_t * int display_R, display_origin_x, display_origin_y; int origin_x, origin_y; - spokes_context_t *ctxt = (spokes_context_t *)context; + spokes_setup_t *s = (spokes_setup_t *)context->setup; /* calculate theta for twist */ - double theta=M_PI*ctxt->twist; + double theta=M_PI*s->twist; /* Based on the fragment's dimensions, calculate the origin and radius of the largest circle that can fully fit in the frame */ @@ -190,43 +183,19 @@ static void spokes_render_fragment(til_module_context_t *context, til_stream_t * perimiter_y=(i-width)+offset%stride; } - spokes_draw_segmented_line(fragment, ctxt->iterations, theta, origin_x, origin_y, perimiter_x, perimiter_y, color, ctxt->thickness); + spokes_draw_segmented_line(fragment, s->iterations, theta, origin_x, origin_y, perimiter_x, perimiter_y, color, s->thickness); /* Calculate and draw the mirror line... */ perimiter_x=abs(perimiter_x-width); perimiter_y=abs(perimiter_y-height); - spokes_draw_segmented_line(fragment, ctxt->iterations, theta, origin_x, origin_y, perimiter_x, perimiter_y, color, ctxt->thickness); + spokes_draw_segmented_line(fragment, s->iterations, theta, origin_x, origin_y, perimiter_x, perimiter_y, color, s->thickness); } } -static til_module_context_t * spokes_create_context(const til_module_t *module, til_stream_t *stream, unsigned seed, unsigned ticks, unsigned n_cpus, til_setup_t *setup) -{ - spokes_context_t *ctxt; - - ctxt = til_module_context_new(module, sizeof(spokes_context_t), stream, seed, ticks, n_cpus, setup); - if (!ctxt) - return NULL; - ctxt->iterations = ((spokes_setup_t *)setup)->iterations; - ctxt->twist = ((spokes_setup_t *)setup)->twist; - ctxt->thickness = ((spokes_setup_t *)setup)->thickness; - return &ctxt->til_module_context; - -} - - -static void spokes_destroy_context(til_module_context_t *context) -{ - free(context); - -} - - int spokes_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup); til_module_t spokes_module = { - .create_context = spokes_create_context, - .destroy_context = spokes_destroy_context, .render_fragment = spokes_render_fragment, .setup = spokes_setup, .name = "spokes", -- cgit v1.2.3