forked from len0rd/rockbox
Add new lcd_bmp and lcd_bmp_part APIs.
This new APIs wrap around lcd_[mono|transparent]_bitmap/_part calls and handle all kinds bitmaps. The intended use is to draw bitmaps that come from read_bmp_fd/_file. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30936 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
6223ad266e
commit
13209604c1
10 changed files with 68 additions and 79 deletions
|
@ -109,14 +109,11 @@ void screen_put_icon_with_offset(struct screen * display,
|
||||||
void screen_put_iconxy(struct screen * display,
|
void screen_put_iconxy(struct screen * display,
|
||||||
int xpos, int ypos, enum themable_icons icon)
|
int xpos, int ypos, enum themable_icons icon)
|
||||||
{
|
{
|
||||||
const void *data;
|
|
||||||
const int screen = display->screen_type;
|
const int screen = display->screen_type;
|
||||||
const int width = ICON_WIDTH(screen);
|
const int width = ICON_WIDTH(screen);
|
||||||
const int height = ICON_HEIGHT(screen);
|
const int height = ICON_HEIGHT(screen);
|
||||||
const int is_rtl = lang_is_rtl();
|
const int is_rtl = lang_is_rtl();
|
||||||
int stride;
|
|
||||||
const struct bitmap *iconset;
|
const struct bitmap *iconset;
|
||||||
screen_bitmap_part_func *draw_func = NULL;
|
|
||||||
|
|
||||||
if (icon == Icon_NOICON)
|
if (icon == Icon_NOICON)
|
||||||
{
|
{
|
||||||
|
@ -145,9 +142,6 @@ void screen_put_iconxy(struct screen * display,
|
||||||
{
|
{
|
||||||
iconset = &inbuilt_iconset[screen];
|
iconset = &inbuilt_iconset[screen];
|
||||||
}
|
}
|
||||||
data = iconset->data;
|
|
||||||
stride = STRIDE(display->screen_type, iconset->width, iconset->height);
|
|
||||||
|
|
||||||
/* add some left padding to the icons if they are on the edge */
|
/* add some left padding to the icons if they are on the edge */
|
||||||
if (xpos == 0)
|
if (xpos == 0)
|
||||||
xpos++;
|
xpos++;
|
||||||
|
@ -155,14 +149,8 @@ void screen_put_iconxy(struct screen * display,
|
||||||
if (is_rtl)
|
if (is_rtl)
|
||||||
xpos = display->getwidth() - xpos - width;
|
xpos = display->getwidth() - xpos - width;
|
||||||
|
|
||||||
#if (LCD_DEPTH == 16) || defined(LCD_REMOTE_DEPTH) && (LCD_REMOTE_DEPTH == 16)
|
|
||||||
if (display->depth == 16)
|
|
||||||
draw_func = display->transparent_bitmap_part;
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
draw_func = display->bitmap_part;
|
|
||||||
|
|
||||||
draw_func(data, 0, height * icon, stride, xpos, ypos, width, height);
|
display->bmp_part(iconset, 0, height * icon, xpos, ypos, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void screen_put_cursorxy(struct screen * display, int x, int y, bool on)
|
void screen_put_cursorxy(struct screen * display, int x, int y, bool on)
|
||||||
|
|
|
@ -234,18 +234,7 @@ void gui_bitmap_scrollbar_draw(struct screen * screen, struct bitmap *bm, int x,
|
||||||
else if (bm->height < starty + height)
|
else if (bm->height < starty + height)
|
||||||
height = bm->height - starty;
|
height = bm->height - starty;
|
||||||
|
|
||||||
#if LCD_DEPTH > 1
|
screen->bmp_part(bm, startx, starty, x, y, width, height);
|
||||||
if (bm->format == FORMAT_MONO)
|
|
||||||
#endif
|
|
||||||
screen->mono_bitmap_part(bm->data, startx, starty,
|
|
||||||
bm->width, x, y, width, height);
|
|
||||||
#if LCD_DEPTH > 1
|
|
||||||
else
|
|
||||||
screen->transparent_bitmap_part((fb_data *)bm->data, startx, starty,
|
|
||||||
STRIDE(screen->screen_type,
|
|
||||||
bm->width, bm->height),
|
|
||||||
x, y, width, height);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_busy_slider(struct screen *s, int x, int y, int width, int height)
|
void show_busy_slider(struct screen *s, int x, int y, int width, int height)
|
||||||
|
|
|
@ -248,22 +248,8 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb)
|
||||||
if (pb->backdrop)
|
if (pb->backdrop)
|
||||||
{
|
{
|
||||||
struct gui_img *img = pb->backdrop;
|
struct gui_img *img = pb->backdrop;
|
||||||
char *img_data = core_get_data(img->buflib_handle);
|
img->bm.data = core_get_data(img->buflib_handle);
|
||||||
#if LCD_DEPTH > 1
|
display->bmp_part(&img->bm, 0, 0, x, y, width, height);
|
||||||
if(img->bm.format == FORMAT_MONO) {
|
|
||||||
#endif
|
|
||||||
display->mono_bitmap_part(img_data,
|
|
||||||
0, 0, img->bm.width,
|
|
||||||
x, y, width, height);
|
|
||||||
#if LCD_DEPTH > 1
|
|
||||||
} else {
|
|
||||||
display->transparent_bitmap_part((fb_data *)img_data,
|
|
||||||
0, 0,
|
|
||||||
STRIDE(display->screen_type,
|
|
||||||
img->bm.width, img->bm.height),
|
|
||||||
x, y, width, height);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
flags |= DONT_CLEAR_EXCESS;
|
flags |= DONT_CLEAR_EXCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,7 +273,7 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb)
|
||||||
int xoff = 0, yoff = 0;
|
int xoff = 0, yoff = 0;
|
||||||
int w = width, h = height;
|
int w = width, h = height;
|
||||||
struct gui_img *img = pb->slider;
|
struct gui_img *img = pb->slider;
|
||||||
char *img_data = core_get_data(img->buflib_handle);
|
img->bm.data = core_get_data(img->buflib_handle);
|
||||||
|
|
||||||
if (flags&HORIZONTAL)
|
if (flags&HORIZONTAL)
|
||||||
{
|
{
|
||||||
|
@ -305,21 +291,7 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb)
|
||||||
yoff = height - yoff;
|
yoff = height - yoff;
|
||||||
yoff -= h / 2;
|
yoff -= h / 2;
|
||||||
}
|
}
|
||||||
#if LCD_DEPTH > 1
|
display->bmp_part(&img->bm, 0, 0, x + xoff, y + yoff, w, h);
|
||||||
if(img->bm.format == FORMAT_MONO) {
|
|
||||||
#endif
|
|
||||||
display->mono_bitmap_part(img_data,
|
|
||||||
0, 0, img->bm.width,
|
|
||||||
x + xoff, y + yoff, w, h);
|
|
||||||
#if LCD_DEPTH > 1
|
|
||||||
} else {
|
|
||||||
display->transparent_bitmap_part((fb_data *)img_data,
|
|
||||||
0, 0,
|
|
||||||
STRIDE(display->screen_type,
|
|
||||||
img->bm.width, img->bm.height),
|
|
||||||
x + xoff, y + yoff, w, h);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pb->type == SKIN_TOKEN_PROGRESSBAR)
|
if (pb->type == SKIN_TOKEN_PROGRESSBAR)
|
||||||
|
@ -357,30 +329,14 @@ void clear_image_pos(struct gui_wps *gwps, struct gui_img *img)
|
||||||
void wps_draw_image(struct gui_wps *gwps, struct gui_img *img, int subimage)
|
void wps_draw_image(struct gui_wps *gwps, struct gui_img *img, int subimage)
|
||||||
{
|
{
|
||||||
struct screen *display = gwps->display;
|
struct screen *display = gwps->display;
|
||||||
char *img_data = core_get_data(img->buflib_handle);
|
img->bm.data = core_get_data(img->buflib_handle);
|
||||||
if(img->always_display)
|
if(img->always_display)
|
||||||
display->set_drawmode(DRMODE_FG);
|
display->set_drawmode(DRMODE_FG);
|
||||||
else
|
else
|
||||||
display->set_drawmode(DRMODE_SOLID);
|
display->set_drawmode(DRMODE_SOLID);
|
||||||
|
|
||||||
#if LCD_DEPTH > 1
|
display->bmp_part(&img->bm, 0, img->subimage_height * subimage,
|
||||||
if(img->bm.format == FORMAT_MONO) {
|
img->x, img->y, img->bm.width, img->subimage_height);
|
||||||
#endif
|
|
||||||
display->mono_bitmap_part(img_data,
|
|
||||||
0, img->subimage_height * subimage,
|
|
||||||
img->bm.width, img->x,
|
|
||||||
img->y, img->bm.width,
|
|
||||||
img->subimage_height);
|
|
||||||
#if LCD_DEPTH > 1
|
|
||||||
} else {
|
|
||||||
display->transparent_bitmap_part((fb_data *)img_data,
|
|
||||||
0, img->subimage_height * subimage,
|
|
||||||
STRIDE(display->screen_type,
|
|
||||||
img->bm.width, img->bm.height),
|
|
||||||
img->x, img->y, img->bm.width,
|
|
||||||
img->subimage_height);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -147,12 +147,12 @@ void* plugin_get_buffer(size_t *buffer_size);
|
||||||
#define PLUGIN_MAGIC 0x526F634B /* RocK */
|
#define PLUGIN_MAGIC 0x526F634B /* RocK */
|
||||||
|
|
||||||
/* increase this every time the api struct changes */
|
/* increase this every time the api struct changes */
|
||||||
#define PLUGIN_API_VERSION 213
|
#define PLUGIN_API_VERSION 214
|
||||||
|
|
||||||
/* update this to latest version if a change to the api struct breaks
|
/* update this to latest version if a change to the api struct breaks
|
||||||
backwards compatibility (and please take the opportunity to sort in any
|
backwards compatibility (and please take the opportunity to sort in any
|
||||||
new function which are "waiting" at the end of the function table) */
|
new function which are "waiting" at the end of the function table) */
|
||||||
#define PLUGIN_MIN_API_VERSION 213
|
#define PLUGIN_MIN_API_VERSION 214
|
||||||
|
|
||||||
/* plugin return codes */
|
/* plugin return codes */
|
||||||
/* internal returns start at 0x100 to make exit(1..255) work */
|
/* internal returns start at 0x100 to make exit(1..255) work */
|
||||||
|
|
|
@ -197,6 +197,8 @@ struct screen screens[NB_SCREENS] =
|
||||||
.transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap_transparent,
|
.transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap_transparent,
|
||||||
.transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_transparent_part,
|
.transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_transparent_part,
|
||||||
#endif
|
#endif
|
||||||
|
.bmp = &lcd_bmp,
|
||||||
|
.bmp_part = &lcd_bmp_part,
|
||||||
#if LCD_DEPTH > 1
|
#if LCD_DEPTH > 1
|
||||||
#if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1
|
#if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1
|
||||||
.color_to_native=&lcd_color_to_native,
|
.color_to_native=&lcd_color_to_native,
|
||||||
|
@ -296,6 +298,8 @@ struct screen screens[NB_SCREENS] =
|
||||||
.transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_remote_bitmap_part,
|
.transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_remote_bitmap_part,
|
||||||
/* No colour remotes yet */
|
/* No colour remotes yet */
|
||||||
#endif
|
#endif
|
||||||
|
.bmp = &lcd_remote_bmp,
|
||||||
|
.bmp_part = &lcd_remote_bmp_part,
|
||||||
#if LCD_REMOTE_DEPTH > 1
|
#if LCD_REMOTE_DEPTH > 1
|
||||||
#if defined(HAVE_LCD_COLOR)
|
#if defined(HAVE_LCD_COLOR)
|
||||||
.color_to_native=&lcd_remote_color_to_native,
|
.color_to_native=&lcd_remote_color_to_native,
|
||||||
|
|
|
@ -97,6 +97,9 @@ struct screen
|
||||||
int x, int y, int width, int height);
|
int x, int y, int width, int height);
|
||||||
void (*transparent_bitmap_part)(const void *src, int src_x, int src_y,
|
void (*transparent_bitmap_part)(const void *src, int src_x, int src_y,
|
||||||
int stride, int x, int y, int width, int height);
|
int stride, int x, int y, int width, int height);
|
||||||
|
void (*bmp)(const struct bitmap *bm, int x, int y);
|
||||||
|
void (*bmp_part)(const struct bitmap* bm, int src_x, int src_y,
|
||||||
|
int x, int y, int width, int height);
|
||||||
void (*set_drawmode)(int mode);
|
void (*set_drawmode)(int mode);
|
||||||
#if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1
|
#if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1
|
||||||
unsigned (*color_to_native)(unsigned color);
|
unsigned (*color_to_native)(unsigned color);
|
||||||
|
|
|
@ -515,3 +515,21 @@ void ICODE_ATTR lcd_alpha_bitmap_part(const unsigned char *src, int src_x,
|
||||||
#endif
|
#endif
|
||||||
} while (--row);
|
} while (--row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Draw a partial bitmap (mono or native) including alpha channel */
|
||||||
|
void ICODE_ATTR lcd_bmp_part(const struct bitmap* bm, int src_x, int src_y,
|
||||||
|
int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
int bitmap_stride = STRIDE_MAIN(bm->width, bm->height);
|
||||||
|
if (bm->format == FORMAT_MONO)
|
||||||
|
lcd_mono_bitmap_part(bm->data, src_x, src_y, bitmap_stride, x, y, width, height);
|
||||||
|
else
|
||||||
|
lcd_bitmap_transparent_part((fb_data*)bm->data,
|
||||||
|
src_x, src_y, bitmap_stride, x, y, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Draw a native bitmap with alpha channel */
|
||||||
|
void ICODE_ATTR lcd_bmp(const struct bitmap *bmp, int x, int y)
|
||||||
|
{
|
||||||
|
lcd_bmp_part(bmp, 0, 0, x, y, bmp->width, bmp->height);
|
||||||
|
}
|
||||||
|
|
|
@ -501,3 +501,29 @@ void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string,
|
||||||
{
|
{
|
||||||
LCDFN(puts_scroll_style_xyoffset)(x, y, string, style, x_offset, 0);
|
LCDFN(puts_scroll_style_xyoffset)(x, y, string, style, x_offset, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(HAVE_LCD_COLOR) || !defined(MAIN_LCD)
|
||||||
|
/* see lcd-16bit-common.c for others */
|
||||||
|
#ifdef MAIN_LCD
|
||||||
|
#define THIS_STRIDE STRIDE_MAIN
|
||||||
|
#else
|
||||||
|
#define THIS_STRIDE STRIDE_REMOTE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void LCDFN(bmp_part)(const struct bitmap* bm, int src_x, int src_y,
|
||||||
|
int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
if (bm->format == FORMAT_MONO)
|
||||||
|
LCDFN(mono_bitmap_part)((FBFN(data)*)(bm->data),
|
||||||
|
src_x, src_y, THIS_STRIDE(bm->width, bm->height), x, y, width, height);
|
||||||
|
else
|
||||||
|
LCDFN(bitmap_part)((FBFN(data)*)(bm->data),
|
||||||
|
src_x, src_y, THIS_STRIDE(bm->width, bm->height), x, y, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LCDFN(bmp)(const struct bitmap* bm, int x, int y)
|
||||||
|
{
|
||||||
|
LCDFN(bmp_part)(bm, 0, 0, x, y, bm->width, bm->height);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -216,6 +216,8 @@ extern void lcd_bitmap_remote_transparent(const fb_remote_data *src, int x,
|
||||||
#define lcd_remote_mono_bitmap lcd_remote_bitmap
|
#define lcd_remote_mono_bitmap lcd_remote_bitmap
|
||||||
#define lcd_remote_mono_bitmap_part lcd_remote_bitmap_part
|
#define lcd_remote_mono_bitmap_part lcd_remote_bitmap_part
|
||||||
#endif /* LCD_REMOTE_DEPTH */
|
#endif /* LCD_REMOTE_DEPTH */
|
||||||
|
extern void lcd_remote_bmp_part(const struct bitmap* bm, int src_x, int src_y,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
extern void lcd_remote_bmp(const struct bitmap* bm, int x, int y);
|
||||||
#endif
|
#endif
|
||||||
#endif /* __LCD_REMOTE_H__ */
|
#endif /* __LCD_REMOTE_H__ */
|
||||||
|
|
|
@ -543,6 +543,9 @@ extern void lcd_bitmap_transparent_part(const fb_data *src,
|
||||||
int height);
|
int height);
|
||||||
extern void lcd_bitmap_transparent(const fb_data *src, int x, int y,
|
extern void lcd_bitmap_transparent(const fb_data *src, int x, int y,
|
||||||
int width, int height);
|
int width, int height);
|
||||||
|
extern void lcd_bmp_part(const struct bitmap* bm, int src_x, int src_y,
|
||||||
|
int x, int y, int width, int height);
|
||||||
|
extern void lcd_bmp(const struct bitmap* bm, int x, int y);
|
||||||
#else /* LCD_DEPTH == 1 */
|
#else /* LCD_DEPTH == 1 */
|
||||||
#define lcd_mono_bitmap lcd_bitmap
|
#define lcd_mono_bitmap lcd_bitmap
|
||||||
#define lcd_mono_bitmap_part lcd_bitmap_part
|
#define lcd_mono_bitmap_part lcd_bitmap_part
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue