summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2009-02-10 01:23:18 +0000
committerJens Arnold <amiconn@rockbox.org>2009-02-10 01:23:18 +0000
commit0358d9b382057ad45ba86882b55bc4cec630e726 (patch)
tree706a1fbed5b5afa83409be618a32547beb857774
parentabc3edcb95756c7a19bd592a81f7633ff31d9606 (diff)
downloadrockbox-0358d9b382057ad45ba86882b55bc4cec630e726.tar.gz
rockbox-0358d9b382057ad45ba86882b55bc4cec630e726.zip
Simulate backlight for colour targets. Implements the idea from FS #9884, but uses SDL alpha blending. Display is dimmed to 1/3 for targets with transflective LCD, and set to black for others.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19961 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/export/config-ipodcolor.h3
-rw-r--r--firmware/export/config-ipodnano.h3
-rw-r--r--firmware/export/config-ipodvideo.h3
-rw-r--r--uisimulator/sdl/lcd-bitmap.c24
-rw-r--r--uisimulator/sdl/lcd-sdl.c3
5 files changed, 31 insertions, 5 deletions
diff --git a/firmware/export/config-ipodcolor.h b/firmware/export/config-ipodcolor.h
index e7395919d6..e8a048d97f 100644
--- a/firmware/export/config-ipodcolor.h
+++ b/firmware/export/config-ipodcolor.h
@@ -49,6 +49,9 @@
#define LCD_DEPTH 16 /* 65536 colours */
#define LCD_PIXELFORMAT RGB565SWAPPED /* rgb565 byte-swapped */
+/* LCD stays visible without backlight - simulator hint */
+#define HAVE_TRANSFLECTIVE_LCD
+
#define CONFIG_KEYPAD IPOD_4G_PAD
/* Define this if you do software codec */
diff --git a/firmware/export/config-ipodnano.h b/firmware/export/config-ipodnano.h
index 3bf44b3abe..c90deb8e2f 100644
--- a/firmware/export/config-ipodnano.h
+++ b/firmware/export/config-ipodnano.h
@@ -49,6 +49,9 @@
#define LCD_DEPTH 16 /* 65536 colours */
#define LCD_PIXELFORMAT RGB565SWAPPED /* rgb565 byte-swapped */
+/* LCD stays visible without backlight - simulator hint */
+#define HAVE_TRANSFLECTIVE_LCD
+
#define CONFIG_KEYPAD IPOD_4G_PAD
/* Define this if you do software codec */
diff --git a/firmware/export/config-ipodvideo.h b/firmware/export/config-ipodvideo.h
index d3e8dc0140..ca8e43db77 100644
--- a/firmware/export/config-ipodvideo.h
+++ b/firmware/export/config-ipodvideo.h
@@ -49,6 +49,9 @@
#define LCD_DEPTH 16 /* 65536 colours */
#define LCD_PIXELFORMAT RGB565 /* rgb565 */
+/* LCD stays visible without backlight - simulator hint */
+#define HAVE_TRANSFLECTIVE_LCD
+
#define CONFIG_KEYPAD IPOD_4G_PAD
/* Define this if you do software codec */
diff --git a/uisimulator/sdl/lcd-bitmap.c b/uisimulator/sdl/lcd-bitmap.c
index b4e6dcd4c0..8caac784ef 100644
--- a/uisimulator/sdl/lcd-bitmap.c
+++ b/uisimulator/sdl/lcd-bitmap.c
@@ -63,7 +63,16 @@ SDL_Color lcd_color2_bright = {RED_CMP(LCD_BRIGHTCOLOR_2),
#else
#define NUM_SHADES 129
#endif
-#endif /* LCD_DEPTH <= 8 */
+
+#else /* LCD_DEPTH > 8 */
+
+#ifdef HAVE_TRANSFLECTIVE_LCD
+#define BACKLIGHT_OFF_ALPHA 85 /* 1/3 brightness */
+#else
+#define BACKLIGHT_OFF_ALPHA 0 /* pitch black */
+#endif
+
+#endif /* LCD_DEPTH */
#if LCD_DEPTH < 8
unsigned long (*lcd_ex_getpixel)(int, int) = NULL;
@@ -135,12 +144,17 @@ void sim_backlight(int value)
&lcd_color2_bright, NUM_SHADES, NUM_SHADES);
#endif
}
+#else /* LCD_DEPTH > 8 */
+ if (value > 0) {
+ SDL_SetAlpha(lcd_surface, 0, SDL_ALPHA_OPAQUE); /* full on */
+ } else {
+ SDL_SetAlpha(lcd_surface, SDL_SRCALPHA, BACKLIGHT_OFF_ALPHA);
+ }
+#endif /* LCD_DEPTH */
+
sdl_gui_update(lcd_surface, 0, 0, SIM_LCD_WIDTH, SIM_LCD_HEIGHT,
SIM_LCD_WIDTH, SIM_LCD_HEIGHT,
background ? UI_LCD_POSX : 0, background? UI_LCD_POSY : 0);
-#else /* LCD_DEPTH > 8 */
- (void)value; /* not yet simulated */
-#endif /* LCD_DEPTH */
}
#endif /* HAVE_BACKLIGHT */
@@ -153,7 +167,7 @@ void sim_lcd_init(void)
SIM_LCD_HEIGHT * display_zoom,
LCD_DEPTH, 0, 0, 0, 0);
#else
- lcd_surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
+ lcd_surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
SIM_LCD_WIDTH * display_zoom,
SIM_LCD_HEIGHT * display_zoom,
8, 0, 0, 0, 0);
diff --git a/uisimulator/sdl/lcd-sdl.c b/uisimulator/sdl/lcd-sdl.c
index 373e07ffc0..aa74c14cd9 100644
--- a/uisimulator/sdl/lcd-sdl.c
+++ b/uisimulator/sdl/lcd-sdl.c
@@ -90,6 +90,9 @@ void sdl_gui_update(SDL_Surface *surface, int x_start, int y_start, int width,
SDL_Rect dest= {(ui_x + x_start) * display_zoom, (ui_y + y_start) * display_zoom,
xmax * display_zoom, ymax * display_zoom};
+ if (surface->flags & SDL_SRCALPHA) /* alpha needs a black background */
+ SDL_FillRect(gui_surface, &dest, 0);
+
SDL_BlitSurface(surface, &src, gui_surface, &dest);
SDL_Flip(gui_surface);