Squashed commit of the following:
apps/graphics/pdcur34: Various fixes from initial testing. Still does not work apps/graphics/pdcurs34/nuttx: Completes first cut at framebuffer rendering logic.
This commit is contained in:
parent
ad54b77f33
commit
42bb5643bf
@ -223,7 +223,7 @@ static void draw_rect1(FAR struct fb_state_s *state,
|
||||
static void draw_rect(FAR struct fb_state_s *state,
|
||||
FAR struct nxgl_rect_s *rect, int color)
|
||||
{
|
||||
#ifdef CONFIG_NX_UPDATE
|
||||
#ifdef CONFIG_LCD_UPDATE
|
||||
int ret;
|
||||
#endif
|
||||
|
||||
@ -247,7 +247,7 @@ static void draw_rect(FAR struct fb_state_s *state,
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NX_UPDATE
|
||||
#ifdef CONFIG_LCD_UPDATE
|
||||
ret = ioctl(state->fd, FBIO_UPDATE,
|
||||
(unsigned long)((uintptr_t)rect));
|
||||
if (ret < 0)
|
||||
|
@ -9,45 +9,45 @@ config PDCURSES_FBDEV
|
||||
|
||||
choice
|
||||
prompt "TUI Font Selection"
|
||||
default PDCURSES_FOUNT_6X9
|
||||
default PDCURSES_FONT_6X13
|
||||
|
||||
config PDCURSES_FOUNT_4X6
|
||||
config PDCURSES_FONT_4X6
|
||||
bool "4x6"
|
||||
select NXFONT_X11_MISC_FIXED_4X6
|
||||
---help---
|
||||
Enables font ID FONTID_X11_MISC_FIXED_4X6 == 21.
|
||||
|
||||
config PDCURSES_FOUNT_5X7
|
||||
config PDCURSES_FONT_5X7
|
||||
bool "5x7"
|
||||
select NXFONT_X11_MISC_FIXED_5X7
|
||||
---help---
|
||||
Enables font ID FONTID_X11_MISC_FIXED_5X7 == 22.
|
||||
|
||||
config PDCURSES_FOUNT_5X8
|
||||
config PDCURSES_FONT_5X8
|
||||
bool "5x8"
|
||||
select NXFONT_X11_MISC_FIXED_5X8
|
||||
---help---
|
||||
Enables font ID FONTID_X11_MISC_FIXED_5X8 == 23.
|
||||
|
||||
config PDCURSES_FOUNT_6X9
|
||||
config PDCURSES_FONT_6X9
|
||||
bool "6x9"
|
||||
select NXFONT_X11_MISC_FIXED_6X9
|
||||
---help---
|
||||
Enables font ID FONTID_X11_MISC_FIXED_6X9 == 24.
|
||||
|
||||
config PDCURSES_FOUNT_6X10
|
||||
config PDCURSES_FONT_6X10
|
||||
bool "6x10"
|
||||
select NXFONT_X11_MISC_FIXED_6X10
|
||||
---help---
|
||||
Enables font ID FONTID_X11_MISC_FIXED_6X10 == 25.
|
||||
|
||||
config PDCURSES_FOUNT_6X12
|
||||
config PDCURSES_FONT_6X12
|
||||
bool "6x12"
|
||||
select NXFONT_X11_MISC_FIXED_6X12
|
||||
---help---
|
||||
Enables font ID FONTID_X11_MISC_FIXED_6X12 == 26.
|
||||
|
||||
config PDCURSES_FOUNT_6X13
|
||||
config PDCURSES_FONT_6X13
|
||||
bool "6x13"
|
||||
select NXFONT_X11_MISC_FIXED_6X13
|
||||
select NXFONT_X11_MISC_FIXED_6X13B
|
||||
@ -55,7 +55,7 @@ config PDCURSES_FOUNT_6X13
|
||||
Enables font ID FONTID_X11_MISC_FIXED_6X13 == 27 and
|
||||
bold font ID FONTID_X11_MISC_FIXED_6X13B == 28.
|
||||
|
||||
config PDCURSES_FOUNT_7X13
|
||||
config PDCURSES_FONT_7X13
|
||||
bool "7x13"
|
||||
select NXFONT_X11_MISC_FIXED_7X13
|
||||
select NXFONT_X11_MISC_FIXED_7X13B
|
||||
@ -63,7 +63,7 @@ config PDCURSES_FOUNT_7X13
|
||||
Enables font ID FONTID_X11_MISC_FIXED_7X13 == 30 and
|
||||
bold font ID FONTID_X11_MISC_FIXED_7X13B == 31.
|
||||
|
||||
config PDCURSES_FOUNT_7X14
|
||||
config PDCURSES_FONT_7X14
|
||||
bool "7x14"
|
||||
select NXFONT_X11_MISC_FIXED_7X14
|
||||
select NXFONT_X11_MISC_FIXED_7X14B
|
||||
@ -71,7 +71,7 @@ config PDCURSES_FOUNT_7X14
|
||||
Enables font ID FONTID_X11_MISC_FIXED_7X14 == 33 and
|
||||
bold font ID FONTID_X11_MISC_FIXED_7X14B == 34.
|
||||
|
||||
config PDCURSES_FOUNT_8X13
|
||||
config PDCURSES_FONT_8X13
|
||||
bool "8x13"
|
||||
select NXFONT_X11_MISC_FIXED_8X13
|
||||
select NXFONT_X11_MISC_FIXED_8X13B
|
||||
@ -79,7 +79,7 @@ config PDCURSES_FOUNT_8X13
|
||||
Enables font ID FONTID_X11_MISC_FIXED_8X13 == 35 and
|
||||
bold font ID FONTID_X11_MISC_FIXED_8X13B == 36.
|
||||
|
||||
config PDCURSES_FOUNT_9X15
|
||||
config PDCURSES_FONT_9X15
|
||||
bool "9x15"
|
||||
select NXFONT_X11_MISC_FIXED_9X15
|
||||
select NXFONT_X11_MISC_FIXED_9X15B
|
||||
@ -87,7 +87,7 @@ config PDCURSES_FOUNT_9X15
|
||||
Enables font ID FONTID_X11_MISC_FIXED_9X15 == 38 and
|
||||
bold font ID FONTID_X11_MISC_FIXED_9X15B == 39.
|
||||
|
||||
config PDCURSES_FOUNT_9X18
|
||||
config PDCURSES_FONT_9X18
|
||||
bool "9x18"
|
||||
select NXFONT_X11_MISC_FIXED_9X18
|
||||
select NXFONT_X11_MISC_FIXED_9X18B
|
||||
@ -95,10 +95,29 @@ config PDCURSES_FOUNT_9X18
|
||||
Enables font ID FONTID_X11_MISC_FIXED_9X18 == 40 and
|
||||
bold font ID FONTID_X11_MISC_FIXED_9X18B == 41.
|
||||
|
||||
config PDCURSES_FOUNT_10X20
|
||||
config PDCURSES_FONT_10X20
|
||||
bool "10x20"
|
||||
select NXFONT_X11_MISC_FIXED_10X20
|
||||
---help---
|
||||
Enables font ID FONTID_X11_MISC_FIXED_10X20 == 42.
|
||||
|
||||
endchoice # TUI Font Selection
|
||||
|
||||
choice
|
||||
prompt "Color Format Selection"
|
||||
default PDCURSES_COLORFMT_RGB565
|
||||
|
||||
config PDCURSES_COLORFMT_Y1
|
||||
bool "BPP=1 Monochrome"
|
||||
depends on EXPERIMENTAL
|
||||
|
||||
config PDCURSES_COLORFMT_RGB332
|
||||
bool "BPP=8 RGB332"
|
||||
|
||||
config PDCURSES_COLORFMT_RGB565
|
||||
bool "BPP=16 RGB565"
|
||||
|
||||
config PDCURSES_COLORFMT_RGB888
|
||||
bool "BPP=32 RGB888"
|
||||
|
||||
endchoice # Color Format Selection
|
||||
|
@ -37,8 +37,6 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "pdcnuttx.h"
|
||||
|
||||
/****************************************************************************
|
||||
@ -62,7 +60,302 @@
|
||||
* ports define it in pdcdisp.c, but this is not required.
|
||||
*/
|
||||
|
||||
chtype acs_map[128];
|
||||
#ifdef CONFIG_PDCURSES_CHTYPE_LONG
|
||||
|
||||
# define A(x) ((chtype)x | A_ALTCHARSET)
|
||||
|
||||
chtype acs_map[128] =
|
||||
{
|
||||
A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9),
|
||||
A(10), A(11), A(12), A(13), A(14), A(15), A(16), A(17), A(18),
|
||||
A(19), A(20), A(21), A(22), A(23), A(24), A(25), A(26), A(27),
|
||||
A(28), A(29), A(30), A(31), ' ', '!', '"', '#', '$', '%', '&',
|
||||
'\'', '(', ')', '*',
|
||||
|
||||
A(0x1a), A(0x1b), A(0x18), A(0x19),
|
||||
|
||||
'/',
|
||||
|
||||
0xdb,
|
||||
|
||||
'1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=',
|
||||
'>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
|
||||
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
||||
'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
|
||||
|
||||
A(0x04), 0xb1,
|
||||
|
||||
'b', 'c', 'd', 'e',
|
||||
|
||||
0xf8, 0xf1, 0xb0, A(0x0f), 0xd9, 0xbf, 0xda, 0xc0, 0xc5, 0x2d,
|
||||
0x2d, 0xc4, 0x2d, 0x5f, 0xc3, 0xb4, 0xc1, 0xc2, 0xb3, 0xf3,
|
||||
0xf2, 0xe3, 0xd8, 0x9c, 0xf9,
|
||||
|
||||
A(127)
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_pixel_[x|y]
|
||||
*
|
||||
* Description:
|
||||
* Convert row or column text position to framebuffer x/y positions
|
||||
* in pixels.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline fb_coord_t PDC_pixel_x(FAR struct pdc_fbstate_s *fbstate,
|
||||
int col)
|
||||
{
|
||||
return col * fbstate->fwidth + fbstate->hoffset;
|
||||
}
|
||||
|
||||
static inline fb_coord_t PDC_pixel_y(FAR struct pdc_fbstate_s *fbstate,
|
||||
int row)
|
||||
{
|
||||
return row * fbstate->fheight + fbstate->voffset;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_fbmem_[x|y]
|
||||
*
|
||||
* Description:
|
||||
* Convert row or column pixel position to framebuffer x/y byte offsets.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline fb_coord_t PDC_fbmem_x(FAR struct pdc_fbstate_s *fbstate,
|
||||
int col)
|
||||
{
|
||||
return (PDC_pixel_x(fbstate, col) * PDCURSES_BPP + 7) >> 3;
|
||||
}
|
||||
|
||||
static inline fb_coord_t PDC_fbmem_y(FAR struct pdc_fbstate_s *fbstate,
|
||||
int row)
|
||||
{
|
||||
return PDC_pixel_y(fbstate, row) * fbstate->stride;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_color
|
||||
*
|
||||
* Description:
|
||||
* Convert a pixel code to a RGB device pixel.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline pdc_color_t PDC_color(FAR struct pdc_fbstate_s *fbstate,
|
||||
short color)
|
||||
{
|
||||
#if defined(CONFIG_PDCURSES_COLORFMT_RGB332)
|
||||
return RGBTO8(fbstate->rgbcolor[color].red,
|
||||
fbstate->rgbcolor[color].green,
|
||||
fbstate->rgbcolor[color].blue);
|
||||
#elif defined(CONFIG_PDCURSES_COLORFMT_RGB565)
|
||||
return RGBTO16(fbstate->rgbcolor[color].red,
|
||||
fbstate->rgbcolor[color].green,
|
||||
fbstate->rgbcolor[color].blue);
|
||||
#elif defined(CONFIG_PDCURSES_COLORFMT_RGB888)
|
||||
return RGBTO24(fbstate->rgbcolor[color].red,
|
||||
fbstate->rgbcolor[color].green,
|
||||
fbstate->rgbcolor[color].blue);
|
||||
#else
|
||||
# error No color format selected
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_set_bg
|
||||
*
|
||||
* Description:
|
||||
* Set the glyph memory to the device background RGB color.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline void PDC_set_bg(FAR struct pdc_fbstate_s *fbstate,
|
||||
FAR uint8_t *fbstart, short bg)
|
||||
{
|
||||
pdc_color_t bgcolor = PDC_color(fbstate, bg);
|
||||
int row;
|
||||
|
||||
/* Set the glyph to the background color. */
|
||||
|
||||
for (row = 0; row < fbstate->fheight; row++, fbstart += fbstate->stride)
|
||||
{
|
||||
FAR pdc_color_t *fbdest;
|
||||
int col;
|
||||
|
||||
for (col = 0, fbdest = (FAR pdc_color_t *)fbstart;
|
||||
col < fbstate->fwidth;
|
||||
col++)
|
||||
{
|
||||
*fbdest++ = bgcolor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_render_gyph
|
||||
*
|
||||
* Description:
|
||||
* Render the font into the glyph memory using the foreground RGB color.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline void PDC_render_gyph(FAR struct pdc_fbstate_s *fbstate,
|
||||
FAR const struct nx_fontbitmap_s *fbm,
|
||||
FAR uint8_t *fbstart, short fg)
|
||||
{
|
||||
pdc_color_t fgcolor = PDC_color(fbstate, fg);
|
||||
int ret;
|
||||
|
||||
/* Then render the glyph into the allocated memory
|
||||
*
|
||||
* REVISIT: The case where visibility==1 is not yet handled. In that
|
||||
* case, only the lowe quarter of the glyph should be reversed.
|
||||
*/
|
||||
|
||||
ret = RENDERER((FAR pdc_color_t *)fbstart,
|
||||
fbstate->fheight, fbstate->fwidth, fbstate->stride,
|
||||
fbm, fgcolor);
|
||||
if (ret < 0)
|
||||
{
|
||||
/* Actually, the RENDERER never returns a failure */
|
||||
|
||||
PDC_LOG(("ERROR: RENDERER failed: %d\n", ret));
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_update
|
||||
*
|
||||
* Description:
|
||||
* Update the LCD display is necessary.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_LCD_UPDATE
|
||||
static void PDC_update(FAR struct pdc_fbstate_s *fbstate, int row, int col,
|
||||
int nchars)
|
||||
{
|
||||
struct nxgl_rect_s rect;
|
||||
int ret;
|
||||
|
||||
if (nchars > 0)
|
||||
{
|
||||
/* Setup the bounding rectangle */
|
||||
|
||||
rect.pt1.x = PDC_pixel_x(FAR fbstate, col);
|
||||
rect.pt1.y = PDC_pixel_x(FAR fbstate, row);
|
||||
rect.pt2.x = rect.pt1.x + nchars * fbstate->fwidth - 1;
|
||||
rect.pt2.y = y + fbstate->fheight - 1;
|
||||
|
||||
/* Then perfom the update via IOCTL */
|
||||
|
||||
ret = ioctl(fbstate->fd, FBIO_UPDATE,
|
||||
(unsigned long)((uintptr_t)rect));
|
||||
if (ret < 0)
|
||||
{
|
||||
PDC_LOG(("ERROR: ioctl(FBIO_UPDATE) failed: %d\n", errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define PDC_update(f,r,c,n)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: PDC_putc
|
||||
*
|
||||
* Description:
|
||||
* Put one character with selected attributes at the selected drawing
|
||||
* position.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void PDC_putc(FAR struct pdc_fbstate_s *fbstate, int row, int col,
|
||||
chtype ch)
|
||||
{
|
||||
FAR const struct nx_fontbitmap_s *fbm;
|
||||
FAR uint8_t *dest;
|
||||
short fg;
|
||||
short bg;
|
||||
#ifdef HAVE_BOLD_FONT
|
||||
bool bold = ((ch & A_BOLD) != 0);
|
||||
#endif
|
||||
|
||||
/* Clip */
|
||||
|
||||
if (row < 0 || row >= SP->lines || col < 0 || col >= SP->cols)
|
||||
{
|
||||
PDC_LOG(("ERROR: Position out of range: row=%d col=%d\n", row, col));
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get the forground and background colors of the character */
|
||||
|
||||
PDC_pair_content(PAIR_NUMBER(ch), &fg, &bg);
|
||||
|
||||
/* Handle the A_REVERSE attribute. */
|
||||
|
||||
if ((ch & A_REVERSE) != 0)
|
||||
{
|
||||
/* Swap the foreground and background colors if reversed */
|
||||
|
||||
short tmp = fg;
|
||||
fg = bg;
|
||||
bg = tmp;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PDCURSES_CHTYPE_LONG
|
||||
/* Translate characters 0-127 via acs_map[], if they're flagged with
|
||||
* A_ALTCHARSET in the attribute portion of the chtype.
|
||||
*/
|
||||
|
||||
if (ch & A_ALTCHARSET && !(ch & 0xff80))
|
||||
{
|
||||
ch = (ch & (A_ATTRIBUTES ^ A_ALTCHARSET)) | acs_map[ch & 0x7f];
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Calculation the destination address in the framebuffer */
|
||||
|
||||
dest = (FAR uint8_t *)fbstate->fbmem +
|
||||
PDC_fbmem_y(fbstate, row) +
|
||||
PDC_fbmem_x(fbstate, col);
|
||||
|
||||
/* Initialize the glyph to the (possibly reversed) background color */
|
||||
|
||||
PDC_set_bg(fbstate, dest, bg);
|
||||
|
||||
/* Does the code map to a font? */
|
||||
|
||||
#ifdef HAVE_BOLD_FONT
|
||||
fbm = nxf_getbitmap(bold ? fbstate->hfont : fbstate->hbold,
|
||||
ch & A_CHARTEXT);
|
||||
#else
|
||||
fbm = nxf_getbitmap(fbstate->hfont, ch);
|
||||
#endif
|
||||
|
||||
if (fbm != NULL)
|
||||
{
|
||||
/* Yes.. render the glyph */
|
||||
|
||||
PDC_render_gyph(fbstate, fbm, dest, fg);
|
||||
}
|
||||
|
||||
/* Apply more attributes */
|
||||
|
||||
if ((ch & (A_UNDERLINE | A_LEFTLINE | A_RIGHTLINE)) != 0)
|
||||
{
|
||||
#warning Missing logic
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -79,41 +372,38 @@ chtype acs_map[128];
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* Position hardware cursor at (y, x) */
|
||||
|
||||
void PDC_gotoyx(int row, int col)
|
||||
{
|
||||
chtype ch;
|
||||
FAR struct pdc_fbscreen_s *fbscreen = (FAR struct pdc_fbscreen_s *)SP;
|
||||
FAR struct pdc_fbstate_s *fbstate;
|
||||
int oldrow;
|
||||
int oldcol;
|
||||
chtype ch;
|
||||
|
||||
PDC_LOG(("PDC_gotoyx() - called: row %d col %d\n", row, col));
|
||||
|
||||
if (SP->mono)
|
||||
{
|
||||
return;
|
||||
}
|
||||
DEBUGASSERT(fbscreen != NULL);
|
||||
fbstate = &fbscreen->fbstate;
|
||||
|
||||
/* Clear the old cursor */
|
||||
|
||||
oldrow = SP->cursrow;
|
||||
oldcol = SP->curscol;
|
||||
|
||||
PDC_transform_line(oldrow, oldcol, 1, curscr->_y[oldrow] + oldcol);
|
||||
PDC_putc(fbstate, oldrow, oldcol, curscr->_y[oldrow][oldcol]);
|
||||
PDC_update(fbstate, oldrow, oldcol, 1);
|
||||
|
||||
if (SP->visibility == 0)
|
||||
if (SP->visibility != 0)
|
||||
{
|
||||
return;
|
||||
/* Draw a new cursor by overprinting the existing character in
|
||||
* reverse, either the full cell (when visibility == 2) or the
|
||||
* lowest quarter of it (when visibility == 1)
|
||||
*/
|
||||
|
||||
ch = curscr->_y[row][col] ^ A_REVERSE;
|
||||
PDC_putc(fbstate, row, col, ch);
|
||||
PDC_update(fbstate, row, col, 1);
|
||||
}
|
||||
|
||||
/* Draw a new cursor by overprinting the existing character in reverse,
|
||||
* either the full cell (when visibility == 2) or the lowest quarter of
|
||||
* it (when visibility == 1)
|
||||
*/
|
||||
|
||||
ch = curscr->_y[row][col] ^ A_REVERSE;
|
||||
|
||||
PDC_transform_line(row, col, 1, &ch);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -132,10 +422,7 @@ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
|
||||
{
|
||||
FAR struct pdc_fbscreen_s *fbscreen = (FAR struct pdc_fbscreen_s *)SP;
|
||||
FAR struct pdc_fbstate_s *fbstate;
|
||||
chtype ch;
|
||||
short fg;
|
||||
short bg;
|
||||
bool bold;
|
||||
int nextx;
|
||||
int i;
|
||||
|
||||
PDC_LOG(("PDC_transform_line() - called: lineno=%d x=%d len=%d\n",
|
||||
@ -144,64 +431,22 @@ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
|
||||
DEBUGASSERT(fbscreen != NULL);
|
||||
fbstate = &fbscreen->fbstate;
|
||||
|
||||
/* Set up the start position for the transfer */
|
||||
#warning Missing logic
|
||||
|
||||
/* Add each character to the framebuffer at the current position,
|
||||
* incrementing the horizontal position after each character.
|
||||
*/
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
for (i = 0, nextx = x; i < len; i++, nextx++)
|
||||
{
|
||||
ch = srcp[i];
|
||||
|
||||
/* Get the forground and background colors of the font */
|
||||
|
||||
PDC_pair_content(PAIR_NUMBER(ch), &fg, &bg);
|
||||
|
||||
/* Handle attributes */
|
||||
|
||||
bold = false;
|
||||
if (!SP->mono)
|
||||
if (nextx >= SP->cols)
|
||||
{
|
||||
/* REVISIT: Only bold and reverse attributed handled */
|
||||
/* Bold will select the bold font.
|
||||
*/
|
||||
|
||||
bold = ((ch & A_BOLD) != 0);
|
||||
|
||||
/* Swap the foreground and background colors if reversed */
|
||||
|
||||
if ((ch & A_REVERSE) != 0)
|
||||
{
|
||||
short tmp = fg;
|
||||
fg = bg;
|
||||
bg = tmp;
|
||||
}
|
||||
PDC_LOG(("ERROR: Write past end of line\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PDCURSESCHTYPE_LONG
|
||||
/* Translate characters 0-127 via acs_map[], if they're flagged with
|
||||
* A_ALTCHARSET in the attribute portion of the chtype.
|
||||
*/
|
||||
/* Render the font glyph into the framebuffer */
|
||||
|
||||
if (ch & A_ALTCHARSET && !(ch & 0xff80))
|
||||
{
|
||||
ch = (ch & (A_ATTRIBUTES ^ A_ALTCHARSET)) | acs_map[ch & 0x7f];
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Rend the font glyph into the framebuffer */
|
||||
#warning Missing logic
|
||||
|
||||
/* Apply more attributes */
|
||||
|
||||
if ((ch & (A_UNDERLINE | A_LEFTLINE | A_RIGHTLINE)) != 0)
|
||||
{
|
||||
#warning Missing logic
|
||||
}
|
||||
|
||||
/* Increment the X position by the font width */
|
||||
#warning Missing logic
|
||||
PDC_putc(fbstate, lineno, nextx, srcp[i]);
|
||||
}
|
||||
|
||||
PDC_update(fbstate, lineno, x, nextx - x);
|
||||
}
|
||||
|
@ -42,8 +42,12 @@
|
||||
|
||||
#include "nuttx/config.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "nuttx/nx/nx.h"
|
||||
#include "nuttx/nx/nxfonts.h"
|
||||
#include <nuttx/video/fb.h>
|
||||
#include <nuttx/video/rgbcolors.h>
|
||||
|
||||
#include "curspriv.h"
|
||||
|
||||
@ -53,55 +57,105 @@
|
||||
|
||||
#undef HAVE_BOLD_FONT
|
||||
|
||||
#if defined(CONFIG_PDCURSES_FOUNT_4X6)
|
||||
#if defined(CONFIG_PDCURSES_FONT_4X6)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_4X6
|
||||
# define PDCURSES_BOLD_FONTID FONTID_X11_MISC_FIXED_4X6
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_5X7)
|
||||
#elif defined(CONFIG_PDCURSES_FONT_5X7)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_5X7
|
||||
# define PDCURSES_BOLD_FONTID FONTID_X11_MISC_FIXED_5X7
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_5X8)
|
||||
#elif defined(CONFIG_PDCURSES_FONT_5X8)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_5X8
|
||||
# define PDCURSES_BOLD_FONTID FONTID_X11_MISC_FIXED_5X8
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_6X9)
|
||||
#elif defined(CONFIG_PDCURSES_FONT_6X9)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_6X9
|
||||
# define PDCURSES_BOLD_FONTID FONTID_X11_MISC_FIXED_6X9
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_6X10)
|
||||
#elif defined(CONFIG_PDCURSES_FONT_6X10)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_6X10
|
||||
# define PDCURSES_BOLD_FONTID FONTID_X11_MISC_FIXED_6X10
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_6X12)
|
||||
#elif defined(CONFIG_PDCURSES_FONT_6X12)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_6X12
|
||||
# define PDCURSES_BOLD_FONTID FONTID_X11_MISC_FIXED_6X12
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_6X13)
|
||||
#elif defined(CONFIG_PDCURSES_FONT_6X13)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_6X13
|
||||
# define PDCURSES_BOLD_FONTID FONTID_X11_MISC_FIXED_6X13B
|
||||
# define HAVE_BOLD_FONT 1
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_7X13)
|
||||
#elif defined(CONFIG_PDCURSES_FONT_7X13)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_7X13
|
||||
# define PDCURSES_BOLD_FONTID FONTID_X11_MISC_FIXED_7X13B
|
||||
# define HAVE_BOLD_FONT 1
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_7X14)
|
||||
#elif defined(CONFIG_PDCURSES_FONT_7X14)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_7X14
|
||||
# define PDCURSES_BOLD_FONTID FONTID_X11_MISC_FIXED_7X14B
|
||||
# define HAVE_BOLD_FONT 1
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_8X13)
|
||||
#elif defined(CONFIG_PDCURSES_FONT_8X13)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_8X13
|
||||
# define PDCURSES_BOLD_FONTID FONTID_X11_MISC_FIXED_8X13B
|
||||
# define HAVE_BOLD_FONT 1
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_9X15)
|
||||
#elif defined(CONFIG_PDCURSES_FONT_9X15)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_9X15
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_9X15B
|
||||
# define HAVE_BOLD_FONT 1
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_9X18)
|
||||
#elif defined(CONFIG_PDCURSES_FONT_9X18)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_9X18
|
||||
# define PDCURSES_BOLD_FONTID FONTID_X11_MISC_FIXED_9X18B
|
||||
# define HAVE_BOLD_FONT 1
|
||||
#elif defined(CONFIG_PDCURSES_FOUNT_10X20)
|
||||
#elif defined(CONFIG_PDCURSES_FONT_10X20)
|
||||
# define PDCURSES_FONTID FONTID_X11_MISC_FIXED_10X20
|
||||
# define PDCURSES_BOLD_FONTID FONTID_X11_MISC_FIXED_10X20
|
||||
#else
|
||||
# error No fixed width font selected
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_PDCURSES_COLORFMT_Y1)
|
||||
# warning CONFIG_PDCURSES_COLORFMT_Y1 not yet supported
|
||||
# define PDCURSES_COLORFMT FB_FMT_Y1
|
||||
# define PDCURSES_BPP 1
|
||||
#elif defined(CONFIG_PDCURSES_COLORFMT_RGB332)
|
||||
# define PDCURSES_COLORFMT FB_FMT_RGB8_332
|
||||
# define PDCURSES_BPP 8
|
||||
# define PDCURSES_BPP_MASK 7
|
||||
# define PDCURSES_BPP_SHIFT 3
|
||||
#elif defined(CONFIG_PDCURSES_COLORFMT_RGB565)
|
||||
# define PDCURSES_COLORFMT FB_FMT_RGB16_565
|
||||
# define PDCURSES_BPP 16
|
||||
# define PDCURSES_BPP_MASK 15
|
||||
# define PDCURSES_BPP_SHIFT 4
|
||||
#elif defined(CONFIG_PDCURSES_COLORFMT_RGB888)
|
||||
# define PDCURSES_COLORFMT FB_FMT_RGB24 /* RGB24 at 32-BPP */
|
||||
# define PDCURSES_BPP 32
|
||||
# define PDCURSES_BPP_MASK 31
|
||||
# define PDCURSES_BPP_SHIFT 5
|
||||
#else
|
||||
# error No color format selected
|
||||
#endif
|
||||
|
||||
/* Select renderer -- Some additional logic would be required to support
|
||||
* pixel depths that are not directly addressable (1,2,4, and 24).
|
||||
*/
|
||||
|
||||
#if PDCURSES_BPP == 1
|
||||
# define RENDERER nxf_convert_1bpp
|
||||
#elif PDCURSES_BPP == 2
|
||||
# define RENDERER nxf_convert_2bpp
|
||||
#elif PDCURSES_BPP == 4
|
||||
# define RENDERER nxf_convert_4bpp
|
||||
#elif PDCURSES_BPP == 8
|
||||
# define RENDERER nxf_convert_8bpp
|
||||
#elif PDCURSES_BPP == 16
|
||||
# define RENDERER nxf_convert_16bpp
|
||||
#elif PDCURSES_BPP == 24
|
||||
# define RENDERER nxf_convert_24bpp
|
||||
#elif PDCURSES_BPP == 32
|
||||
# define RENDERER nxf_convert_32bpp
|
||||
#else
|
||||
# error "Unsupported bits-per-pixel"
|
||||
#endif
|
||||
|
||||
/* Convert bits to bytes to hold an even number of pixels */
|
||||
|
||||
#define PDCURSES_ALIGN_UP(n) (((n) + PDCURSES_BPP_MASK) >> 3)
|
||||
#define PDCURSES_ALIGN_DOWN(n) (((n) & ~PDCURSES_BPP_MASK) >> 3)
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
@ -131,6 +185,16 @@ struct pdc_rgbcolor_s
|
||||
uint8_t blue;
|
||||
};
|
||||
|
||||
/* Holds one framebuffer pixel */
|
||||
|
||||
#if defined(CONFIG_PDCURSES_COLORFMT_RGB332)
|
||||
typedef uint8_t pdc_color_t;
|
||||
#elif defined(CONFIG_PDCURSES_COLORFMT_RGB565)
|
||||
typedef uint16_t pdc_color_t;
|
||||
#elif defined(CONFIG_PDCURSES_COLORFMT_RGB888)
|
||||
typedef uint32_t pdc_color_t;
|
||||
#endif
|
||||
|
||||
/* This structure provides the overall state of the frambuffer device */
|
||||
|
||||
struct pdc_fbstate_s
|
||||
@ -138,26 +202,26 @@ struct pdc_fbstate_s
|
||||
/* Framebuffer */
|
||||
|
||||
int fd; /* Open framebuffer driver file descriptor */
|
||||
fb_coord_t xres; /* Horizontal resolution in pixel columns */
|
||||
fb_coord_t yres; /* Vertical resolution in pixel rows */
|
||||
fb_coord_t stride; /* Length of a line in bytes */
|
||||
uint8_t bpp; /* Bits per pixel */
|
||||
FAR void *fbmem; /* Start of framebuffer memory */
|
||||
fb_coord_t xres; /* Horizontal resolution (pixels) */
|
||||
fb_coord_t yres; /* Vertical resolution (rows) */
|
||||
fb_coord_t stride; /* Length of a line (bytes) */
|
||||
|
||||
/* Font */
|
||||
|
||||
NXHANDLE hfont; /* Handled uses to access selected font */
|
||||
uint8_t fheight; /* Height of the font in pixels */
|
||||
uint8_t fwidth; /* Width of the font in pixels */
|
||||
#ifdef HAVE_BOLD_FONT
|
||||
NXHANDLE hbold; /* Handled uses to access bold font */
|
||||
#endif
|
||||
uint8_t fheight; /* Height of the font (rows) */
|
||||
uint8_t fwidth; /* Width of the font (pixels) */
|
||||
|
||||
/* Drawable area (See also SP->lines and SP->cols) */
|
||||
|
||||
uint8_t hoffset; /* Offset from left of display in pixels */
|
||||
uint8_t voffset; /* Offset from top of display in lines */
|
||||
|
||||
/* Cursor position in display rows x pixels */
|
||||
|
||||
struct nxgl_point_s curpos;
|
||||
fb_coord_t xpos; /* Drawing X position (pixels) */
|
||||
fb_coord_t ypos; /* Drawing Y position (rows) */
|
||||
uint8_t hoffset; /* Offset from left of display (pixels) */
|
||||
uint8_t voffset; /* Offset from top of display (rows) */
|
||||
|
||||
/* Colors */
|
||||
|
||||
|
@ -163,6 +163,22 @@ int PDC_scr_open(int argc, char **argv)
|
||||
fbstate->xres = vinfo.xres; /* Horizontal resolution in pixel columns */
|
||||
fbstate->yres = vinfo.yres; /* Vertical resolution in pixel rows */
|
||||
|
||||
/* Only one color format supported. */
|
||||
|
||||
if (vinfo.fmt != PDCURSES_COLORFMT)
|
||||
{
|
||||
PDC_LOG(("ERROR: color format=%u not supported\n", vinfo.fmt));
|
||||
goto errout_with_fd;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PDCURSES_COLORFMT_Y1
|
||||
/* Remember if we are using a monochrome framebuffer */
|
||||
|
||||
SP->mono = true;
|
||||
#endif
|
||||
|
||||
/* Get characteristics of the color plane */
|
||||
|
||||
ret = ioctl(fbstate->fd, FBIOGET_PLANEINFO,
|
||||
(unsigned long)((uintptr_t)&pinfo));
|
||||
if (ret < 0)
|
||||
@ -179,14 +195,10 @@ int PDC_scr_open(int argc, char **argv)
|
||||
PDC_LOG((" bpp: %u\n", pinfo.bpp));
|
||||
|
||||
fbstate->stride = pinfo.stride; /* Length of a line in bytes */
|
||||
fbstate->bpp = pinfo.bpp; /* Bits per pixel */
|
||||
|
||||
/* Only these pixel depths are supported. vinfo.fmt is ignored, only
|
||||
* certain color formats are supported.
|
||||
*/
|
||||
/* Only one pixel depth is supported. */
|
||||
|
||||
if (pinfo.bpp != 32 && pinfo.bpp != 16 &&
|
||||
pinfo.bpp != 8 && pinfo.bpp != 1)
|
||||
if (pinfo.bpp != PDCURSES_BPP)
|
||||
{
|
||||
PDC_LOG(("ERROR: bpp=%u not supported\n", pinfo.bpp));
|
||||
goto errout_with_fd;
|
||||
@ -202,7 +214,7 @@ int PDC_scr_open(int argc, char **argv)
|
||||
*/
|
||||
|
||||
fbstate->fbmem = mmap(NULL, pinfo.fblen, PROT_READ|PROT_WRITE,
|
||||
MAP_SHARED|MAP_FILE, fbstate->fd, 0);
|
||||
MAP_SHARED|MAP_FILE, fbstate->fd, 0);
|
||||
if (fbstate->fbmem == MAP_FAILED)
|
||||
{
|
||||
PDC_LOG(("ERROR: ioctl(FBIOGET_PLANEINFO) failed: %d\n", errno));
|
||||
@ -211,22 +223,36 @@ int PDC_scr_open(int argc, char **argv)
|
||||
|
||||
PDC_LOG(("Mapped FB: %p\n", fbstate->fbmem));
|
||||
|
||||
/* The the handle for the selected font */
|
||||
/* Get the handle for the selected font */
|
||||
|
||||
fbstate->hfont = nxf_getfonthandle(PDCURSES_FONTID);
|
||||
if (fbstate->hfont == NULL)
|
||||
{
|
||||
PDC_LOG(("ERROR: Failed to get font handle: %d\n", errno);)
|
||||
PDC_LOG(("ERROR: Failed to get font handle: %d\n", errno));
|
||||
goto errout_with_fd;
|
||||
}
|
||||
|
||||
#ifdef HAVE_BOLD_FONT
|
||||
/* Get the handle for the matching bold font. It is assume that the
|
||||
* geometry of the bold font is exactly the same as the geometry of
|
||||
* the "normal" font.
|
||||
*/
|
||||
|
||||
fbstate->hbold = nxf_getfonthandle(PDCURSES_BOLD_FONTID);
|
||||
if (fbstate->hbold == NULL)
|
||||
{
|
||||
PDC_LOG(("ERROR: Failed to get font handle: %d\n", errno));
|
||||
goto errout_with_font;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Get information about the fontset */
|
||||
|
||||
fontset = nxf_getfontset(fbstate->hfont);
|
||||
if (fontset == NULL)
|
||||
{
|
||||
PDC_LOG(("ERROR: Failed to get font handle: %d\n", errno);)
|
||||
goto errout_with_font;
|
||||
PDC_LOG(("ERROR: Failed to get font handle: %d\n", errno));
|
||||
goto errout_with_boldfont;
|
||||
}
|
||||
|
||||
PDC_LOG(("Fonset (ID=%d):\n", PDCURSES_FONTID));
|
||||
@ -243,12 +269,15 @@ int PDC_scr_open(int argc, char **argv)
|
||||
SP->lines = fbstate->yres / fbstate->fheight;
|
||||
SP->cols = fbstate->xres / fbstate->fwidth;
|
||||
|
||||
fbstate->hoffset = (fbstate->yres - fbstate->fheight * SP->lines) / 2;
|
||||
fbstate->hoffset = (fbstate->yres - fbstate->fheight * SP->lines) / 2;
|
||||
fbstate->hoffset = (fbstate->xres - fbstate->fwidth * SP->cols) / 2;
|
||||
fbstate->voffset = (fbstate->yres - fbstate->fheight * SP->lines) / 2;
|
||||
|
||||
return OK;
|
||||
|
||||
errout_with_boldfont:
|
||||
#ifdef HAVE_BOLD_FONT
|
||||
errout_with_font:
|
||||
#endif
|
||||
|
||||
errout_with_fd:
|
||||
close(fbstate->fd);
|
||||
@ -387,6 +416,7 @@ int PDC_pair_content(short pair, short *fg, short *bg)
|
||||
fbstate = &fbscreen->fbstate;
|
||||
|
||||
*fg = fbstate->colorpair[pair].fg;
|
||||
*bg = fbstate->colorpair[pair].bg;
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user