Integrating font capabilities; debug bitmap logic

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1415 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2008-12-04 23:03:33 +00:00
parent 6956b4543e
commit acaffaf715
10 changed files with 43 additions and 73 deletions

View File

@ -228,7 +228,7 @@ struct nxeg_state_s
ubyte wnum; /* Window number */ ubyte wnum; /* Window number */
nxgl_mxpixel_t color[CONFIG_NX_NPLANES]; /* Window color */ nxgl_mxpixel_t color[CONFIG_NX_NPLANES]; /* Window color */
#if !defined(CONFIG_EXAMPLES_NX_RAWWINDOWS) && defined(CONFIG_NX_KBD) #ifdef CONFIG_NX_KBD
ubyte height; /* Max height of a font in pixels */ ubyte height; /* Max height of a font in pixels */
ubyte width; /* Max width of a font in pixels */ ubyte width; /* Max width of a font in pixels */
@ -287,9 +287,9 @@ extern FAR void *nx_listenerthread(FAR void *arg);
extern void nxeg_kbdin(NXWINDOW hwnd, ubyte nch, const ubyte *ch, FAR void *arg); extern void nxeg_kbdin(NXWINDOW hwnd, ubyte nch, const ubyte *ch, FAR void *arg);
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS #ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
extern void nxeg_tbkbdin(NXWINDOW hwnd, ubyte nch, const ubyte *ch, FAR void *arg); extern void nxeg_tbkbdin(NXWINDOW hwnd, ubyte nch, const ubyte *ch, FAR void *arg);
#endif
extern void nxeg_filltext(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, extern void nxeg_filltext(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
FAR struct nxeg_state_s *st); FAR struct nxeg_state_s *st);
#endif #endif
#endif
#endif /* __EXAMPLES_NX_NX_INTERNAL_H */ #endif /* __EXAMPLES_NX_NX_INTERNAL_H */

View File

