qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>, Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PATCH 6/6] sdl2: Fix RGB555
Date: Wed, 29 Apr 2015 09:49:30 +0200	[thread overview]
Message-ID: <1430293770-1965-7-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1430293770-1965-1-git-send-email-kraxel@redhat.com>

From: Max Reitz <mreitz@redhat.com>

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>
Signed-off-by: Gerd Hoffmann <kraxel@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 8ee04ad..f0dc909 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 bb56747..d0b340f 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,
-- 
1.8.3.1

      parent reply	other threads:[~2015-04-29  7:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-29  7:49 [Qemu-devel] [PATCH 0/6] sdl2: add opengl rendering support Gerd Hoffmann
2015-04-29  7:49 ` [Qemu-devel] [PATCH 1/6] opengl: add shader build infrastructure Gerd Hoffmann
2015-04-29  7:49 ` [Qemu-devel] [PATCH 2/6] opengl: add shader helper functions Gerd Hoffmann
2015-04-29  7:49 ` [Qemu-devel] [PATCH 3/6] console-gl: add opengl rendering " Gerd Hoffmann
2015-04-29  7:49 ` [Qemu-devel] [PATCH 4/6] sdl2: move SDL_* includes to sdl2.h Gerd Hoffmann
2015-04-29  7:49 ` [Qemu-devel] [PATCH 5/6] sdl2: add support for display rendering using opengl Gerd Hoffmann
2015-04-29  7:49 ` Gerd Hoffmann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1430293770-1965-7-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).