diff options
Diffstat (limited to 'firmware/target')
-rw-r--r-- | firmware/target/hosted/sdl/lcd-sdl.c | 39 | ||||
-rw-r--r-- | firmware/target/hosted/sdl/system-sdl.c | 10 |
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, | |||
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 | ||
76 | void sdl_gui_update(SDL_Surface *surface, int x_start, int y_start, int width, | 103 | 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) | |||
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 | ||