diff options
author | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-03-28 19:29:30 +0000 |
---|---|---|
committer | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-03-28 19:29:30 +0000 |
commit | d6a01ce6a92b091e540b37c5f09fb441a9aaea30 (patch) | |
tree | 3e362aceae490cf42ce2a690d5e86f7fcb1cfe5b /nuttx/graphics | |
parent | 79b7dc6f097ae217d02206884ef509fd78e94fb0 (diff) |
The NX console appears to be fully functional
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4536 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/graphics')
-rw-r--r-- | nuttx/graphics/nxconsole/nxcon_font.c | 45 | ||||
-rw-r--r-- | nuttx/graphics/nxconsole/nxcon_internal.h | 47 | ||||
-rwxr-xr-x | nuttx/graphics/nxconsole/nxcon_redraw.c | 21 | ||||
-rw-r--r-- | nuttx/graphics/nxconsole/nxcon_register.c | 21 | ||||
-rw-r--r-- | nuttx/graphics/nxconsole/nxcon_unregister.c | 6 | ||||
-rw-r--r-- | nuttx/graphics/nxmu/nx_disconnect.c | 2 | ||||
-rw-r--r-- | nuttx/graphics/nxmu/nx_releasebkgd.c | 2 | ||||
-rw-r--r-- | nuttx/graphics/nxmu/nxmu_server.c | 25 |
8 files changed, 83 insertions, 86 deletions
diff --git a/nuttx/graphics/nxconsole/nxcon_font.c b/nuttx/graphics/nxconsole/nxcon_font.c index c8336a289a..436f91477d 100644 --- a/nuttx/graphics/nxconsole/nxcon_font.c +++ b/nuttx/graphics/nxconsole/nxcon_font.c @@ -47,6 +47,8 @@ #include <errno.h> #include <debug.h> +#include <nuttx/kmalloc.h> + #include <nuttx/nx/nx.h> #include <nuttx/nx/nxtk.h> #include <nuttx/nx/nxfonts.h> @@ -103,14 +105,16 @@ * Name: nxcon_freeglyph ****************************************************************************/ +#ifdef CONFIG_NXCONSOLE_FONTCACHE static void nxcon_freeglyph(FAR struct nxcon_glyph_s *glyph) { if (glyph->bitmap) { - free(glyph->bitmap); + kfree(glyph->bitmap); } memset(glyph, 0, sizeof(struct nxcon_glyph_s)); } +#endif /**************************************************************************** * Name: nxcon_allocglyph @@ -183,9 +187,6 @@ nxcon_allocglyph(FAR struct nxcon_state_s *priv) luglyph->usecnt = 1; return luglyph; #else - /* TODO: Instead allocating an freeing, just allocate the max glyph once */ - - nxcon_freeglyph(&priv->glyph); return &priv->glyph; #endif } @@ -236,7 +237,6 @@ 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; @@ -255,29 +255,50 @@ nxcon_renderglyph(FAR struct nxcon_state_s *priv, glyph->width = fbm->metric.width + fbm->metric.xoffset; glyph->height = fbm->metric.height + fbm->metric.yoffset; - /* Allocate memory to hold the glyph with its offsets */ + /* Get the physical width of the glyph in bytes */ glyph->stride = (glyph->width * CONFIG_NXCONSOLE_BPP + 7) / 8; - bmsize = glyph->stride * glyph->height; - glyph->bitmap = (FAR uint8_t *)malloc(bmsize); + + /* 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 if (glyph->bitmap) { - /* Initialize the glyph memory to the background color */ + /* Initialize the glyph memory to the background color using the + * hard-coded bits-per-pixel (BPP). + * + * TODO: The rest of NX is configured to support multiple devices + * with differing BPP. They logic should be extended to support + * differing BPP's as well. + */ #if CONFIG_NXCONSOLE_BPP < 8 pixel = priv->wcolor[0]; + # if CONFIG_NXCONSOLE_BPP == 1 + /* Pack 1-bit pixels into a 2-bits */ pixel &= 0x01; - pixel = (pixel) << 1 |pixel; + pixel = (pixel) << 1 | pixel; + # endif # if CONFIG_NXCONSOLE_BPP < 4 + /* Pack 2-bit pixels into a nibble */ pixel &= 0x03; - pixel = (pixel) << 2 |pixel; + pixel = (pixel) << 2 | pixel; + # endif /* Pack 4-bit nibbles into a byte */ @@ -323,7 +344,9 @@ 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; } } diff --git a/nuttx/graphics/nxconsole/nxcon_internal.h b/nuttx/graphics/nxconsole/nxcon_internal.h index f5cbc9c6d5..963511b298 100644 --- a/nuttx/graphics/nxconsole/nxcon_internal.h +++ b/nuttx/graphics/nxconsole/nxcon_internal.h @@ -55,53 +55,6 @@ /**************************************************************************** * Definitions ****************************************************************************/ -/* Configuration ************************************************************/ -/* The maximum number of characters that can be remembered */ - -#ifndef CONFIG_NXCONSOLE_MXCHARS -# define CONFIG_NXCONSOLE_MXCHARS 128 -#endif - -/* Font cache -- this is the number or pre-rendered font glyphs that can be - * remembered. - */ - -#ifdef CONFIG_NXCONSOLE_FONTCACHE -# ifndef CONFIG_NXCONSOLE_CACHESIZE -# define CONFIG_NXCONSOLE_CACHESIZE 16 -# endif -#else -# undef CONFIG_NXCONSOLE_CACHESIZE -#endif - -/* Pixel depth */ - -#ifndef CONFIG_NXCONSOLE_BPP -# if !defined(CONFIG_NX_DISABLE_1BPP) -# define CONFIG_NXCONSOLE_BPP 1 -# elif !defined(CONFIG_NX_DISABLE_2BPP) -# define CONFIG_NXCONSOLE_BPP 2 -# elif !defined(CONFIG_NX_DISABLE_4BPP) -# define CONFIG_NXCONSOLE_BPP 4 -# elif !defined(CONFIG_NX_DISABLE_8BPP) -# define CONFIG_NXCONSOLE_BPP 8 -# elif !defined(CONFIG_NX_DISABLE_16BPP) -# define CONFIG_NXCONSOLE_BPP 16 -//#elif !defined(CONFIG_NX_DISABLE_24BPP) -//# define CONFIG_NXCONSOLE_BPP 24 -# elif !defined(CONFIG_NX_DISABLE_32BPP) -# define CONFIG_NXCONSOLE_BPP 32 -# else -# error "No pixel depth provided" -# endif -#endif - -/* Space (in rows) between lines */ - -#ifndef CONFIG_NXCONSOLE_LINESEPARATION -# define CONFIG_NXCONSOLE_LINESEPARATION 2 -#endif - /* NxConsole Definitions ****************************************************/ /* Bitmap flags */ diff --git a/nuttx/graphics/nxconsole/nxcon_redraw.c b/nuttx/graphics/nxconsole/nxcon_redraw.c index 23bebd6225..1a40a7ee16 100755 --- a/nuttx/graphics/nxconsole/nxcon_redraw.c +++ b/nuttx/graphics/nxconsole/nxcon_redraw.c @@ -41,6 +41,7 @@ #include <stdint.h> #include <stdbool.h> +#include <semaphore.h> #include <assert.h> #include <errno.h> #include <debug.h> @@ -112,6 +113,25 @@ void nxcon_redraw(NXCONSOLE handle, FAR const struct nxgl_rect_s *rect, bool mor priv = (FAR struct nxcon_state_s *)handle; + /* Get exclusive access to the state structure */ + + do + { + ret = sem_wait(&priv->exclsem); + + /* Check for errors */ + + if (ret < 0) + { + /* The only expected error is if the wait failed because of it + * was interrupted by a signal. + */ + + DEBUGASSERT(errno == EINTR); + } + } + while (ret < 0); + /* Fill the rectangular region with the window background color */ ret = priv->ops->fill(priv, rect, priv->wndo.wcolor); @@ -128,4 +148,5 @@ void nxcon_redraw(NXCONSOLE handle, FAR const struct nxgl_rect_s *rect, bool mor { nxcon_fillchar(priv, rect, &priv->bm[i]); } + ret = sem_post(&priv->exclsem); } diff --git a/nuttx/graphics/nxconsole/nxcon_register.c b/nuttx/graphics/nxconsole/nxcon_register.c index cc878b2399..78f6a10519 100644 --- a/nuttx/graphics/nxconsole/nxcon_register.c +++ b/nuttx/graphics/nxconsole/nxcon_register.c @@ -120,13 +120,32 @@ FAR struct nxcon_state_s * priv->fwidth = fontset->mxwidth; priv->spwidth = fontset->spwidth; - /* Set up the text caches */ + /* Set up the text cache */ priv->maxchars = CONFIG_NXCONSOLE_MXCHARS; + + /* Set up the font glyph bitmap cache (if enabled) */ + #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 */ nxcon_home(priv); diff --git a/nuttx/graphics/nxconsole/nxcon_unregister.c b/nuttx/graphics/nxconsole/nxcon_unregister.c index 8a19736edd..25dbd40c66 100644 --- a/nuttx/graphics/nxconsole/nxcon_unregister.c +++ b/nuttx/graphics/nxconsole/nxcon_unregister.c @@ -97,6 +97,12 @@ void nxcon_unregister(NXCONSOLE handle) priv = (FAR struct nxcon_state_s *)handle; sem_destroy(&priv->exclsem); + /* Free the pre-allocated glyph bitmap */ + +#ifndef CONFIG_NXCONSOLE_FONTCACHE + kfree(priv->glyph.bitmap); +#endif + /* Unregister the driver */ snprintf(devname, NX_DEVNAME_SIZE, NX_DEVNAME_FORMAT, priv->minor); diff --git a/nuttx/graphics/nxmu/nx_disconnect.c b/nuttx/graphics/nxmu/nx_disconnect.c index 24fb114f49..f4711b0053 100644 --- a/nuttx/graphics/nxmu/nx_disconnect.c +++ b/nuttx/graphics/nxmu/nx_disconnect.c @@ -94,7 +94,7 @@ void nx_disconnect(NXHANDLE handle) /* Inform the server that this client no longer exists */ - msg.msgid = NX_SVRMSG_CONNECT; + msg.msgid = NX_SVRMSG_DISCONNECT; msg.conn = conn; ret = mq_send(conn->cwrmq, &msg, sizeof(struct nxsvrmsg_s), NX_SVRMSG_PRIO); diff --git a/nuttx/graphics/nxmu/nx_releasebkgd.c b/nuttx/graphics/nxmu/nx_releasebkgd.c index 4e8a756790..99815b1e71 100644 --- a/nuttx/graphics/nxmu/nx_releasebkgd.c +++ b/nuttx/graphics/nxmu/nx_releasebkgd.c @@ -1,7 +1,7 @@ /**************************************************************************** * graphics/nxmu/nx_releasebkgd.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without diff --git a/nuttx/graphics/nxmu/nxmu_server.c b/nuttx/graphics/nxmu/nxmu_server.c index 9cd9e578a9..fbd03464fd 100644 --- a/nuttx/graphics/nxmu/nxmu_server.c +++ b/nuttx/graphics/nxmu/nxmu_server.c @@ -130,31 +130,6 @@ static inline void nxmu_connect(FAR struct nxfe_conn_s *conn) } /**************************************************************************** - * Name: nxmu_release - ****************************************************************************/ - -static int nxmu_release(FAR struct nxfe_state_s *fe) -{ - FAR struct nxbe_window_s *wnd; - struct nxclimsg_s outmsg; - int ret; - - /* Don't want windows to close while we do this */ - - for (wnd = fe->be.topwnd; wnd; wnd = wnd->below) - { - outmsg.msgid = NX_CLIMSG_DISCONNECTED; - ret = mq_send(wnd->conn->swrmq, &outmsg, sizeof(struct nxclimsg_s), NX_CLIMSG_PRIO); - if (ret < 0) - { - gdbg("mq_send failed: %d\n", errno); - } - } - - return OK; -} - -/**************************************************************************** * Name: nxmu_shutdown ****************************************************************************/ |