From d61f9cc53728e5a9230a5c3fb4f60c4468e7e612 Mon Sep 17 00:00:00 2001 From: Milo Turner Date: Wed, 19 Feb 2020 13:12:00 -0500 Subject: [PATCH] [backend] tell the backend to load fonts --- src/ctxt/ctxt.c | 1 + src/ctxt/theme.c | 12 ++++++++++++ src/ctxt/theme.h | 6 ++++++ test/main.c | 16 ++++++++-------- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/ctxt/ctxt.c b/src/ctxt/ctxt.c index d368843..6a27dce 100644 --- a/src/ctxt/ctxt.c +++ b/src/ctxt/ctxt.c @@ -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"); struct ax_theme* 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); if (out_thm != NULL) { *out_thm = thm; diff --git a/src/ctxt/theme.c b/src/ctxt/theme.c index ddd6b1b..ca93c6f 100644 --- a/src/ctxt/theme.c +++ b/src/ctxt/theme.c @@ -1,6 +1,8 @@ #include "theme.h" #include "../util.h" #include "../util/region.h" +#include "../backend.h" +#include "../concurrent/msgq.h" #include 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) { enum ax_color_cat val; diff --git a/src/ctxt/theme.h b/src/ctxt/theme.h index 541c88c..6baed57 100644 --- a/src/ctxt/theme.h +++ b/src/ctxt/theme.h @@ -4,6 +4,8 @@ #include struct rgn; +struct msgq; + #define THEME_BUILDER_DESIRED_REGION_SIZE (16*1024) enum ax_color_cat { @@ -69,6 +71,10 @@ void ax__theme_builder_finish( struct rgn* dst_rgn, struct ax_theme** out_thm); +void ax__theme_request_load( + struct ax_theme* thm, + struct msgq* mq); + static inline int64_t ax__theme_color( struct ax_theme* thm, enum ax_color_cat i) diff --git a/test/main.c b/test/main.c index 8560fa6..1961e58 100644 --- a/test/main.c +++ b/test/main.c @@ -1,6 +1,7 @@ #include #include "../src/ax.h" -#include "../src/ctxt/theme.h" +#include "../src/ctxt.h" +#include "../src/backend.h" int main(void) @@ -8,7 +9,7 @@ int main(void) struct ax_ctxt* ax = ax_new(); ax_set_logger(ax, 0, false); - int rv; + int rv = 0; #define GUARD(f, ...) if ((rv = f(__VA_ARGS__)) != 0) goto cleanup ax_begin_theme(ax); @@ -19,14 +20,13 @@ int main(void) struct ax_theme* 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) { - goto cleanup; - } - ax__debug_theme(thm); + bool shutdown = false; + ax__backend_wait_for_event(ax->bac); + ax__backend_step(ax->bac, &shutdown); -cleanup: +//cleanup: if (rv != 0) { printf("error: %s\n", ax_get_error(ax)); }