summaryrefslogtreecommitdiff
path: root/src/modules/moire
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-05-11 12:51:00 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-05-11 15:19:25 -0700
commit0d9aa593e68f33da8ea71a04b930bb6093dbaccb (patch)
tree679fd3c55385e597176b51a7d4b4c297680ad341 /src/modules/moire
parentdede4eca3e2fca76f297b5f5b901434cb99eafb0 (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/moire')
-rw-r--r--src/modules/moire/moire.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/modules/moire/moire.c b/src/modules/moire/moire.c
index 2c992d6..eb4c10b 100644
--- a/src/modules/moire/moire.c
+++ b/src/modules/moire/moire.c
@@ -38,7 +38,7 @@ typedef struct moire_center_t {
typedef struct moire_context_t {
til_module_context_t til_module_context;
- moire_setup_t setup;
+ moire_setup_t *setup;
moire_center_t centers[];
} moire_context_t;
@@ -50,7 +50,7 @@ static til_module_context_t * moire_create_context(const til_module_t *module, t
if (!ctxt)
return NULL;
- ctxt->setup = *(moire_setup_t *)setup;
+ ctxt->setup = (moire_setup_t *)setup;
for (unsigned i = 0; i < ((moire_setup_t *)setup)->n_centers; i++) {
ctxt->centers[i].seed = rand_r(&seed) * (1.f / (float)RAND_MAX) * 2 * M_PI;
@@ -69,7 +69,7 @@ static void moire_prepare_frame(til_module_context_t *context, til_stream_t *str
*res_frame_plan = (til_frame_plan_t){ .fragmenter = til_fragmenter_slice_per_cpu };
- for (unsigned i = 0; i < ctxt->setup.n_centers; i++) {
+ for (unsigned i = 0; i < ctxt->setup->n_centers; i++) {
ctxt->centers[i].x = cosf(ctxt->centers[i].seed + (float)ticks * .001f * ctxt->centers[i].dir);
ctxt->centers[i].y = sinf(ctxt->centers[i].seed + (float)ticks * .001f * ctxt->centers[i].dir);
}
@@ -93,7 +93,7 @@ static void moire_render_fragment(til_module_context_t *context, til_stream_t *s
for (int x = fragment->x; x < fragment->x + fragment->width; x++, cx += xf) {
int filled = 0;
- for (unsigned i = 0; i < ctxt->setup.n_centers; i++) {
+ for (unsigned i = 0; i < ctxt->setup->n_centers; i++) {
float dx, dy;
dx = cx - ctxt->centers[i].x;
© All Rights Reserved