[backend] tell the backend to load fonts

This commit is contained in:
Milo Turner 2020-02-19 13:12:00 -05:00
parent 0a07bac2e7
commit d61f9cc537
4 changed files with 27 additions and 8 deletions

View File

@ -99,6 +99,7 @@ void ax_end_theme(struct ax_ctxt* ax, struct ax_theme** out_thm)
ASSERT(ax->thmb != NULL, "`ax_end_theme' called while not building a theme"); ASSERT(ax->thmb != NULL, "`ax_end_theme' called while not building a theme");
struct ax_theme* thm; struct ax_theme* thm;
ax__theme_builder_finish(ax->thmb, ax->init_rgn, &thm); ax__theme_builder_finish(ax->thmb, ax->init_rgn, &thm);
ax__theme_request_load(thm, ax__backend_msgq(ax->bac));
rgn_clear(&ax->thmb_rgn); rgn_clear(&ax->thmb_rgn);
if (out_thm != NULL) { if (out_thm != NULL) {
*out_thm = thm; *out_thm = thm;

View File

@ -1,6 +1,8 @@
#include "theme.h" #include "theme.h"
#include "../util.h" #include "../util.h"
#include "../util/region.h" #include "../util/region.h"
#include "../backend.h"
#include "../concurrent/msgq.h"
#include <inttypes.h> #include <inttypes.h>
static const char* default_font_path(struct rgn* rgn) static const char* default_font_path(struct rgn* rgn)
@ -115,6 +117,16 @@ void ax__theme_builder_finish(
} }
} }
void ax__theme_request_load(struct ax_theme* thm, struct msgq* mq)
{
for (size_t i = 0; i < AX_FONT__COUNT; i++) {
struct ax_msg_load_font* m = msgq_begin_send_typed(mq, ax_msg_load_font);
m->theme = thm;
m->category = i;
msgq_end_send(mq);
}
}
int ax__string_to_color_cat(const char* str, enum ax_color_cat* out_cat) int ax__string_to_color_cat(const char* str, enum ax_color_cat* out_cat)
{ {
enum ax_color_cat val; enum ax_color_cat val;

View File

@ -4,6 +4,8 @@
#include <stddef.h> #include <stddef.h>
struct rgn; struct rgn;
struct msgq;
#define THEME_BUILDER_DESIRED_REGION_SIZE (16*1024) #define THEME_BUILDER_DESIRED_REGION_SIZE (16*1024)
enum ax_color_cat { enum ax_color_cat {
@ -69,6 +71,10 @@ void ax__theme_builder_finish(
struct rgn* dst_rgn, struct rgn* dst_rgn,
struct ax_theme** out_thm); struct ax_theme** out_thm);
void ax__theme_request_load(
struct ax_theme* thm,
struct msgq* mq);
static inline int64_t ax__theme_color( static inline int64_t ax__theme_color(
struct ax_theme* thm, struct ax_theme* thm,
enum ax_color_cat i) enum ax_color_cat i)

View File

@ -1,6 +1,7 @@
#include <stdio.h> #include <stdio.h>
#include "../src/ax.h" #include "../src/ax.h"
#include "../src/ctxt/theme.h" #include "../src/ctxt.h"
#include "../src/backend.h"
int main(void) int main(void)
@ -8,7 +9,7 @@ int main(void)
struct ax_ctxt* ax = ax_new(); struct ax_ctxt* ax = ax_new();
ax_set_logger(ax, 0, false); ax_set_logger(ax, 0, false);
int rv; int rv = 0;
#define GUARD(f, ...) if ((rv = f(__VA_ARGS__)) != 0) goto cleanup #define GUARD(f, ...) if ((rv = f(__VA_ARGS__)) != 0) goto cleanup
ax_begin_theme(ax); ax_begin_theme(ax);
@ -19,14 +20,13 @@ int main(void)
struct ax_theme* thm; struct ax_theme* thm;
ax_end_theme(ax, &thm); ax_end_theme(ax, &thm);
ax_log(ax, "got here"); ax_log(ax, "Got here\n");
if ((rv = ax_select_theme(ax, thm)) != 0) { bool shutdown = false;
goto cleanup; ax__backend_wait_for_event(ax->bac);
} ax__backend_step(ax->bac, &shutdown);
ax__debug_theme(thm);
cleanup: //cleanup:
if (rv != 0) { if (rv != 0) {
printf("error: %s\n", ax_get_error(ax)); printf("error: %s\n", ax_get_error(ax));
} }