[theme] remove ax__theme_load(), put it in ax__theme_builder_finish()
This commit is contained in:
parent
d78b6cc828
commit
7b2c1f0e07
|
@ -109,20 +109,26 @@ void ax_begin_theme(struct ax_ctxt* ax)
|
||||||
|
|
||||||
struct ax_theme* ax_end_theme(struct ax_ctxt* ax)
|
struct ax_theme* ax_end_theme(struct ax_ctxt* ax)
|
||||||
{
|
{
|
||||||
ASSERT(ax->thmb != NULL, "`ax_end_theme' called while not building a theme");
|
if (ax->thmb == NULL) {
|
||||||
|
ax_log(ax, "`ax_end_theme' called while not building a theme");
|
||||||
struct ax_theme* thm = ax__theme_builder_finish(ax->thmb, ax->init_rgn);
|
return NULL;
|
||||||
|
}
|
||||||
|
struct ax_theme* thm = ax__theme_builder_finish(
|
||||||
|
ax->thmb,
|
||||||
|
ax->init_rgn,
|
||||||
|
ax__backend_msgq(ax->bac));
|
||||||
ax->thmb = NULL;
|
ax->thmb = NULL;
|
||||||
rgn_clear(ax->thmb_rgn);
|
rgn_clear(ax->thmb_rgn);
|
||||||
|
|
||||||
ax__theme_load(thm, ax__backend_msgq(ax->bac));
|
|
||||||
return thm;
|
return thm;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ax_set_theme_color(
|
void ax_set_theme_color(
|
||||||
struct ax_ctxt* ax, const char* cat_name, int64_t rgb)
|
struct ax_ctxt* ax, const char* cat_name, int64_t rgb)
|
||||||
{
|
{
|
||||||
ASSERT(ax->thmb != NULL, "`ax_set_theme_color' called while not building a theme");
|
if (ax->thmb == NULL) {
|
||||||
|
ax_log(ax, "`ax_set_theme_color' called while not building a theme");
|
||||||
|
return;
|
||||||
|
}
|
||||||
enum ax_color_cat cat;
|
enum ax_color_cat cat;
|
||||||
if (ax__string_to_color_cat(cat_name, &cat) != 0) {
|
if (ax__string_to_color_cat(cat_name, &cat) != 0) {
|
||||||
ax->thmb->err =
|
ax->thmb->err =
|
||||||
|
@ -135,7 +141,10 @@ void ax_set_theme_color(
|
||||||
void ax_set_theme_font(
|
void ax_set_theme_font(
|
||||||
struct ax_ctxt* ax, const char* cat_name, const char* fnt_path, size_t fnt_size)
|
struct ax_ctxt* ax, const char* cat_name, const char* fnt_path, size_t fnt_size)
|
||||||
{
|
{
|
||||||
ASSERT(ax->thmb != NULL, "`ax_set_theme_font' called while not building a theme");
|
if (ax->thmb == NULL) {
|
||||||
|
ax_log(ax, "`ax_set_theme_font' called while not building a theme");
|
||||||
|
return;
|
||||||
|
}
|
||||||
enum ax_font_cat cat;
|
enum ax_font_cat cat;
|
||||||
if (ax__string_to_font_cat(cat_name, &cat) != 0) {
|
if (ax__string_to_font_cat(cat_name, &cat) != 0) {
|
||||||
ax->thmb->err =
|
ax->thmb->err =
|
||||||
|
@ -148,7 +157,10 @@ void ax_set_theme_font(
|
||||||
void ax_set_theme_iconset(
|
void ax_set_theme_iconset(
|
||||||
struct ax_ctxt* ax, const char* iconset_dir)
|
struct ax_ctxt* ax, const char* iconset_dir)
|
||||||
{
|
{
|
||||||
ASSERT(ax->thmb != NULL, "`ax_set_theme_iconset' called while not building a theme");
|
if (ax->thmb == NULL) {
|
||||||
|
ax_log(ax, "`ax_set_theme_iconset' called while not building a theme");
|
||||||
|
return;
|
||||||
|
}
|
||||||
UNIMPLEMENTED();
|
UNIMPLEMENTED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +171,10 @@ void ax_theme_wait_until_loaded(struct ax_ctxt* ax, struct ax_theme* thm)
|
||||||
struct msgq* mq = msgq_new(rgn);
|
struct msgq* mq = msgq_new(rgn);
|
||||||
ax__theme_on_load(thm, mq);
|
ax__theme_on_load(thm, mq);
|
||||||
msgq_begin_recv_and_wait(mq);
|
msgq_begin_recv_and_wait(mq);
|
||||||
MSGQ_RECV_ALL(mq) {}
|
MSGQ_RECV_ALL(mq) {
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
msgq_end_recv(mq);
|
msgq_end_recv(mq);
|
||||||
rgn_cleanup(rgn);
|
rgn_cleanup(rgn);
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,8 @@ void ax__theme_set_font(
|
||||||
|
|
||||||
struct ax_theme* ax__theme_builder_finish(
|
struct ax_theme* ax__theme_builder_finish(
|
||||||
struct ax_theme_builder* thmb,
|
struct ax_theme_builder* thmb,
|
||||||
struct rgn* dst_rgn)
|
struct rgn* dst_rgn,
|
||||||
|
struct msgq* req_to_load_mq)
|
||||||
{
|
{
|
||||||
struct ax_theme* thm = ralloc_typed(dst_rgn, struct ax_theme, 1);
|
struct ax_theme* thm = ralloc_typed(dst_rgn, struct ax_theme, 1);
|
||||||
if (thmb->err != NULL) {
|
if (thmb->err != NULL) {
|
||||||
|
@ -99,6 +100,15 @@ struct ax_theme* ax__theme_builder_finish(
|
||||||
thm->on_load = NULL;
|
thm->on_load = NULL;
|
||||||
pthread_mutex_init(&thm->mx, NULL);
|
pthread_mutex_init(&thm->mx, NULL);
|
||||||
rgn_pin(dst_rgn, thm, (void*) pthread_mutex_destroy);
|
rgn_pin(dst_rgn, thm, (void*) pthread_mutex_destroy);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < AX_FONT__COUNT; i++) {
|
||||||
|
struct ax_msg_load_font* m =
|
||||||
|
msgq_begin_send_typed(req_to_load_mq, ax_msg_load_font);
|
||||||
|
m->theme = thm;
|
||||||
|
m->category = i;
|
||||||
|
msgq_end_send(req_to_load_mq);
|
||||||
|
}
|
||||||
|
|
||||||
return thm;
|
return thm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,16 +167,6 @@ void ax__theme_set_font_handle(
|
||||||
pthread_mutex_unlock(&thm->mx);
|
pthread_mutex_unlock(&thm->mx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ax__theme_load(struct ax_theme* thm, struct msgq* req_mq)
|
|
||||||
{
|
|
||||||
for (size_t i = 0; i < AX_FONT__COUNT; i++) {
|
|
||||||
struct ax_msg_load_font* m = msgq_begin_send_typed(req_mq, ax_msg_load_font);
|
|
||||||
m->theme = thm;
|
|
||||||
m->category = i;
|
|
||||||
msgq_end_send(req_mq);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ax__theme_on_load(struct ax_theme* thm, struct msgq* res_mq)
|
void ax__theme_on_load(struct ax_theme* thm, struct msgq* res_mq)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&thm->mx);
|
pthread_mutex_lock(&thm->mx);
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
struct rgn;
|
struct rgn;
|
||||||
struct msgq;
|
struct msgq;
|
||||||
struct msgq_list;
|
struct msgq_list;
|
||||||
|
struct ax_font_h;
|
||||||
|
|
||||||
#define THEME_BUILDER_DESIRED_REGION_SIZE (16*1024)
|
#define THEME_BUILDER_DESIRED_REGION_SIZE (16*1024)
|
||||||
|
|
||||||
|
@ -36,8 +37,6 @@ enum ax_font_cat {
|
||||||
AX_FONT__DEFAULT,
|
AX_FONT__DEFAULT,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ax_font_h; // defined by backend
|
|
||||||
|
|
||||||
struct ax_theme {
|
struct ax_theme {
|
||||||
const char* err;
|
const char* err;
|
||||||
int64_t color[AX_COLOR__COUNT];
|
int64_t color[AX_COLOR__COUNT];
|
||||||
|
@ -75,7 +74,8 @@ void ax__theme_set_font(
|
||||||
|
|
||||||
struct ax_theme* ax__theme_builder_finish(
|
struct ax_theme* ax__theme_builder_finish(
|
||||||
struct ax_theme_builder* thmb,
|
struct ax_theme_builder* thmb,
|
||||||
struct rgn* dst_rgn);
|
struct rgn* dst_rgn,
|
||||||
|
struct msgq* req_to_load_mq);
|
||||||
|
|
||||||
static inline int64_t ax__theme_color(
|
static inline int64_t ax__theme_color(
|
||||||
struct ax_theme* thm,
|
struct ax_theme* thm,
|
||||||
|
@ -107,10 +107,6 @@ void ax__theme_set_font_handle(
|
||||||
enum ax_font_cat i,
|
enum ax_font_cat i,
|
||||||
struct ax_font_h* h);
|
struct ax_font_h* h);
|
||||||
|
|
||||||
void ax__theme_load(
|
|
||||||
struct ax_theme* thm,
|
|
||||||
struct msgq* req_mq);
|
|
||||||
|
|
||||||
void ax__theme_on_load(
|
void ax__theme_on_load(
|
||||||
struct ax_theme* thm,
|
struct ax_theme* thm,
|
||||||
struct msgq* res_mq);
|
struct msgq* res_mq);
|
||||||
|
|
Loading…
Reference in New Issue