qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] sdl2: Fix RGB555
@ 2015-03-03 17:25 Max Reitz
  2015-03-04 13:45 ` Gerd Hoffmann
  0 siblings, 1 reply; 2+ messages in thread
From: Max Reitz @ 2015-03-03 17:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Max Reitz

Reproducable with:

$ x86_64-softmmu/qemu-system-x86_64 \
    -kernel $vmlinuz_of_your_choice \
    -append vga=0x313 -sdl

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 include/ui/console.h |  5 +++++
 ui/sdl2-2d.c         | 15 +++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 0f97d86..1193728 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -272,6 +272,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 f907c21..d279d53 100644
--- a/ui/sdl2-2d.c
+++ b/ui/sdl2-2d.c
@@ -91,10 +91,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,
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] sdl2: Fix RGB555
  2015-03-03 17:25 [Qemu-devel] [PATCH] sdl2: Fix RGB555 Max Reitz
@ 2015-03-04 13:45 ` Gerd Hoffmann
  0 siblings, 0 replies; 2+ messages in thread
From: Gerd Hoffmann @ 2015-03-04 13:45 UTC (permalink / raw)
  To: Max Reitz; +Cc: qemu-devel

On Di, 2015-03-03 at 12:25 -0500, Max Reitz wrote:
> Reproducable with:
> 
> $ x86_64-softmmu/qemu-system-x86_64 \
>     -kernel $vmlinuz_of_your_choice \
>     -append vga=0x313 -sdl

Added to sdl patch queue.

thanks,
  Gerd

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-04 13:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-03 17:25 [Qemu-devel] [PATCH] sdl2: Fix RGB555 Max Reitz
2015-03-04 13:45 ` Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).