From 622a6cc576f1e5b97abcb78441ed04674217bfe6 Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 20 Jul 2011 02:13:08 +0000 Subject: 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 --- apps/examples/nx/nx_internal.h | 7 ++++++- apps/examples/nx/nx_kbdin.c | 2 +- apps/examples/nx/nx_main.c | 16 +++++++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) (limited to 'apps/examples/nx') diff --git a/apps/examples/nx/nx_internal.h b/apps/examples/nx/nx_internal.h index 96e84a958..897c09722 100644 --- a/apps/examples/nx/nx_internal.h +++ b/apps/examples/nx/nx_internal.h @@ -196,6 +196,7 @@ enum exitcode_e NXEXIT_LCDINITIALIZE, NXEXIT_LCDGETDEV, NXEXIT_NXOPEN, + NXEXIT_FONTOPEN, NXEXIT_NXOPENTOOLBAR, NXEXIT_NXCONNECT, NXEXIT_NXSETBGCOLOR, @@ -251,7 +252,7 @@ struct nxeg_state_s * Public Variables ****************************************************************************/ -/* The connecton handler */ +/* The connecton handle */ extern NXHANDLE g_hnx; @@ -262,6 +263,10 @@ extern const struct nx_callback_s g_nxcb; extern const struct nx_callback_s g_tbcb; #endif +/* The font handle */ + +extern NXHANDLE g_fonthandle; + /* The screen resolution */ extern nxgl_coord_t g_xres; diff --git a/apps/examples/nx/nx_kbdin.c b/apps/examples/nx/nx_kbdin.c index 66d54b046..b2a40d352 100644 --- a/apps/examples/nx/nx_kbdin.c +++ b/apps/examples/nx/nx_kbdin.c @@ -323,7 +323,7 @@ nxeg_getglyph(FAR struct nxeg_state_s *st, uint8_t ch) { /* No, it is not cached... Does the code map to a glyph? */ - bm = nxf_getbitmap(ch, NXFONT_DEFAULT); + bm = nxf_getbitmap(g_fonthandle, ch); if (!bm) { /* No, there is no glyph for this code. Use space */ diff --git a/apps/examples/nx/nx_main.c b/apps/examples/nx/nx_main.c index 72e8fe2ca..6d85d0fb7 100644 --- a/apps/examples/nx/nx_main.c +++ b/apps/examples/nx/nx_main.c @@ -102,6 +102,10 @@ static const uint8_t g_kbdmsg1[] = "NuttX is cool!"; static const uint8_t g_kbdmsg2[] = "NuttX is fun!"; #endif +/* The font handle */ + +NXHANDLE g_fonthandle; + /**************************************************************************** * Public Data ****************************************************************************/ @@ -179,7 +183,7 @@ static void nxeg_initstate(FAR struct nxeg_state_s *st, int wnum, */ #ifdef CONFIG_NX_KBD - fontset = nxf_getfontset(NXFONT_DEFAULT); + fontset = nxf_getfontset(g_fonthandle); st->nchars = 0; st->nglyphs = 0; st->height = fontset->mxheight; @@ -637,6 +641,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_NX_BGCOLOR); -- cgit v1.2.3