1
0
Fork 0
forked from len0rd/rockbox

Provide font_lock(). Font_get_bits() or ..width() may have to read glyph cache misses from disk so provide a means to lock the buflib memory during the wait.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30814 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Fred Bauer 2011-10-21 18:05:52 +00:00
parent d228d4d130
commit 04a015dde0
3 changed files with 13 additions and 0 deletions

View file

@ -101,6 +101,7 @@ void LCDFN(fill_viewport)(void)
static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
{ {
unsigned short *ucs; unsigned short *ucs;
font_lock(current_vp->font, true);
struct font* pf = font_get(current_vp->font); struct font* pf = font_get(current_vp->font);
int vp_flags = current_vp->flags; int vp_flags = current_vp->flags;
int rtl_next_non_diac_width, last_non_diacritic_width; int rtl_next_non_diac_width, last_non_diacritic_width;
@ -233,6 +234,7 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
} }
} }
} }
font_lock(current_vp->font, false);
} }
/* put a string at a given pixel position */ /* put a string at a given pixel position */

View file

@ -123,6 +123,7 @@ int font_load_ex(const char *path, size_t buffer_size);
int font_glyphs_to_bufsize(const char *path, int glyphs); int font_glyphs_to_bufsize(const char *path, int glyphs);
void font_unload(int font_id); void font_unload(int font_id);
void font_unload_all(void); void font_unload_all(void);
void font_lock(int font_id, bool lock);
struct font* font_get(int font); struct font* font_get(int font);

View file

@ -124,6 +124,14 @@ static void lock_font_handle(int handle, bool lock)
alloc->handle_locks--; alloc->handle_locks--;
} }
void font_lock(int font_id, bool lock)
{
if( font_id == FONT_SYSFIXED )
return;
if( buflib_allocations[font_id] >= 0 )
lock_font_handle(buflib_allocations[font_id], lock);
}
static struct buflib_callbacks buflibops = {buflibmove_callback, NULL }; static struct buflib_callbacks buflibops = {buflibmove_callback, NULL };
static inline struct font *pf_from_handle(int handle) static inline struct font *pf_from_handle(int handle)
@ -1007,6 +1015,7 @@ int font_getstringsize(const unsigned char *str, int *w, int *h, int fontnumber)
unsigned short ch; unsigned short ch;
int width = 0; int width = 0;
font_lock( fontnumber, true );
for (str = utf8decode(str, &ch); ch != 0 ; str = utf8decode(str, &ch)) for (str = utf8decode(str, &ch); ch != 0 ; str = utf8decode(str, &ch))
{ {
if (is_diacritic(ch, NULL)) if (is_diacritic(ch, NULL))
@ -1019,6 +1028,7 @@ int font_getstringsize(const unsigned char *str, int *w, int *h, int fontnumber)
*w = width; *w = width;
if ( h ) if ( h )
*h = pf->height; *h = pf->height;
font_lock( fontnumber, false );
return width; return width;
} }