summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2007-09-18 19:05:35 +0000
committerNils Wallménius <nils@rockbox.org>2007-09-18 19:05:35 +0000
commita896f3d8b8a6fa7ab422b23701c0ea7c245cb307 (patch)
treeadef537d65e0f648e0eefa41117518ea8c332e89
parent98a39fb0579e983d559c3b64144903481d7b7a9a (diff)
downloadrockbox-a896f3d8b8a6fa7ab422b23701c0ea7c245cb307.tar.gz
rockbox-a896f3d8b8a6fa7ab422b23701c0ea7c245cb307.tar.bz2
rockbox-a896f3d8b8a6fa7ab422b23701c0ea7c245cb307.zip
Simplify initing of the screens[] struct by using an initializer, also some reordering of the struct, and the required plugin api bump
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14743 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugin.h4
-rw-r--r--apps/screen_access.c294
-rw-r--r--apps/screen_access.h17
3 files changed, 150 insertions, 165 deletions
diff --git a/apps/plugin.h b/apps/plugin.h
index 3971a1357c..ab6213850d 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -112,12 +112,12 @@
#define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */
-#define PLUGIN_API_VERSION 74
+#define PLUGIN_API_VERSION 75
/* 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 74
+#define PLUGIN_MIN_API_VERSION 75
/* plugin return codes */
enum plugin_status {
diff --git a/apps/screen_access.c b/apps/screen_access.c
index b5731cf33a..251bd7e848 100644
--- a/apps/screen_access.c
+++ b/apps/screen_access.c
@@ -30,181 +30,168 @@
#include "screen_access.h"
#include "textarea.h"
-struct screen screens[NB_SCREENS];
-
-void screen_init(struct screen * screen, enum screen_type screen_type)
+struct screen screens[NB_SCREENS] =
{
- switch(screen_type)
{
-#ifdef HAVE_REMOTE_LCD
- case SCREEN_REMOTE:
- screen->is_color=false;/* No color remotes yet */
- screen->pixel_format=LCD_REMOTE_PIXELFORMAT;
- screen->depth=LCD_REMOTE_DEPTH;
- screen->has_disk_led=false;
-
- screen->width=LCD_REMOTE_WIDTH;
- screen->height=LCD_REMOTE_HEIGHT;
- screen->setmargins=&lcd_remote_setmargins;
- screen->getymargin=&lcd_remote_getymargin;
- screen->getxmargin=&lcd_remote_getxmargin;
- screen->getstringsize=&lcd_remote_getstringsize;
-#if 1 /* all remote LCDs are bitmapped so far */
- screen->setfont=&lcd_remote_setfont;
- screen->setfont(FONT_UI);
- screen->mono_bitmap=&lcd_remote_mono_bitmap;
- screen->mono_bitmap_part=&lcd_remote_mono_bitmap_part;
- screen->bitmap=(screen_bitmap_func*)&lcd_remote_bitmap;
- screen->bitmap_part=(screen_bitmap_part_func*)&lcd_remote_bitmap_part;
- screen->set_drawmode=&lcd_remote_set_drawmode;
-#if LCD_REMOTE_DEPTH <= 2
- /* No transparency yet for grayscale and mono lcd */
- screen->transparent_bitmap=(screen_bitmap_func*)&lcd_remote_bitmap;
- screen->transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_remote_bitmap_part;
- /* No colour remotes yet */
-#endif
-#if LCD_REMOTE_DEPTH > 1
+ .screen_type=SCREEN_MAIN,
+ .width=LCD_WIDTH,
+ .height=LCD_HEIGHT,
+ .depth=LCD_DEPTH,
#if defined(HAVE_LCD_COLOR)
- screen->color_to_native=&lcd_remote_color_to_native;
-#endif
- screen->get_background=&lcd_remote_get_background;
- screen->get_foreground=&lcd_remote_get_foreground;
- screen->set_background=&lcd_remote_set_background;
- screen->set_foreground=&lcd_remote_set_foreground;
-#endif /* LCD_REMOTE_DEPTH > 1 */
- screen->update_rect=&lcd_remote_update_rect;
- screen->fillrect=&lcd_remote_fillrect;
- screen->drawrect=&lcd_remote_drawrect;
- screen->drawpixel=&lcd_remote_drawpixel;
- screen->drawline=&lcd_remote_drawline;
- screen->vline=&lcd_remote_vline;
- screen->hline=&lcd_remote_hline;
- screen->scroll_step=&lcd_remote_scroll_step;
- screen->invertscroll=&lcd_remote_invertscroll;
- screen->puts_style_offset=&lcd_remote_puts_style_offset;
- screen->puts_scroll_style=&lcd_remote_puts_scroll_style;
- screen->puts_scroll_style_offset=&lcd_remote_puts_scroll_style_offset;
-#endif /* 1 */
-
-#if 0 /* no charcell remote LCDs so far */
- screen->double_height=&lcd_remote_double_height;
- screen->putc=&lcd_remote_putc;
- screen->get_locked_pattern=&lcd_remote_get_locked_pattern;
- screen->define_pattern=&lcd_remote_define_pattern;
- screen->icon=&lcd_remote_icon;
-#endif /* 0 */
-
- screen->init=&lcd_remote_init;
- screen->putsxy=&lcd_remote_putsxy;
- screen->puts=&lcd_remote_puts;
- screen->puts_offset=&lcd_remote_puts_offset;
- screen->puts_scroll=&lcd_remote_puts_scroll;
- screen->puts_scroll_offset=&lcd_remote_puts_scroll_offset;
- screen->scroll_speed=&lcd_remote_scroll_speed;
- screen->scroll_delay=&lcd_remote_scroll_delay;
- screen->stop_scroll=&lcd_remote_stop_scroll;
- screen->clear_display=&lcd_remote_clear_display;
- screen->update=&lcd_remote_update;
- screen->backlight_on=&remote_backlight_on;
- screen->backlight_off=&remote_backlight_off;
- screen->is_backlight_on=&is_remote_backlight_on;
- screen->backlight_set_timeout=&remote_backlight_set_timeout;
- break;
-#endif /* HAVE_REMOTE_LCD */
-
- case SCREEN_MAIN:
- default:
-#if defined(HAVE_LCD_COLOR)
- screen->is_color=true;
+ .is_color=true,
#else
- screen->is_color=false;
+ .is_color=false,
#endif
#ifdef HAVE_LCD_BITMAP
- screen->pixel_format=LCD_PIXELFORMAT;
+ .pixel_format=LCD_PIXELFORMAT,
#endif
- screen->depth=LCD_DEPTH;
#if (CONFIG_LED == LED_VIRTUAL)
- screen->has_disk_led=false;
+ .has_disk_led=false,
#elif defined(HAVE_REMOTE_LCD)
- screen->has_disk_led=true;
+ .has_disk_led=true,
#endif
- screen->width=LCD_WIDTH;
- screen->height=LCD_HEIGHT;
- screen->setmargins=&lcd_setmargins;
- screen->getymargin=&lcd_getymargin;
- screen->getxmargin=&lcd_getxmargin;
- screen->getstringsize=&lcd_getstringsize;
+ .setmargins=&lcd_setmargins,
+ .getymargin=&lcd_getymargin,
+ .getxmargin=&lcd_getxmargin,
+ .getstringsize=&lcd_getstringsize,
#ifdef HAVE_LCD_BITMAP
- screen->setfont=&lcd_setfont;
- screen->setfont(FONT_UI);
- screen->mono_bitmap=&lcd_mono_bitmap;
- screen->mono_bitmap_part=&lcd_mono_bitmap_part;
- screen->set_drawmode=&lcd_set_drawmode;
- screen->bitmap=(screen_bitmap_func*)&lcd_bitmap;
- screen->bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_part;
+ .setfont=&lcd_setfont,
+ .mono_bitmap=&lcd_mono_bitmap,
+ .mono_bitmap_part=&lcd_mono_bitmap_part,
+ .set_drawmode=&lcd_set_drawmode,
+ .bitmap=(screen_bitmap_func*)&lcd_bitmap,
+ .bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_part,
#if LCD_DEPTH <= 2
- /* No transparency yet for grayscale and mono lcd */
- screen->transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap;
- screen->transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_part;
+ /* No transparency yet for grayscale and mono lcd */
+ .transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap,
+ .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_part,
#else
- screen->transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap_transparent;
- screen->transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_transparent_part;
+ .transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap_transparent,
+ .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_transparent_part,
#endif
#if LCD_DEPTH > 1
#if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1
- screen->color_to_native=&lcd_color_to_native;
+ .color_to_native=&lcd_color_to_native,
#endif
- screen->get_background=&lcd_get_background;
- screen->get_foreground=&lcd_get_foreground;
- screen->set_background=&lcd_set_background;
- screen->set_foreground=&lcd_set_foreground;
+ .get_background=&lcd_get_background,
+ .get_foreground=&lcd_get_foreground,
+ .set_background=&lcd_set_background,
+ .set_foreground=&lcd_set_foreground,
#endif /* LCD_DEPTH > 1 */
- screen->update_rect=&lcd_update_rect;
- screen->fillrect=&lcd_fillrect;
- screen->drawrect=&lcd_drawrect;
- screen->drawpixel=&lcd_drawpixel;
- screen->drawline=&lcd_drawline;
- screen->vline=&lcd_vline;
- screen->hline=&lcd_hline;
- screen->scroll_step=&lcd_scroll_step;
- screen->invertscroll=&lcd_invertscroll;
- screen->puts_style_offset=&lcd_puts_style_offset;
- screen->puts_scroll_style=&lcd_puts_scroll_style;
- screen->puts_scroll_style_offset=&lcd_puts_scroll_style_offset;
+ .update_rect=&lcd_update_rect,
+ .fillrect=&lcd_fillrect,
+ .drawrect=&lcd_drawrect,
+ .drawpixel=&lcd_drawpixel,
+ .drawline=&lcd_drawline,
+ .vline=&lcd_vline,
+ .hline=&lcd_hline,
+ .scroll_step=&lcd_scroll_step,
+ .invertscroll=&lcd_invertscroll,
+ .puts_style_offset=&lcd_puts_style_offset,
+ .puts_scroll_style=&lcd_puts_scroll_style,
+ .puts_scroll_style_offset=&lcd_puts_scroll_style_offset,
#endif /* HAVE_LCD_BITMAP */
#ifdef HAVE_LCD_CHARCELLS
- screen->double_height=&lcd_double_height;
- screen->putc=&lcd_putc;
- screen->get_locked_pattern=&lcd_get_locked_pattern;
- screen->define_pattern=&lcd_define_pattern;
- screen->unlock_pattern=&lcd_unlock_pattern;
- screen->icon=&lcd_icon;
+ .double_height=&lcd_double_height,
+ .putc=&lcd_putc,
+ .get_locked_pattern=&lcd_get_locked_pattern,
+ .define_pattern=&lcd_define_pattern,
+ .unlock_pattern=&lcd_unlock_pattern,
+ .icon=&lcd_icon,
#endif /* HAVE_LCD_CHARCELLS */
- screen->init=&lcd_init;
- screen->putsxy=&lcd_putsxy;
- screen->puts=&lcd_puts;
- screen->puts_offset=&lcd_puts_offset;
- screen->puts_scroll=&lcd_puts_scroll;
- screen->puts_scroll_offset=&lcd_puts_scroll_offset;
- screen->scroll_speed=&lcd_scroll_speed;
- screen->scroll_delay=&lcd_scroll_delay;
- screen->stop_scroll=&lcd_stop_scroll;
- screen->clear_display=&lcd_clear_display;
- screen->update=&lcd_update;
- screen->backlight_on=&backlight_on;
- screen->backlight_off=&backlight_off;
- screen->is_backlight_on=&is_backlight_on;
- screen->backlight_set_timeout=&backlight_set_timeout;
- break;
- }
- screen->screen_type=screen_type;
+ .putsxy=&lcd_putsxy,
+ .puts=&lcd_puts,
+ .puts_offset=&lcd_puts_offset,
+ .puts_scroll=&lcd_puts_scroll,
+ .puts_scroll_offset=&lcd_puts_scroll_offset,
+ .scroll_speed=&lcd_scroll_speed,
+ .scroll_delay=&lcd_scroll_delay,
+ .stop_scroll=&lcd_stop_scroll,
+ .clear_display=&lcd_clear_display,
+ .update=&lcd_update,
+ .backlight_on=&backlight_on,
+ .backlight_off=&backlight_off,
+ .is_backlight_on=&is_backlight_on,
+ .backlight_set_timeout=&backlight_set_timeout
#ifdef HAS_BUTTONBAR
- screen->has_buttonbar=false;
+ ,.has_buttonbar=false
#endif
- gui_textarea_update_nblines(screen);
-}
+ }
+#ifdef HAVE_REMOTE_LCD
+ ,{
+ .screen_type=SCREEN_REMOTE,
+ .width=LCD_REMOTE_WIDTH,
+ .height=LCD_REMOTE_HEIGHT,
+ .depth=LCD_REMOTE_DEPTH,
+ .is_color=false,/* No color remotes yet */
+ .pixel_format=LCD_REMOTE_PIXELFORMAT,
+ .has_disk_led=false,
+ .setmargins=&lcd_remote_setmargins,
+ .getymargin=&lcd_remote_getymargin,
+ .getxmargin=&lcd_remote_getxmargin,
+ .getstringsize=&lcd_remote_getstringsize,
+#if 1 /* all remote LCDs are bitmapped so far */
+ .setfont=&lcd_remote_setfont,
+ .mono_bitmap=&lcd_remote_mono_bitmap,
+ .mono_bitmap_part=&lcd_remote_mono_bitmap_part,
+ .bitmap=(screen_bitmap_func*)&lcd_remote_bitmap,
+ .bitmap_part=(screen_bitmap_part_func*)&lcd_remote_bitmap_part,
+ .set_drawmode=&lcd_remote_set_drawmode,
+#if LCD_REMOTE_DEPTH <= 2
+ /* No transparency yet for grayscale and mono lcd */
+ .transparent_bitmap=(screen_bitmap_func*)&lcd_remote_bitmap,
+ .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_remote_bitmap_part,
+ /* No colour remotes yet */
+#endif
+#if LCD_REMOTE_DEPTH > 1
+#if defined(HAVE_LCD_COLOR)
+ .color_to_native=&lcd_remote_color_to_native,
+#endif
+ .get_background=&lcd_remote_get_background,
+ .get_foreground=&lcd_remote_get_foreground,
+ .set_background=&lcd_remote_set_background,
+ .set_foreground=&lcd_remote_set_foreground,
+#endif /* LCD_REMOTE_DEPTH > 1 */
+ .update_rect=&lcd_remote_update_rect,
+ .fillrect=&lcd_remote_fillrect,
+ .drawrect=&lcd_remote_drawrect,
+ .drawpixel=&lcd_remote_drawpixel,
+ .drawline=&lcd_remote_drawline,
+ .vline=&lcd_remote_vline,
+ .hline=&lcd_remote_hline,
+ .scroll_step=&lcd_remote_scroll_step,
+ .invertscroll=&lcd_remote_invertscroll,
+ .puts_style_offset=&lcd_remote_puts_style_offset,
+ .puts_scroll_style=&lcd_remote_puts_scroll_style,
+ .puts_scroll_style_offset=&lcd_remote_puts_scroll_style_offset,
+#endif /* 1 */
+
+#if 0 /* no charcell remote LCDs so far */
+ .double_height=&lcd_remote_double_height,
+ .putc=&lcd_remote_putc,
+ .get_locked_pattern=&lcd_remote_get_locked_pattern,
+ .define_pattern=&lcd_remote_define_pattern,
+ .icon=&lcd_remote_icon,
+#endif /* 0 */
+ .putsxy=&lcd_remote_putsxy,
+ .puts=&lcd_remote_puts,
+ .puts_offset=&lcd_remote_puts_offset,
+ .puts_scroll=&lcd_remote_puts_scroll,
+ .puts_scroll_offset=&lcd_remote_puts_scroll_offset,
+ .scroll_speed=&lcd_remote_scroll_speed,
+ .scroll_delay=&lcd_remote_scroll_delay,
+ .stop_scroll=&lcd_remote_stop_scroll,
+ .clear_display=&lcd_remote_clear_display,
+ .update=&lcd_remote_update,
+ .backlight_on=&remote_backlight_on,
+ .backlight_off=&remote_backlight_off,
+ .is_backlight_on=&is_remote_backlight_on,
+ .backlight_set_timeout=&remote_backlight_set_timeout
+ }
+#endif /* HAVE_REMOTE_LCD */
+};
#ifdef HAVE_LCD_BITMAP
void screen_clear_area(struct screen * display, int xstart, int ystart,
@@ -220,5 +207,10 @@ void screen_access_init(void)
{
int i;
FOR_NB_SCREENS(i)
- screen_init(&screens[i], i);
+ {
+#ifdef HAVE_LCD_BITMAP
+ ((struct screen*)&screens[i])->setfont(FONT_UI);
+#endif
+ gui_textarea_update_nblines(&screens[i]);
+ }
}
diff --git a/apps/screen_access.h b/apps/screen_access.h
index 822aab4a88..05a53d5d0f 100644
--- a/apps/screen_access.h
+++ b/apps/screen_access.h
@@ -51,18 +51,20 @@ typedef void screen_bitmap_part_func(const void *src, int src_x, int src_y,
typedef void screen_bitmap_func(const void *src, int x, int y, int width,
int height);
+/* if this struct is changed the plugin api may break so bump the api
+ versions in plugin.h */
struct screen
{
- int width, height;
- int nb_lines;
enum screen_type screen_type;
+ int width, height;
int depth;
- bool is_color;
+ int nb_lines;
#ifdef HAVE_LCD_BITMAP
int pixel_format;
#endif
int char_width;
int char_height;
+ bool is_color;
#if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
bool has_disk_led;
#endif
@@ -72,7 +74,6 @@ struct screen
void (*setmargins)(int x, int y);
int (*getxmargin)(void);
int (*getymargin)(void);
-
int (*getstringsize)(const unsigned char *str, int *w, int *h);
#if defined(HAVE_LCD_BITMAP) || defined(HAVE_REMOTE_LCD) /* always bitmap */
void (*setfont)(int newfont);
@@ -124,7 +125,6 @@ struct screen
void (*define_pattern)(unsigned long ucs, const char *pattern);
void (*unlock_pattern)(unsigned long ucs);
#endif
- void (*init)(void);
void (*putsxy)(int x, int y, const unsigned char *str);
void (*puts)(int x, int y, const unsigned char *str);
void (*puts_offset)(int x, int y, const unsigned char *str, int offset);
@@ -142,13 +142,6 @@ struct screen
void (*backlight_set_timeout)(int index);
};
-/*
- * Initializes the given screen structure for a given display
- * - screen : the screen structure
- * - display_type : currently 2 possibles values : MAIN or REMOTE
- */
-extern void screen_init(struct screen * screen, enum screen_type screen_type);
-
#ifdef HAS_BUTTONBAR
/*
* Sets if the given screen has a buttonbar or not