diff options
author | Fred Bauer <fred.w.bauer@gmail.com> | 2011-10-21 18:05:52 +0000 |
---|---|---|
committer | Fred Bauer <fred.w.bauer@gmail.com> | 2011-10-21 18:05:52 +0000 |
commit | 04a015dde0f7edfe5ee913dc8cc6c1395dc9a419 (patch) | |
tree | 8824e321737f0734859679a205b7ab9a4119d322 | |
parent | d228d4d13059eae67f01485ee3e29b50b643b38a (diff) | |
download | rockbox-04a015dde0f7edfe5ee913dc8cc6c1395dc9a419.tar.gz 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
-rw-r--r-- | firmware/drivers/lcd-bitmap-common.c | 2 | ||||
-rw-r--r-- | firmware/export/font.h | 1 | ||||
-rw-r--r-- | firmware/font.c | 10 |
3 files changed, 13 insertions, 0 deletions
diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c index 8d95825858..fb49deb76b 100644 --- a/firmware/drivers/lcd-bitmap-common.c +++ b/firmware/drivers/lcd-bitmap-common.c | |||
@@ -101,6 +101,7 @@ void LCDFN(fill_viewport)(void) | |||
101 | static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) | 101 | static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) |
102 | { | 102 | { |
103 | unsigned short *ucs; | 103 | unsigned short *ucs; |
104 | font_lock(current_vp->font, true); | ||
104 | struct font* pf = font_get(current_vp->font); | 105 | struct font* pf = font_get(current_vp->font); |
105 | int vp_flags = current_vp->flags; | 106 | int vp_flags = current_vp->flags; |
106 | int rtl_next_non_diac_width, last_non_diacritic_width; | 107 | 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) | |||
233 | } | 234 | } |
234 | } | 235 | } |
235 | } | 236 | } |
237 | font_lock(current_vp->font, false); | ||
236 | } | 238 | } |
237 | 239 | ||
238 | /* put a string at a given pixel position */ | 240 | /* put a string at a given pixel position */ |
diff --git a/firmware/export/font.h b/firmware/export/font.h index 02476c17ff..914d3aa2ff 100644 --- a/firmware/export/font.h +++ b/firmware/export/font.h | |||
@@ -123,6 +123,7 @@ int font_load_ex(const char *path, size_t buffer_size); | |||
123 | int font_glyphs_to_bufsize(const char *path, int glyphs); | 123 | int font_glyphs_to_bufsize(const char *path, int glyphs); |
124 | void font_unload(int font_id); | 124 | void font_unload(int font_id); |
125 | void font_unload_all(void); | 125 | void font_unload_all(void); |
126 | void font_lock(int font_id, bool lock); | ||
126 | 127 | ||
127 | struct font* font_get(int font); | 128 | struct font* font_get(int font); |
128 | 129 | ||
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) | |||
124 | alloc->handle_locks--; | 124 | alloc->handle_locks--; |
125 | } | 125 | } |
126 | 126 | ||
127 | void font_lock(int font_id, bool lock) | ||
128 | { | ||
129 | if( font_id == FONT_SYSFIXED ) | ||
130 | return; | ||
131 | if( buflib_allocations[font_id] >= 0 ) | ||
132 | lock_font_handle(buflib_allocations[font_id], lock); | ||
133 | } | ||
134 | |||
127 | static struct buflib_callbacks buflibops = {buflibmove_callback, NULL }; | 135 | static struct buflib_callbacks buflibops = {buflibmove_callback, NULL }; |
128 | 136 | ||
129 | static inline struct font *pf_from_handle(int handle) | 137 | 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) | |||
1007 | unsigned short ch; | 1015 | unsigned short ch; |
1008 | int width = 0; | 1016 | int width = 0; |
1009 | 1017 | ||
1018 | font_lock( fontnumber, true ); | ||
1010 | for (str = utf8decode(str, &ch); ch != 0 ; str = utf8decode(str, &ch)) | 1019 | for (str = utf8decode(str, &ch); ch != 0 ; str = utf8decode(str, &ch)) |
1011 | { | 1020 | { |
1012 | if (is_diacritic(ch, NULL)) | 1021 | if (is_diacritic(ch, NULL)) |
@@ -1019,6 +1028,7 @@ int font_getstringsize(const unsigned char *str, int *w, int *h, int fontnumber) | |||
1019 | *w = width; | 1028 | *w = width; |
1020 | if ( h ) | 1029 | if ( h ) |
1021 | *h = pf->height; | 1030 | *h = pf->height; |
1031 | font_lock( fontnumber, false ); | ||
1022 | return width; | 1032 | return width; |
1023 | } | 1033 | } |
1024 | 1034 | ||