summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/ui/console.h5
-rw-r--r--ui/sdl2-2d.c15
2 files changed, 18 insertions, 2 deletions
diff --git a/include/ui/console.h b/include/ui/console.h
index d2116927f9..0b7589600b 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -280,6 +280,11 @@ static inline int surface_bytes_per_pixel(DisplaySurface *s)
return (bits + 7) / 8;
}
+static inline pixman_format_code_t surface_format(DisplaySurface *s)
+{
+ return s->format;
+}
+
#ifdef CONFIG_CURSES
#include <curses.h>
typedef chtype console_ch_t;
diff --git a/ui/sdl2-2d.c b/ui/sdl2-2d.c
index bb56747140..d0b340f956 100644
--- a/ui/sdl2-2d.c
+++ b/ui/sdl2-2d.c
@@ -89,10 +89,21 @@ void sdl2_2d_switch(DisplayChangeListener *dcl,
surface_width(new_surface),
surface_height(new_surface));
- if (surface_bits_per_pixel(scon->surface) == 16) {
+ switch (surface_format(scon->surface)) {
+ case PIXMAN_x1r5g5b5:
+ format = SDL_PIXELFORMAT_ARGB1555;
+ break;
+ case PIXMAN_r5g6b5:
format = SDL_PIXELFORMAT_RGB565;
- } else if (surface_bits_per_pixel(scon->surface) == 32) {
+ break;
+ case PIXMAN_x8r8g8b8:
format = SDL_PIXELFORMAT_ARGB8888;
+ break;
+ case PIXMAN_r8g8b8x8:
+ format = SDL_PIXELFORMAT_RGBA8888;
+ break;
+ default:
+ g_assert_not_reached();
}
scon->texture = SDL_CreateTexture(scon->real_renderer, format,
SDL_TEXTUREACCESS_STREAMING,