lcd/grey: Enable viewport fg_pattern and bg_pattern for all bitmap targets.

Greylib performed a horrible hack and stored fg and bg patterns in other
struct viewport fields. One of them was just removed. So instead of
this hack simply enable the *_pattern fields for mono targets as well,
so that greylib can use them normally.

Change-Id: Ib0842ebcc97f5bf9d9382b4471903afa2f96f39f
This commit is contained in:
Thomas Martitz 2014-01-07 22:14:41 +01:00
parent e1c7b3b8f7
commit d146970ca1
5 changed files with 27 additions and 42 deletions

View file

@ -198,10 +198,6 @@ struct _grey_info
struct viewport *vp; /* current viewport in use */
};
/* Stuff these here for now. LCD depth of 1 has no 'pattern' members. */
#define _GREY_FG_BRIGHTNESS(vp) ((vp)->flags)
#define _GREY_BG_BRIGHTNESS(vp) ((vp)->line_height)
/* Global variable, defined in the plugin */
extern struct _grey_info _grey_info;

View file

@ -34,12 +34,12 @@ extern struct viewport _grey_default_vp;
static void setpixel(unsigned char *address)
{
*address = _GREY_FG_BRIGHTNESS(_grey_info.vp);
*address = _grey_info.vp->fg_pattern;
}
static void clearpixel(unsigned char *address)
{
*address = _GREY_BG_BRIGHTNESS(_grey_info.vp);
*address = _grey_info.vp->bg_pattern;
}
static void flippixel(unsigned char *address)
@ -75,7 +75,7 @@ void grey_clear_display(void)
struct viewport *vp = &_grey_default_vp;
int value = (vp->drawmode & DRMODE_INVERSEVID) ?
_GREY_FG_BRIGHTNESS(vp) : _GREY_BG_BRIGHTNESS(vp);
vp->fg_pattern : vp->bg_pattern;
rb->memset(_grey_info.curbuffer, value,
_GREY_MULUQ(_grey_info.cb_width, _grey_info.cb_height));
@ -207,7 +207,7 @@ void grey_hline(int x1, int x2, int y)
if (vp->drawmode & DRMODE_BG)
{
fillopt = true;
value = _GREY_BG_BRIGHTNESS(vp);
value = vp->bg_pattern;
}
}
else
@ -215,7 +215,7 @@ void grey_hline(int x1, int x2, int y)
if (vp->drawmode & DRMODE_FG)
{
fillopt = true;
value = _GREY_FG_BRIGHTNESS(vp);
value = vp->fg_pattern;
}
}
if (!fillopt && vp->drawmode != DRMODE_COMPLEMENT)
@ -386,7 +386,7 @@ void grey_fillrect(int x, int y, int width, int height)
if (vp->drawmode & DRMODE_BG)
{
fillopt = true;
value = _GREY_BG_BRIGHTNESS(vp);
value = vp->bg_pattern;
}
}
else
@ -394,7 +394,7 @@ void grey_fillrect(int x, int y, int width, int height)
if (vp->drawmode & DRMODE_FG)
{
fillopt = true;
value = _GREY_FG_BRIGHTNESS(vp);
value = vp->fg_pattern;
}
}
@ -544,7 +544,7 @@ void grey_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
break;
case DRMODE_BG:
bg = _GREY_BG_BRIGHTNESS(vp);
bg = vp->bg_pattern;
do
{
if (!(data & 0x01))
@ -557,7 +557,7 @@ void grey_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
break;
case DRMODE_FG:
fg = _GREY_FG_BRIGHTNESS(vp);
fg = vp->fg_pattern;
do
{
if (data & 0x01)
@ -570,8 +570,8 @@ void grey_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
break;
case DRMODE_SOLID:
fg = _GREY_FG_BRIGHTNESS(vp);
bg = _GREY_BG_BRIGHTNESS(vp);
fg = vp->fg_pattern;
bg = vp->bg_pattern;
do
{
*dst_col = (data & 0x01) ? fg : bg;
@ -699,8 +699,7 @@ void grey_ub_clear_display(void)
{
struct viewport *vp = &_grey_default_vp;
int value = _grey_info.gvalue[(vp->drawmode & DRMODE_INVERSEVID) ?
_GREY_FG_BRIGHTNESS(vp) :
_GREY_BG_BRIGHTNESS(vp)];
vp->fg_pattern : vp->bg_pattern];
rb->memset(_grey_info.values, value,
_GREY_MULUQ(_grey_info.width, _grey_info.height));

View file

@ -79,25 +79,25 @@ int grey_get_drawmode(void)
/* Set the foreground shade for subsequent drawing operations */
void grey_set_foreground(unsigned brightness)
{
_GREY_FG_BRIGHTNESS(_grey_info.vp) = brightness;
_grey_info.vp->fg_pattern = brightness;
}
/* Return the current foreground shade */
unsigned grey_get_foreground(void)
{
return _GREY_FG_BRIGHTNESS(_grey_info.vp);
return _grey_info.vp->fg_pattern;
}
/* Set the background shade for subsequent drawing operations */
void grey_set_background(unsigned brightness)
{
_GREY_BG_BRIGHTNESS(_grey_info.vp) = brightness;
_grey_info.vp->bg_pattern = brightness;
}
/* Return the current background shade */
unsigned grey_get_background(void)
{
return _GREY_BG_BRIGHTNESS(_grey_info.vp);
return _grey_info.vp->bg_pattern;
}
/* Set draw mode, foreground and background shades at once */
@ -177,8 +177,8 @@ void grey_viewport_set_fullscreen(struct viewport *vp,
vp->y = 0;
vp->width = _grey_info.width;
vp->height = _grey_info.height;
_GREY_FG_BRIGHTNESS(vp) = 0;
_GREY_BG_BRIGHTNESS(vp) = 255;
vp->fg_pattern = 0;
vp->bg_pattern = 255;
vp->drawmode = DRMODE_SOLID;
vp->font = FONT_SYSFIXED;
@ -258,4 +258,3 @@ void grey_framebuffer_set_pos(int x, int y, int width, int height)
grey_update_clip_rect();
}

View file

@ -48,8 +48,7 @@ void grey_scroll_left(int count)
data = _grey_info.buffer;
data_end = data + _GREY_MULUQ(_grey_info.width, _grey_info.height);
length = _grey_info.width - count;
blank = (vp->drawmode & DRMODE_INVERSEVID) ?
_GREY_FG_BRIGHTNESS(vp) : _GREY_BG_BRIGHTNESS(vp);
blank = (vp->drawmode & DRMODE_INVERSEVID) ? vp->fg_pattern : vp->bg_pattern;
do
{
@ -77,8 +76,7 @@ void grey_scroll_right(int count)
data = _grey_info.buffer;
data_end = data + _GREY_MULUQ(_grey_info.width, _grey_info.height);
length = _grey_info.width - count;
blank = (vp->drawmode & DRMODE_INVERSEVID) ?
_GREY_FG_BRIGHTNESS(vp) : _GREY_BG_BRIGHTNESS(vp);
blank = (vp->drawmode & DRMODE_INVERSEVID) ? vp->fg_pattern : vp->bg_pattern;
do
{
@ -104,8 +102,7 @@ void grey_scroll_up(int count)
shift = _GREY_MULUQ(_grey_info.width, count);
length = _GREY_MULUQ(_grey_info.width, _grey_info.height - count);
blank = (vp->drawmode & DRMODE_INVERSEVID) ?
_GREY_FG_BRIGHTNESS(vp) : _GREY_BG_BRIGHTNESS(vp);
blank = (vp->drawmode & DRMODE_INVERSEVID) ? vp->fg_pattern : vp->bg_pattern;
rb->memmove(_grey_info.buffer, _grey_info.buffer + shift,
length);
@ -127,8 +124,7 @@ void grey_scroll_down(int count)
shift = _GREY_MULUQ(_grey_info.width, count);
length = _GREY_MULUQ(_grey_info.width, _grey_info.height - count);
blank = (vp->drawmode & DRMODE_INVERSEVID) ?
_GREY_FG_BRIGHTNESS(vp) : _GREY_BG_BRIGHTNESS(vp);
blank = (vp->drawmode & DRMODE_INVERSEVID) ? vp->fg_pattern : vp->bg_pattern;
rb->memmove(_grey_info.buffer + shift, _grey_info.buffer,
length);
@ -155,8 +151,7 @@ void grey_ub_scroll_left(int count)
length = (_grey_info.width - count) << _GREY_BSHIFT;
count <<= _GREY_BSHIFT;
blank = _grey_info.gvalue[(vp->drawmode & DRMODE_INVERSEVID) ?
_GREY_FG_BRIGHTNESS(vp) :
_GREY_BG_BRIGHTNESS(vp)];
vp->fg_pattern : vp->bg_pattern];
do
{
rb->memmove(data, data + count, length);
@ -189,8 +184,7 @@ void grey_ub_scroll_right(int count)
length = (_grey_info.width - count) << _GREY_BSHIFT;
count <<= _GREY_BSHIFT;
blank = _grey_info.gvalue[(vp->drawmode & DRMODE_INVERSEVID) ?
_GREY_FG_BRIGHTNESS(vp) :
_GREY_BG_BRIGHTNESS(vp)];
vp->fg_pattern : vp->bg_pattern];
do
{
rb->memmove(data + count, data, length);
@ -220,8 +214,7 @@ void grey_ub_scroll_up(int count)
dst = _grey_info.values;
end = dst + _GREY_MULUQ(_grey_info.height, _grey_info.width);
blank = _grey_info.gvalue[(vp->drawmode & DRMODE_INVERSEVID) ?
_GREY_FG_BRIGHTNESS(vp) :
_GREY_BG_BRIGHTNESS(vp)];
vp->fg_pattern : vp->bg_pattern];
#if (LCD_PIXELFORMAT == VERTICAL_PACKING) \
|| (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)
@ -296,8 +289,7 @@ void grey_ub_scroll_down(int count)
start = _grey_info.values;
dst = start + _GREY_MULUQ(_grey_info.height, _grey_info.width);
blank = _grey_info.gvalue[(vp->drawmode & DRMODE_INVERSEVID) ?
_GREY_FG_BRIGHTNESS(vp) :
_GREY_BG_BRIGHTNESS(vp)];
vp->fg_pattern : vp->bg_pattern];
#if (LCD_PIXELFORMAT == VERTICAL_PACKING) \
|| (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)

View file

@ -44,8 +44,7 @@ struct viewport {
int flags;
int font;
int drawmode;
#endif
#if LCD_DEPTH > 1
/* needed for even for mono displays to support greylib */
unsigned fg_pattern;
unsigned bg_pattern;
#endif