apps/graphics/pdcurs34: Simply and combine some logic.
This commit is contained in:
parent
966faf3859
commit
a2ee61a124
@ -623,7 +623,10 @@ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
|
|||||||
|
|
||||||
void PDC_clear_screen(FAR struct pdc_fbstate_s *fbstate)
|
void PDC_clear_screen(FAR struct pdc_fbstate_s *fbstate)
|
||||||
{
|
{
|
||||||
|
FAR pdc_color_t *dest;
|
||||||
|
FAR pdc_color_t bgcolor;
|
||||||
FAR uint8_t *line;
|
FAR uint8_t *line;
|
||||||
|
int width;
|
||||||
int row;
|
int row;
|
||||||
int col;
|
int col;
|
||||||
|
|
||||||
@ -632,31 +635,32 @@ void PDC_clear_screen(FAR struct pdc_fbstate_s *fbstate)
|
|||||||
int ret;
|
int ret;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Get the background color and display width */
|
||||||
|
|
||||||
|
bgcolor = PDCURSES_INIT_COLOR;
|
||||||
|
width = fbstate->xres;
|
||||||
|
|
||||||
#if PDCURSES_BPP < 8
|
#if PDCURSES_BPP < 8
|
||||||
FAR uint8_t *dest;
|
/* Pack multiple pixels into one byte */
|
||||||
uint8_t color8;
|
|
||||||
int width;
|
|
||||||
|
|
||||||
/* Get a byte that packs multiple pixels into one byte */
|
#if PDCURSES_BPP == 1 /* BPP = 1 */
|
||||||
|
bgcolor &= 1; /* Isolate 0 */
|
||||||
color8 = PDCURSES_INIT_COLOR;
|
bgcolor = bgcolor << 1 | bgcolor; /* Replicate 0 to 1 */
|
||||||
|
bgcolor = bgcolor << 2 | bgcolor; /* Replicate 0-1 to 2-3 */
|
||||||
#if PDCURSES_BPP < 2 /* BPP = 1 */
|
bgcolor = bgcolor << 4 | bgcolor; /* Replicate 0-3 to 4-7 */
|
||||||
color8 &= 1; /* Isolate 0 */
|
#elif PDCURSES_BPP == 2 /* BPP = 2 */
|
||||||
color8 = color8 << 1 | color8; /* Replicate 0 to 1 */
|
bgcolor &= 3; /* Isolate 0-1 */
|
||||||
|
bgcolor = bgcolor << 2 | bgcolor; /* Replicate 0-1 to 2-3 */
|
||||||
|
bgcolor = bgcolor << 4 | bgcolor; /* Replicate 0-3 to 4-7 */
|
||||||
|
#else /* BPP = 4 */
|
||||||
|
bgcolor &= 15; /* Isolate 0-3 */
|
||||||
|
bgcolor = bgcolor << 4 | bgcolor; /* Replicate 0-3 to 4-7 */
|
||||||
#endif
|
#endif
|
||||||
#if PDCURSES_BPP < 4 /* BPP = (1,2} */
|
/* Convert the width of the display to units of bytes. */
|
||||||
color8 &= 3; /* Isolate 0-1 */
|
|
||||||
color8 = color8 << 2 | color8; /* Replicate 0-1 to 2-3 */
|
|
||||||
#endif /* BPP = (1,2,4} */
|
|
||||||
color8 &= 15; /* Isolate 0-3 */
|
|
||||||
color8 = color8 << 4 | color8; /* Replicate 0-3 to 4-7 */
|
|
||||||
|
|
||||||
/* Get the width of the display in bytes. */
|
width /= PDCURSES_PPB;
|
||||||
|
#endif
|
||||||
|
|
||||||
width = fbstate->xres / PDCURSES_PPB;
|
|
||||||
|
|
||||||
/* Now copy the color into the entire glyph region */
|
|
||||||
/* Write the initial color into the entire framebuffer */
|
/* Write the initial color into the entire framebuffer */
|
||||||
|
|
||||||
for (row = 0, line = (FAR uint8_t *)fbstate->fbmem;
|
for (row = 0, line = (FAR uint8_t *)fbstate->fbmem;
|
||||||
@ -667,26 +671,9 @@ void PDC_clear_screen(FAR struct pdc_fbstate_s *fbstate)
|
|||||||
col < width;
|
col < width;
|
||||||
col++)
|
col++)
|
||||||
{
|
{
|
||||||
*dest++ = color8;
|
*dest++ = bgcolor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
FAR pdc_color_t *dest;
|
|
||||||
|
|
||||||
/* Write the initial color into the entire framebuffer */
|
|
||||||
|
|
||||||
for (row = 0, line = (FAR uint8_t *)fbstate->fbmem;
|
|
||||||
row < fbstate->yres;
|
|
||||||
row++, line += fbstate->stride)
|
|
||||||
{
|
|
||||||
for (col = 0, dest = (FAR pdc_color_t *)line;
|
|
||||||
col < fbstate->xres;
|
|
||||||
col++)
|
|
||||||
{
|
|
||||||
*dest++ = PDCURSES_INIT_COLOR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_LCD_UPDATE
|
#ifdef CONFIG_LCD_UPDATE
|
||||||
/* Update the entire display */
|
/* Update the entire display */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user