From patchwork Wed Apr 3 10:48:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Damian, Alexandru" X-Patchwork-Id: 233355 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2BEDA2C00B0 for ; Wed, 3 Apr 2013 21:48:57 +1100 (EST) Received: from localhost ([::1]:56881 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UNLFP-00086a-Dt for incoming@patchwork.ozlabs.org; Wed, 03 Apr 2013 06:48:55 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UNLEw-0007qU-VU for qemu-devel@nongnu.org; Wed, 03 Apr 2013 06:48:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UNLEr-0001au-Rw for qemu-devel@nongnu.org; Wed, 03 Apr 2013 06:48:26 -0400 Received: from mail-oa0-f53.google.com ([209.85.219.53]:49206) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UNLEr-0001ae-I8 for qemu-devel@nongnu.org; Wed, 03 Apr 2013 06:48:21 -0400 Received: by mail-oa0-f53.google.com with SMTP id m17so1333915oag.26 for ; Wed, 03 Apr 2013 03:48:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:x-gm-message-state; bh=r1C7riTNniauRhxSLnGxCkDkwvkUL1wBHBUPrQNtTL4=; b=jWRxWMH6+OfCbzW0U5BBvAwcJtfLMFm8WZBMYste0BIAP8rnlHXyjMgQ+CpqFeQ77R VS32gqbvWwVC9IVOFgUz0ccQjRn//NcVoDMNyvqJ6Wv2nxB0HMI7CymJOZ2fRAsvEw05 CxeprvCOobSB2NPTl6yxdPBkPPhMTtdZHi3l7cuW/lkcFsOP41isKQXdDzDlmkHETQVj 5EAy4tf6ah7nzq7QaaO7ElWpAMuNPD+anWG9s1zds3+wCF5GWTaFsGfv1xit90gHQLvn h+bFgIfvCFL+GWkAqT06qUiIjh9Uo8UjGTqpkwAm6XyCkZL2YZMeoaXLUrxv0WCeC4Um VUbQ== MIME-Version: 1.0 X-Received: by 10.182.169.71 with SMTP id ac7mr666239obc.88.1364986100707; Wed, 03 Apr 2013 03:48:20 -0700 (PDT) Received: by 10.76.167.38 with HTTP; Wed, 3 Apr 2013 03:48:20 -0700 (PDT) In-Reply-To: References: <1364574522-4093-1-git-send-email-alexandru.damian@intel.com> <515BFB30.4070603@redhat.com> Date: Wed, 3 Apr 2013 13:48:20 +0300 Message-ID: From: "Damian, Alexandru" To: Gerd Hoffmann X-Gm-Message-State: ALoCoQl1SR7MAZccMvrDYMqgNAgOapAZf3QEjeMsHY2+EHBSDRr2zTOhkBc13IaX1h41UvvpA/G6 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.219.53 Cc: blauwirbel@gmail.com, pbonzini@redhat.com, Jan Kiszka , qemu-devel@nongnu.org Subject: Re: [Qemu-devel] [PATCH] vmware_vga: do not cache depth and bypp 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 Something like this, please comment, not ready to submit. From: Alexandru DAMIAN Date: Wed, 3 Apr 2013 13:43:31 +0300 Subject: [PATCH] qemu console: Add depth preservation on allocation Since there are multiple bit depths supported for consoles, we must preserve the depth when creating new consoles for resizing, etc. Signed-off-by: Alexandru DAMIAN --- hw/vga.c | 6 +++--- hw/vmware_vga.c | 2 +- include/ui/console.h | 4 ++-- ui/console.c | 17 ++++++++++------- 4 files changed, 16 insertions(+), 13 deletions(-) if (ds->have_text) { @@ -1266,14 +1266,17 @@ static void qemu_alloc_display(DisplaySurface *surface, int width, int height, #endif } -DisplaySurface *qemu_create_displaysurface(int width, int height) +DisplaySurface *qemu_create_displaysurface(int width, int height, int depth) { DisplaySurface *surface = g_new0(DisplaySurface, 1); int linesize = width * 4; + // when first allocating a display, depth comes through as 0 from s->last_depth + if (depth == 0) depth = 32; + trace_displaysurface_create(surface, width, height); qemu_alloc_display(surface, width, height, linesize, - qemu_default_pixelformat(32), 0); + qemu_default_pixelformat(depth), 0); return surface; } @@ -1472,7 +1475,7 @@ static void dumb_display_init(void) width = active_console->g_width; height = active_console->g_height; } - ds->surface = qemu_create_displaysurface(width, height); + ds->surface = qemu_create_displaysurface(width, height, 32); register_displaystate(ds); } @@ -1515,7 +1518,7 @@ QemuConsole *graphic_console_init(vga_hw_update_ptr update, s->hw_text_update = text_update; s->hw = opaque; - ds->surface = qemu_create_displaysurface(640, 480); + ds->surface = qemu_create_displaysurface(640, 480, 32); register_displaystate(ds); return s; @@ -1668,13 +1671,13 @@ void text_consoles_set_display(DisplayState *ds) } } -void qemu_console_resize(QemuConsole *s, int width, int height) +void qemu_console_resize(QemuConsole *s, int width, int height, int depth) { s->g_width = width; s->g_height = height; if (is_graphic_console()) { DisplaySurface *surface; - surface = qemu_create_displaysurface(width, height); + surface = qemu_create_displaysurface(width, height, depth); dpy_gfx_replace_surface(s, surface); } } diff --git a/hw/vga.c b/hw/vga.c index f9292ed..204efa0 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -1324,7 +1324,7 @@ static void vga_draw_text(VGACommonState *s, int full_update) cw != s->last_cw || cheight != s->last_ch || s->last_depth) { s->last_scr_width = width * cw; s->last_scr_height = height * cheight; - qemu_console_resize(s->con, s->last_scr_width, s->last_scr_height); + qemu_console_resize(s->con, s->last_scr_width, s->last_scr_height, s->last_depth); surface = qemu_console_surface(s->con); dpy_text_resize(s->con, width, height); s->last_depth = 0; @@ -1677,7 +1677,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update) s->vram_ptr + (s->start_addr * 4), byteswap); dpy_gfx_replace_surface(s->con, surface); } else { - qemu_console_resize(s->con, disp_width, height); + qemu_console_resize(s->con, disp_width, height, depth); surface = qemu_console_surface(s->con); } s->last_scr_width = disp_width; @@ -2049,7 +2049,7 @@ static void vga_update_text(void *opaque, console_ch_t *chardata) cw != s->last_cw || cheight != s->last_ch) { s->last_scr_width = width * cw; s->last_scr_height = height * cheight; - qemu_console_resize(s->con, s->last_scr_width, s->last_scr_height); + qemu_console_resize(s->con, s->last_scr_width, s->last_scr_height, s->last_depth); dpy_text_resize(s->con, width, height); s->last_depth = 0; s->last_width = width; diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c index 75ef404..85696e1 100644 --- a/hw/vmware_vga.c +++ b/hw/vmware_vga.c @@ -985,7 +985,7 @@ static inline void vmsvga_check_size(struct vmsvga_state_s *s) if (s->new_width != surface_width(surface) || s->new_height != surface_height(surface)) { - qemu_console_resize(s->vga.con, s->new_width, s->new_height); + qemu_console_resize(s->vga.con, s->new_width, s->new_height, surface_bits_per_pixel(surface)); s->invalidated = 1; } } diff --git a/include/ui/console.h b/include/ui/console.h index a234c72..868c068 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -201,7 +201,7 @@ DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp, PixelFormat qemu_different_endianness_pixelformat(int bpp); PixelFormat qemu_default_pixelformat(int bpp); -DisplaySurface *qemu_create_displaysurface(int width, int height); +DisplaySurface *qemu_create_displaysurface(int width, int height, int depth); void qemu_free_displaysurface(DisplaySurface *surface); static inline int is_surface_bgr(DisplaySurface *surface) @@ -302,7 +302,7 @@ int is_fixedsize_console(void); void text_consoles_set_display(DisplayState *ds); void console_select(unsigned int index); void console_color_init(DisplayState *ds); -void qemu_console_resize(QemuConsole *con, int width, int height); +void qemu_console_resize(QemuConsole *con, int width, int height, int depth); void qemu_console_copy(QemuConsole *con, int src_x, int src_y, int dst_x, int dst_y, int w, int h); DisplaySurface *qemu_console_surface(QemuConsole *con); diff --git a/ui/console.c b/ui/console.c index e84ba8b..cc35cad 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1059,7 +1059,7 @@ void console_select(unsigned int index) } active_console = s; if (ds->have_gfx) { - surface = qemu_create_displaysurface(s->g_width, s->g_height); + surface = qemu_create_displaysurface(s->g_width, s->g_height, 32); dpy_gfx_replace_surface(s, surface); }