Font cache: Replace fixed-size array with variable size link list.

This commit is contained in:
Gregory Nutt
2017-01-06 09:07:25 -06:00
parent a0199be503
commit 0b52e6f571
6 changed files with 312 additions and 189 deletions
+2 -2
View File
@@ -99,7 +99,7 @@ FAR const struct nxterm_bitmap_s *
nxterm_addchar(FAR struct nxterm_state_s *priv, uint8_t ch)
{
FAR struct nxterm_bitmap_s *bm = NULL;
FAR struct nxfonts_glyph_s *glyph;
FAR const struct nxfonts_glyph_s *glyph;
/* Is there space for another character on the display? */
@@ -275,7 +275,7 @@ void nxterm_fillchar(FAR struct nxterm_state_s *priv,
FAR const struct nxgl_rect_s *rect,
FAR const struct nxterm_bitmap_s *bm)
{
FAR struct nxfonts_glyph_s *glyph;
FAR const struct nxfonts_glyph_s *glyph;
struct nxgl_rect_s bounds;
struct nxgl_rect_s intersection;
struct nxgl_size_s fsize;
+2 -1
View File
@@ -106,7 +106,8 @@ FAR struct nxterm_state_s *
/* Connect to the font cache for the configured font characteristics */
priv->fcache = nxf_cache_connect(wndo->fontid, wndo->fcolor[0],
wndo->wcolor[0], CONFIG_NXTERM_BPP);
wndo->wcolor[0], CONFIG_NXTERM_BPP,
CONFIG_NXTERM_CACHESIZE);
if (priv->fcache == NULL)
{
gerr("ERROR: Failed to connect to font cache for font ID %d: %d\n",
+12 -11
View File
@@ -203,11 +203,6 @@
#endif
/* Font Cache Definitions (**************************************************/
/* Limit to range of font cache usage count */
#define MAX_USECNT 255 /* Limit to range of a uint8_t */
/****************************************************************************
* Public Types
****************************************************************************/
@@ -469,14 +464,16 @@ typedef FAR void *FCACHE;
struct nxfonts_glyph_s
{
FAR struct nxfonts_glyph_s *flink; /* Implements a singly linked list */
uint8_t code; /* Character code */
uint8_t height; /* Height of this glyph (in rows) */
uint8_t width; /* Width of this glyph (in pixels) */
uint8_t stride; /* Width of the glyph row (in bytes) */
uint8_t usecnt; /* Use count */
FAR uint8_t *bitmap; /* Allocated bitmap memory */
FAR uint8_t bitmap[1]; /* Bitmap memory, actual size varies */
};
#define SIZEOF_NXFONTS_GLYPH_S(b) (sizeof(struct nxfonts_glyph_s) + (b) - 1)
/****************************************************************************
* Public Data
****************************************************************************/
@@ -596,11 +593,15 @@ int nxf_convert_32bpp(FAR uint32_t *dest, uint16_t height,
*
* Description:
* Create a new font cache for the provided 'fontid'. If the cache
* already, then just increment a reference count return the handler for
* already, then just increment a reference count return the handle for
* the existing font cache.
*
* Input Parameters:
* fontid - Identifies the font supported by this cache
* fontid - Identifies the font supported by this cache
* fgcolor - Foreground color
* bgcolor - Background color
* bpp - Bits per pixel
* maxglyphs - Maximum number of glyphs permitted in the cache
*
* Returned value:
* On success a non-NULL handle is returned that then may sequently be
@@ -612,7 +613,7 @@ int nxf_convert_32bpp(FAR uint32_t *dest, uint16_t height,
FCACHE nxf_cache_connect(enum nx_fontid_e fontid,
nxgl_mxpixel_t fgcolor, nxgl_mxpixel_t bgcolor,
int bpp);
int bpp, int maxglyph);
/****************************************************************************
* Name: nxf_cache_disconnect
@@ -666,7 +667,7 @@ NXHANDLE nxf_cache_getfonthandle(FCACHE fcache);
*
****************************************************************************/
FAR struct nxfonts_glyph_s *nxf_cache_getglyph(FCACHE fcache, uint8_t ch);
FAR const struct nxfonts_glyph_s *nxf_cache_getglyph(FCACHE fcache, uint8_t ch);
#undef EXTERN
#if defined(__cplusplus)
+1
View File
@@ -58,5 +58,6 @@ void sq_addfirst(FAR sq_entry_t *node, sq_queue_t *queue)
{
queue->tail = node;
}
queue->head = node;
}
+3 -2
View File
@@ -44,10 +44,10 @@
****************************************************************************/
/****************************************************************************
* Name:
* Name: sq_remafter
*
* Description:
* sq_remafter removes the entry following 'node; from the'queue' Returns
* sq_remafter removes the entry following 'node' from the'queue' Returns
* a reference to the removed entry.
*
****************************************************************************/
@@ -55,6 +55,7 @@
FAR sq_entry_t *sq_remafter(FAR sq_entry_t *node, sq_queue_t *queue)
{
FAR sq_entry_t *ret = node->flink;
if (queue->head && ret)
{
if (queue->tail == ret)
File diff suppressed because it is too large Load Diff