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/nxhello | |
parent | 89b5382e22ed897121c864865fdb79acddc9ba14 (diff) | |
download | px4-nuttx-622a6cc576f1e5b97abcb78441ed04674217bfe6.tar.gz px4-nuttx-622a6cc576f1e5b97abcb78441ed04674217bfe6.tar.bz2 px4-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/nxhello')
-rw-r--r-- | apps/examples/nxhello/nxhello.h | 4 | ||||
-rw-r--r-- | apps/examples/nxhello/nxhello_bkgd.c | 6 | ||||
-rw-r--r-- | apps/examples/nxhello/nxhello_main.c | 12 |
3 files changed, 18 insertions, 4 deletions
diff --git a/apps/examples/nxhello/nxhello.h b/apps/examples/nxhello/nxhello.h index d5d5c724b..b7343a054 100644 --- a/apps/examples/nxhello/nxhello.h +++ b/apps/examples/nxhello/nxhello.h @@ -120,6 +120,7 @@ enum exitcode_e NXEXIT_LCDINITIALIZE, NXEXIT_LCDGETDEV, NXEXIT_NXOPEN, + NXEXIT_FONTOPEN, NXEXIT_NXREQUESTBKGD, NXEXIT_NXSETBGCOLOR }; @@ -147,10 +148,11 @@ struct nxhello_bitmap_s struct nxhello_data_s { - /* The NX handle */ + /* The NX handles */ NXHANDLE hnx; NXHANDLE hbkgd; + NXHANDLE hfont; /* The screen resolution */ diff --git a/apps/examples/nxhello/nxhello_bkgd.c b/apps/examples/nxhello/nxhello_bkgd.c index 9ec3e5141..f3c6b8add 100644 --- a/apps/examples/nxhello/nxhello_bkgd.c +++ b/apps/examples/nxhello/nxhello_bkgd.c @@ -228,7 +228,7 @@ static void nxhello_center(FAR struct nxgl_point_s *pos, { /* Get the font bitmap for this character */ - fbm = nxf_getbitmap(*ptr, NXFONT_DEFAULT); + fbm = nxf_getbitmap(g_nxhello.hfont, *ptr); if (fbm) { /* Add the font size */ @@ -353,7 +353,7 @@ void nxhello_hello(NXWINDOW hwnd) /* Get information about the font we are going to use */ - fontset = nxf_getfontset(NXFONT_DEFAULT); + fontset = nxf_getfontset(g_nxhello.hfont); /* Allocate a bit of memory to hold the largest rendered font */ @@ -377,7 +377,7 @@ void nxhello_hello(NXWINDOW hwnd) { /* Get the bitmap font for this ASCII code */ - fbm = nxf_getbitmap(*ptr, NXFONT_DEFAULT); + fbm = nxf_getbitmap(g_nxhello.hfont, *ptr); if (fbm) { uint8_t fheight; /* Height of this glyph (in rows) */ diff --git a/apps/examples/nxhello/nxhello_main.c b/apps/examples/nxhello/nxhello_main.c index 02b2f17a2..98b16bb1d 100644 --- a/apps/examples/nxhello/nxhello_main.c +++ b/apps/examples/nxhello/nxhello_main.c @@ -61,6 +61,7 @@ #include <nuttx/arch.h> #include <nuttx/nx.h> #include <nuttx/nxglib.h> +#include <nuttx/nxfonts.h> #include "nxhello.h" @@ -101,6 +102,7 @@ struct nxhello_data_s g_nxhello = { NULL, /* hnx */ NULL, /* hbkgd */ + NULL, /* hfont */ 0, /* xres */ 0, /* yres */ false, /* havpos */ @@ -228,6 +230,16 @@ int MAIN_NAME(int argc, char *argv[]) goto errout; } + /* Get the default font handle */ + + g_nxhello.hfont = nxf_getfonthandle(NXFONT_DEFAULT); + if (!g_nxhello.hfont) + { + message("user_start: Failed to get font handle: %d\n", errno); + g_nxhello.code = NXEXIT_FONTOPEN; + goto errout; + } + /* Set the background to the configured background color */ message(MAIN_NAME_STRING ": Set background color=%d\n", |