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:
parent
6956b4543e
commit
acaffaf715
@ -228,7 +228,7 @@ struct nxeg_state_s
|
||||
ubyte wnum; /* Window number */
|
||||
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 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);
|
||||
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
|
||||
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,
|
||||
FAR struct nxeg_state_s *st);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* __EXAMPLES_NX_NX_INTERNAL_H */
|
||||
|
@ -61,7 +61,6 @@
|
||||
* pixel depths that are not directly addressable (1,2,4, and 24).
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
|
||||
#if CONFIG_EXAMPLES_NX_BPP == 8
|
||||
# define RENDERER nxf_convert_8bpp
|
||||
#elif CONFIG_EXAMPLES_NX_BPP == 16
|
||||
@ -71,7 +70,6 @@
|
||||
#else
|
||||
# error "Unsupported CONFIG_EXAMPLES_NX_BPP"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
@ -97,7 +95,6 @@
|
||||
* Name: nxeg_fillchar
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
|
||||
static void nxeg_fillchar(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
|
||||
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))
|
||||
{
|
||||
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,
|
||||
(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)
|
||||
{
|
||||
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
|
||||
|
||||
/****************************************************************************
|
||||
* 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
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
|
||||
static inline FAR const struct nxeg_glyph_s *
|
||||
nxeg_renderglyph(FAR struct nxeg_state_s *st, ubyte ch)
|
||||
{
|
||||
FAR struct nxeg_glyph_s *glyph = NULL;
|
||||
FAR nxgl_mxpixel_t *ptr;
|
||||
int bmstride;
|
||||
int bmsize;
|
||||
int row;
|
||||
int col;
|
||||
@ -170,13 +147,15 @@ nxeg_renderglyph(FAR struct nxeg_state_s *st, ubyte ch)
|
||||
{
|
||||
/* Allocate the glyph */
|
||||
|
||||
glyph = &st->glyph[st->nglyphs];
|
||||
glyph = &st->glyph[st->nglyphs];
|
||||
glyph->code = ch;
|
||||
|
||||
/* Allocate the maximum size for the bitmap */
|
||||
|
||||
glyph->stride = (st->width * CONFIG_EXAMPLES_NX_BPP + 4) / 8;
|
||||
bmsize = glyph->stride * st->height;
|
||||
glyph->bitmap = (FAR ubyte *)malloc(bmsize);
|
||||
|
||||
if (glyph->bitmap)
|
||||
{
|
||||
/* 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 */
|
||||
|
||||
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);
|
||||
if (glyph->width <= 0)
|
||||
{
|
||||
@ -216,13 +195,11 @@ nxeg_renderglyph(FAR struct nxeg_state_s *st, ubyte ch)
|
||||
|
||||
return glyph;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxeg_getglyph
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
|
||||
static FAR const struct nxeg_glyph_s *
|
||||
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 */
|
||||
|
||||
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)
|
||||
{
|
||||
@ -243,13 +219,11 @@ nxeg_getglyph(FAR struct nxeg_state_s *st, ubyte ch)
|
||||
|
||||
return nxeg_renderglyph(st, ch);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxeg_addchar
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
|
||||
static FAR const struct nxeg_bitmap_s *
|
||||
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? */
|
||||
|
||||
message("nxeg_addchar: ch=%02x\n", ch);
|
||||
if (st->nchars < NXTK_MAXKBDCHARS)
|
||||
{
|
||||
/* Yes, setup the bitmap */
|
||||
|
||||
bm = &st->bm[st->nchars];
|
||||
bm = &st->bm[st->nchars];
|
||||
|
||||
/* 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.y = 2;
|
||||
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++;
|
||||
}
|
||||
return bm;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxeg_addchars
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
|
||||
static inline void nxeg_addchars(NXWINDOW hwnd, FAR struct nxeg_state_s *st,
|
||||
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);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* 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;
|
||||
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);
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -358,7 +324,6 @@ void nxeg_tbkbdin(NXWINDOW hwnd, ubyte nch, const ubyte *ch, FAR void *arg)
|
||||
* Name: nxeg_tbkbdin
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
|
||||
void nxeg_filltext(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
|
||||
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]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_NX_KBD */
|
||||
|
@ -143,7 +143,7 @@ static void nxeg_drivemouse(void)
|
||||
static void nxeg_initstate(FAR struct nxeg_state_s *st, int wnum,
|
||||
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;
|
||||
#endif
|
||||
|
||||
@ -158,7 +158,7 @@ static void nxeg_initstate(FAR struct nxeg_state_s *st, int wnum,
|
||||
* state structure
|
||||
*/
|
||||
|
||||
#if !defined(CONFIG_EXAMPLES_NX_RAWWINDOWS) && defined(CONFIG_NX_KBD)
|
||||
#ifdef CONFIG_NX_KBD
|
||||
fontset = nxf_getfontset();
|
||||
st->nchars = 0;
|
||||
st->nglyphs = 0;
|
||||
|
@ -179,7 +179,7 @@ void nxbe_clipper(FAR struct nxbe_window_s *wnd,
|
||||
FAR struct nxbe_clipops_s *cops,
|
||||
FAR struct nxbe_plane_s *plane)
|
||||
{
|
||||
struct nxbe_clipstack_s stack;
|
||||
struct nxbe_clipstack_s stack;
|
||||
FAR struct nxbe_window_s *currw;
|
||||
struct nxgl_rect_s rect;
|
||||
struct nxgl_rect_s obscuredrect;
|
||||
|
@ -102,10 +102,12 @@ void NXGL_FUNCNAME(nxgl_copyrectangle,NXGLIB_SUFFIX)
|
||||
|
||||
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);
|
||||
rows = dest->pt2.y - dest->pt1.y + 1;
|
||||
width = dest->pt2.x - dest->pt1.x + 1;
|
||||
rows = dest->pt2.y - dest->pt1.y + 1;
|
||||
|
||||
#if NXGLIB_BITSPERPIXEL < 8
|
||||
# ifdef CONFIG_NXGL_PACKEDMSFIRST
|
||||
@ -168,7 +170,7 @@ void NXGL_FUNCNAME(nxgl_copyrectangle,NXGLIB_SUFFIX)
|
||||
#else
|
||||
/* 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
|
||||
dline += deststride;
|
||||
sline += srcstride;
|
||||
|
@ -85,8 +85,8 @@
|
||||
* will receive the bit map.
|
||||
* src - The start of the source image.
|
||||
* origin - The origin of the upper, left-most corner of the full bitmap.
|
||||
* Both dest and origin are in window coordinates, however, origin
|
||||
* may lie outside of the display.
|
||||
* Both dest and origin are in sub-window coordinates, however, the
|
||||
* origin may lie outside of the sub-window display.
|
||||
* stride - The width of the full source image in pixels.
|
||||
*
|
||||
* Return:
|
||||
|
@ -85,8 +85,8 @@
|
||||
* will receive the bit map.
|
||||
* src - The start of the source image.
|
||||
* origin - The origin of the upper, left-most corner of the full bitmap.
|
||||
* Both dest and origin are in window coordinates, however, origin
|
||||
* may lie outside of the display.
|
||||
* Both dest and origin are in sub-window coordinates, however, the
|
||||
* origin may lie outside of the sub-window display.
|
||||
* stride - The width of the full source image in pixels.
|
||||
*
|
||||
* Return:
|
||||
|
@ -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
|
||||
* dest - Describes the rectangular on the display that will receive the
|
||||
* 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.
|
||||
* Both dest and origin are in window coordinates, however, origin
|
||||
* may lie outside of the display.
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
#include <fixedmath.h>
|
||||
#include <nuttx/fb.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor definitions
|
||||
|
@ -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
|
||||
* dest - Describes the rectangular region on in the client sub-window
|
||||
* 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.
|
||||
* Both dest and origin are in window coordinates, however, origin
|
||||
* may lie outside of the display.
|
||||
* Both dest and origin are in sub-window coordinates, however, the
|
||||
* origin may lie outside of the sub-window display.
|
||||
* stride - The width of the full source image in pixels.
|
||||
*
|
||||
* Return:
|
||||
@ -286,7 +287,7 @@ EXTERN int nxtk_movewindow(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *rect,
|
||||
|
||||
EXTERN int nxtk_bitmapwindow(NXTKWINDOW hfwnd,
|
||||
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,
|
||||
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,
|
||||
nxgl_mxpixel_t color[CONFIG_NX_NPLANES]);
|
||||
|
||||
/****************************************************************************
|
||||
* 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.
|
||||
* src - The start of the source image.
|
||||
* origin - The origin of the upper, left-most corner of the full bitmap.
|
||||
* Both dest and origin are in window coordinates, however, origin
|
||||
* may lie outside of the display.
|
||||
* Both dest and origin are in sub-window coordinates, however, the
|
||||
* origin may lie outside of the sub-window display.
|
||||
* stride - The width of the full source image in pixels.
|
||||
*
|
||||
* Return:
|
||||
|
Loading…
Reference in New Issue
Block a user