diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-05-11 12:51:00 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-05-11 15:19:25 -0700 |
commit | 0d9aa593e68f33da8ea71a04b930bb6093dbaccb (patch) | |
tree | 679fd3c55385e597176b51a7d4b4c297680ad341 /src/modules/blinds | |
parent | dede4eca3e2fca76f297b5f5b901434cb99eafb0 (diff) |
modules/*: stop storing setup by value in contexts
With setup refcounting and a reference bound to the context, we
should just dereference the single instance. The way setups are
used it just as a read-only thing to affect context behavior...
Note I've left the module-type-specific setup pointer despite it
duplicating the setup pointer in the module_context. This is
just a convenience thing so the accessors don't have to cast the
general til_setup_t* to my_module_setup_t* everywhere.
Diffstat (limited to 'src/modules/blinds')
-rw-r--r-- | src/modules/blinds/blinds.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/modules/blinds/blinds.c b/src/modules/blinds/blinds.c index 12de39f..0494cd1 100644 --- a/src/modules/blinds/blinds.c +++ b/src/modules/blinds/blinds.c @@ -38,7 +38,7 @@ typedef struct blinds_context_t { } vars; float *t, *step, *count; - blinds_setup_t setup; + blinds_setup_t *setup; } blinds_context_t; @@ -54,7 +54,7 @@ static til_module_context_t * blinds_create_context(const til_module_t *module, ctxt->taps.step = til_tap_init_float(ctxt, &ctxt->step, 1, &ctxt->vars.step, "step"); ctxt->taps.count = til_tap_init_float(ctxt, &ctxt->count, 1, &ctxt->vars.count, "count"); - ctxt->setup = *(blinds_setup_t *)setup; + ctxt->setup = (blinds_setup_t *)setup; return &ctxt->til_module_context; } @@ -104,17 +104,17 @@ static void blinds_render_fragment(til_module_context_t *context, til_stream_t * *ctxt->step = .1f; if (!til_stream_tap_context(stream, context, NULL, &ctxt->taps.count)) - *ctxt->count = ctxt->setup.count; + *ctxt->count = ctxt->setup->count; til_fb_fragment_clear(fragment); for (t = *ctxt->t, blind = 0; blind < (unsigned)*ctxt->count; blind++, t += *ctxt->step) { - switch (ctxt->setup.orientation) { + switch (ctxt->setup->orientation) { case BLINDS_ORIENTATION_HORIZONTAL: - draw_blind_horizontal(fragment, blind, ctxt->setup.count, 1.f - fabsf(cosf(t))); + draw_blind_horizontal(fragment, blind, ctxt->setup->count, 1.f - fabsf(cosf(t))); break; case BLINDS_ORIENTATION_VERTICAL: - draw_blind_vertical(fragment, blind, ctxt->setup.count, 1.f - fabsf(cosf(t))); + draw_blind_vertical(fragment, blind, ctxt->setup->count, 1.f - fabsf(cosf(t))); break; } } |