forked from len0rd/rockbox
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:
parent
e1c7b3b8f7
commit
d146970ca1
5 changed files with 27 additions and 42 deletions
|
@ -198,10 +198,6 @@ struct _grey_info
|
||||||
struct viewport *vp; /* current viewport in use */
|
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 */
|
/* Global variable, defined in the plugin */
|
||||||
extern struct _grey_info _grey_info;
|
extern struct _grey_info _grey_info;
|
||||||
|
|
||||||
|
|
|
@ -34,12 +34,12 @@ extern struct viewport _grey_default_vp;
|
||||||
|
|
||||||
static void setpixel(unsigned char *address)
|
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)
|
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)
|
static void flippixel(unsigned char *address)
|
||||||
|
@ -75,7 +75,7 @@ void grey_clear_display(void)
|
||||||
struct viewport *vp = &_grey_default_vp;
|
struct viewport *vp = &_grey_default_vp;
|
||||||
|
|
||||||
int value = (vp->drawmode & DRMODE_INVERSEVID) ?
|
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,
|
rb->memset(_grey_info.curbuffer, value,
|
||||||
_GREY_MULUQ(_grey_info.cb_width, _grey_info.cb_height));
|
_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)
|
if (vp->drawmode & DRMODE_BG)
|
||||||
{
|
{
|
||||||
fillopt = true;
|
fillopt = true;
|
||||||
value = _GREY_BG_BRIGHTNESS(vp);
|
value = vp->bg_pattern;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -215,7 +215,7 @@ void grey_hline(int x1, int x2, int y)
|
||||||
if (vp->drawmode & DRMODE_FG)
|
if (vp->drawmode & DRMODE_FG)
|
||||||
{
|
{
|
||||||
fillopt = true;
|
fillopt = true;
|
||||||
value = _GREY_FG_BRIGHTNESS(vp);
|
value = vp->fg_pattern;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!fillopt && vp->drawmode != DRMODE_COMPLEMENT)
|
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)
|
if (vp->drawmode & DRMODE_BG)
|
||||||
{
|
{
|
||||||
fillopt = true;
|
fillopt = true;
|
||||||
value = _GREY_BG_BRIGHTNESS(vp);
|
value = vp->bg_pattern;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -394,7 +394,7 @@ void grey_fillrect(int x, int y, int width, int height)
|
||||||
if (vp->drawmode & DRMODE_FG)
|
if (vp->drawmode & DRMODE_FG)
|
||||||
{
|
{
|
||||||
fillopt = true;
|
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;
|
break;
|
||||||
|
|
||||||
case DRMODE_BG:
|
case DRMODE_BG:
|
||||||
bg = _GREY_BG_BRIGHTNESS(vp);
|
bg = vp->bg_pattern;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (!(data & 0x01))
|
if (!(data & 0x01))
|
||||||
|
@ -557,7 +557,7 @@ void grey_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DRMODE_FG:
|
case DRMODE_FG:
|
||||||
fg = _GREY_FG_BRIGHTNESS(vp);
|
fg = vp->fg_pattern;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (data & 0x01)
|
if (data & 0x01)
|
||||||
|
@ -570,8 +570,8 @@ void grey_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DRMODE_SOLID:
|
case DRMODE_SOLID:
|
||||||
fg = _GREY_FG_BRIGHTNESS(vp);
|
fg = vp->fg_pattern;
|
||||||
bg = _GREY_BG_BRIGHTNESS(vp);
|
bg = vp->bg_pattern;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
*dst_col = (data & 0x01) ? fg : bg;
|
*dst_col = (data & 0x01) ? fg : bg;
|
||||||
|
@ -699,8 +699,7 @@ void grey_ub_clear_display(void)
|
||||||
{
|
{
|
||||||
struct viewport *vp = &_grey_default_vp;
|
struct viewport *vp = &_grey_default_vp;
|
||||||
int value = _grey_info.gvalue[(vp->drawmode & DRMODE_INVERSEVID) ?
|
int value = _grey_info.gvalue[(vp->drawmode & DRMODE_INVERSEVID) ?
|
||||||
_GREY_FG_BRIGHTNESS(vp) :
|
vp->fg_pattern : vp->bg_pattern];
|
||||||
_GREY_BG_BRIGHTNESS(vp)];
|
|
||||||
|
|
||||||
rb->memset(_grey_info.values, value,
|
rb->memset(_grey_info.values, value,
|
||||||
_GREY_MULUQ(_grey_info.width, _grey_info.height));
|
_GREY_MULUQ(_grey_info.width, _grey_info.height));
|
||||||
|
|
|
@ -79,25 +79,25 @@ int grey_get_drawmode(void)
|
||||||
/* Set the foreground shade for subsequent drawing operations */
|
/* Set the foreground shade for subsequent drawing operations */
|
||||||
void grey_set_foreground(unsigned brightness)
|
void grey_set_foreground(unsigned brightness)
|
||||||
{
|
{
|
||||||
_GREY_FG_BRIGHTNESS(_grey_info.vp) = brightness;
|
_grey_info.vp->fg_pattern = brightness;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the current foreground shade */
|
/* Return the current foreground shade */
|
||||||
unsigned grey_get_foreground(void)
|
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 */
|
/* Set the background shade for subsequent drawing operations */
|
||||||
void grey_set_background(unsigned brightness)
|
void grey_set_background(unsigned brightness)
|
||||||
{
|
{
|
||||||
_GREY_BG_BRIGHTNESS(_grey_info.vp) = brightness;
|
_grey_info.vp->bg_pattern = brightness;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the current background shade */
|
/* Return the current background shade */
|
||||||
unsigned grey_get_background(void)
|
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 */
|
/* 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->y = 0;
|
||||||
vp->width = _grey_info.width;
|
vp->width = _grey_info.width;
|
||||||
vp->height = _grey_info.height;
|
vp->height = _grey_info.height;
|
||||||
_GREY_FG_BRIGHTNESS(vp) = 0;
|
vp->fg_pattern = 0;
|
||||||
_GREY_BG_BRIGHTNESS(vp) = 255;
|
vp->bg_pattern = 255;
|
||||||
vp->drawmode = DRMODE_SOLID;
|
vp->drawmode = DRMODE_SOLID;
|
||||||
vp->font = FONT_SYSFIXED;
|
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();
|
grey_update_clip_rect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,7 @@ void grey_scroll_left(int count)
|
||||||
data = _grey_info.buffer;
|
data = _grey_info.buffer;
|
||||||
data_end = data + _GREY_MULUQ(_grey_info.width, _grey_info.height);
|
data_end = data + _GREY_MULUQ(_grey_info.width, _grey_info.height);
|
||||||
length = _grey_info.width - count;
|
length = _grey_info.width - count;
|
||||||
blank = (vp->drawmode & DRMODE_INVERSEVID) ?
|
blank = (vp->drawmode & DRMODE_INVERSEVID) ? vp->fg_pattern : vp->bg_pattern;
|
||||||
_GREY_FG_BRIGHTNESS(vp) : _GREY_BG_BRIGHTNESS(vp);
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -77,8 +76,7 @@ void grey_scroll_right(int count)
|
||||||
data = _grey_info.buffer;
|
data = _grey_info.buffer;
|
||||||
data_end = data + _GREY_MULUQ(_grey_info.width, _grey_info.height);
|
data_end = data + _GREY_MULUQ(_grey_info.width, _grey_info.height);
|
||||||
length = _grey_info.width - count;
|
length = _grey_info.width - count;
|
||||||
blank = (vp->drawmode & DRMODE_INVERSEVID) ?
|
blank = (vp->drawmode & DRMODE_INVERSEVID) ? vp->fg_pattern : vp->bg_pattern;
|
||||||
_GREY_FG_BRIGHTNESS(vp) : _GREY_BG_BRIGHTNESS(vp);
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -104,8 +102,7 @@ void grey_scroll_up(int count)
|
||||||
|
|
||||||
shift = _GREY_MULUQ(_grey_info.width, count);
|
shift = _GREY_MULUQ(_grey_info.width, count);
|
||||||
length = _GREY_MULUQ(_grey_info.width, _grey_info.height - count);
|
length = _GREY_MULUQ(_grey_info.width, _grey_info.height - count);
|
||||||
blank = (vp->drawmode & DRMODE_INVERSEVID) ?
|
blank = (vp->drawmode & DRMODE_INVERSEVID) ? vp->fg_pattern : vp->bg_pattern;
|
||||||
_GREY_FG_BRIGHTNESS(vp) : _GREY_BG_BRIGHTNESS(vp);
|
|
||||||
|
|
||||||
rb->memmove(_grey_info.buffer, _grey_info.buffer + shift,
|
rb->memmove(_grey_info.buffer, _grey_info.buffer + shift,
|
||||||
length);
|
length);
|
||||||
|
@ -127,8 +124,7 @@ void grey_scroll_down(int count)
|
||||||
|
|
||||||
shift = _GREY_MULUQ(_grey_info.width, count);
|
shift = _GREY_MULUQ(_grey_info.width, count);
|
||||||
length = _GREY_MULUQ(_grey_info.width, _grey_info.height - count);
|
length = _GREY_MULUQ(_grey_info.width, _grey_info.height - count);
|
||||||
blank = (vp->drawmode & DRMODE_INVERSEVID) ?
|
blank = (vp->drawmode & DRMODE_INVERSEVID) ? vp->fg_pattern : vp->bg_pattern;
|
||||||
_GREY_FG_BRIGHTNESS(vp) : _GREY_BG_BRIGHTNESS(vp);
|
|
||||||
|
|
||||||
rb->memmove(_grey_info.buffer + shift, _grey_info.buffer,
|
rb->memmove(_grey_info.buffer + shift, _grey_info.buffer,
|
||||||
length);
|
length);
|
||||||
|
@ -155,8 +151,7 @@ void grey_ub_scroll_left(int count)
|
||||||
length = (_grey_info.width - count) << _GREY_BSHIFT;
|
length = (_grey_info.width - count) << _GREY_BSHIFT;
|
||||||
count <<= _GREY_BSHIFT;
|
count <<= _GREY_BSHIFT;
|
||||||
blank = _grey_info.gvalue[(vp->drawmode & DRMODE_INVERSEVID) ?
|
blank = _grey_info.gvalue[(vp->drawmode & DRMODE_INVERSEVID) ?
|
||||||
_GREY_FG_BRIGHTNESS(vp) :
|
vp->fg_pattern : vp->bg_pattern];
|
||||||
_GREY_BG_BRIGHTNESS(vp)];
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
rb->memmove(data, data + count, length);
|
rb->memmove(data, data + count, length);
|
||||||
|
@ -189,8 +184,7 @@ void grey_ub_scroll_right(int count)
|
||||||
length = (_grey_info.width - count) << _GREY_BSHIFT;
|
length = (_grey_info.width - count) << _GREY_BSHIFT;
|
||||||
count <<= _GREY_BSHIFT;
|
count <<= _GREY_BSHIFT;
|
||||||
blank = _grey_info.gvalue[(vp->drawmode & DRMODE_INVERSEVID) ?
|
blank = _grey_info.gvalue[(vp->drawmode & DRMODE_INVERSEVID) ?
|
||||||
_GREY_FG_BRIGHTNESS(vp) :
|
vp->fg_pattern : vp->bg_pattern];
|
||||||
_GREY_BG_BRIGHTNESS(vp)];
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
rb->memmove(data + count, data, length);
|
rb->memmove(data + count, data, length);
|
||||||
|
@ -220,8 +214,7 @@ void grey_ub_scroll_up(int count)
|
||||||
dst = _grey_info.values;
|
dst = _grey_info.values;
|
||||||
end = dst + _GREY_MULUQ(_grey_info.height, _grey_info.width);
|
end = dst + _GREY_MULUQ(_grey_info.height, _grey_info.width);
|
||||||
blank = _grey_info.gvalue[(vp->drawmode & DRMODE_INVERSEVID) ?
|
blank = _grey_info.gvalue[(vp->drawmode & DRMODE_INVERSEVID) ?
|
||||||
_GREY_FG_BRIGHTNESS(vp) :
|
vp->fg_pattern : vp->bg_pattern];
|
||||||
_GREY_BG_BRIGHTNESS(vp)];
|
|
||||||
|
|
||||||
#if (LCD_PIXELFORMAT == VERTICAL_PACKING) \
|
#if (LCD_PIXELFORMAT == VERTICAL_PACKING) \
|
||||||
|| (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)
|
|| (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)
|
||||||
|
@ -296,8 +289,7 @@ void grey_ub_scroll_down(int count)
|
||||||
start = _grey_info.values;
|
start = _grey_info.values;
|
||||||
dst = start + _GREY_MULUQ(_grey_info.height, _grey_info.width);
|
dst = start + _GREY_MULUQ(_grey_info.height, _grey_info.width);
|
||||||
blank = _grey_info.gvalue[(vp->drawmode & DRMODE_INVERSEVID) ?
|
blank = _grey_info.gvalue[(vp->drawmode & DRMODE_INVERSEVID) ?
|
||||||
_GREY_FG_BRIGHTNESS(vp) :
|
vp->fg_pattern : vp->bg_pattern];
|
||||||
_GREY_BG_BRIGHTNESS(vp)];
|
|
||||||
|
|
||||||
#if (LCD_PIXELFORMAT == VERTICAL_PACKING) \
|
#if (LCD_PIXELFORMAT == VERTICAL_PACKING) \
|
||||||
|| (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)
|
|| (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)
|
||||||
|
|
|
@ -44,8 +44,7 @@ struct viewport {
|
||||||
int flags;
|
int flags;
|
||||||
int font;
|
int font;
|
||||||
int drawmode;
|
int drawmode;
|
||||||
#endif
|
/* needed for even for mono displays to support greylib */
|
||||||
#if LCD_DEPTH > 1
|
|
||||||
unsigned fg_pattern;
|
unsigned fg_pattern;
|
||||||
unsigned bg_pattern;
|
unsigned bg_pattern;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue