summaryrefslogtreecommitdiffstats
path: root/firmware/target/hosted/sdl
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-12-27 22:08:34 +0000
committerThomas Martitz <kugel@rockbox.org>2010-12-27 22:08:34 +0000
commit3c43503283f5322999bb52f28762d88a0413885e (patch)
tree8961c9a2e4554bfa1a3d864e11300d7856e71a3c /firmware/target/hosted/sdl
parent0bf1bd1d51750bf9eb0b3e149452dc1c3a89166c (diff)
downloadrockbox-3c43503283f5322999bb52f28762d88a0413885e.tar.gz
rockbox-3c43503283f5322999bb52f28762d88a0413885e.zip
Vastly increase speed of SDL screen updates for RGB565.
Flyspray: FS#11834 (with minor changes by me). Author: Thomas Jarosch git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28914 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/hosted/sdl')
-rw-r--r--firmware/target/hosted/sdl/lcd-sdl.c39
-rw-r--r--firmware/target/hosted/sdl/system-sdl.c10
2 files changed, 40 insertions, 9 deletions
diff --git a/firmware/target/hosted/sdl/lcd-sdl.c b/firmware/target/hosted/sdl/lcd-sdl.c
index 96b1a04aa6..5559369e0e 100644
--- a/firmware/target/hosted/sdl/lcd-sdl.c
+++ b/firmware/target/hosted/sdl/lcd-sdl.c
@@ -30,10 +30,40 @@ void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width,
int height, int max_x, int max_y,
unsigned long (*getpixel)(int, int))
{
+ SDL_Rect dest;
+#if LCD_DEPTH >= 8 && (LCD_PIXELFORMAT == RGB565) \
+ && !defined(LCD_STRIDEFORMAT) && !defined(HAVE_LCD_SPLIT)
+ SDL_Rect src;
+ (void)max_x;
+ (void)max_y;
+ (void)getpixel;
+ /* Update complete screen via one blit operation (fast) */
+ SDL_Surface *lcd = SDL_CreateRGBSurfaceFrom(lcd_framebuffer, LCD_FBWIDTH,
+ LCD_FBHEIGHT, LCD_DEPTH,
+ LCD_FBWIDTH * LCD_DEPTH/8,
+ 0, 0, 0, 0);
+ src.x = x_start;
+ src.y = y_start;
+ src.w = width;
+ src.h = height;
+
+ if (display_zoom == 1) {
+ dest = src;
+ SDL_BlitSurface(lcd, &src, surface, &dest);
+ } else {
+ /* Note: SDL_SoftStretch is currently marked as DO NOT USE
+ but there are no real alternatives for efficent zooming. */
+ dest.x = src.x * display_zoom;
+ dest.y = src.y * display_zoom;
+ dest.w = src.w * display_zoom;
+ dest.h = src.h * display_zoom;
+ SDL_SoftStretch(lcd, &src, surface, &dest);
+ }
+ SDL_FreeSurface(lcd);
+#else
int x, y;
int xmax, ymax;
- SDL_Rect dest;
-
+ /* Very slow pixel-by-pixel drawing */
ymax = y_start + height;
xmax = x_start + width;
@@ -42,8 +72,6 @@ void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width,
if(ymax >= max_y)
ymax = max_y;
- SDL_LockSurface(surface);
-
dest.w = display_zoom;
dest.h = display_zoom;
@@ -69,8 +97,7 @@ void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width,
}
#endif
}
-
- SDL_UnlockSurface(surface);
+#endif
}
void sdl_gui_update(SDL_Surface *surface, int x_start, int y_start, int width,
diff --git a/firmware/target/hosted/sdl/system-sdl.c b/firmware/target/hosted/sdl/system-sdl.c
index 6937c373e3..b900d38b43 100644
--- a/firmware/target/hosted/sdl/system-sdl.c
+++ b/firmware/target/hosted/sdl/system-sdl.c
@@ -84,6 +84,7 @@ static int sdl_event_thread(void * param)
SDL_Surface *picture_surface = NULL;
int width, height;
+ int depth;
/* Try and load the background image. If it fails go without */
if (background) {
@@ -115,9 +116,12 @@ static int sdl_event_thread(void * param)
height = SIM_LCD_HEIGHT;
}
}
-
-
- if ((gui_surface = SDL_SetVideoMode(width * display_zoom, height * display_zoom, 24, SDL_HWSURFACE|SDL_DOUBLEBUF)) == NULL) {
+
+ depth = LCD_DEPTH;
+ if (depth < 8)
+ depth = 16;
+
+ if ((gui_surface = SDL_SetVideoMode(width * display_zoom, height * display_zoom, depth, SDL_HWSURFACE|SDL_DOUBLEBUF)) == NULL) {
panicf("%s", SDL_GetError());
}