Patchwork vmware_vga: do not cache depth and bypp

login
register
mail settings
Submitter Damian, Alexandru
Date April 3, 2013, 10:48 a.m.
Message ID <CAJ2CSBt3pQMxCnkw271qV7CzLFe=hr1P2_-y3oYrJqetzsTAwQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/233355/
State New
Headers show

Comments

Damian, Alexandru - April 3, 2013, 10:48 a.m.
Something like this, please comment, not ready to submit.


From: Alexandru DAMIAN <alexandru.damian@intel.com>
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 <alexandru.damian@intel.com>
---
 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);
     }
 }

Patch

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);
         }