mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 11:56:10 +08:00
Font cache: Replace fixed-size array with variable size link list.
This commit is contained in:
@@ -99,7 +99,7 @@ FAR const struct nxterm_bitmap_s *
|
|||||||
nxterm_addchar(FAR struct nxterm_state_s *priv, uint8_t ch)
|
nxterm_addchar(FAR struct nxterm_state_s *priv, uint8_t ch)
|
||||||
{
|
{
|
||||||
FAR struct nxterm_bitmap_s *bm = NULL;
|
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? */
|
/* 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 nxgl_rect_s *rect,
|
||||||
FAR const struct nxterm_bitmap_s *bm)
|
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 bounds;
|
||||||
struct nxgl_rect_s intersection;
|
struct nxgl_rect_s intersection;
|
||||||
struct nxgl_size_s fsize;
|
struct nxgl_size_s fsize;
|
||||||
|
|||||||
@@ -106,7 +106,8 @@ FAR struct nxterm_state_s *
|
|||||||
/* Connect to the font cache for the configured font characteristics */
|
/* Connect to the font cache for the configured font characteristics */
|
||||||
|
|
||||||
priv->fcache = nxf_cache_connect(wndo->fontid, wndo->fcolor[0],
|
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)
|
if (priv->fcache == NULL)
|
||||||
{
|
{
|
||||||
gerr("ERROR: Failed to connect to font cache for font ID %d: %d\n",
|
gerr("ERROR: Failed to connect to font cache for font ID %d: %d\n",
|
||||||
|
|||||||
+12
-11
@@ -203,11 +203,6 @@
|
|||||||
|
|
||||||
#endif
|
#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
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -469,14 +464,16 @@ typedef FAR void *FCACHE;
|
|||||||
|
|
||||||
struct nxfonts_glyph_s
|
struct nxfonts_glyph_s
|
||||||
{
|
{
|
||||||
|
FAR struct nxfonts_glyph_s *flink; /* Implements a singly linked list */
|
||||||
uint8_t code; /* Character code */
|
uint8_t code; /* Character code */
|
||||||
uint8_t height; /* Height of this glyph (in rows) */
|
uint8_t height; /* Height of this glyph (in rows) */
|
||||||
uint8_t width; /* Width of this glyph (in pixels) */
|
uint8_t width; /* Width of this glyph (in pixels) */
|
||||||
uint8_t stride; /* Width of the glyph row (in bytes) */
|
uint8_t stride; /* Width of the glyph row (in bytes) */
|
||||||
uint8_t usecnt; /* Use count */
|
FAR uint8_t bitmap[1]; /* Bitmap memory, actual size varies */
|
||||||
FAR uint8_t *bitmap; /* Allocated bitmap memory */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define SIZEOF_NXFONTS_GLYPH_S(b) (sizeof(struct nxfonts_glyph_s) + (b) - 1)
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -596,11 +593,15 @@ int nxf_convert_32bpp(FAR uint32_t *dest, uint16_t height,
|
|||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Create a new font cache for the provided 'fontid'. If the cache
|
* 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.
|
* the existing font cache.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* 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:
|
* Returned value:
|
||||||
* On success a non-NULL handle is returned that then may sequently be
|
* 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,
|
FCACHE nxf_cache_connect(enum nx_fontid_e fontid,
|
||||||
nxgl_mxpixel_t fgcolor, nxgl_mxpixel_t bgcolor,
|
nxgl_mxpixel_t fgcolor, nxgl_mxpixel_t bgcolor,
|
||||||
int bpp);
|
int bpp, int maxglyph);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nxf_cache_disconnect
|
* 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
|
#undef EXTERN
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
|
|||||||
@@ -58,5 +58,6 @@ void sq_addfirst(FAR sq_entry_t *node, sq_queue_t *queue)
|
|||||||
{
|
{
|
||||||
queue->tail = node;
|
queue->tail = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
queue->head = node;
|
queue->head = node;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,10 +44,10 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name:
|
* Name: sq_remafter
|
||||||
*
|
*
|
||||||
* Description:
|
* 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.
|
* 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 *sq_remafter(FAR sq_entry_t *node, sq_queue_t *queue)
|
||||||
{
|
{
|
||||||
FAR sq_entry_t *ret = node->flink;
|
FAR sq_entry_t *ret = node->flink;
|
||||||
|
|
||||||
if (queue->head && ret)
|
if (queue->head && ret)
|
||||||
{
|
{
|
||||||
if (queue->tail == ret)
|
if (queue->tail == ret)
|
||||||
|
|||||||
+292
-173
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user