@ -61,7 +61,6 @@
* pixel depths that are not directly addressable (1,2,4, and 24). * pixel depths that are not directly addressable (1,2,4, and 24).
*/ */
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
#if CONFIG_EXAMPLES_NX_BPP == 8 #if CONFIG_EXAMPLES_NX_BPP == 8
# define RENDERER nxf_convert_8bpp # define RENDERER nxf_convert_8bpp
#elif CONFIG_EXAMPLES_NX_BPP == 16 #elif CONFIG_EXAMPLES_NX_BPP == 16
@ -71,7 +70,6 @@
#else #else
# error "Unsupported CONFIG_EXAMPLES_NX_BPP" # error "Unsupported CONFIG_EXAMPLES_NX_BPP"
#endif #endif
#endif
/**************************************************************************** /****************************************************************************
* Private Types * Private Types
@ -97,7 +95,6 @@
* Name: nxeg_fillchar * Name: nxeg_fillchar
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
static void nxeg_fillchar(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, static void nxeg_fillchar(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
FAR const struct nxeg_bitmap_s *bm) FAR const struct nxeg_bitmap_s *bm)
{ {
@ -110,41 +107,23 @@ static void nxeg_fillchar(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
if (!nxgl_nullrect(&intersection)) if (!nxgl_nullrect(&intersection))
{ {
FAR void *src = (FAR void *)bm->glyph->bitmap; FAR void *src = (FAR void *)bm->glyph->bitmap;
ret = nxtk_bitmapwindow((NXTKWINDOW)hwnd, &intersection, src, #ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
ret = nxtk_bitmapwindow((NXTKWINDOW)hwnd, &intersection, &src,
&bm->bounds.pt1, &bm->bounds.pt1,
(unsigned int)bm->glyph->stride); (unsigned int)bm->glyph->stride);
#if 0
EXTERN int nxtk_bitmapwindow(NXTKWINDOW hfwnd,
FAR const struct nxgl_rect_s *dest,
FAR const void *src[CONFIG_NX_NPLANES],
FAR const struct nxgl_point_s *origin,
unsigned int stride);
#endif
if (ret < 0) if (ret < 0)
{ {
message("nxeg_fillchar: nxtk_bitmapwindow failed: %d\n", errno); message("nxeg_fillchar: nxtk_bitmapwindow failed: %d\n", errno);
} }
} #else
} ret = nx_bitmap((NXWINDOW)hwnd, &intersection, &src,
&bm->bounds.pt1,
(unsigned int)bm->glyph->stride);
if (ret < 0)
{
message("nxeg_fillchar: nx_bitmapwindow failed: %d\n", errno);
}
#endif #endif
/****************************************************************************
* Name: nxeg_kbdinfo
****************************************************************************/
static void nxeg_kbdinfo(ubyte nch, const ubyte *ch)
{
int i;
for (i = 0; i < nch; i++)
{
if (isprint(ch[i]))
{
message(" ch[%d]=%c (%02x)\n", i, ch[i], ch[i]);
}
else
{
message(" ch[%d]= (%02x)\n", i, ch[i]);
}
} }
} }
@ -152,13 +131,11 @@ static void nxeg_kbdinfo(ubyte nch, const ubyte *ch)
* Name: nxeg_renderglyph * Name: nxeg_renderglyph
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
static inline FAR const struct nxeg_glyph_s * static inline FAR const struct nxeg_glyph_s *
nxeg_renderglyph(FAR struct nxeg_state_s *st, ubyte ch) nxeg_renderglyph(FAR struct nxeg_state_s *st, ubyte ch)
{ {
FAR struct nxeg_glyph_s *glyph = NULL; FAR struct nxeg_glyph_s *glyph = NULL;
FAR nxgl_mxpixel_t *ptr; FAR nxgl_mxpixel_t *ptr;
int bmstride;
int bmsize; int bmsize;
int row; int row;
int col; int col;
@ -170,13 +147,15 @@ nxeg_renderglyph(FAR struct nxeg_state_s *st, ubyte ch)
{ {
/* Allocate the glyph */ /* Allocate the glyph */
glyph = &st->glyph[st->nglyphs]; glyph = &st->glyph[st->nglyphs];
glyph->code = ch;
/* Allocate the maximum size for the bitmap */ /* Allocate the maximum size for the bitmap */
glyph->stride = (st->width * CONFIG_EXAMPLES_NX_BPP + 4) / 8; glyph->stride = (st->width * CONFIG_EXAMPLES_NX_BPP + 4) / 8;
bmsize = glyph->stride * st->height; bmsize = glyph->stride * st->height;
glyph->bitmap = (FAR ubyte *)malloc(bmsize); glyph->bitmap = (FAR ubyte *)malloc(bmsize);
if (glyph->bitmap) if (glyph->bitmap)
{ {
/* Initialize the glyph memory to the background color */ /* Initialize the glyph memory to the background color */
@ -196,7 +175,7 @@ nxeg_renderglyph(FAR struct nxeg_state_s *st, ubyte ch)
/* Then render the glyph into the allocated memory */ /* Then render the glyph into the allocated memory */
glyph->width = RENDERER((FAR nxgl_mxpixel_t*)glyph->bitmap, glyph->width = RENDERER((FAR nxgl_mxpixel_t*)glyph->bitmap,
st->height, st->width, bmstride, st->height, st->width, glyph->stride,
ch, CONFIG_EXAMPLES_NX_FONTCOLOR); ch, CONFIG_EXAMPLES_NX_FONTCOLOR);
if (glyph->width <= 0) if (glyph->width <= 0)
{ {
@ -216,13 +195,11 @@ nxeg_renderglyph(FAR struct nxeg_state_s *st, ubyte ch)
return glyph; return glyph;
} }
#endif
/**************************************************************************** /****************************************************************************
* Name: nxeg_getglyph * Name: nxeg_getglyph
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
static FAR const struct nxeg_glyph_s * static FAR const struct nxeg_glyph_s *
nxeg_getglyph(FAR struct nxeg_state_s *st, ubyte ch) nxeg_getglyph(FAR struct nxeg_state_s *st, ubyte ch)
{ {
@ -230,8 +207,7 @@ nxeg_getglyph(FAR struct nxeg_state_s *st, ubyte ch)
/* First, try to find the glyph in the cache of pre-rendered glyphs */ /* First, try to find the glyph in the cache of pre-rendered glyphs */
message("nxeg_getglyph: ch=%02x\n", ch); for (i = 0; i < st->nglyphs; i++)
for (i = 0; i < st->nglyphs; i++)
{ {
if (st->glyph[i].code == ch) if (st->glyph[i].code == ch)
{ {
@ -243,13 +219,11 @@ nxeg_getglyph(FAR struct nxeg_state_s *st, ubyte ch)
return nxeg_renderglyph(st, ch); return nxeg_renderglyph(st, ch);
} }
#endif
/**************************************************************************** /****************************************************************************
* Name: nxeg_addchar * Name: nxeg_addchar
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
static FAR const struct nxeg_bitmap_s * static FAR const struct nxeg_bitmap_s *
nxeg_addchar(FAR struct nxeg_state_s *st, ubyte ch) nxeg_addchar(FAR struct nxeg_state_s *st, ubyte ch)
{ {
@ -260,12 +234,11 @@ nxeg_addchar(FAR struct nxeg_state_s *st, ubyte ch)
/* Is there space for another character on the display? */ /* Is there space for another character on the display? */
message("nxeg_addchar: ch=%02x\n", ch);
if (st->nchars < NXTK_MAXKBDCHARS) if (st->nchars < NXTK_MAXKBDCHARS)
{ {
/* Yes, setup the bitmap */ /* Yes, setup the bitmap */
bm = &st->bm[st->nchars]; bm = &st->bm[st->nchars];
/* Find the matching glyph */ /* Find the matching glyph */
@ -295,19 +268,17 @@ nxeg_addchar(FAR struct nxeg_state_s *st, ubyte ch)
bm->bounds.pt1.x = leftx; bm->bounds.pt1.x = leftx;
bm->bounds.pt1.y = 2; bm->bounds.pt1.y = 2;
bm->bounds.pt2.x = leftx + bm->glyph->width - 1; bm->bounds.pt2.x = leftx + bm->glyph->width - 1;
bm->bounds.pt2.x = 2 + st->height - 1; bm->bounds.pt2.y = 2 + st->height - 1;
st->nchars++; st->nchars++;
} }
return bm; return bm;
} }
#endif
/**************************************************************************** /****************************************************************************
* Name: nxeg_addchars * Name: nxeg_addchars
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
static inline void nxeg_addchars(NXWINDOW hwnd, FAR struct nxeg_state_s *st, static inline void nxeg_addchars(NXWINDOW hwnd, FAR struct nxeg_state_s *st,
ubyte nch, FAR const ubyte *ch) ubyte nch, FAR const ubyte *ch)
{ {
@ -319,7 +290,6 @@ static inline void nxeg_addchars(NXWINDOW hwnd, FAR struct nxeg_state_s *st,
nxeg_fillchar(hwnd, &bm->bounds, bm); nxeg_fillchar(hwnd, &bm->bounds, bm);
} }
} }
#endif
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
@ -333,11 +303,7 @@ void nxeg_kbdin(NXWINDOW hwnd, ubyte nch, FAR const ubyte *ch, FAR void *arg)
{ {
FAR struct nxeg_state_s *st = (FAR struct nxeg_state_s *)arg; FAR struct nxeg_state_s *st = (FAR struct nxeg_state_s *)arg;
message("nxeg_kbdin%d: hwnd=%p nch=%d\n", st->wnum, hwnd, nch); message("nxeg_kbdin%d: hwnd=%p nch=%d\n", st->wnum, hwnd, nch);
#ifdef CONFIG_EXAMPLES_NX_RAWWINDOWS
nxeg_kbdinfo(nch, ch);
#else
nxeg_addchars(hwnd, st, nch, ch); nxeg_addchars(hwnd, st, nch, ch);
#endif
} }
/**************************************************************************** /****************************************************************************
@ -358,7 +324,6 @@ void nxeg_tbkbdin(NXWINDOW hwnd, ubyte nch, const ubyte *ch, FAR void *arg)
* Name: nxeg_tbkbdin * Name: nxeg_tbkbdin
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
void nxeg_filltext(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, void nxeg_filltext(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
FAR struct nxeg_state_s *st) FAR struct nxeg_state_s *st)
{ {
@ -368,6 +333,5 @@ void nxeg_filltext(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
nxeg_fillchar(hwnd, rect, &st->bm[i]); nxeg_fillchar(hwnd, rect, &st->bm[i]);
} }
} }
#endif
#endif /* CONFIG_NX_KBD */ #endif /* CONFIG_NX_KBD */

View File

@ -143,7 +143,7 @@ static void nxeg_drivemouse(void)
static void nxeg_initstate(FAR struct nxeg_state_s *st, int wnum, static void nxeg_initstate(FAR struct nxeg_state_s *st, int wnum,
nxgl_mxpixel_t color) nxgl_mxpixel_t color)
{ {
#if !defined(CONFIG_EXAMPLES_NX_RAWWINDOWS) && defined(CONFIG_NX_KBD) #ifdef CONFIG_NX_KBD
FAR const struct nx_font_s *fontset; FAR const struct nx_font_s *fontset;
#endif #endif
@ -158,7 +158,7 @@ static void nxeg_initstate(FAR struct nxeg_state_s *st, int wnum,
* state structure * state structure
*/ */
#if !defined(CONFIG_EXAMPLES_NX_RAWWINDOWS) && defined(CONFIG_NX_KBD) #ifdef CONFIG_NX_KBD
fontset = nxf_getfontset(); fontset = nxf_getfontset();
st->nchars = 0; st->nchars = 0;
st->nglyphs = 0; st->nglyphs = 0;

View File

@ -179,7 +179,7 @@ void nxbe_clipper(FAR struct nxbe_window_s *wnd,
FAR struct nxbe_clipops_s *cops, FAR struct nxbe_clipops_s *cops,
FAR struct nxbe_plane_s *plane) FAR struct nxbe_plane_s *plane)
{ {
struct nxbe_clipstack_s stack; struct nxbe_clipstack_s stack;
FAR struct nxbe_window_s *currw; FAR struct nxbe_window_s *currw;
struct nxgl_rect_s rect; struct nxgl_rect_s rect;
struct nxgl_rect_s obscuredrect; struct nxgl_rect_s obscuredrect;

View File

@ -102,10 +102,12 @@ void NXGL_FUNCNAME(nxgl_copyrectangle,NXGLIB_SUFFIX)
deststride = pinfo->stride; deststride = pinfo->stride;
/* Get the dimensions of the rectange to fill: height in rows and width in bytes */ /* Get the dimensions of the rectange to fill: width in pixels,
* height in rows
*/
width = NXGL_SCALEX(dest->pt2.x - dest->pt1.x + 1); width = dest->pt2.x - dest->pt1.x + 1;
rows = dest->pt2.y - dest->pt1.y + 1; rows = dest->pt2.y - dest->pt1.y + 1;
#if NXGLIB_BITSPERPIXEL < 8 #if NXGLIB_BITSPERPIXEL < 8
# ifdef CONFIG_NXGL_PACKEDMSFIRST # ifdef CONFIG_NXGL_PACKEDMSFIRST
@ -168,7 +170,7 @@ void NXGL_FUNCNAME(nxgl_copyrectangle,NXGLIB_SUFFIX)
#else #else
/* Copy the whole line */ /* Copy the whole line */
NXGL_MEMCPY((NXGL_PIXEL_T*)dest, (NXGL_PIXEL_T*)sline, width); NXGL_MEMCPY((NXGL_PIXEL_T*)dline, (NXGL_PIXEL_T*)sline, width);
#endif #endif
dline += deststride; dline += deststride;
sline += srcstride; sline += srcstride;

View File

@ -85,8 +85,8 @@
* will receive the bit map. * will receive the bit map.
* src - The start of the source image. * src - The start of the source image.
* origin - The origin of the upper, left-most corner of the full bitmap. * origin - The origin of the upper, left-most corner of the full bitmap.
* Both dest and origin are in window coordinates, however, origin * Both dest and origin are in sub-window coordinates, however, the
* may lie outside of the display. * origin may lie outside of the sub-window display.
* stride - The width of the full source image in pixels. * stride - The width of the full source image in pixels.
* *
* Return: * Return:

View File

@ -85,8 +85,8 @@
* will receive the bit map. * will receive the bit map.
* src - The start of the source image. * src - The start of the source image.
* origin - The origin of the upper, left-most corner of the full bitmap. * origin - The origin of the upper, left-most corner of the full bitmap.
* Both dest and origin are in window coordinates, however, origin * Both dest and origin are in sub-window coordinates, however, the
* may lie outside of the display. * origin may lie outside of the sub-window display.
* stride - The width of the full source image in pixels. * stride - The width of the full source image in pixels.
* *
* Return: * Return:

View File

@ -659,7 +659,8 @@ EXTERN int nx_move(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
* hwnd - The window that will receive the bitmap image * hwnd - The window that will receive the bitmap image
* dest - Describes the rectangular on the display that will receive the * dest - Describes the rectangular on the display that will receive the
* the bit map. * the bit map.
* src - The start of the source image. * src - The start of the source image. This is an array source
* images of size CONFIG_NX_NPLANES.
* origin - The origin of the upper, left-most corner of the full bitmap. * origin - The origin of the upper, left-most corner of the full bitmap.
* Both dest and origin are in window coordinates, however, origin * Both dest and origin are in window coordinates, however, origin
* may lie outside of the display. * may lie outside of the display.

View File

@ -43,6 +43,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <fixedmath.h> #include <fixedmath.h>
#include <nuttx/fb.h>
/**************************************************************************** /****************************************************************************
* Pre-processor definitions * Pre-processor definitions

View File

@ -273,10 +273,11 @@ EXTERN int nxtk_movewindow(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect,
* hfwnd The client sub0window that will receive the bitmap image * hfwnd The client sub0window that will receive the bitmap image
* dest - Describes the rectangular region on in the client sub-window * dest - Describes the rectangular region on in the client sub-window
* will receive the bit map. * will receive the bit map.
* src - The start of the source image. * src - The start of the source image(s). This is an array source
* images of size CONFIG_NX_NPLANES.
* origin - The origin of the upper, left-most corner of the full bitmap. * origin - The origin of the upper, left-most corner of the full bitmap.
* Both dest and origin are in window coordinates, however, origin * Both dest and origin are in sub-window coordinates, however, the
* may lie outside of the display. * origin may lie outside of the sub-window display.
* stride - The width of the full source image in pixels. * stride - The width of the full source image in pixels.
* *
* Return: * Return:
@ -286,7 +287,7 @@ EXTERN int nxtk_movewindow(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect,
EXTERN int nxtk_bitmapwindow(NXTKWINDOW hfwnd, EXTERN int nxtk_bitmapwindow(NXTKWINDOW hfwnd,
FAR const struct nxgl_rect_s *dest, FAR const struct nxgl_rect_s *dest,
FAR const void **src, FAR const void *src[CONFIG_NX_NPLANES],
FAR const struct nxgl_point_s *origin, FAR const struct nxgl_point_s *origin,
unsigned int stride); unsigned int stride);
@ -364,6 +365,7 @@ EXTERN int nxtk_filltoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect
EXTERN int nxtk_filltraptoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_trapezoid_s *trap, EXTERN int nxtk_filltraptoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_trapezoid_s *trap,
nxgl_mxpixel_t color[CONFIG_NX_NPLANES]); nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
/**************************************************************************** /****************************************************************************
* Name: nxtk_movetoolbar * Name: nxtk_movetoolbar
* *
@ -399,8 +401,8 @@ EXTERN int nxtk_movetoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect
* will receive the bit map. * will receive the bit map.
* src - The start of the source image. * src - The start of the source image.
* origin - The origin of the upper, left-most corner of the full bitmap. * origin - The origin of the upper, left-most corner of the full bitmap.
* Both dest and origin are in window coordinates, however, origin * Both dest and origin are in sub-window coordinates, however, the
* may lie outside of the display. * origin may lie outside of the sub-window display.
* stride - The width of the full source image in pixels. * stride - The width of the full source image in pixels.
* *
* Return: * Return: