mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
Adapt OSD in plugin lib to be greylib compatible.
Requires addition of viewports and alternate framebuffers to greylib which are essentially similar to the core implementation except that the framebuffer can be any size and relationship to a viewport. Drawing is always fully clipped to the intersecting area. Adapt oscilloscope.c to the API change. FFT will use the new features (later update). Get rid of silly and wrong lcd_bmp_part use in OSD. Remove it from plugin API (must be made incompatible now). Change-Id: Iafa5e2174148fb8ad11db6b9d4add0dcabc5c563
This commit is contained in:
parent
f668c36241
commit
371c86bf3f
11 changed files with 1057 additions and 356 deletions
|
@ -799,7 +799,6 @@ static const struct plugin_api rockbox_api = {
|
|||
lcd_set_viewport,
|
||||
viewport_set_fullscreen,
|
||||
lcd_set_framebuffer,
|
||||
lcd_bmp_part,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -155,12 +155,12 @@ void* plugin_get_buffer(size_t *buffer_size);
|
|||
#define PLUGIN_MAGIC 0x526F634B /* RocK */
|
||||
|
||||
/* increase this every time the api struct changes */
|
||||
#define PLUGIN_API_VERSION 221
|
||||
#define PLUGIN_API_VERSION 222
|
||||
|
||||
/* update this to latest version if a change to the api struct breaks
|
||||
backwards compatibility (and please take the opportunity to sort in any
|
||||
new function which are "waiting" at the end of the function table) */
|
||||
#define PLUGIN_MIN_API_VERSION 220
|
||||
#define PLUGIN_MIN_API_VERSION 222
|
||||
|
||||
/* plugin return codes */
|
||||
/* internal returns start at 0x100 to make exit(1..255) work */
|
||||
|
@ -970,8 +970,6 @@ struct plugin_api {
|
|||
void (*viewport_set_fullscreen)(struct viewport *vp,
|
||||
const enum screen_type screen);
|
||||
void (*lcd_set_framebuffer)(fb_data *fb);
|
||||
void (*lcd_bmp_part)(const struct bitmap *bm, int src_x, int src_y,
|
||||
int x, int y, int width, int height);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -60,6 +60,16 @@ void grey_release(void);
|
|||
void grey_show(bool enable);
|
||||
void grey_deferred_lcd_update(void);
|
||||
|
||||
/* Viewports and framebuffers */
|
||||
void grey_clear_viewport(void);
|
||||
void grey_set_viewport(struct viewport *vp);
|
||||
void grey_viewport_set_fullscreen(struct viewport *vp,
|
||||
const enum screen_type screen);
|
||||
void grey_viewport_set_pos(struct viewport *vp,
|
||||
int x, int y, int width, int height);
|
||||
void grey_set_framebuffer(unsigned char *buffer);
|
||||
void grey_framebuffer_set_pos(int x, int y, int width, int height);
|
||||
|
||||
/* Update functions */
|
||||
void grey_update(void);
|
||||
void grey_update_rect(int x, int y, int width, int height);
|
||||
|
@ -175,13 +185,23 @@ struct _grey_info
|
|||
unsigned char *values; /* start of greyscale pixel values */
|
||||
unsigned char *phases; /* start of greyscale pixel phases */
|
||||
unsigned char *buffer; /* start of chunky pixel buffer (for buffered mode) */
|
||||
unsigned char *curbuffer; /* start of current framebuffer (for buffered mode) */
|
||||
int cb_x; /* horizontal position of current framebuffer (for buffered mode) */
|
||||
int cb_y; /* vertical position of current framebuffer (for buffered mode) */
|
||||
int cb_width; /* width of current framebuffer (for buffered mode) */
|
||||
int cb_height; /* height of current framebuffer (for buffered mode) */
|
||||
int clip_l;
|
||||
int clip_t;
|
||||
int clip_r;
|
||||
int clip_b;
|
||||
unsigned char gvalue[256]; /* calculated brightness -> greyvalue table */
|
||||
int fg_brightness; /* current foreground brightness */
|
||||
int bg_brightness; /* current background brightness */
|
||||
int drawmode; /* current draw mode */
|
||||
int curfont; /* current selected font */
|
||||
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;
|
||||
|
||||
|
|
|
@ -677,10 +677,11 @@ bool grey_init(unsigned char *gbuf, long gbuf_size,
|
|||
_grey_info.bheight = bdim;
|
||||
#endif
|
||||
_grey_info.flags = features & 0xff;
|
||||
_grey_info.fg_brightness = 0;
|
||||
_grey_info.bg_brightness = 255;
|
||||
_grey_info.drawmode = DRMODE_SOLID;
|
||||
_grey_info.curfont = FONT_SYSFIXED;
|
||||
|
||||
/* default viewport and settings */
|
||||
grey_set_viewport(NULL);
|
||||
grey_viewport_set_fullscreen(NULL, SCREEN_MAIN);
|
||||
grey_set_framebuffer(NULL);
|
||||
|
||||
/* precalculate the value -> pattern index conversion table, taking
|
||||
linearisation and gamma correction into account */
|
||||
|
|
|
@ -28,16 +28,18 @@
|
|||
#include "plugin.h"
|
||||
#include "grey.h"
|
||||
|
||||
extern struct viewport _grey_default_vp;
|
||||
|
||||
/*** low-level drawing functions ***/
|
||||
|
||||
static void setpixel(unsigned char *address)
|
||||
{
|
||||
*address = _grey_info.fg_brightness;
|
||||
*address = _GREY_FG_BRIGHTNESS(_grey_info.vp);
|
||||
}
|
||||
|
||||
static void clearpixel(unsigned char *address)
|
||||
{
|
||||
*address = _grey_info.bg_brightness;
|
||||
*address = _GREY_BG_BRIGHTNESS(_grey_info.vp);
|
||||
}
|
||||
|
||||
static void flippixel(unsigned char *address)
|
||||
|
@ -57,35 +59,56 @@ void (* const _grey_pixelfuncs[8])(unsigned char *address) = {
|
|||
|
||||
/*** Drawing functions ***/
|
||||
|
||||
/* Clear the current viewport */
|
||||
void grey_clear_viewport(void)
|
||||
{
|
||||
struct viewport *vp = _grey_info.vp;
|
||||
int drawmode = vp->drawmode;
|
||||
vp->drawmode = DRMODE_SOLID | DRMODE_INVERSEVID;
|
||||
grey_fillrect(0, 0, vp->width, vp->height);
|
||||
vp->drawmode = drawmode;
|
||||
}
|
||||
|
||||
/* Clear the whole display */
|
||||
void grey_clear_display(void)
|
||||
{
|
||||
int value = (_grey_info.drawmode & DRMODE_INVERSEVID) ?
|
||||
_grey_info.fg_brightness : _grey_info.bg_brightness;
|
||||
struct viewport *vp = &_grey_default_vp;
|
||||
|
||||
rb->memset(_grey_info.buffer, value,
|
||||
_GREY_MULUQ(_grey_info.width, _grey_info.height));
|
||||
int value = (vp->drawmode & DRMODE_INVERSEVID) ?
|
||||
_GREY_FG_BRIGHTNESS(vp) : _GREY_BG_BRIGHTNESS(vp);
|
||||
|
||||
rb->memset(_grey_info.curbuffer, value,
|
||||
_GREY_MULUQ(_grey_info.cb_width, _grey_info.cb_height));
|
||||
}
|
||||
|
||||
/* Set a single pixel */
|
||||
void grey_drawpixel(int x, int y)
|
||||
{
|
||||
if (((unsigned)x < (unsigned)_grey_info.width)
|
||||
&& ((unsigned)y < (unsigned)_grey_info.height))
|
||||
_grey_pixelfuncs[_grey_info.drawmode](&_grey_info.buffer[_GREY_MULUQ(
|
||||
_grey_info.width, y) + x]);
|
||||
if (x >= _grey_info.clip_l && x < _grey_info.clip_r &&
|
||||
y >= _grey_info.clip_t && y < _grey_info.clip_b)
|
||||
{
|
||||
int dst_stride = _grey_info.cb_width;
|
||||
struct viewport *vp = _grey_info.vp;
|
||||
_grey_pixelfuncs[vp->drawmode](
|
||||
&_grey_info.curbuffer[
|
||||
_GREY_MULUQ(dst_stride, vp->y - _grey_info.cb_y + y) +
|
||||
vp->x - _grey_info.cb_x + x]);
|
||||
}
|
||||
}
|
||||
|
||||
/* Draw a line */
|
||||
void grey_drawline(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
struct viewport *vp = _grey_info.vp;
|
||||
int numpixels;
|
||||
int i;
|
||||
int deltax, deltay;
|
||||
int d, dinc1, dinc2;
|
||||
int x, xinc1, xinc2;
|
||||
int y, yinc1, yinc2;
|
||||
void (*pfunc)(unsigned char *address) = _grey_pixelfuncs[_grey_info.drawmode];
|
||||
void (*pfunc)(unsigned char *address) = _grey_pixelfuncs[vp->drawmode];
|
||||
int dwidth;
|
||||
int xoffs, yoffs;
|
||||
|
||||
deltax = abs(x2 - x1);
|
||||
deltay = abs(y2 - y1);
|
||||
|
@ -127,11 +150,18 @@ void grey_drawline(int x1, int y1, int x2, int y2)
|
|||
x = x1;
|
||||
y = y1;
|
||||
|
||||
dwidth = _grey_info.cb_width;
|
||||
xoffs = vp->x - _grey_info.cb_x;
|
||||
yoffs = vp->y - _grey_info.cb_y;
|
||||
|
||||
for (i = 0; i < numpixels; i++)
|
||||
{
|
||||
if (((unsigned)x < (unsigned)_grey_info.width)
|
||||
&& ((unsigned)y < (unsigned)_grey_info.height))
|
||||
pfunc(&_grey_info.buffer[_GREY_MULUQ(_grey_info.width, y) + x]);
|
||||
if (x >= _grey_info.clip_l && x < _grey_info.clip_r &&
|
||||
y >= _grey_info.clip_t && y < _grey_info.clip_b)
|
||||
{
|
||||
pfunc(&_grey_info.curbuffer[_GREY_MULUQ(dwidth, yoffs + y) +
|
||||
xoffs + x]);
|
||||
}
|
||||
|
||||
if (d < 0)
|
||||
{
|
||||
|
@ -151,10 +181,12 @@ void grey_drawline(int x1, int y1, int x2, int y2)
|
|||
/* Draw a horizontal line (optimised) */
|
||||
void grey_hline(int x1, int x2, int y)
|
||||
{
|
||||
struct viewport *vp = _grey_info.vp;
|
||||
int x;
|
||||
int value = 0;
|
||||
unsigned char *dst;
|
||||
bool fillopt = false;
|
||||
int dwidth;
|
||||
|
||||
/* direction flip */
|
||||
if (x2 < x1)
|
||||
|
@ -165,37 +197,40 @@ void grey_hline(int x1, int x2, int y)
|
|||
}
|
||||
|
||||
/* nothing to draw? */
|
||||
if (((unsigned)y >= (unsigned)_grey_info.height)
|
||||
|| (x1 >= _grey_info.width) || (x2 < 0))
|
||||
if (y < _grey_info.clip_t || y >= _grey_info.clip_b ||
|
||||
x1 >= _grey_info.clip_r || x2 < _grey_info.clip_l)
|
||||
return;
|
||||
|
||||
/* drawmode and optimisation */
|
||||
if (_grey_info.drawmode & DRMODE_INVERSEVID)
|
||||
if (vp->drawmode & DRMODE_INVERSEVID)
|
||||
{
|
||||
if (_grey_info.drawmode & DRMODE_BG)
|
||||
if (vp->drawmode & DRMODE_BG)
|
||||
{
|
||||
fillopt = true;
|
||||
value = _grey_info.bg_brightness;
|
||||
value = _GREY_BG_BRIGHTNESS(vp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_grey_info.drawmode & DRMODE_FG)
|
||||
if (vp->drawmode & DRMODE_FG)
|
||||
{
|
||||
fillopt = true;
|
||||
value = _grey_info.fg_brightness;
|
||||
value = _GREY_FG_BRIGHTNESS(vp);
|
||||
}
|
||||
}
|
||||
if (!fillopt && _grey_info.drawmode != DRMODE_COMPLEMENT)
|
||||
if (!fillopt && vp->drawmode != DRMODE_COMPLEMENT)
|
||||
return;
|
||||
|
||||
/* clipping */
|
||||
if (x1 < 0)
|
||||
x1 = 0;
|
||||
if (x2 >= _grey_info.width)
|
||||
x2 = _grey_info.width - 1;
|
||||
if (x1 < _grey_info.clip_l)
|
||||
x1 = _grey_info.clip_l;
|
||||
if (x2 >= _grey_info.clip_r)
|
||||
x2 = _grey_info.clip_r - 1;
|
||||
|
||||
dst = &_grey_info.buffer[_GREY_MULUQ(_grey_info.width, y) + x1];
|
||||
dwidth = _grey_info.cb_width;
|
||||
dst = &_grey_info.curbuffer[
|
||||
_GREY_MULUQ(dwidth, vp->y - _grey_info.cb_y + y) +
|
||||
vp->x - _grey_info.cb_x + x1];
|
||||
|
||||
if (fillopt)
|
||||
rb->memset(dst, value, x2 - x1 + 1);
|
||||
|
@ -211,9 +246,11 @@ void grey_hline(int x1, int x2, int y)
|
|||
/* Draw a vertical line (optimised) */
|
||||
void grey_vline(int x, int y1, int y2)
|
||||
{
|
||||
struct viewport *vp = _grey_info.vp;
|
||||
int y;
|
||||
unsigned char *dst, *dst_end;
|
||||
void (*pfunc)(unsigned char *address);
|
||||
int dwidth;
|
||||
|
||||
/* direction flip */
|
||||
if (y2 < y1)
|
||||
|
@ -224,24 +261,27 @@ void grey_vline(int x, int y1, int y2)
|
|||
}
|
||||
|
||||
/* nothing to draw? */
|
||||
if (((unsigned)x >= (unsigned)_grey_info.width)
|
||||
|| (y1 >= _grey_info.height) || (y2 < 0))
|
||||
if (x < _grey_info.clip_l || x >= _grey_info.clip_r ||
|
||||
y1 >= _grey_info.clip_b || y2 < _grey_info.clip_t)
|
||||
return;
|
||||
|
||||
/* clipping */
|
||||
if (y1 < 0)
|
||||
y1 = 0;
|
||||
if (y2 >= _grey_info.height)
|
||||
y2 = _grey_info.height - 1;
|
||||
if (y1 < _grey_info.clip_t)
|
||||
y1 = _grey_info.clip_t;
|
||||
if (y2 >= _grey_info.clip_b)
|
||||
y2 = _grey_info.clip_b - 1;
|
||||
|
||||
pfunc = _grey_pixelfuncs[_grey_info.drawmode];
|
||||
dst = &_grey_info.buffer[_GREY_MULUQ(_grey_info.width, y1) + x];
|
||||
dwidth = _grey_info.cb_width;
|
||||
pfunc = _grey_pixelfuncs[vp->drawmode];
|
||||
dst = &_grey_info.curbuffer[
|
||||
_GREY_MULUQ(dwidth, vp->y - _grey_info.cb_y + y1) +
|
||||
vp->x - _grey_info.cb_x + x];
|
||||
|
||||
dst_end = dst + _GREY_MULUQ(_grey_info.width, y2 - y1);
|
||||
dst_end = dst + _GREY_MULUQ(dwidth, y2 - y1);
|
||||
do
|
||||
{
|
||||
pfunc(dst);
|
||||
dst += _grey_info.width;
|
||||
dst += dwidth;
|
||||
}
|
||||
while (dst <= dst_end);
|
||||
}
|
||||
|
@ -334,53 +374,63 @@ void grey_drawrect(int x, int y, int width, int height)
|
|||
/* Fill a rectangular area */
|
||||
void grey_fillrect(int x, int y, int width, int height)
|
||||
{
|
||||
struct viewport *vp = _grey_info.vp;
|
||||
int value = 0;
|
||||
unsigned char *dst, *dst_end;
|
||||
bool fillopt = false;
|
||||
|
||||
/* nothing to draw? */
|
||||
if ((width <= 0) || (height <= 0) || (x >= _grey_info.width)
|
||||
|| (y >= _grey_info.height) || (x + width <= 0) || (y + height <= 0))
|
||||
return;
|
||||
int dwidth;
|
||||
|
||||
/* drawmode and optimisation */
|
||||
if (_grey_info.drawmode & DRMODE_INVERSEVID)
|
||||
if (vp->drawmode & DRMODE_INVERSEVID)
|
||||
{
|
||||
if (_grey_info.drawmode & DRMODE_BG)
|
||||
if (vp->drawmode & DRMODE_BG)
|
||||
{
|
||||
fillopt = true;
|
||||
value = _grey_info.bg_brightness;
|
||||
value = _GREY_BG_BRIGHTNESS(vp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_grey_info.drawmode & DRMODE_FG)
|
||||
if (vp->drawmode & DRMODE_FG)
|
||||
{
|
||||
fillopt = true;
|
||||
value = _grey_info.fg_brightness;
|
||||
value = _GREY_FG_BRIGHTNESS(vp);
|
||||
|
||||
}
|
||||
}
|
||||
if (!fillopt && _grey_info.drawmode != DRMODE_COMPLEMENT)
|
||||
if (!fillopt && vp->drawmode != DRMODE_COMPLEMENT)
|
||||
return;
|
||||
|
||||
/* clipping */
|
||||
if (x < 0)
|
||||
if (x < _grey_info.clip_l)
|
||||
{
|
||||
width += x;
|
||||
x = 0;
|
||||
width += x - _grey_info.clip_l;
|
||||
x = _grey_info.clip_l;
|
||||
}
|
||||
if (y < 0)
|
||||
{
|
||||
height += y;
|
||||
y = 0;
|
||||
}
|
||||
if (x + width > _grey_info.width)
|
||||
width = _grey_info.width - x;
|
||||
if (y + height > _grey_info.height)
|
||||
height = _grey_info.height - y;
|
||||
|
||||
dst = &_grey_info.buffer[_GREY_MULUQ(_grey_info.width, y) + x];
|
||||
dst_end = dst + _GREY_MULUQ(_grey_info.width, height);
|
||||
if (x + width > _grey_info.clip_r)
|
||||
width = _grey_info.clip_r - x;
|
||||
|
||||
if (width <= 0)
|
||||
return;
|
||||
|
||||
if (y < _grey_info.clip_t)
|
||||
{
|
||||
height += y - _grey_info.clip_t;
|
||||
y = _grey_info.clip_t;
|
||||
}
|
||||
|
||||
if (y + height > _grey_info.clip_b)
|
||||
height = _grey_info.clip_b - y;
|
||||
|
||||
if (height <= 0)
|
||||
return;
|
||||
|
||||
dwidth = _grey_info.cb_width;
|
||||
dst = &_grey_info.curbuffer[
|
||||
_GREY_MULUQ(dwidth, _grey_info.vp->y - _grey_info.cb_y + y) +
|
||||
_grey_info.vp->x - _grey_info.cb_x + x];
|
||||
dst_end = dst + _GREY_MULUQ(dwidth, height);
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -395,7 +445,7 @@ void grey_fillrect(int x, int y, int width, int height)
|
|||
*dst_row = ~(*dst_row);
|
||||
while (++dst_row < row_end);
|
||||
}
|
||||
dst += _grey_info.width;
|
||||
dst += dwidth;
|
||||
}
|
||||
while (dst < dst_end);
|
||||
}
|
||||
|
@ -413,40 +463,49 @@ void grey_fillrect(int x, int y, int width, int height)
|
|||
void grey_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
||||
int stride, int x, int y, int width, int height)
|
||||
{
|
||||
struct viewport *vp = _grey_info.vp;
|
||||
const unsigned char *src_end;
|
||||
unsigned char *dst, *dst_end;
|
||||
unsigned dmask = 0x100; /* bit 8 == sentinel */
|
||||
int drmode = _grey_info.drawmode;
|
||||
int drmode = vp->drawmode;
|
||||
int dwidth;
|
||||
|
||||
/* nothing to draw? */
|
||||
if ((width <= 0) || (height <= 0) || (x >= _grey_info.width)
|
||||
|| (y >= _grey_info.height) || (x + width <= 0) || (y + height <= 0))
|
||||
/* clipping */
|
||||
if (x < _grey_info.clip_l)
|
||||
{
|
||||
int dx = x - _grey_info.clip_l;
|
||||
width += dx;
|
||||
src_x -= dx;
|
||||
x = _grey_info.clip_l;
|
||||
}
|
||||
|
||||
if (x + width > _grey_info.clip_r)
|
||||
width = _grey_info.clip_r - x;
|
||||
|
||||
if (width <= 0)
|
||||
return;
|
||||
|
||||
/* clipping */
|
||||
if (x < 0)
|
||||
if (y < _grey_info.clip_t)
|
||||
{
|
||||
width += x;
|
||||
src_x -= x;
|
||||
x = 0;
|
||||
int dy = y - _grey_info.clip_t;
|
||||
height += dy;
|
||||
src_y += dy;
|
||||
y = _grey_info.clip_t;
|
||||
}
|
||||
if (y < 0)
|
||||
{
|
||||
height += y;
|
||||
src_y -= y;
|
||||
y = 0;
|
||||
}
|
||||
if (x + width > _grey_info.width)
|
||||
width = _grey_info.width - x;
|
||||
if (y + height > _grey_info.height)
|
||||
height = _grey_info.height - y;
|
||||
|
||||
if (y + height > _grey_info.clip_b)
|
||||
height = _grey_info.clip_b - y;
|
||||
|
||||
if (height <= 0)
|
||||
return;
|
||||
|
||||
src += _GREY_MULUQ(stride, src_y >> 3) + src_x; /* move starting point */
|
||||
src_y &= 7;
|
||||
src_end = src + width;
|
||||
dwidth = _grey_info.width;
|
||||
dst = &_grey_info.buffer[_GREY_MULUQ(dwidth, y) + x];
|
||||
dwidth = _grey_info.cb_width;
|
||||
dst = &_grey_info.curbuffer[
|
||||
_GREY_MULUQ(dwidth, vp->y - _grey_info.cb_y + y) +
|
||||
vp->x - _grey_info.cb_x + x];
|
||||
dst_end = dst + _GREY_MULUQ(dwidth, height);
|
||||
|
||||
if (drmode & DRMODE_INVERSEVID)
|
||||
|
@ -485,7 +544,7 @@ void grey_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
|||
break;
|
||||
|
||||
case DRMODE_BG:
|
||||
bg = _grey_info.bg_brightness;
|
||||
bg = _GREY_BG_BRIGHTNESS(vp);
|
||||
do
|
||||
{
|
||||
if (!(data & 0x01))
|
||||
|
@ -498,7 +557,7 @@ void grey_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
|||
break;
|
||||
|
||||
case DRMODE_FG:
|
||||
fg = _grey_info.fg_brightness;
|
||||
fg = _GREY_FG_BRIGHTNESS(vp);
|
||||
do
|
||||
{
|
||||
if (data & 0x01)
|
||||
|
@ -511,8 +570,8 @@ void grey_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
|||
break;
|
||||
|
||||
case DRMODE_SOLID:
|
||||
fg = _grey_info.fg_brightness;
|
||||
bg = _grey_info.bg_brightness;
|
||||
fg = _GREY_FG_BRIGHTNESS(vp);
|
||||
bg = _GREY_BG_BRIGHTNESS(vp);
|
||||
do
|
||||
{
|
||||
*dst_col = (data & 0x01) ? fg : bg;
|
||||
|
@ -537,38 +596,48 @@ void grey_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
|||
int stride, int x, int y, int width, int height)
|
||||
{
|
||||
unsigned char *dst, *dst_end;
|
||||
|
||||
/* nothing to draw? */
|
||||
if ((width <= 0) || (height <= 0) || (x >= _grey_info.width)
|
||||
|| (y >= _grey_info.height) || (x + width <= 0) || (y + height <= 0))
|
||||
return;
|
||||
int dwidth;
|
||||
|
||||
/* clipping */
|
||||
if (x < 0)
|
||||
if (x < _grey_info.clip_l)
|
||||
{
|
||||
width += x;
|
||||
src_x -= x;
|
||||
x = 0;
|
||||
int dx = x - _grey_info.clip_l;
|
||||
width += dx;
|
||||
src_x -= dx;
|
||||
x = _grey_info.clip_l;
|
||||
}
|
||||
|
||||
if (x + width > _grey_info.clip_r)
|
||||
width = _grey_info.clip_r - x;
|
||||
|
||||
if (width <= 0)
|
||||
return;
|
||||
|
||||
if (y < 0)
|
||||
{
|
||||
height += y;
|
||||
src_y -= y;
|
||||
y = 0;
|
||||
int dy = y - _grey_info.clip_t;
|
||||
height += dy;
|
||||
src_y -= dy;
|
||||
y = _grey_info.clip_t;
|
||||
}
|
||||
if (x + width > _grey_info.width)
|
||||
width = _grey_info.width - x;
|
||||
if (y + height > _grey_info.height)
|
||||
height = _grey_info.height - y;
|
||||
|
||||
if (y + height > _grey_info.clip_b)
|
||||
height = _grey_info.clip_b - y;
|
||||
|
||||
if (height <= 0)
|
||||
return;
|
||||
|
||||
dwidth = _grey_info.cb_width;
|
||||
src += _GREY_MULUQ(stride, src_y) + src_x; /* move starting point */
|
||||
dst = &_grey_info.buffer[_GREY_MULUQ(_grey_info.width, y) + x];
|
||||
dst_end = dst + _GREY_MULUQ(_grey_info.width, height);
|
||||
dst = &_grey_info.curbuffer[
|
||||
_GREY_MULUQ(dwidth, _grey_info.vp->y - _grey_info.cb_y + y) +
|
||||
_grey_info.vp->x - _grey_info.cb_x + x];
|
||||
dst_end = dst + _GREY_MULUQ(dwidth, height);
|
||||
|
||||
do
|
||||
{
|
||||
rb->memcpy(dst, src, width);
|
||||
dst += _grey_info.width;
|
||||
dst += dwidth;
|
||||
src += stride;
|
||||
}
|
||||
while (dst < dst_end);
|
||||
|
@ -586,11 +655,15 @@ void grey_putsxyofs(int x, int y, int ofs, const unsigned char *str)
|
|||
{
|
||||
int ch;
|
||||
unsigned short *ucs;
|
||||
struct font* pf = rb->font_get(_grey_info.curfont);
|
||||
struct font* pf;
|
||||
|
||||
if (_grey_info.clip_b <= _grey_info.clip_t)
|
||||
return;
|
||||
|
||||
pf = rb->font_get(_grey_info.vp->font);
|
||||
ucs = rb->bidi_l2v(str, 1);
|
||||
|
||||
while ((ch = *ucs++) != 0 && x < _grey_info.width)
|
||||
while ((ch = *ucs++) != 0 && x < _grey_info.clip_r)
|
||||
{
|
||||
int width;
|
||||
const unsigned char *bits;
|
||||
|
@ -624,9 +697,10 @@ void grey_putsxy(int x, int y, const unsigned char *str)
|
|||
/* Clear the greyscale display (sets all pixels to white) */
|
||||
void grey_ub_clear_display(void)
|
||||
{
|
||||
int value = _grey_info.gvalue[(_grey_info.drawmode & DRMODE_INVERSEVID) ?
|
||||
_grey_info.fg_brightness :
|
||||
_grey_info.bg_brightness];
|
||||
struct viewport *vp = &_grey_default_vp;
|
||||
int value = _grey_info.gvalue[(vp->drawmode & DRMODE_INVERSEVID) ?
|
||||
_GREY_FG_BRIGHTNESS(vp) :
|
||||
_GREY_BG_BRIGHTNESS(vp)];
|
||||
|
||||
rb->memset(_grey_info.values, value,
|
||||
_GREY_MULUQ(_grey_info.width, _grey_info.height));
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
#include "plugin.h"
|
||||
#include "grey.h"
|
||||
|
||||
/* Default greylib viewport struct */
|
||||
struct viewport _grey_default_vp;
|
||||
|
||||
/* Set position of the top left corner of the greyscale overlay
|
||||
Note that depending on the target LCD, either x or y gets rounded
|
||||
to the nearest multiple of 4 or 8 */
|
||||
|
@ -64,37 +67,37 @@ void grey_set_position(int x, int y)
|
|||
/* Set the draw mode for subsequent drawing operations */
|
||||
void grey_set_drawmode(int mode)
|
||||
{
|
||||
_grey_info.drawmode = mode & (DRMODE_SOLID|DRMODE_INVERSEVID);
|
||||
_grey_info.vp->drawmode = mode & (DRMODE_SOLID|DRMODE_INVERSEVID);
|
||||
}
|
||||
|
||||
/* Return the current draw mode */
|
||||
int grey_get_drawmode(void)
|
||||
{
|
||||
return _grey_info.drawmode;
|
||||
return _grey_info.vp->drawmode;
|
||||
}
|
||||
|
||||
/* Set the foreground shade for subsequent drawing operations */
|
||||
void grey_set_foreground(unsigned brightness)
|
||||
{
|
||||
_grey_info.fg_brightness = brightness;
|
||||
_GREY_FG_BRIGHTNESS(_grey_info.vp) = brightness;
|
||||
}
|
||||
|
||||
/* Return the current foreground shade */
|
||||
unsigned grey_get_foreground(void)
|
||||
{
|
||||
return _grey_info.fg_brightness;
|
||||
return _GREY_FG_BRIGHTNESS(_grey_info.vp);
|
||||
}
|
||||
|
||||
/* Set the background shade for subsequent drawing operations */
|
||||
void grey_set_background(unsigned brightness)
|
||||
{
|
||||
_grey_info.bg_brightness = brightness;
|
||||
_GREY_BG_BRIGHTNESS(_grey_info.vp) = brightness;
|
||||
}
|
||||
|
||||
/* Return the current background shade */
|
||||
unsigned grey_get_background(void)
|
||||
{
|
||||
return _grey_info.bg_brightness;
|
||||
return _GREY_BG_BRIGHTNESS(_grey_info.vp);
|
||||
}
|
||||
|
||||
/* Set draw mode, foreground and background shades at once */
|
||||
|
@ -108,11 +111,151 @@ void grey_set_drawinfo(int mode, unsigned fg_brightness, unsigned bg_brightness)
|
|||
/* Set font for the text output routines */
|
||||
void grey_setfont(int newfont)
|
||||
{
|
||||
_grey_info.curfont = newfont;
|
||||
_grey_info.vp->font = newfont;
|
||||
}
|
||||
|
||||
/* Get width and height of a text when printed with the current font */
|
||||
int grey_getstringsize(const unsigned char *str, int *w, int *h)
|
||||
{
|
||||
return rb->font_getstringsize(str, w, h, _grey_info.curfont);
|
||||
return rb->font_getstringsize(str, w, h, _grey_info.vp->font);
|
||||
}
|
||||
|
||||
/* Helper to establish visible area between viewport and framebuffer */
|
||||
static void grey_update_clip_rect(void)
|
||||
{
|
||||
if (!(_grey_info.flags & GREY_BUFFERED))
|
||||
return; /* no chunky buffer */
|
||||
|
||||
struct viewport *vp = _grey_info.vp;
|
||||
|
||||
if (!vp || !_grey_info.curbuffer)
|
||||
return;
|
||||
|
||||
/* Get overall intersection of framebuffer and viewport in viewport
|
||||
coordinates so that later clipping of drawing is kept as simple as
|
||||
possible. If l <= r and/or b <= t after intersecting, draw routines
|
||||
will see this as an empty area. */
|
||||
_grey_info.clip_l = _grey_info.cb_x - vp->x;
|
||||
_grey_info.clip_t = _grey_info.cb_y - vp->y;
|
||||
_grey_info.clip_r = _grey_info.clip_l + _grey_info.cb_width;
|
||||
_grey_info.clip_b = _grey_info.clip_t + _grey_info.cb_height;
|
||||
|
||||
if (_grey_info.clip_l < 0)
|
||||
_grey_info.clip_l = 0;
|
||||
|
||||
if (_grey_info.clip_t < 0)
|
||||
_grey_info.clip_t = 0;
|
||||
|
||||
if (_grey_info.clip_r > vp->width)
|
||||
_grey_info.clip_r = vp->width;
|
||||
|
||||
if (_grey_info.clip_b > vp->height)
|
||||
_grey_info.clip_b = vp->height;
|
||||
}
|
||||
|
||||
/* Set current grey viewport for draw routines */
|
||||
void grey_set_viewport(struct viewport *vp)
|
||||
{
|
||||
if (vp == NULL)
|
||||
vp = &_grey_default_vp;
|
||||
|
||||
if (_grey_info.vp != vp)
|
||||
{
|
||||
_grey_info.vp = vp;
|
||||
grey_update_clip_rect();
|
||||
}
|
||||
}
|
||||
|
||||
/* Set viewport to default settings */
|
||||
void grey_viewport_set_fullscreen(struct viewport *vp,
|
||||
const enum screen_type screen)
|
||||
{
|
||||
if (vp == NULL)
|
||||
vp = &_grey_default_vp;
|
||||
|
||||
vp->x = 0;
|
||||
vp->y = 0;
|
||||
vp->width = _grey_info.width;
|
||||
vp->height = _grey_info.height;
|
||||
_GREY_FG_BRIGHTNESS(vp) = 0;
|
||||
_GREY_BG_BRIGHTNESS(vp) = 255;
|
||||
vp->drawmode = DRMODE_SOLID;
|
||||
vp->font = FONT_SYSFIXED;
|
||||
|
||||
if (vp == _grey_info.vp)
|
||||
grey_update_clip_rect(); /* is current one in use */
|
||||
|
||||
(void)screen;
|
||||
}
|
||||
|
||||
void grey_viewport_set_pos(struct viewport *vp,
|
||||
int x, int y, int width, int height)
|
||||
{
|
||||
if (vp == NULL || vp == &_grey_default_vp)
|
||||
return; /* Cannot be moved or resized */
|
||||
|
||||
if (width < 0)
|
||||
width = 0; /* 'tis okay */
|
||||
|
||||
if (height < 0)
|
||||
height = 0;
|
||||
|
||||
vp->x = x;
|
||||
vp->y = y;
|
||||
vp->width = width;
|
||||
vp->height = height;
|
||||
|
||||
if (vp == _grey_info.vp)
|
||||
grey_update_clip_rect(); /* is current one in use */
|
||||
}
|
||||
|
||||
/* Set current grey chunky buffer for draw routines */
|
||||
void grey_set_framebuffer(unsigned char *buffer)
|
||||
{
|
||||
if (!(_grey_info.flags & GREY_BUFFERED))
|
||||
return; /* no chunky buffer */
|
||||
|
||||
if (buffer == NULL)
|
||||
buffer = _grey_info.buffer; /* Default */
|
||||
|
||||
if (buffer != _grey_info.curbuffer)
|
||||
{
|
||||
_grey_info.curbuffer = buffer;
|
||||
|
||||
if (buffer == _grey_info.buffer)
|
||||
{
|
||||
/* Setting to default fb resets dimensions */
|
||||
grey_framebuffer_set_pos(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Specify the dimensions of the current framebuffer */
|
||||
void grey_framebuffer_set_pos(int x, int y, int width, int height)
|
||||
{
|
||||
if (!(_grey_info.flags & GREY_BUFFERED))
|
||||
return; /* no chunky buffer */
|
||||
|
||||
if (_grey_info.curbuffer == _grey_info.buffer)
|
||||
{
|
||||
/* This cannot be moved or resized */
|
||||
x = 0;
|
||||
y = 0;
|
||||
width = _grey_info.width;
|
||||
height = _grey_info.height;
|
||||
}
|
||||
else if (width <= 0 || height <= 0)
|
||||
return;
|
||||
|
||||
if (x == _grey_info.cb_x && y == _grey_info.cb_y &&
|
||||
width == _grey_info.cb_width && height == _grey_info.cb_height)
|
||||
return; /* No change */
|
||||
|
||||
_grey_info.cb_x = x;
|
||||
_grey_info.cb_y = y;
|
||||
_grey_info.cb_width = width;
|
||||
_grey_info.cb_height = height;
|
||||
|
||||
grey_update_clip_rect();
|
||||
}
|
||||
|
||||
|
|
|
@ -28,11 +28,14 @@
|
|||
#include "plugin.h"
|
||||
#include "grey.h"
|
||||
|
||||
extern struct viewport _grey_default_vp;
|
||||
|
||||
/*** Scrolling ***/
|
||||
|
||||
/* Scroll left */
|
||||
void grey_scroll_left(int count)
|
||||
{
|
||||
struct viewport *vp = &_grey_default_vp;
|
||||
unsigned char *data, *data_end;
|
||||
int length, blank;
|
||||
|
||||
|
@ -45,8 +48,8 @@ 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 = (_grey_info.drawmode & DRMODE_INVERSEVID) ?
|
||||
_grey_info.fg_brightness : _grey_info.bg_brightness;
|
||||
blank = (vp->drawmode & DRMODE_INVERSEVID) ?
|
||||
_GREY_FG_BRIGHTNESS(vp) : _GREY_BG_BRIGHTNESS(vp);
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -61,6 +64,7 @@ void grey_scroll_left(int count)
|
|||
/* Scroll right */
|
||||
void grey_scroll_right(int count)
|
||||
{
|
||||
struct viewport *vp = &_grey_default_vp;
|
||||
unsigned char *data, *data_end;
|
||||
int length, blank;
|
||||
|
||||
|
@ -73,8 +77,8 @@ 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 = (_grey_info.drawmode & DRMODE_INVERSEVID) ?
|
||||
_grey_info.fg_brightness : _grey_info.bg_brightness;
|
||||
blank = (vp->drawmode & DRMODE_INVERSEVID) ?
|
||||
_GREY_FG_BRIGHTNESS(vp) : _GREY_BG_BRIGHTNESS(vp);
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -88,6 +92,7 @@ void grey_scroll_right(int count)
|
|||
/* Scroll up */
|
||||
void grey_scroll_up(int count)
|
||||
{
|
||||
struct viewport *vp = &_grey_default_vp;
|
||||
long shift, length;
|
||||
int blank;
|
||||
|
||||
|
@ -99,8 +104,8 @@ void grey_scroll_up(int count)
|
|||
|
||||
shift = _GREY_MULUQ(_grey_info.width, count);
|
||||
length = _GREY_MULUQ(_grey_info.width, _grey_info.height - count);
|
||||
blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ?
|
||||
_grey_info.fg_brightness : _grey_info.bg_brightness;
|
||||
blank = (vp->drawmode & DRMODE_INVERSEVID) ?
|
||||
_GREY_FG_BRIGHTNESS(vp) : _GREY_BG_BRIGHTNESS(vp);
|
||||
|
||||
rb->memmove(_grey_info.buffer, _grey_info.buffer + shift,
|
||||
length);
|
||||
|
@ -110,6 +115,7 @@ void grey_scroll_up(int count)
|
|||
/* Scroll down */
|
||||
void grey_scroll_down(int count)
|
||||
{
|
||||
struct viewport *vp = &_grey_default_vp;
|
||||
long shift, length;
|
||||
int blank;
|
||||
|
||||
|
@ -121,8 +127,8 @@ void grey_scroll_down(int count)
|
|||
|
||||
shift = _GREY_MULUQ(_grey_info.width, count);
|
||||
length = _GREY_MULUQ(_grey_info.width, _grey_info.height - count);
|
||||
blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ?
|
||||
_grey_info.fg_brightness : _grey_info.bg_brightness;
|
||||
blank = (vp->drawmode & DRMODE_INVERSEVID) ?
|
||||
_GREY_FG_BRIGHTNESS(vp) : _GREY_BG_BRIGHTNESS(vp);
|
||||
|
||||
rb->memmove(_grey_info.buffer + shift, _grey_info.buffer,
|
||||
length);
|
||||
|
@ -134,6 +140,7 @@ void grey_scroll_down(int count)
|
|||
/* Scroll left */
|
||||
void grey_ub_scroll_left(int count)
|
||||
{
|
||||
struct viewport *vp = &_grey_default_vp;
|
||||
unsigned char *data, *data_end;
|
||||
int blank, length;
|
||||
|
||||
|
@ -147,9 +154,9 @@ void grey_ub_scroll_left(int count)
|
|||
data_end = data + _GREY_MULUQ(_grey_info.width, _grey_info.height);
|
||||
length = (_grey_info.width - count) << _GREY_BSHIFT;
|
||||
count <<= _GREY_BSHIFT;
|
||||
blank = _grey_info.gvalue[(_grey_info.drawmode & DRMODE_INVERSEVID) ?
|
||||
_grey_info.fg_brightness :
|
||||
_grey_info.bg_brightness];
|
||||
blank = _grey_info.gvalue[(vp->drawmode & DRMODE_INVERSEVID) ?
|
||||
_GREY_FG_BRIGHTNESS(vp) :
|
||||
_GREY_BG_BRIGHTNESS(vp)];
|
||||
do
|
||||
{
|
||||
rb->memmove(data, data + count, length);
|
||||
|
@ -167,6 +174,7 @@ void grey_ub_scroll_left(int count)
|
|||
/* Scroll right */
|
||||
void grey_ub_scroll_right(int count)
|
||||
{
|
||||
struct viewport *vp = &_grey_default_vp;
|
||||
unsigned char *data, *data_end;
|
||||
int blank, length;
|
||||
|
||||
|
@ -180,9 +188,9 @@ void grey_ub_scroll_right(int count)
|
|||
data_end = data + _GREY_MULUQ(_grey_info.width, _grey_info.height);
|
||||
length = (_grey_info.width - count) << _GREY_BSHIFT;
|
||||
count <<= _GREY_BSHIFT;
|
||||
blank = _grey_info.gvalue[(_grey_info.drawmode & DRMODE_INVERSEVID) ?
|
||||
_grey_info.fg_brightness :
|
||||
_grey_info.bg_brightness];
|
||||
blank = _grey_info.gvalue[(vp->drawmode & DRMODE_INVERSEVID) ?
|
||||
_GREY_FG_BRIGHTNESS(vp) :
|
||||
_GREY_BG_BRIGHTNESS(vp)];
|
||||
do
|
||||
{
|
||||
rb->memmove(data + count, data, length);
|
||||
|
@ -199,6 +207,7 @@ void grey_ub_scroll_right(int count)
|
|||
/* Scroll up */
|
||||
void grey_ub_scroll_up(int count)
|
||||
{
|
||||
struct viewport *vp = &_grey_default_vp;
|
||||
unsigned char *dst, *end, *src;
|
||||
int blank;
|
||||
|
||||
|
@ -210,9 +219,9 @@ 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[(_grey_info.drawmode & DRMODE_INVERSEVID) ?
|
||||
_grey_info.fg_brightness :
|
||||
_grey_info.bg_brightness];
|
||||
blank = _grey_info.gvalue[(vp->drawmode & DRMODE_INVERSEVID) ?
|
||||
_GREY_FG_BRIGHTNESS(vp) :
|
||||
_GREY_BG_BRIGHTNESS(vp)];
|
||||
|
||||
#if (LCD_PIXELFORMAT == VERTICAL_PACKING) \
|
||||
|| (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)
|
||||
|
@ -274,6 +283,7 @@ void grey_ub_scroll_up(int count)
|
|||
/* Scroll down */
|
||||
void grey_ub_scroll_down(int count)
|
||||
{
|
||||
struct viewport *vp = &_grey_default_vp;
|
||||
unsigned char *start, *dst;
|
||||
int blank;
|
||||
|
||||
|
@ -285,9 +295,9 @@ 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[(_grey_info.drawmode & DRMODE_INVERSEVID) ?
|
||||
_grey_info.fg_brightness :
|
||||
_grey_info.bg_brightness];
|
||||
blank = _grey_info.gvalue[(vp->drawmode & DRMODE_INVERSEVID) ?
|
||||
_GREY_FG_BRIGHTNESS(vp) :
|
||||
_GREY_BG_BRIGHTNESS(vp)];
|
||||
|
||||
#if (LCD_PIXELFORMAT == VERTICAL_PACKING) \
|
||||
|| (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)
|
||||
|
|
|
@ -40,12 +40,13 @@
|
|||
#define mylcd_(fn) pgfx_##fn
|
||||
#define mylcd_ub_(fn) pgfx_##fn
|
||||
|
||||
#elif defined (HAVE_LCD_BITMAP) && (LCD_DEPTH < 8) && defined(__GREY_H__)
|
||||
#elif defined (HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) && defined(__GREY_H__)
|
||||
#define MYLCD_CFG_GREYLIB /* using greylib */
|
||||
#define mylcd_(fn) grey_##fn
|
||||
#define myxlcd_(fn) grey_##fn
|
||||
#define mylcd_ub_(fn) grey_ub_##fn
|
||||
#define myxlcd_ub_(fn) grey_ub_##fn
|
||||
#define mylcd_viewport_(fn) grey_viewport_##fn
|
||||
|
||||
/* Common colors */
|
||||
#define MYLCD_BLACK GREY_BLACK
|
||||
|
@ -61,6 +62,7 @@
|
|||
#define myxlcd_(fn) xlcd_##fn
|
||||
#define mylcd_ub_(fn) rb->lcd_##fn
|
||||
#define myxlcd_ub_(fn) xlcd_##fn
|
||||
#define mylcd_viewport_(fn) rb->viewport_##fn
|
||||
|
||||
/* Common colors */
|
||||
#define MYLCD_BLACK LCD_BLACK
|
||||
|
@ -180,4 +182,11 @@ static inline void mylcd_ub_update_rect(int x, int y, int w, int h)
|
|||
#define mylcd_ub_scroll_down myxlcd_ub_(scroll_down)
|
||||
#endif /* HAVE_LCD_BITMAP */
|
||||
|
||||
/* Viewports */
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
#define mylcd_clear_viewport mylcd_(clear_viewport)
|
||||
#define mylcd_set_viewport mylcd_(set_viewport)
|
||||
#define mylcd_viewport_set_fullscreen mylcd_viewport_(set_fullscreen)
|
||||
#endif /* HAVE_LCD_BITMAP */
|
||||
|
||||
#endif /* MYLCD_H */
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -23,6 +23,10 @@
|
|||
#ifndef OSD_H
|
||||
#define OSD_H
|
||||
|
||||
#ifndef HAVE_LCD_BITMAP
|
||||
#error OSD requires bitmapped LCD
|
||||
#endif
|
||||
|
||||
/* At this time: assumes use of the default viewport for normal drawing */
|
||||
|
||||
/* Callback implemented by user. Paramters are OSD vp-relative coordinates */
|
||||
|
@ -30,8 +34,20 @@ typedef void (* osd_draw_cb_fn_t)(int x, int y, int width, int height);
|
|||
|
||||
/* Initialize the OSD, set its backbuffer, update callback and enable it if
|
||||
* the call succeeded. */
|
||||
bool osd_init(void *backbuf, size_t backbuf_size,
|
||||
osd_draw_cb_fn_t draw_cb);
|
||||
enum osd_init_flags
|
||||
{
|
||||
OSD_INIT_MAJOR_WIDTH = 0x0, /* Width guides buffer dims (default) */
|
||||
OSD_INIT_MAJOR_HEIGHT = 0x1, /* Height guides buffer dims */
|
||||
OSD_INIT_MINOR_MIN = 0x2, /* Treat minor axis dim as a minimum */
|
||||
OSD_INIT_MINOR_MAX = 0x4, /* Treat minor axis dim as a maximum */
|
||||
/* To get exact minor size, combine min/max flags */
|
||||
};
|
||||
bool osd_init(unsigned flags, void *backbuf, size_t backbuf_size,
|
||||
osd_draw_cb_fn_t draw_cb, int *width,
|
||||
int *height, size_t *bufused);
|
||||
|
||||
/* Destroy the OSD, rendering it disabled */
|
||||
void osd_destroy(void);
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -91,4 +107,46 @@ void osd_lcd_update(void);
|
|||
/* Update a part of the screen and restore OSD if it is visible */
|
||||
void osd_lcd_update_rect(int x, int y, int width, int height);
|
||||
|
||||
#if LCD_DEPTH < 4
|
||||
/* Like other functions but for greylib surface (requires GREY_BUFFERED) */
|
||||
bool osd_grey_init(unsigned flags, void *backbuf, size_t backbuf_size,
|
||||
osd_draw_cb_fn_t draw_cb, int *width,
|
||||
int *height, size_t *bufused);
|
||||
void osd_grey_destroy(void);
|
||||
bool osd_grey_show(unsigned flags);
|
||||
bool osd_grey_update(void);
|
||||
bool osd_grey_update_rect(int x, int y, int width, int height);
|
||||
bool osd_grey_update_pos(int x, int y, int width, int height);
|
||||
void osd_grey_monitor_timeout(void);
|
||||
void osd_grey_set_timeout(long timeout);
|
||||
struct viewport * osd_grey_get_viewport(void);
|
||||
void osd_grey_get_max_dims(int *maxwidth, int *maxheight);
|
||||
bool osd_grey_enabled(void);
|
||||
void osd_grey_lcd_update_prepare(void);
|
||||
void osd_grey_lcd_update(void);
|
||||
void osd_grey_lcd_update_rect(int x, int y, int width, int height);
|
||||
#endif /* LCD_DEPTH < 4 */
|
||||
|
||||
/* MYLCD-style helper defines to compile with different graphics libs */
|
||||
#ifdef __GREY_H__
|
||||
#define myosd_(fn) osd_grey_##fn
|
||||
#else
|
||||
#define myosd_(fn) osd_##fn
|
||||
#endif
|
||||
|
||||
#define myosd_init myosd_(init)
|
||||
#define myosd_destroy myosd_(destroy)
|
||||
#define myosd_show myosd_(show)
|
||||
#define myosd_update myosd_(update)
|
||||
#define myosd_update_rect myosd_(update_rect)
|
||||
#define myosd_update_pos myosd_(update_pos)
|
||||
#define myosd_monitor_timeout myosd_(monitor_timeout)
|
||||
#define myosd_set_timeout myosd_(set_timeout)
|
||||
#define myosd_get_viewport myosd_(get_viewport)
|
||||
#define myosd_get_max_dims myosd_(get_max_dims)
|
||||
#define myosd_enabled myosd_(enabled)
|
||||
#define myosd_lcd_update_prepare myosd_(lcd_update_prepare)
|
||||
#define myosd_lcd_update myosd_(lcd_update)
|
||||
#define myosd_lcd_update_rect myosd_(lcd_update_rect)
|
||||
|
||||
#endif /* OSD_H */
|
||||
|
|
|
@ -727,7 +727,14 @@ static void osc_osd_init(void)
|
|||
/* Grab the plugin buffer for the OSD back buffer */
|
||||
size_t bufsize;
|
||||
void *buf = rb->plugin_get_buffer(&bufsize);
|
||||
osd_init(buf, bufsize, osd_lcd_draw_cb);
|
||||
|
||||
int width, height;
|
||||
rb->lcd_setfont(FONT_UI);
|
||||
rb->lcd_getstringsize("M", NULL, &height);
|
||||
width = LCD_WIDTH;
|
||||
height += 2 + 2*OSC_OSD_MARGIN_SIZE;
|
||||
osd_init(OSD_INIT_MAJOR_HEIGHT | OSD_INIT_MINOR_MAX, buf, bufsize,
|
||||
osd_lcd_draw_cb, &width, &height, NULL);
|
||||
}
|
||||
|
||||
/* Format a message by ID and show the OSD */
|
||||
|
@ -1826,7 +1833,7 @@ static long oscilloscope_draw(void)
|
|||
|
||||
static void osc_cleanup(void)
|
||||
{
|
||||
osd_init(NULL, 0, NULL);
|
||||
osd_destroy();
|
||||
|
||||
#ifdef OSCILLOSCOPE_GRAPHMODE
|
||||
anim_waveform_exit();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue