diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/font.c | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/firmware/font.c b/firmware/font.c index dfc8abacb7..577fb8af81 100644 --- a/firmware/font.c +++ b/firmware/font.c | |||
@@ -77,7 +77,7 @@ extern struct font sysfont; | |||
77 | 77 | ||
78 | struct buflib_alloc_data { | 78 | struct buflib_alloc_data { |
79 | struct font font; | 79 | struct font font; |
80 | bool handle_locked; /* is the buflib handle currently locked? */ | 80 | int handle_locks; /* is the buflib handle currently locked? */ |
81 | int refcount; /* how many times has this font been loaded? */ | 81 | int refcount; /* how many times has this font been loaded? */ |
82 | unsigned char buffer[]; | 82 | unsigned char buffer[]; |
83 | }; | 83 | }; |
@@ -90,7 +90,7 @@ static int buflibmove_callback(int handle, void* current, void* new) | |||
90 | struct buflib_alloc_data *alloc = (struct buflib_alloc_data*)current; | 90 | struct buflib_alloc_data *alloc = (struct buflib_alloc_data*)current; |
91 | ptrdiff_t diff = new - current; | 91 | ptrdiff_t diff = new - current; |
92 | 92 | ||
93 | if (alloc->handle_locked) | 93 | if (alloc->handle_locks > 0) |
94 | return BUFLIB_CB_CANNOT_MOVE; | 94 | return BUFLIB_CB_CANNOT_MOVE; |
95 | 95 | ||
96 | #define UPDATE(x) if (x) { x = PTR_ADD(x, diff); } | 96 | #define UPDATE(x) if (x) { x = PTR_ADD(x, diff); } |
@@ -111,7 +111,10 @@ static int buflibmove_callback(int handle, void* current, void* new) | |||
111 | static void lock_font_handle(int handle, bool lock) | 111 | static void lock_font_handle(int handle, bool lock) |
112 | { | 112 | { |
113 | struct buflib_alloc_data *alloc = core_get_data(handle); | 113 | struct buflib_alloc_data *alloc = core_get_data(handle); |
114 | alloc->handle_locked = lock; | 114 | if ( lock ) |
115 | alloc->handle_locks++; | ||
116 | else | ||
117 | alloc->handle_locks--; | ||
115 | } | 118 | } |
116 | 119 | ||
117 | static struct buflib_callbacks buflibops = {buflibmove_callback, NULL }; | 120 | static struct buflib_callbacks buflibops = {buflibmove_callback, NULL }; |
@@ -342,15 +345,6 @@ static struct font* font_load_cached(struct font* pf) | |||
342 | return pf; | 345 | return pf; |
343 | } | 346 | } |
344 | 347 | ||
345 | static void font_reset(int font_id) | ||
346 | { | ||
347 | struct font *pf = pf_from_handle(buflib_allocations[font_id]); | ||
348 | // fixme | ||
349 | memset(pf, 0, sizeof(struct font)); | ||
350 | pf->fd = -1; | ||
351 | } | ||
352 | |||
353 | |||
354 | static bool internal_load_font(int font_id, const char *path, | 348 | static bool internal_load_font(int font_id, const char *path, |
355 | char *buf, size_t buf_size, | 349 | char *buf, size_t buf_size, |
356 | int handle | 350 | int handle |
@@ -358,13 +352,6 @@ static bool internal_load_font(int font_id, const char *path, | |||
358 | { | 352 | { |
359 | size_t size; | 353 | size_t size; |
360 | struct font* pf = pf_from_handle(handle); | 354 | struct font* pf = pf_from_handle(handle); |
361 | /* save loaded glyphs */ | ||
362 | glyph_cache_save(pf); | ||
363 | /* Close font file handle */ | ||
364 | if (pf->fd >= 0) | ||
365 | close(pf->fd); | ||
366 | |||
367 | font_reset(font_id); | ||
368 | 355 | ||
369 | /* open and read entire font file*/ | 356 | /* open and read entire font file*/ |
370 | pf->fd = open(path, O_RDONLY|O_BINARY); | 357 | pf->fd = open(path, O_RDONLY|O_BINARY); |
@@ -455,8 +442,7 @@ static int alloc_and_init(int font_idx, const char* name, size_t size) | |||
455 | return handle; | 442 | return handle; |
456 | pdata = core_get_data(handle); | 443 | pdata = core_get_data(handle); |
457 | pf = &pdata->font; | 444 | pf = &pdata->font; |
458 | font_reset(font_idx); | 445 | pdata->handle_locks = 0; |
459 | pdata->handle_locked = false; | ||
460 | pdata->refcount = 1; | 446 | pdata->refcount = 1; |
461 | pf->buffer_position = pf->buffer_start = buffer_from_handle(handle); | 447 | pf->buffer_position = pf->buffer_start = buffer_from_handle(handle); |
462 | pf->buffer_size = size; | 448 | pf->buffer_size = size; |