summaryrefslogtreecommitdiff
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
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
-rw-r--r--apps/plugins/test_fps.c1
-rw-r--r--firmware/target/hosted/sdl/lcd-sdl.c39
-rw-r--r--firmware/target/hosted/sdl/system-sdl.c10
3 files changed, 41 insertions, 9 deletions
diff --git a/apps/plugins/test_fps.c b/apps/plugins/test_fps.c
index 24c0700e6d..295c172524 100644
--- a/apps/plugins/test_fps.c
+++ b/apps/plugins/test_fps.c
@@ -370,6 +370,7 @@ enum plugin_status plugin_start(const void* parameter)
370 backlight_force_on(); /* backlight control in lib/helper.c */ 370 backlight_force_on(); /* backlight control in lib/helper.c */
371 371
372 time_main_update(); 372 time_main_update();
373 rb->sleep(HZ);
373#if defined(HAVE_LCD_COLOR) && (MEMORYSIZE > 2) 374#if defined(HAVE_LCD_COLOR) && (MEMORYSIZE > 2)
374 time_main_yuv(); 375 time_main_yuv();
375#endif 376#endif
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,
30 int height, int max_x, int max_y, 30 int height, int max_x, int max_y,
31 unsigned long (*getpixel)(int, int)) 31 unsigned long (*getpixel)(int, int))
32{ 32{
33 SDL_Rect dest;
34#if LCD_DEPTH >= 8 && (LCD_PIXELFORMAT == RGB565) \
35 && !defined(LCD_STRIDEFORMAT) && !defined(HAVE_LCD_SPLIT)
36 SDL_Rect src;
37 (void)max_x;
38 (void)max_y;
39 (void)getpixel;
40 /* Update complete screen via one blit operation (fast) */
41 SDL_Surface *lcd = SDL_CreateRGBSurfaceFrom(lcd_framebuffer, LCD_FBWIDTH,
42 LCD_FBHEIGHT, LCD_DEPTH,
43 LCD_FBWIDTH * LCD_DEPTH/8,
44 0, 0, 0, 0);
45 src.x = x_start;
46 src.y = y_start;
47 src.w = width;
48 src.h = height;
49
50 if (display_zoom == 1) {
51 dest = src;
52 SDL_BlitSurface(lcd, &src, surface, &dest);
53 } else {
54 /* Note: SDL_SoftStretch is currently marked as DO NOT USE
55 but there are no real alternatives for efficent zooming. */
56 dest.x = src.x * display_zoom;
57 dest.y = src.y * display_zoom;
58 dest.w = src.w * display_zoom;
59 dest.h = src.h * display_zoom;
60 SDL_SoftStretch(lcd, &src, surface, &dest);
61 }
62 SDL_FreeSurface(lcd);
63#else
33 int x, y; 64 int x, y;
34 int xmax, ymax; 65 int xmax, ymax;
35 SDL_Rect dest; 66 /* Very slow pixel-by-pixel drawing */
36
37 ymax = y_start + height; 67 ymax = y_start + height;
38 xmax = x_start + width; 68 xmax = x_start + width;
39 69
@@ -42,8 +72,6 @@ void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width,
42 if(ymax >= max_y) 72 if(ymax >= max_y)
43 ymax = max_y; 73 ymax = max_y;
44 74
45 SDL_LockSurface(surface);
46
47 dest.w = display_zoom; 75 dest.w = display_zoom;
48 dest.h = display_zoom; 76 dest.h = display_zoom;
49 77
@@ -69,8 +97,7 @@ void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width,
69 } 97 }
70#endif 98#endif
71 } 99 }
72 100#endif
73 SDL_UnlockSurface(surface);
74} 101}
75 102
76void sdl_gui_update(SDL_Surface *surface, int x_start, int y_start, int width, 103void 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)
84 84
85 SDL_Surface *picture_surface = NULL; 85 SDL_Surface *picture_surface = NULL;
86 int width, height; 86 int width, height;
87 int depth;
87 88
88 /* Try and load the background image. If it fails go without */ 89 /* Try and load the background image. If it fails go without */
89 if (background) { 90 if (background) {
@@ -115,9 +116,12 @@ static int sdl_event_thread(void * param)
115 height = SIM_LCD_HEIGHT; 116 height = SIM_LCD_HEIGHT;
116 } 117 }
117 } 118 }
118 119
119 120 depth = LCD_DEPTH;
120 if ((gui_surface = SDL_SetVideoMode(width * display_zoom, height * display_zoom, 24, SDL_HWSURFACE|SDL_DOUBLEBUF)) == NULL) { 121 if (depth < 8)
122 depth = 16;
123
124 if ((gui_surface = SDL_SetVideoMode(width * display_zoom, height * display_zoom, depth, SDL_HWSURFACE|SDL_DOUBLEBUF)) == NULL) {
121 panicf("%s", SDL_GetError()); 125 panicf("%s", SDL_GetError());
122 } 126 }
123 127