summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2022-05-01 10:46:32 -0700
committerVito Caputo <vcaputo@pengaru.com>2022-05-01 13:50:28 -0700
commit4c81b4d185eddba20b514cebd8b0afd6567f603a (patch)
treef7f4e0927e0cea57a8a32a77af1ddae65838106f /src
parenta81425632db81527bcecd2d0fbdb5b09c25141ba (diff)
til: introduce "blank" built-in module
rtv special-cased handling a nil module to mean clear the fragment, and called this "none" But it really makes more sense for rtv to treat "none" as not doing anything at all for its snow_module - not even blanking. And it would be nice to have a consistent way to express a blank module throughout rototiller, so this introduces a concept of built-in modules accessible only via explicit lookup by name which don't get enumerated via til_get_modules(), as they're inherently uninteresting more utility-oriented modules for use by other modules. For now it's only "blank" that constitutes the built-ins list, but expanding this is only a matter of introducing more modules there. Future commits will rework rtv to use "blank" in place of its current "none", and rtv's "none" will be reworked to represent no snow mechanism at all, obviating the need to specify snow_duration=0,snow_module=none required today.
Diffstat (limited to 'src')
-rw-r--r--src/til.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/src/til.c b/src/til.c
index ce880b3..08a574c 100644
--- a/src/til.c
+++ b/src/til.c
@@ -103,13 +103,52 @@ void til_shutdown(void)
}
+static void _blank_prepare_frame(void *context, unsigned ticks, unsigned n_cpus, til_fb_fragment_t *fragment, til_fragmenter_t *res_fragmenter)
+{
+ *res_fragmenter = til_fragmenter_slice_per_cpu;
+}
+
+
+static void _blank_render_fragment(void *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment)
+{
+ til_fb_fragment_clear(fragment);
+}
+
+
+static til_module_t _blank_module = {
+ .prepare_frame = _blank_prepare_frame,
+ .render_fragment = _blank_render_fragment,
+ .name = "blank",
+ .description = "built-in blanker",
+ .author = "built-in",
+};
+
+
const til_module_t * til_lookup_module(const char *name)
{
+ static const til_module_t *builtins[] = {
+ &_blank_module,
+ };
+ static struct {
+ const til_module_t **modules;
+ size_t n_modules;
+ } module_lists[] = {
+ {
+ builtins,
+ nelems(builtins),
+ },
+ { modules,
+ nelems(modules),
+ }
+ };
+
assert(name);
- for (size_t i = 0; i < nelems(modules); i++) {
- if (!strcasecmp(name, modules[i]->name))
- return modules[i];
+ for (size_t n = 0; n < nelems(module_lists); n++) {
+ for (size_t i = 0; i < module_lists[n].n_modules; i++) {
+ if (!strcasecmp(name, module_lists[n].modules[i]->name))
+ return module_lists[n].modules[i];
+ }
}
return NULL;
© All Rights Reserved