From patchwork Tue May 5 09:43:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 468025 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 100A914090B for ; Tue, 5 May 2015 19:46:43 +1000 (AEST) Received: from localhost ([::1]:37912 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YpZR3-0004y6-18 for incoming@patchwork.ozlabs.org; Tue, 05 May 2015 05:46:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YpZOH-0000Gr-Tu for qemu-devel@nongnu.org; Tue, 05 May 2015 05:43:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YpZOG-0002R9-Na for qemu-devel@nongnu.org; Tue, 05 May 2015 05:43:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42775) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YpZOG-0002R3-JH for qemu-devel@nongnu.org; Tue, 05 May 2015 05:43:48 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 3571F8EA21 for ; Tue, 5 May 2015 09:43:48 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-78.ams2.redhat.com [10.36.116.78]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t459hhZY001902; Tue, 5 May 2015 05:43:47 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 91ED0832C4; Tue, 5 May 2015 11:43:46 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 5 May 2015 11:43:37 +0200 Message-Id: <1430819017-10877-7-git-send-email-kraxel@redhat.com> In-Reply-To: <1430819017-10877-1-git-send-email-kraxel@redhat.com> References: <1430819017-10877-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann , Max Reitz Subject: [Qemu-devel] [PULL 6/6] sdl2: Fix RGB555 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 d211692..0b75896 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,