summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-03-30 22:49:08 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-03-30 22:49:08 +0000
commit09d24e98e3b0d4616dfb176f31dc2b1dbdf0ece1 (patch)
tree5cba9b70ef679b51a066c54102b96ee40f87126c
parent5b84f46123eba280494381126ad4bc6417f92f9d (diff)
More fixes for NxConsole driver
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4543 7fd9a85b-ad96-42d3-883c-3090e2eb8679
-rw-r--r--nuttx/Documentation/NXGraphicsSubsystem.html24
-rw-r--r--nuttx/configs/sim/nx/defconfig18
-rw-r--r--nuttx/configs/sim/nx11/defconfig18
-rw-r--r--nuttx/configs/stm3210e-eval/nsh2/defconfig22
-rw-r--r--nuttx/configs/stm3210e-eval/nx/defconfig22
-rw-r--r--nuttx/configs/stm3210e-eval/nxconsole/defconfig22
-rw-r--r--nuttx/configs/stm3210e-eval/nxlines/defconfig22
-rw-r--r--nuttx/configs/stm3210e-eval/nxtext/defconfig22
-rw-r--r--nuttx/graphics/README.txt22
-rw-r--r--nuttx/graphics/nxconsole/nxcon_font.c29
-rw-r--r--nuttx/graphics/nxconsole/nxcon_internal.h10
-rw-r--r--nuttx/graphics/nxconsole/nxcon_register.c20
-rwxr-xr-xnuttx/graphics/nxconsole/nxcon_scroll.c4
-rw-r--r--nuttx/graphics/nxconsole/nxcon_unregister.c14
-rw-r--r--nuttx/include/nuttx/nx/nxconsole.h25
15 files changed, 135 insertions, 159 deletions
diff --git a/nuttx/Documentation/NXGraphicsSubsystem.html b/nuttx/Documentation/NXGraphicsSubsystem.html
index ecace15d0c..38baf54ee1 100644
--- a/nuttx/Documentation/NXGraphicsSubsystem.html
+++ b/nuttx/Documentation/NXGraphicsSubsystem.html
@@ -3368,13 +3368,25 @@ int nxf_convert_32bpp(FAR uint32_t *dest, uint16_t height,
<dd>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.
- <dt><code>CONFIG_NXCONSOLE_FONTCACHE</code>:
- <dd>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 <code>CONFIG_NXCONSOLE_CACHESIZE</code>.
- Default: No font caching.
<dt><code>CONFIG_NXCONSOLE_CACHESIZE</code>:
- <dd>If <code>CONFIG_NXCONSOLE_FONTCACHE</code>, then this setting will control the size of the font cache (in number of glyphs). Default: 16.
+ <dd>
+ 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 <code>CONFIG_NXCONSOLE_CACHESIZE</code> 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.
+ <blockquote>
+ 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 <code>CONFIG_NXCONSOLE_CACHESIZE</code>
+ is something that you should try.
+ Alternatively, you can reduce the size of <code>CONFIG_MQ_MAXMSGSIZE</code> which will force NxConsole task to pace the server task.
+ <code>CONFIG_NXCONSOLE_CACHESIZE</code> should be larger than <code>CONFIG_MQ_MAXMSGSIZE</code> in any event.
+ </blockquote>
<dt><code>CONFIG_NXCONSOLE_LINESEPARATION</code>:
<dd>This the space (in rows) between each row of test. Default: 0
<dt><code>CONFIG_NXCONSOLE_NOWRAP</code>:
diff --git a/nuttx/configs/sim/nx/defconfig b/nuttx/configs/sim/nx/defconfig
index f8139b32ca..e34dadcd87 100644
--- a/nuttx/configs/sim/nx/defconfig
+++ b/nuttx/configs/sim/nx/defconfig
@@ -438,15 +438,16 @@ CONFIG_NX_MXCLIENTMSGS=16
# 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. (NOTE: There is still
+# inherently a race condition in this!). 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.
# CONFIG_NXCONSOLE_LINESEPARATION
# This the space (in rows) between each row of test. Default: 2
# CONFIG_NXCONSOLE_NOWRAP
@@ -458,7 +459,6 @@ CONFIG_NXCONSOLE=n
CONFIG_NXCONSOLE_BPP=8
# CONFIG_NXCONSOLE_NOGETRUN
CONFIG_NXCONSOLE_MXCHARS=256
-# CONFIG_NXCONSOLE_FONTCACHE
# CONFIG_NXCONSOLE_CACHESIZE
# CONFIG_NXCONSOLE_LINESEPARATION
# CONFIG_NXCONSOLE_NOWRAP
diff --git a/nuttx/configs/sim/nx11/defconfig b/nuttx/configs/sim/nx11/defconfig
index d8b1d6019e..7866cc1b2a 100644
--- a/nuttx/configs/sim/nx11/defconfig
+++ b/nuttx/configs/sim/nx11/defconfig
@@ -439,15 +439,16 @@ CONFIG_NX_MXCLIENTMSGS=16
# 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. (NOTE: There is still
+# inherently a race condition in this!). 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.
# CONFIG_NXCONSOLE_LINESEPARATION
# This the space (in rows) between each row of test. Default: 2
# CONFIG_NXCONSOLE_NOWRAP
@@ -459,7 +460,6 @@ CONFIG_NXCONSOLE=n
CONFIG_NXCONSOLE_BPP=32
# CONFIG_NXCONSOLE_NOGETRUN
CONFIG_NXCONSOLE_MXCHARS=256
-# CONFIG_NXCONSOLE_FONTCACHE
# CONFIG_NXCONSOLE_CACHESIZE
# CONFIG_NXCONSOLE_LINESEPARATION
# CONFIG_NXCONSOLE_NOWRAP
diff --git a/nuttx/configs/stm3210e-eval/nsh2/defconfig b/nuttx/configs/stm3210e-eval/nsh2/defconfig
index 228abf2309..9fbbcce88c 100644
--- a/nuttx/configs/stm3210e-eval/nsh2/defconfig
+++ b/nuttx/configs/stm3210e-eval/nsh2/defconfig
@@ -1057,15 +1057,16 @@ CONFIG_NX_MXCLIENTMSGS=16
# 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. (NOTE: There is still
+# inherently a race condition in this!). 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.
# CONFIG_NXCONSOLE_LINESEPARATION
# This the space (in rows) between each row of test. Default: 2
# CONFIG_NXCONSOLE_NOWRAP
@@ -1075,10 +1076,9 @@ CONFIG_NX_MXCLIENTMSGS=16
#
CONFIG_NXCONSOLE=n
CONFIG_NXCONSOLE_BPP=16
-# CONFIG_NXCONSOLE_NOGETRUN
+CONFIG_NXCONSOLE_NOGETRUN=y
CONFIG_NXCONSOLE_MXCHARS=256
-# CONFIG_NXCONSOLE_FONTCACHE
-# CONFIG_NXCONSOLE_CACHESIZE
+CONFIG_NXCONSOLE_CACHESIZE=32
# CONFIG_NXCONSOLE_LINESEPARATION
# CONFIG_NXCONSOLE_NOWRAP
diff --git a/nuttx/configs/stm3210e-eval/nx/defconfig b/nuttx/configs/stm3210e-eval/nx/defconfig
index 02cafd33d7..1df6b454d5 100644
--- a/nuttx/configs/stm3210e-eval/nx/defconfig
+++ b/nuttx/configs/stm3210e-eval/nx/defconfig
@@ -907,15 +907,16 @@ CONFIG_NX_MXCLIENTMSGS=16
# 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. (NOTE: There is still
+# inherently a race condition in this!). 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.
# CONFIG_NXCONSOLE_LINESEPARATION
# This the space (in rows) between each row of test. Default: 2
# CONFIG_NXCONSOLE_NOWRAP
@@ -925,10 +926,9 @@ CONFIG_NX_MXCLIENTMSGS=16
#
CONFIG_NXCONSOLE=n
CONFIG_NXCONSOLE_BPP=16
-# CONFIG_NXCONSOLE_NOGETRUN
+CONFIG_NXCONSOLE_NOGETRUN=y
CONFIG_NXCONSOLE_MXCHARS=256
-# CONFIG_NXCONSOLE_FONTCACHE
-# CONFIG_NXCONSOLE_CACHESIZE
+CONFIG_NXCONSOLE_CACHESIZE=32
# CONFIG_NXCONSOLE_LINESEPARATION
# CONFIG_NXCONSOLE_NOWRAP
diff --git a/nuttx/configs/stm3210e-eval/nxconsole/defconfig b/nuttx/configs/stm3210e-eval/nxconsole/defconfig
index 5945bb6426..b3bc9e3cc9 100644
--- a/nuttx/configs/stm3210e-eval/nxconsole/defconfig
+++ b/nuttx/configs/stm3210e-eval/nxconsole/defconfig
@@ -915,15 +915,16 @@ CONFIG_NX_MXCLIENTMSGS=16
# 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. (NOTE: There is still
+# inherently a race condition in this!). 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.
# CONFIG_NXCONSOLE_LINESEPARATION
# This the space (in rows) between each row of test. Default: 2
# CONFIG_NXCONSOLE_NOWRAP
@@ -933,10 +934,9 @@ CONFIG_NX_MXCLIENTMSGS=16
#
CONFIG_NXCONSOLE=y
CONFIG_NXCONSOLE_BPP=16
-# CONFIG_NXCONSOLE_NOGETRUN
+CONFIG_NXCONSOLE_NOGETRUN=y
CONFIG_NXCONSOLE_MXCHARS=256
-# CONFIG_NXCONSOLE_FONTCACHE
-# CONFIG_NXCONSOLE_CACHESIZE
+CONFIG_NXCONSOLE_CACHESIZE=32
# CONFIG_NXCONSOLE_LINESEPARATION
# CONFIG_NXCONSOLE_NOWRAP
diff --git a/nuttx/configs/stm3210e-eval/nxlines/defconfig b/nuttx/configs/stm3210e-eval/nxlines/defconfig
index fa067ae41c..76dc411c96 100644
--- a/nuttx/configs/stm3210e-eval/nxlines/defconfig
+++ b/nuttx/configs/stm3210e-eval/nxlines/defconfig
@@ -906,15 +906,16 @@ CONFIG_NX_MXCLIENTMSGS=16
# 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. (NOTE: There is still
+# inherently a race condition in this!). 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.
# CONFIG_NXCONSOLE_LINESEPARATION
# This the space (in rows) between each row of test. Default: 2
# CONFIG_NXCONSOLE_NOWRAP
@@ -924,10 +925,9 @@ CONFIG_NX_MXCLIENTMSGS=16
#
CONFIG_NXCONSOLE=n
CONFIG_NXCONSOLE_BPP=16
-# CONFIG_NXCONSOLE_NOGETRUN
+CONFIG_NXCONSOLE_NOGETRUN=y
CONFIG_NXCONSOLE_MXCHARS=256
-# CONFIG_NXCONSOLE_FONTCACHE
-# CONFIG_NXCONSOLE_CACHESIZE
+CONFIG_NXCONSOLE_CACHESIZE=32
# CONFIG_NXCONSOLE_LINESEPARATION
# CONFIG_NXCONSOLE_NOWRAP
diff --git a/nuttx/configs/stm3210e-eval/nxtext/defconfig b/nuttx/configs/stm3210e-eval/nxtext/defconfig
index 753b69190d..434635faec 100644
--- a/nuttx/configs/stm3210e-eval/nxtext/defconfig
+++ b/nuttx/configs/stm3210e-eval/nxtext/defconfig
@@ -906,15 +906,16 @@ CONFIG_NX_MXCLIENTMSGS=16
# 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. (NOTE: There is still
+# inherently a race condition in this!). 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.
# CONFIG_NXCONSOLE_LINESEPARATION
# This the space (in rows) between each row of test. Default: 2
# CONFIG_NXCONSOLE_NOWRAP
@@ -924,10 +925,9 @@ CONFIG_NX_MXCLIENTMSGS=16
#
CONFIG_NXCONSOLE=n
CONFIG_NXCONSOLE_BPP=16
-# CONFIG_NXCONSOLE_NOGETRUN
+CONFIG_NXCONSOLE_NOGETRUN=y
CONFIG_NXCONSOLE_MXCHARS=256
-# CONFIG_NXCONSOLE_FONTCACHE
-# CONFIG_NXCONSOLE_CACHESIZE
+CONFIG_NXCONSOLE_CACHESIZE=32
# CONFIG_NXCONSOLE_LINESEPARATION
# CONFIG_NXCONSOLE_NOWRAP
diff --git a/nuttx/graphics/README.txt b/nuttx/graphics/README.txt
index 935df9140c..a816cdb584 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 cb5320d257..2677b9c158 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 996ea9d5db..ebcab909b5 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 78f6a10519..663764dcef 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 b0a1a2335f..882c99ed8c 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 25dbd40c66..e516ef64ac 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 */
diff --git a/nuttx/include/nuttx/nx/nxconsole.h b/nuttx/include/nuttx/nx/nxconsole.h
index 6d04044331..4a9e43ea5d 100644
--- a/nuttx/include/nuttx/nx/nxconsole.h
+++ b/nuttx/include/nuttx/nx/nxconsole.h
@@ -77,15 +77,16 @@
* 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. (NOTE: There is still
+ * inherently a race condition in this!). 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.
* CONFIG_NXCONSOLE_LINESEPARATION
* This the space (in rows) between each row of test. Default: 0
* CONFIG_NXCONSOLE_NOWRAP
@@ -104,12 +105,8 @@
* remembered.
*/
-#ifdef CONFIG_NXCONSOLE_FONTCACHE
-# ifndef CONFIG_NXCONSOLE_CACHESIZE
-# define CONFIG_NXCONSOLE_CACHESIZE 16
-# endif
-#else
-# undef CONFIG_NXCONSOLE_CACHESIZE
+#ifndef CONFIG_NXCONSOLE_CACHESIZE
+# define CONFIG_NXCONSOLE_CACHESIZE 16
#endif
/* Pixel depth */