summaryrefslogtreecommitdiffstats
path: root/firmware/font.c
diff options
context:
space:
mode:
authorFred Bauer <fred.w.bauer@gmail.com>2011-10-21 18:05:52 +0000
committerFred Bauer <fred.w.bauer@gmail.com>2011-10-21 18:05:52 +0000
commit04a015dde0f7edfe5ee913dc8cc6c1395dc9a419 (patch)
tree8824e321737f0734859679a205b7ab9a4119d322 /firmware/font.c
parentd228d4d13059eae67f01485ee3e29b50b643b38a (diff)
downloadrockbox-04a015dde0f7edfe5ee913dc8cc6c1395dc9a419.tar.gz
rockbox-04a015dde0f7edfe5ee913dc8cc6c1395dc9a419.tar.bz2
rockbox-04a015dde0f7edfe5ee913dc8cc6c1395dc9a419.zip
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
Diffstat (limited to 'firmware/font.c')
-rw-r--r--firmware/font.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/firmware/font.c b/firmware/font.c
index 943f2e2d06..6a9a68357f 100644
--- a/firmware/font.c
+++ b/firmware/font.c
@@ -124,6 +124,14 @@ static void lock_font_handle(int handle, bool lock)
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 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;
int width = 0;
+ font_lock( fontnumber, true );
for (str = utf8decode(str, &ch); ch != 0 ; str = utf8decode(str, &ch))
{
if (is_diacritic(ch, NULL))
@@ -1019,6 +1028,7 @@ int font_getstringsize(const unsigned char *str, int *w, int *h, int fontnumber)
*w = width;
if ( h )
*h = pf->height;
+ font_lock( fontnumber, false );
return width;
}