summaryrefslogtreecommitdiff
path: root/firmware/font.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/font.c')
-rw-r--r--firmware/font.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/firmware/font.c b/firmware/font.c
index 724cb84d57..7ce64ed47d 100644
--- a/firmware/font.c
+++ b/firmware/font.c
@@ -90,7 +90,6 @@ extern struct font sysfont;
90 90
91struct buflib_alloc_data { 91struct buflib_alloc_data {
92 struct font font; /* must be the first member! */ 92 struct font font; /* must be the first member! */
93 int handle_locks; /* is the buflib handle currently locked? */
94 int refcount; /* how many times has this font been loaded? */ 93 int refcount; /* how many times has this font been loaded? */
95 unsigned char buffer[]; 94 unsigned char buffer[];
96}; 95};
@@ -107,9 +106,6 @@ static int buflibmove_callback(int handle, void* current, void* new)
107 struct buflib_alloc_data *alloc = (struct buflib_alloc_data*)current; 106 struct buflib_alloc_data *alloc = (struct buflib_alloc_data*)current;
108 ptrdiff_t diff = new - current; 107 ptrdiff_t diff = new - current;
109 108
110 if (alloc->handle_locks > 0)
111 return BUFLIB_CB_CANNOT_MOVE;
112
113#define UPDATE(x) if (x) { x = PTR_ADD(x, diff); } 109#define UPDATE(x) if (x) { x = PTR_ADD(x, diff); }
114 110
115 UPDATE(alloc->font.bits); 111 UPDATE(alloc->font.bits);
@@ -129,18 +125,18 @@ static void lock_font_handle(int handle, bool lock)
129{ 125{
130 if ( handle < 0 ) 126 if ( handle < 0 )
131 return; 127 return;
132 struct buflib_alloc_data *alloc = core_get_data(handle); 128
133 if ( lock ) 129 if (lock)
134 alloc->handle_locks++; 130 core_pin(handle);
135 else 131 else
136 alloc->handle_locks--; 132 core_unpin(handle);
137} 133}
138 134
139void font_lock(int font_id, bool lock) 135void font_lock(int font_id, bool lock)
140{ 136{
141 if( font_id < 0 || font_id >= MAXFONTS ) 137 if( font_id < 0 || font_id >= MAXFONTS )
142 return; 138 return;
143 if( buflib_allocations[font_id] >= 0 ) 139 if( buflib_allocations[font_id] > 0 )
144 lock_font_handle(buflib_allocations[font_id], lock); 140 lock_font_handle(buflib_allocations[font_id], lock);
145} 141}
146 142
@@ -522,8 +518,8 @@ int font_load_ex( const char *path, size_t buf_size, int glyphs )
522 return -1; 518 return -1;
523 } 519 }
524 struct buflib_alloc_data *pdata; 520 struct buflib_alloc_data *pdata;
521 core_pin(handle);
525 pdata = core_get_data(handle); 522 pdata = core_get_data(handle);
526 pdata->handle_locks = 1;
527 pdata->refcount = 1; 523 pdata->refcount = 1;
528 524
529 /* load and init */ 525 /* load and init */