diff options
author | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-03-30 22:49:08 +0000 |
---|---|---|
committer | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-03-30 22:49:08 +0000 |
commit | 3d86917712f6c502e8edc640649e6f204376ba06 (patch) | |
tree | 5cba9b70ef679b51a066c54102b96ee40f87126c /nuttx/graphics | |
parent | 6542745de8fbe0f90de06052821c6d78ab183250 (diff) | |
download | px4-firmware-3d86917712f6c502e8edc640649e6f204376ba06.tar.gz px4-firmware-3d86917712f6c502e8edc640649e6f204376ba06.tar.bz2 px4-firmware-3d86917712f6c502e8edc640649e6f204376ba06.zip |
More fixes for NxConsole driver
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4543 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/graphics')
-rw-r--r-- | nuttx/graphics/README.txt | 22 | ||||
-rw-r--r-- | nuttx/graphics/nxconsole/nxcon_font.c | 29 | ||||
-rw-r--r-- | nuttx/graphics/nxconsole/nxcon_internal.h | 10 | ||||
-rw-r--r-- | nuttx/graphics/nxconsole/nxcon_register.c | 20 | ||||
-rwxr-xr-x | nuttx/graphics/nxconsole/nxcon_scroll.c | 4 | ||||
-rw-r--r-- | nuttx/graphics/nxconsole/nxcon_unregister.c | 14 |
6 files changed, 33 insertions, 66 deletions
diff --git a/nuttx/graphics/README.txt b/nuttx/graphics/README.txt index 935df9140..a816cdb58 100644 --- a/nuttx/graphics/README.txt +++ b/nuttx/graphics/README.txt @@ -336,15 +336,21 @@ CONFIG_NXCONSOLE_MXCHARS NxConsole needs to remember every character written to the console so that it can redraw the window. This setting determines the size of some internal memory allocations used to hold the character data. Default: 128. -CONFIG_NXCONSOLE_FONTCACHE - If this setting is defined, then caching of fonts will be supported by - NxConsole. Each font must be rendered from the tiny font storage format - to the full display size and pixel depth. If this setting is defined, then - the more recently used font glyphs will be retained in a cache of size - CONFIG_NXCONSOLE_CACHESIZE. Default: No font caching. CONFIG_NXCONSOLE_CACHESIZE - If CONFIG_NXCONSOLE_FONTCACHE, then this setting will control the size - of the font cache (in number of glyphs). Default: 16. + NxConsole supports caching of rendered fonts. This font caching is required + for two reasons: (1) First, it improves text performance, but more + importantly (2) it preserves the font memory. Since the NX server runs on + a separate server thread, it requires that the rendered font memory persist + until the server has a chance to render the font. Unfortunately, the font + cache would be quite large if all fonts were saved. The CONFIG_NXCONSOLE_CACHESIZE + setting will control the size of the font cache (in number of glyphs). Only that + number of the most recently used glyphs will be retained. Default: 16. + NOTE: There can still be a race condition between the NxConsole driver and the + NX task. If you every see character corruption (especially when printing + a lot of data or scrolling), then increasing the value of CONFIG_NXCONSOLE_CACHESIZE + is something that you should try. Alternatively, you can reduce the size of + CONFIG_MQ_MAXMSGSIZE which will force NxConsole task to pace the server task. + CONFIG_NXCONSOLE_CACHESIZE should be larger than ONFIG_MQ_MAXMSGSIZE in any event. CONFIG_NXCONSOLE_LINESEPARATION This the space (in rows) between each row of test. Default: 0 CONFIG_NXCONSOLE_NOWRAP diff --git a/nuttx/graphics/nxconsole/nxcon_font.c b/nuttx/graphics/nxconsole/nxcon_font.c index cb5320d25..2677b9c15 100644 --- a/nuttx/graphics/nxconsole/nxcon_font.c +++ b/nuttx/graphics/nxconsole/nxcon_font.c @@ -39,9 +39,12 @@ #include <nuttx/config.h> +#include <string.h> #include <assert.h> #include <debug.h> +#include <nuttx/kmalloc.h> + #include "nxcon_internal.h" /**************************************************************************** @@ -94,7 +97,6 @@ * Name: nxcon_freeglyph ****************************************************************************/ -#ifdef CONFIG_NXCONSOLE_FONTCACHE static void nxcon_freeglyph(FAR struct nxcon_glyph_s *glyph) { if (glyph->bitmap) @@ -103,7 +105,6 @@ static void nxcon_freeglyph(FAR struct nxcon_glyph_s *glyph) } memset(glyph, 0, sizeof(struct nxcon_glyph_s)); } -#endif /**************************************************************************** * Name: nxcon_allocglyph @@ -112,7 +113,6 @@ static void nxcon_freeglyph(FAR struct nxcon_glyph_s *glyph) static inline FAR struct nxcon_glyph_s * nxcon_allocglyph(FAR struct nxcon_state_s *priv) { -#ifdef CONFIG_NXCONSOLE_FONTCACHE FAR struct nxcon_glyph_s *glyph = NULL; FAR struct nxcon_glyph_s *luglyph = NULL; uint8_t luusecnt; @@ -175,16 +175,12 @@ nxcon_allocglyph(FAR struct nxcon_state_s *priv) luglyph->usecnt = 1; return luglyph; -#else - return &priv->glyph; -#endif } /**************************************************************************** * Name: nxcon_findglyph ****************************************************************************/ -#ifdef CONFIG_NXCONSOLE_FONTCACHE static FAR struct nxcon_glyph_s * nxcon_findglyph(FAR struct nxcon_state_s *priv, uint8_t ch) { @@ -211,7 +207,6 @@ nxcon_findglyph(FAR struct nxcon_state_s *priv, uint8_t ch) } return NULL; } -#endif /**************************************************************************** * Name: nxcon_renderglyph @@ -226,6 +221,7 @@ nxcon_renderglyph(FAR struct nxcon_state_s *priv, #if CONFIG_NXCONSOLE_BPP < 8 nxgl_mxpixel_t pixel; #endif + int bmsize; int row; int col; int ret; @@ -246,15 +242,8 @@ nxcon_renderglyph(FAR struct nxcon_state_s *priv, /* Allocate memory to hold the glyph with its offsets */ -#ifdef CONFIG_NXCONSOLE_FONTCACHE - { - DEBUGASSERT(glyph->bitmap == NULL); - int bmsize = glyph->stride * glyph->height; - glyph->bitmap = (FAR uint8_t *)kmalloc(bmsize); - } -#else - DEBUGASSERT(glyph->bitmap != NULL); -#endif + bmsize = glyph->stride * glyph->height; + glyph->bitmap = (FAR uint8_t *)kmalloc(bmsize); if (glyph->bitmap) { @@ -329,9 +318,7 @@ nxcon_renderglyph(FAR struct nxcon_state_s *priv, /* Actually, the RENDERER never returns a failure */ gdbg("nxcon_renderglyph: RENDERER failed\n"); -#ifdef CONFIG_NXCONSOLE_FONTCACHE nxcon_freeglyph(glyph); -#endif glyph = NULL; } } @@ -374,7 +361,6 @@ nxcon_getglyph(NXHANDLE hfont, FAR struct nxcon_state_s *priv, uint8_t ch) /* First, try to find the glyph in the cache of pre-rendered glyphs */ -#ifdef CONFIG_NXCONSOLE_FONTCACHE glyph = nxcon_findglyph(priv, ch); if (glyph) { @@ -382,9 +368,6 @@ nxcon_getglyph(NXHANDLE hfont, FAR struct nxcon_state_s *priv, uint8_t ch) return glyph; } -#else - glyph = NULL; -#endif /* No, it is not cached... Does the code map to a font? */ diff --git a/nuttx/graphics/nxconsole/nxcon_internal.h b/nuttx/graphics/nxconsole/nxcon_internal.h index 996ea9d5d..ebcab909b 100644 --- a/nuttx/graphics/nxconsole/nxcon_internal.h +++ b/nuttx/graphics/nxconsole/nxcon_internal.h @@ -119,9 +119,7 @@ struct nxcon_glyph_s 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) */ -#ifdef CONFIG_NXCONSOLE_FONTCACHE uint8_t usecnt; /* Use count */ -#endif FAR uint8_t *bitmap; /* Allocated bitmap memory */ }; @@ -155,9 +153,7 @@ struct nxcon_state_s uint8_t fheight; /* Max height of a font in pixels */ uint8_t fwidth; /* Max width of a font in pixels */ uint8_t spwidth; /* The width of a space */ -#ifdef CONFIG_NXCONSOLE_FONTCACHE uint8_t maxglyphs; /* Size of the glyph[] array */ -#endif /* VT100 escape sequence processing */ @@ -170,13 +166,7 @@ struct nxcon_state_s /* Glyph cache data storage */ -#ifdef CONFIG_NXCONSOLE_FONTCACHE struct nxcon_glyph_s glyph[CONFIG_NXCONSOLE_CACHESIZE]; -#else - /* A glyph cache of size one -- all fonts will be re-rendered on each use */ - - struct nxcon_glyph_s glyph; -#endif }; /**************************************************************************** diff --git a/nuttx/graphics/nxconsole/nxcon_register.c b/nuttx/graphics/nxconsole/nxcon_register.c index 78f6a1051..663764dce 100644 --- a/nuttx/graphics/nxconsole/nxcon_register.c +++ b/nuttx/graphics/nxconsole/nxcon_register.c @@ -124,27 +124,9 @@ FAR struct nxcon_state_s * priv->maxchars = CONFIG_NXCONSOLE_MXCHARS; - /* Set up the font glyph bitmap cache (if enabled) */ + /* Set up the font glyph bitmap cache */ -#ifdef CONFIG_NXCONSOLE_FONTCACHE priv->maxglyphs = CONFIG_NXCONSOLE_CACHESIZE; -#endif - - /* Pre-allocate maximal sized glyph bitmap memory (only if we are not - * using the glyph cache. - */ - -#ifndef CONFIG_NXCONSOLE_FONTCACHE - { - int allocsize = (priv->fheight * priv->fwidth * CONFIG_NXCONSOLE_BPP + 7) >> 3; - priv->glyph.bitmap = (FAR uint8_t *)kmalloc(allocsize); - if (!priv->glyph.bitmap) - { - gdbg("Failed to allocate glyph memory\n"); - goto errout; - } - } -#endif /* Set the initial display position */ diff --git a/nuttx/graphics/nxconsole/nxcon_scroll.c b/nuttx/graphics/nxconsole/nxcon_scroll.c index b0a1a2335..882c99ed8 100755 --- a/nuttx/graphics/nxconsole/nxcon_scroll.c +++ b/nuttx/graphics/nxconsole/nxcon_scroll.c @@ -87,7 +87,7 @@ * only. ****************************************************************************/ -#ifndef CONFIG_NXCONSOLE_NOGETRUN +#ifdef CONFIG_NXCONSOLE_NOGETRUN static inline void nxcon_movedisplay(FAR struct nxcon_state_s *priv, int bottom, int scrollheight) { @@ -170,7 +170,7 @@ static inline void nxcon_movedisplay(FAR struct nxcon_state_s *priv, /* Move the source rectangle */ - ret = priv->move(priv, &rect, &offset); + ret = priv->ops->move(priv, &rect, &offset); if (ret < 0) { gdbg("move failed: %d\n", errno); diff --git a/nuttx/graphics/nxconsole/nxcon_unregister.c b/nuttx/graphics/nxconsole/nxcon_unregister.c index 25dbd40c6..e516ef64a 100644 --- a/nuttx/graphics/nxconsole/nxcon_unregister.c +++ b/nuttx/graphics/nxconsole/nxcon_unregister.c @@ -89,6 +89,7 @@ void nxcon_unregister(NXCONSOLE handle) { FAR struct nxcon_state_s *priv; char devname[NX_DEVNAME_SIZE]; + int i; DEBUGASSERT(handle); @@ -97,11 +98,16 @@ void nxcon_unregister(NXCONSOLE handle) priv = (FAR struct nxcon_state_s *)handle; sem_destroy(&priv->exclsem); - /* Free the pre-allocated glyph bitmap */ + /* Free all allocated glyph bitmap */ -#ifndef CONFIG_NXCONSOLE_FONTCACHE - kfree(priv->glyph.bitmap); -#endif + for (i = 0; i < CONFIG_NXCONSOLE_CACHESIZE; i++) + { + FAR struct nxcon_glyph_s *glyph = &priv->glyph[i]; + if (glyph->bitmap) + { + kfree(glyph->bitmap); + } + } /* Unregister the driver */ |