diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2019-11-24 16:58:20 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2019-11-24 16:58:20 -0800 |
commit | 0b2f0d406657515559c697533f5e27cf05437507 (patch) | |
tree | 7de9c2e87cfc254f9cdac14c6e302c8ccadf62b5 /src/modules | |
parent | 5ba170c7696e6ae1937724eca7e11ce1553ab3cd (diff) |
montage: rework module skipping
The old approach was just to get things working, it's preferable
to not have empty tiles on-screen where modules were skipped and
have all tiles be smaller to accomodate vacancies.
Now the modules list gets pruned @ context create, so the skipping
only happens once and everywhere else is looking at a modules list
and count of only the keepers.
I also added stars to the skipped modules, for now, since both stars
and pixbounce malfunction when the fragment size changes.
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/montage/montage.c | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/src/modules/montage/montage.c b/src/modules/montage/montage.c index ce2caf9..697c28d 100644 --- a/src/modules/montage/montage.c +++ b/src/modules/montage/montage.c @@ -11,8 +11,6 @@ typedef struct montage_context_t { const rototiller_module_t **modules; - const rototiller_module_t *rtv_module; - const rototiller_module_t *pixbounce_module; void **contexts; size_t n_modules; unsigned n_cpus; @@ -37,30 +35,42 @@ rototiller_module_t montage_module = { }; -static int skip_module(montage_context_t *ctxt, const rototiller_module_t *module) +static void * montage_create_context(unsigned num_cpus) { - /* prevent recursion */ - if (module == &montage_module) - return 1; + const rototiller_module_t **modules, *rtv_module, *pixbounce_module, *stars_module; + size_t n_modules; + montage_context_t *ctxt; - /* also prevents recursion, as rtv could run montage... */ - if (module == ctxt->rtv_module) - return 1; + ctxt = calloc(1, sizeof(montage_context_t)); + if (!ctxt) + return NULL; - /* pixbounce is broken */ - if (module == ctxt->pixbounce_module) - return 1; + rototiller_get_modules(&modules, &n_modules); - return 0; -} + ctxt->modules = calloc(n_modules, sizeof(rototiller_module_t *)); + if (!ctxt->modules) { + free(ctxt); + return NULL; + } -static void * montage_create_context(unsigned num_cpus) -{ - montage_context_t *ctxt = calloc(1, sizeof(montage_context_t)); + rtv_module = rototiller_lookup_module("rtv"); + pixbounce_module = rototiller_lookup_module("pixbounce"); + stars_module = rototiller_lookup_module("stars"); + + for (size_t i = 0; i < n_modules; i++) { + const rototiller_module_t *module = modules[i]; + + if (module == &montage_module || /* prevents recursion */ + module == rtv_module || /* also prevents recursion, rtv can run montage */ + module == pixbounce_module || /* temporarily broken in montage */ + module == stars_module) /* temporarily broken in montage */ + continue; + + ctxt->modules[ctxt->n_modules++] = module; + } ctxt->n_cpus = num_cpus; - rototiller_get_modules(&ctxt->modules, &ctxt->n_modules); ctxt->contexts = calloc(ctxt->n_modules, sizeof(void *)); if (!ctxt->contexts) { @@ -69,15 +79,9 @@ static void * montage_create_context(unsigned num_cpus) return NULL; } - ctxt->rtv_module = rototiller_lookup_module("rtv"); - ctxt->pixbounce_module = rototiller_lookup_module("pixbounce"); - - for (int i = 0; i < ctxt->n_modules; i++) { + for (size_t i = 0; i < ctxt->n_modules; i++) { const rototiller_module_t *module = ctxt->modules[i]; - if (skip_module(ctxt, module)) - continue; - if (module->create_context) /* FIXME errors */ ctxt->contexts[i] = module->create_context(num_cpus); } @@ -93,16 +97,15 @@ static void montage_destroy_context(void *context) for (int i = 0; i < ctxt->n_modules; i++) { const rototiller_module_t *module = ctxt->modules[i]; - if (skip_module(ctxt, module)) - continue; - if (!ctxt->contexts[i]) continue; module->destroy_context(ctxt->contexts[i]); } - free(context); + free(ctxt->contexts); + free(ctxt->modules); + free(ctxt); } @@ -143,8 +146,7 @@ static void montage_render_fragment(void *context, unsigned cpu, fb_fragment_t * montage_context_t *ctxt = context; const rototiller_module_t *module = ctxt->modules[fragment->number]; - if (skip_module(ctxt,module) || - fragment->number >= ctxt->n_modules) { + if (fragment->number >= ctxt->n_modules) { fb_fragment_zero(fragment); |