diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-07-20 02:13:08 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-07-20 02:13:08 +0000 |
commit | 622a6cc576f1e5b97abcb78441ed04674217bfe6 (patch) | |
tree | 985c3306340f9b7edaa060b5ecdfe8e44d24c83c /apps/examples/nxtext | |
parent | 89b5382e22ed897121c864865fdb79acddc9ba14 (diff) | |
download | nuttx-622a6cc576f1e5b97abcb78441ed04674217bfe6.tar.gz nuttx-622a6cc576f1e5b97abcb78441ed04674217bfe6.tar.bz2 nuttx-622a6cc576f1e5b97abcb78441ed04674217bfe6.zip |
Use a handle instead of an ID in each font lookup; this saves doing the font set lookup each time
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3802 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/examples/nxtext')
-rw-r--r-- | apps/examples/nxtext/nxtext_bkgd.c | 2 | ||||
-rw-r--r-- | apps/examples/nxtext/nxtext_internal.h | 5 | ||||
-rw-r--r-- | apps/examples/nxtext/nxtext_main.c | 15 | ||||
-rw-r--r-- | apps/examples/nxtext/nxtext_popup.c | 2 | ||||
-rw-r--r-- | apps/examples/nxtext/nxtext_putc.c | 4 |
5 files changed, 24 insertions, 4 deletions
diff --git a/apps/examples/nxtext/nxtext_bkgd.c b/apps/examples/nxtext/nxtext_bkgd.c index e711c84bb..37894e20c 100644 --- a/apps/examples/nxtext/nxtext_bkgd.c +++ b/apps/examples/nxtext/nxtext_bkgd.c @@ -402,7 +402,7 @@ FAR struct nxtext_state_s *nxbg_getstate(void) * state structure */ - fontset = nxf_getfontset(NXFONT_DEFAULT); + fontset = nxf_getfontset(g_fonthandle); g_bgstate.fheight = fontset->mxheight; g_bgstate.fwidth = fontset->mxwidth; g_bgstate.spwidth = fontset->spwidth; diff --git a/apps/examples/nxtext/nxtext_internal.h b/apps/examples/nxtext/nxtext_internal.h index 16f8bb08a..eb7543329 100644 --- a/apps/examples/nxtext/nxtext_internal.h +++ b/apps/examples/nxtext/nxtext_internal.h @@ -191,6 +191,7 @@ enum exitcode_e NXEXIT_LCDINITIALIZE, NXEXIT_LCDGETDEV, NXEXIT_NXOPEN, + NXEXIT_FONTOPEN, NXEXIT_NXREQUESTBKGD, NXEXIT_NXCONNECT, NXEXIT_NXSETBGCOLOR, @@ -262,6 +263,10 @@ extern NXHANDLE g_hnx; extern NXHANDLE g_bgwnd; +/* The font handle */ + +extern NXHANDLE g_fonthandle; + /* NX callback vtables */ extern const struct nx_callback_s g_bgcb; diff --git a/apps/examples/nxtext/nxtext_main.c b/apps/examples/nxtext/nxtext_main.c index 6a53f9d2c..a9d9207e6 100644 --- a/apps/examples/nxtext/nxtext_main.c +++ b/apps/examples/nxtext/nxtext_main.c @@ -61,6 +61,7 @@ #include <nuttx/arch.h> #include <nuttx/nx.h> #include <nuttx/nxglib.h> +#include <nuttx/nxfonts.h> #include "nxtext_internal.h" @@ -134,6 +135,10 @@ static const char *g_bgmsg[BGMSG_LINES] = NXHANDLE g_hnx = NULL; +/* The font handle */ + +NXHANDLE g_fonthandle = NULL; + /* The screen resolution */ nxgl_coord_t g_xres; @@ -366,6 +371,16 @@ int user_start(int argc, char *argv[]) goto errout; } + /* Get the default font handle */ + + g_fonthandle = nxf_getfonthandle(NXFONT_DEFAULT); + if (!g_fonthandle) + { + message("user_start: Failed to get font handle: %d\n", errno); + g_exitcode = NXEXIT_FONTOPEN; + goto errout; + } + /* Set the background to the configured background color */ message("user_start: Set background color=%d\n", CONFIG_EXAMPLES_NXTEXT_BGCOLOR); diff --git a/apps/examples/nxtext/nxtext_popup.c b/apps/examples/nxtext/nxtext_popup.c index bf9fbae19..8cc72a89e 100644 --- a/apps/examples/nxtext/nxtext_popup.c +++ b/apps/examples/nxtext/nxtext_popup.c @@ -304,7 +304,7 @@ static inline void nxpu_initstate(void) */ #ifdef CONFIG_NX_KBD - fontset = nxf_getfontset(NXFONT_DEFAULT); + fontset = nxf_getfontset(g_fonthandle); g_pustate.fheight = fontset->mxheight; g_pustate.fwidth = fontset->mxwidth; g_pustate.spwidth = fontset->spwidth; diff --git a/apps/examples/nxtext/nxtext_putc.c b/apps/examples/nxtext/nxtext_putc.c index 87da2ad6e..b4e31bb73 100644 --- a/apps/examples/nxtext/nxtext_putc.c +++ b/apps/examples/nxtext/nxtext_putc.c @@ -332,7 +332,7 @@ static int nxtext_fontsize(uint8_t ch, FAR struct nxgl_size_s *size) /* No, it is not cached... Does the code map to a font? */ - fbm = nxf_getbitmap(ch, NXFONT_DEFAULT); + fbm = nxf_getbitmap(g_fonthandle, ch); if (fbm) { /* Yes.. return the font size */ @@ -362,7 +362,7 @@ nxtext_getglyph(FAR struct nxtext_state_s *st, uint8_t ch) { /* No, it is not cached... Does the code map to a font? */ - fbm = nxf_getbitmap(ch, NXFONT_DEFAULT); + fbm = nxf_getbitmap(g_fonthandle, ch); if (fbm) { /* Yes.. render the glyph */ |