mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-01 01:40:13 -05:00
wip: initial multithreaded renderer
This commit is contained in:
parent
d1b88f67e4
commit
c531795b83
8 changed files with 287 additions and 89 deletions
31
config.c
31
config.c
|
|
@ -107,26 +107,28 @@ get_config_path(void)
|
|||
}
|
||||
|
||||
static bool
|
||||
str_to_color(const char *s, uint32_t *color, const char *path, int lineno)
|
||||
str_to_ulong(const char *s, int base, unsigned long *res)
|
||||
{
|
||||
if (s == NULL)
|
||||
return false;
|
||||
|
||||
errno = 0;
|
||||
char *end = NULL;
|
||||
unsigned long res = strtoul(s, &end, 16);
|
||||
|
||||
if (errno != 0) {
|
||||
*res = strtoul(s, &end, base);
|
||||
return errno == 0 && *end == '\0';
|
||||
}
|
||||
|
||||
static bool
|
||||
str_to_color(const char *s, uint32_t *color, const char *path, int lineno)
|
||||
{
|
||||
unsigned long value;
|
||||
if (!str_to_ulong(s, 16, &value)) {
|
||||
LOG_ERRNO("%s:%d: invalid color: %s", path, lineno, s);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (*end != '\0') {
|
||||
LOG_ERR("%s:%d: invalid color: %s", path, lineno, s);
|
||||
return false;
|
||||
}
|
||||
|
||||
*color = res & 0xffffff;
|
||||
*color = value & 0xffffff;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -149,6 +151,15 @@ parse_section_main(const char *key, const char *value, struct config *conf,
|
|||
conf->font = strdup(value);
|
||||
}
|
||||
|
||||
else if (strcmp(key, "workers") == 0) {
|
||||
unsigned long count;
|
||||
if (!str_to_ulong(value, 10, &count)) {
|
||||
LOG_ERR("%s:%d: expected an integer: %s", path, lineno, value);
|
||||
return false;
|
||||
}
|
||||
conf->render_worker_count = count;
|
||||
}
|
||||
|
||||
else {
|
||||
LOG_WARN("%s:%u: invalid key: %s", path, lineno, key);
|
||||
return false;
|
||||
|
|
@ -427,6 +438,8 @@ config_load(struct config *conf)
|
|||
.cursor = 0,
|
||||
},
|
||||
},
|
||||
|
||||
.render_worker_count = sysconf(_SC_NPROCESSORS_ONLN),
|
||||
};
|
||||
|
||||
char *path = get_config_path();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue