From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YnMkd-0007ZH-24 for qemu-devel@nongnu.org; Wed, 29 Apr 2015 03:49:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YnMkX-0008C2-RZ for qemu-devel@nongnu.org; Wed, 29 Apr 2015 03:49:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56184) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YnMkX-0008Bv-M1 for qemu-devel@nongnu.org; Wed, 29 Apr 2015 03:49:41 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 448B28E708 for ; Wed, 29 Apr 2015 07:49:41 +0000 (UTC) From: Gerd Hoffmann Date: Wed, 29 Apr 2015 09:49:30 +0200 Message-Id: <1430293770-1965-7-git-send-email-kraxel@redhat.com> In-Reply-To: <1430293770-1965-1-git-send-email-kraxel@redhat.com> References: <1430293770-1965-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 6/6] sdl2: Fix RGB555 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , Max Reitz From: 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 Signed-off-by: Gerd Hoffmann --- 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 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