pixman patch series.
cover pixman patch series.
Hi,
First round of pixman patches for qemu, so we have something concrete to discuss. Applies on top of the "console cleanups" patch series posted a few days ago.
The long-term goal is to stop reinventing the wheel over and over when it comes to pixel manipulation and to use pixman instead. This patch series is a start. It switches a central data structure (DisplaySurface) over to pixman, so the ui code can easily use pixman to manipulate pixel data. It also collects some low-hanging fruit to show pixman in action.
Comments?
cheers,
Gerd
Gerd Hoffmann (14):
console: remove DisplayAllocator
pixman: add submodule
pixman: windup in configure & makefiles
pixman: helper functions
pixman: add pixman image to DisplaySurface
console: make qemu_alloc_display static
console: don't set PixelFormat alpha fields for 32bpp
qxl: stop direct access to DisplaySurface fields.
vga: stop direct access to DisplaySurface fields.
pixman: switch screendump function. pixman/vnc: use pixman images in vnc. pixman/vnc: remove rgb_prepare_row* functions pixman/vnc: remove dead code.
pixman: drop obsolete fields from DisplaySurface
.gitmodules | 3 + Makefile | 9 ++ Makefile.objs | 1 + configure | 38 ++++++ console.c | 107 +++++++--------- console.h | 62 ++++------ hw/qxl-render.c | 2 +- hw/vga.c | 48 +++----- pixman | 1 + qemu-common.h | 1 - qemu-pixman.c | 60 +++++++++ qemu-pixman.h | 32 +++++ ui/sdl.c | 117 +---------------- ui/vnc-enc-hextile-template.h | 23 ++-- ui/vnc-enc-hextile.c | 53 ++------- ui/vnc-enc-tight.c | 280 +++++++++++++++-------------------------- ui/vnc-enc-zrle.c | 18 ++-- ui/vnc-jobs.c | 3 +- ui/vnc.c | 239 ++++++++++++++++++----------------- ui/vnc.h | 19 +++- 20 files changed, 508 insertions(+), 608 deletions(-) create mode 160000 pixman create mode 100644 qemu-pixman.c create mode 100644 qemu-pixman.h
PATCH 1/14 console: remove DisplayAllocator
Causes [temporary] preformance regression with 24bpp vga modes @ sdl.
--- console.c | 52 +++++++++---------------- console.h | 34 +++-------------- qemu-common.h | 1 - ui/sdl.c | 117 +++------------------------------------------------------ 4 files changed, 31 insertions(+), 173 deletions(-)
console.c +19 -33
@@ -1294,9 +1294,10 @@ static QemuConsole *new_console(DisplayState *ds, console_type_t console_type)return s; } -static DisplaySurface *defaultallocator_create_displaysurface (int width,int height) +DisplaySurface *qemu_create_displaysurface (DisplayState *ds, +int width,int height) { -DisplaySurface *surface = (DisplaySurface *)g_malloc0 (sizeof (DisplaySurface)); +DisplaySurface *surface =g_new0 (DisplaySurface,1 );int linesize = width *4 ; qemu_alloc_display(surface, width, height, linesize,
@@ -1304,13 +1305,15 @@ static DisplaySurface* defaultallocator_create_displaysurface(int width, int heireturn surface; } -static DisplaySurface *defaultallocator_resize_displaysurface (DisplaySurface *surface, -int width,int height) +DisplaySurface *qemu_resize_displaysurface (DisplayState *ds, +int width,int height) {int linesize = width *4 ; -qemu_alloc_display (surface, width, height, linesize, + +trace_displaysurface_resize (ds, ds->surface, width, height); +qemu_alloc_display (ds->surface, width, height, linesize,qemu_default_pixelformat (32 ),0 ); -return surface; +return ds->surface; } void qemu_alloc_display(DisplaySurface *surface, int width, int height,
@@ -1323,7 +1326,7 @@ void qemu_alloc_display(DisplaySurface *surface, int width, int height, surface->pf = pf;if (surface->flags &QEMU_ALLOCATED_FLAG ) { data =g_realloc (surface->data, - surface->linesize * surface->height); + surface->linesize * surface->height); }else { data =g_malloc (surface->linesize * surface->height); }
@@ -1334,7 +1337,7 @@ void qemu_alloc_display(DisplaySurface *surface, int width, int height,#endif } -DisplaySurface *qemu_create_displaysurface_from (int width,int height,int bpp, +DisplaySurface *qemu_create_displaysurface_from (int width,int height,int bpp,int linesize,uint8_t *data) {DisplaySurface *surface = (DisplaySurface *)g_malloc0 (sizeof (DisplaySurface));
@@ -1351,28 +1354,24 @@ DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp,return surface; } -static void defaultallocator_free_displaysurface (DisplaySurface *surface) +void qemu_free_displaysurface (DisplayState *ds) { -if (surface ==NULL ) +trace_displaysurface_free (ds, ds->surface); +if (ds->surface ==NULL ) {return ; -if (surface->flags &QEMU_ALLOCATED_FLAG ) -g_free (surface->data); -g_free (surface); + } +if (ds->surface->flags &QEMU_ALLOCATED_FLAG ) { +g_free (ds->surface->data); + } +g_free (ds->surface); } -static struct DisplayAllocator default_allocator = { - defaultallocator_create_displaysurface, - defaultallocator_resize_displaysurface, - defaultallocator_free_displaysurface -}; -static void dumb_display_init (void ) {DisplayState *ds =g_malloc0 (sizeof (DisplayState));int width =640 ;int height =480 ; - ds->allocator = &default_allocator;if (is_fixedsize_console ()) { width = active_console->g_width; height = active_console->g_height;
@@ -1402,18 +1401,6 @@ DisplayState *get_displaystate(void)return display_state; } -DisplayAllocator *register_displayallocator (DisplayState *ds,DisplayAllocator *da) -{ -if (ds->allocator == &default_allocator) { -DisplaySurface *surf; - surf = da->create_displaysurface (ds_get_width (ds),ds_get_height (ds)); -defaultallocator_free_displaysurface (ds->surface); - ds->surface = surf; - ds->allocator = da; - } -return ds->allocator; -} - DisplayState *graphic_console_init(vga_hw_update_ptr update, vga_hw_invalidate_ptr invalidate, vga_hw_screen_dump_ptr screen_dump,
@@ -1424,7 +1411,6 @@ DisplayState *graphic_console_init(vga_hw_update_ptr update,DisplayState *ds; ds = (DisplayState *)g_malloc0 (sizeof (DisplayState)); - ds->allocator = &default_allocator; ds->surface =qemu_create_displaysurface (ds,640 ,480 ); s =new_console (ds,GRAPHIC_CONSOLE );
console.h +6 -28
@@ -107,7 +107,6 @@ void kbd_put_keysym(int keysym);#define QEMU_BIG_ENDIAN_FLAG 0x01#define QEMU_ALLOCATED_FLAG 0x02 -#define QEMU_REALPIXELS_FLAG 0x04struct PixelFormat {uint8_t bits_per_pixel;
@@ -172,12 +171,6 @@ struct DisplayChangeListener {QLIST_ENTRY (DisplayChangeListener) next; }; -struct DisplayAllocator { -DisplaySurface * (*create_displaysurface)(int width,int height); -DisplaySurface * (*resize_displaysurface)(DisplaySurface *surface,int width,int height); -void (*free_displaysurface)(DisplaySurface *surface); -}; -struct DisplayState {struct DisplaySurface *surface;void *opaque;
@@ -185,7 +178,6 @@ struct DisplayState {bool have_gfx;bool have_text; -struct DisplayAllocator * allocator; QLIST_HEAD(, DisplayChangeListener) listeners;struct DisplayState *next;
@@ -200,24 +192,11 @@ void qemu_alloc_display(DisplaySurface *surface, int width, int height,PixelFormat qemu_different_endianness_pixelformat (int bpp);PixelFormat qemu_default_pixelformat (int bpp); -DisplayAllocator *register_displayallocator (DisplayState *ds,DisplayAllocator *da); - -static inline DisplaySurface *qemu_create_displaysurface (DisplayState *ds,int width,int height) -{ -return ds->allocator->create_displaysurface (width, height); -} - -static inline DisplaySurface *qemu_resize_displaysurface (DisplayState *ds,int width,int height) -{ -trace_displaysurface_resize (ds, ds->surface, width, height); -return ds->allocator->resize_displaysurface (ds->surface, width, height); -} - -static inline void qemu_free_displaysurface (DisplayState *ds) -{ -trace_displaysurface_free (ds, ds->surface); - ds->allocator->free_displaysurface (ds->surface); -} +DisplaySurface *qemu_create_displaysurface (DisplayState *ds, +int width,int height); +DisplaySurface *qemu_resize_displaysurface (DisplayState *ds, +int width,int height); +void qemu_free_displaysurface (DisplayState *ds);static inline int is_surface_bgr (DisplaySurface *surface) {
@@ -229,8 +208,7 @@ static inline int is_surface_bgr(DisplaySurface *surface)static inline int is_buffer_shared (DisplaySurface *surface) { -return (!(surface->flags &QEMU_ALLOCATED_FLAG ) && - !(surface->flags &QEMU_REALPIXELS_FLAG )); +return !(surface->flags &QEMU_ALLOCATED_FLAG ); }void gui_setup_refresh (DisplayState *ds);
qemu-common.h +0 -1
@@ -262,7 +262,6 @@ typedef struct DriveInfo DriveInfo;typedef struct DisplayState DisplayState ;typedef struct DisplayChangeListener DisplayChangeListener ;typedef struct DisplaySurface DisplaySurface ; -typedef struct DisplayAllocator DisplayAllocator ;typedef struct PixelFormat PixelFormat ;typedef struct QemuConsole QemuConsole ;typedef struct CharDriverState CharDriverState ;
ui/sdl.c +6 -111
142 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 2/14 pixman: add submodule
In reply to Gerd HoffmannAdd pixman submodule as fallback for old distros. Picking version 0.18.4. This is shipped by rhel6 and also the minimum version needed by spice so this should serve well as baseline.
--- .gitmodules | 3 +++ pixman | 1 + 2 files changed, 4 insertions(+), 0 deletions(-) create mode 160000 pixman
.gitmodules +3 -0
@@ -19,3 +19,6 @@ [submodule "roms/sgabios"] path = roms/sgabios url = git://git.qemu.org/sgabios.git +[submodule "pixman"] + path = pixman + url = git://anongit.freedesktop.org/pixman
pixman new file +1 -0
@@ -0,0 +1 @@ +Subproject commit 97336fad32acf802003855cd8bd6477fa49a12e3
Signature · 1 line
1.7.1
PATCH 3/14 pixman: windup in configure & makefiles
In reply to Gerd Hoffmann--- Makefile | 9 +++++++++ configure | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 0 deletions(-)
Makefile +9 -0
@@ -105,6 +105,15 @@ endif subdir-libcacard: $(oslib-obj-y) $(trace-obj-y) qemu-timer-common.o +subdir-pixman: pixman/Makefile + $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C pixman V="$(V)" all,) + +pixman/Makefile: $(SRC_PATH)/pixman/configure + (cd pixman; $(SRC_PATH)/pixman/configure --disable-shared --enable-static) + +$(SRC_PATH)/pixman/configure: + (cd $(SRC_PATH)/pixman; autoreconf -v --install) + $(filter %-softmmu,$(SUBDIR_RULES)): $(universal-obj-y) $(trace-obj-y) $(common-obj-y) $(extra-obj-y) subdir-libdis $(filter %-user,$(SUBDIR_RULES)): $(universal-obj-y) $(trace-obj-y) subdir-libdis-user subdir-libuser
configure +38 -0
@@ -147,6 +147,7 @@ curses="" docs="" fdt="" nptl="" +pixman="" sdl="" virtfs="" vnc="yes"
@@ -642,6 +643,10 @@ for opt do # configure to be used by RPM and similar macros that set # lots of directory switches by default. ;; + --pixman-system) pixman="system" + ;; + --pixman-internal) pixman="internal" + ;; --disable-sdl) sdl="no" ;; --enable-sdl) sdl="yes"
@@ -2117,6 +2122,34 @@ else fi ########################################## +# pixman support probe + +if test "$pixman" = ""; then + if $pkg_config pixman-1 > /dev/null 2>&1; then + pixman="system" + else + pixman="internal" + fi +fi +if test "$pixman" = "system"; then + pixman_cflags=`$pkg_config --cflags pixman-1 2>/dev/null` + pixman_libs=`$pkg_config --libs pixman-1 2>/dev/null` +else + if test ! -d ${source_path}/pixman/pixman; then + echo "ERROR: pixman not present. Your options:" + echo " (1) Prefered: Install the pixman devel package (any recent" + echo " distro should have packages as Xorg needs pixman too)." + echo " (2) Fetch the pixman submodule, using:" + echo " git submodule update --init pixman" + exit 1 + fi + pixman_cflags="-I${source_path}/pixman/pixman" + pixman_libs="-Lpixman/pixman/.libs -lpixman-1" +fi +QEMU_CFLAGS="$QEMU_CFLAGS $pixman_cflags" +libs_softmmu="$libs_softmmu $pixman_libs" + +########################################## # libcap probe if test "$cap" != "no" ; then
@@ -3147,6 +3180,7 @@ echo "-Werror enabled $werror" if test "$darwin" = "yes" ; then echo "Cocoa support $cocoa" fi +echo "pixman $pixman" echo "SDL support $sdl" echo "curses support $curses" echo "curl support $curl"
@@ -3909,6 +3943,9 @@ if test "$target_softmmu" = "yes" ; then if test "$smartcard_nss" = "yes" ; then echo "subdir-$target: subdir-libcacard" >> $config_host_mak fi + if test "$pixman" = "internal" ; then + echo "subdir-$target: subdir-pixman" >> $config_host_mak + fi case "$target_arch2" in i386|x86_64) echo "CONFIG_HAVE_CORE_DUMP=y" >> $config_target_mak
@@ -4112,6 +4149,7 @@ DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas" DIRS="$DIRS roms/seabios roms/vgabios" DIRS="$DIRS qapi-generated" DIRS="$DIRS libcacard libcacard/libcacard libcacard/trace" +DIRS="$DIRS pixman" FILES="Makefile tests/tcg/Makefile qdict-test-data.txt" FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit" FILES="$FILES tests/tcg/lm32/Makefile libcacard/Makefile"
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH 03/14] pixman: windup in configure & makefiles
Il 17/10/2012 15:29, Gerd Hoffmann ha scritto:
Quoted 39 lines
Signed-off-by Gerd Hoffmann <[email protected]>--- Makefile | 9 +++++++++ configure | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 0 deletions(-)Makefile +9
-0@@ -105,6 +105,15 @@ endif subdir-libcacard: $(oslib-obj-y) $(trace-obj-y) qemu-timer-common.o +subdir-pixman: pixman/Makefile + $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C pixman V="$(V)" all,) + +pixman/Makefile: $(SRC_PATH)/pixman/configure + (cd pixman; $(SRC_PATH)/pixman/configure --disable-shared --enable-static) + +$(SRC_PATH)/pixman/configure: + (cd $(SRC_PATH)/pixman; autoreconf -v --install) + $(filter %-softmmu,$(SUBDIR_RULES)): $(universal-obj-y) $(trace-obj-y) $(common-obj-y) $(extra-obj-y) subdir-libdis $(filter %-user,$(SUBDIR_RULES)): $(universal-obj-y) $(trace-obj-y) subdir-libdis-user subdir-libuserconfigure +1
-0@@ -147,6 +147,7 @@ curses="" docs="" fdt="" nptl="" +pixman="" sdl="" virtfs="" vnc="yes"
configure for opt do · line 649
Quoted 7 lines
configure +4
-0@@ -642,6 +643,10 @@ for opt do # configure to be used by RPM and similar macros that set # lots of directory switches by default. ;; + --pixman-system) pixman="system" + ;; + --pixman-internal) pixman="internal" + ;;
Let's make this more autoconfy:
--with-system-pixman/--without-system-pixman.
Paolo
Quoted 65 lines
configure +33
-0--disable-sdl) sdl="no" ;; --enable-sdl) sdl="yes"@@ -2117,6 +2122,34 @@ else fi ########################################## +# pixman support probe + +if test "$pixman" = ""; then + if $pkg_config pixman-1 > /dev/null 2>&1; then + pixman="system" + else + pixman="internal" + fi +fi +if test "$pixman" = "system"; then + pixman_cflags=`$pkg_config --cflags pixman-1 2>/dev/null` + pixman_libs=`$pkg_config --libs pixman-1 2>/dev/null` +else + if test ! -d ${source_path}/pixman/pixman; then + echo "ERROR: pixman not present. Your options:" + echo " (1) Prefered: Install the pixman devel package (any recent" + echo " distro should have packages as Xorg needs pixman too)." + echo " (2) Fetch the pixman submodule, using:" + echo " git submodule update --init pixman" + exit 1 + fi + pixman_cflags="-I${source_path}/pixman/pixman" + pixman_libs="-Lpixman/pixman/.libs -lpixman-1" +fi +QEMU_CFLAGS="$QEMU_CFLAGS $pixman_cflags" +libs_softmmu="$libs_softmmu $pixman_libs" + +########################################## # libcap probe if test "$cap" != "no" ; then@@ -3147,6 +3180,7 @@ echo "-Werror enabled $werror" if test "$darwin" = "yes" ; then echo "Cocoa support $cocoa" fi +echo "pixman $pixman" echo "SDL support $sdl" echo "curses support $curses" echo "curl support $curl"@@ -3909,6 +3943,9 @@ if test "$target_softmmu" = "yes" ; then if test "$smartcard_nss" = "yes" ; then echo "subdir-$target: subdir-libcacard" >> $config_host_mak fi + if test "$pixman" = "internal" ; then + echo "subdir-$target: subdir-pixman" >> $config_host_mak + fi case "$target_arch2" in i386|x86_64) echo "CONFIG_HAVE_CORE_DUMP=y" >> $config_target_mak@@ -4112,6 +4149,7 @@ DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas" DIRS="$DIRS roms/seabios roms/vgabios" DIRS="$DIRS qapi-generated" DIRS="$DIRS libcacard libcacard/libcacard libcacard/trace" +DIRS="$DIRS pixman" FILES="Makefile tests/tcg/Makefile qdict-test-data.txt" FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit" FILES="$FILES tests/tcg/lm32/Makefile libcacard/Makefile"
Re: [Qemu-devel] [PATCH 03/14] pixman: windup in configure & makefiles
In reply to Gerd HoffmannI have just noticed that we haven't actually written anywhere what's the oldest version of pixman we support.
Do you know which one it is?
Quoted 114 lines · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>--- Makefile | 9 +++++++++ configure | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 0 deletions(-)Makefile +9
-0@@ -105,6 +105,15 @@ endif subdir-libcacard: $(oslib-obj-y) $(trace-obj-y) qemu-timer-common.o +subdir-pixman: pixman/Makefile + $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C pixman V="$(V)" all,) + +pixman/Makefile: $(SRC_PATH)/pixman/configure + (cd pixman; $(SRC_PATH)/pixman/configure --disable-shared --enable-static) + +$(SRC_PATH)/pixman/configure: + (cd $(SRC_PATH)/pixman; autoreconf -v --install) + $(filter %-softmmu,$(SUBDIR_RULES)): $(universal-obj-y) $(trace-obj-y) $(common-obj-y) $(extra-obj-y) subdir-libdis $(filter %-user,$(SUBDIR_RULES)): $(universal-obj-y) $(trace-obj-y) subdir-libdis-user subdir-libuserconfigure +38
-0@@ -147,6 +147,7 @@ curses="" docs="" fdt="" nptl="" +pixman="" sdl="" virtfs="" vnc="yes"@@ -642,6 +643,10 @@ for opt do # configure to be used by RPM and similar macros that set # lots of directory switches by default. ;; + --pixman-system) pixman="system" + ;; + --pixman-internal) pixman="internal" + ;; --disable-sdl) sdl="no" ;; --enable-sdl) sdl="yes"@@ -2117,6 +2122,34 @@ else fi ########################################## +# pixman support probe + +if test "$pixman" = ""; then + if $pkg_config pixman-1 > /dev/null 2>&1; then + pixman="system" + else + pixman="internal" + fi +fi +if test "$pixman" = "system"; then + pixman_cflags=`$pkg_config --cflags pixman-1 2>/dev/null` + pixman_libs=`$pkg_config --libs pixman-1 2>/dev/null` +else + if test ! -d ${source_path}/pixman/pixman; then + echo "ERROR: pixman not present. Your options:" + echo " (1) Prefered: Install the pixman devel package (any recent" + echo " distro should have packages as Xorg needs pixman too)." + echo " (2) Fetch the pixman submodule, using:" + echo " git submodule update --init pixman" + exit 1 + fi + pixman_cflags="-I${source_path}/pixman/pixman" + pixman_libs="-Lpixman/pixman/.libs -lpixman-1" +fi +QEMU_CFLAGS="$QEMU_CFLAGS $pixman_cflags" +libs_softmmu="$libs_softmmu $pixman_libs" + +########################################## # libcap probe if test "$cap" != "no" ; then@@ -3147,6 +3180,7 @@ echo "-Werror enabled $werror" if test "$darwin" = "yes" ; then echo "Cocoa support $cocoa" fi +echo "pixman $pixman" echo "SDL support $sdl" echo "curses support $curses" echo "curl support $curl"@@ -3909,6 +3943,9 @@ if test "$target_softmmu" = "yes" ; then if test "$smartcard_nss" = "yes" ; then echo "subdir-$target: subdir-libcacard" >> $config_host_mak fi + if test "$pixman" = "internal" ; then + echo "subdir-$target: subdir-pixman" >> $config_host_mak + fi case "$target_arch2" in i386|x86_64) echo "CONFIG_HAVE_CORE_DUMP=y" >> $config_target_mak@@ -4112,6 +4149,7 @@ DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas" DIRS="$DIRS roms/seabios roms/vgabios" DIRS="$DIRS qapi-generated" DIRS="$DIRS libcacard libcacard/libcacard libcacard/trace" +DIRS="$DIRS pixman" FILES="Makefile tests/tcg/Makefile qdict-test-data.txt" FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit" FILES="$FILES tests/tcg/lm32/Makefile libcacard/Makefile"Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH 03/14] pixman: windup in configure & makefiles
Quoted 4 lines · Stefano Stabellini
I have just noticed that we haven't actually written anywhere what's the oldest version of pixman we support.
Do you know which one it is?
0.18.4 is known good.
cheers,
Gerd
PATCH 4/14 pixman: helper functions
In reply to Gerd HoffmannAdd some helper functions which will be put into use by following patches.
--- Makefile.objs | 1 + qemu-pixman.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ qemu-pixman.h | 32 ++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 0 deletions(-) create mode 100644 qemu-pixman.c create mode 100644 qemu-pixman.h
Makefile.objs +1 -0
@@ -64,6 +64,7 @@ common-obj-y = $(block-obj-y) blockdev.o block/ common-obj-y += net.o net/ common-obj-y += qom/ common-obj-y += readline.o console.o cursor.o +common-obj-y += qemu-pixman.o common-obj-y += $(oslib-obj-y) common-obj-$(CONFIG_WIN32) += os-win32.o common-obj-$(CONFIG_POSIX) += os-posix.o
qemu-pixman.c new file +60 -0
60 lines not on this page · raw message
qemu-pixman.h new file +32 -0
@@ -0,0 +1,32 @@ +#ifndef QEMU_PIXMAN_H +#define QEMU_PIXMAN_H + +#include <pixman.h> + +#include "console.h" + +/* +* pixman image formats are defined to be native endian, +* that means host byte order on qemu. So we go define +* fixed formats here for cases where it is needed, like +* feeding libjpeg / libpng and writing screenshots. +*/ + +#ifdef HOST_WORDS_BIGENDIAN +# define PIXMAN_BE_r8g8b8 PIXMAN_r8g8b8 +#else +# define PIXMAN_BE_r8g8b8 PIXMAN_b8g8r8 +#endif + +/* -------------------------------------------------------------------- */ + +int qemu_pixman_get_type (int rshift,int gshift,int bshift); +pixman_format_code_t qemu_pixman_get_format (PixelFormat *pf); + +pixman_image_t *qemu_pixman_linebuf_create (pixman_format_code_t format, +int width); +void qemu_pixman_linebuf_fill (pixman_image_t *linebuf,pixman_image_t *fb, +int width,int y); +void qemu_pixman_image_unref (pixman_image_t *image); + +#endif /* QEMU_PIXMAN_H */
Signature · 1 line
1.7.1
PATCH 5/14 pixman: add pixman image to DisplaySurface
In reply to Gerd HoffmannSurfaces are now allocated using pixman. DisplaySurface gets new struct fields with pixman image and data. DisplayChangeListeners can easily start using pixman now.
--- console.c | 37 ++++++++++++++++++++++++------------- console.h | 3 +++ 2 files changed, 27 insertions(+), 13 deletions(-)
console.c +24 -13
@@ -1319,18 +1319,23 @@ DisplaySurface *qemu_resize_displaysurface(DisplayState *ds,void qemu_alloc_display (DisplaySurface *surface,int width,int height,int linesize,PixelFormat pf,int newflags) { -void *data; surface->width = width; surface->height = height; surface->linesize = linesize; surface->pf = pf; -if (surface->flags &QEMU_ALLOCATED_FLAG ) { - data =g_realloc (surface->data, - surface->linesize * surface->height); - }else { - data =g_malloc (surface->linesize * surface->height); - } - surface->data = (uint8_t *)data; + +qemu_pixman_image_unref (surface->image); + surface->image =NULL ; + surface->data =NULL ; + + surface->format =qemu_pixman_get_format (&pf); +assert (surface->format !=0 ); + surface->image =pixman_image_create_bits (surface->format, + width, height, +NULL , linesize); +assert (surface->image !=NULL ); + + surface->data = (uint8_t *)pixman_image_get_data (surface->image); surface->flags = newflags |QEMU_ALLOCATED_FLAG ;#ifdef HOST_WORDS_BIGENDIAN surface->flags |=QEMU_BIG_ENDIAN_FLAG ;
@@ -1338,14 +1343,22 @@ void qemu_alloc_display(DisplaySurface *surface, int width, int height, }DisplaySurface *qemu_create_displaysurface_from (int width,int height,int bpp, -int linesize,uint8_t *data) +int linesize,uint8_t *data) { -DisplaySurface *surface = (DisplaySurface *)g_malloc0 (sizeof (DisplaySurface)); +DisplaySurface *surface =g_new0 (DisplaySurface,1 ); surface->width = width; surface->height = height; surface->linesize = linesize; surface->pf =qemu_default_pixelformat (bpp); + + surface->format =qemu_pixman_get_format (&surface->pf); +assert (surface->format !=0 ); + surface->image =pixman_image_create_bits (surface->format, + width, height, + (void *)data, linesize); +assert (surface->image !=NULL ); +#ifdef HOST_WORDS_BIGENDIAN surface->flags =QEMU_BIG_ENDIAN_FLAG ;#endif
@@ -1360,9 +1373,7 @@ void qemu_free_displaysurface(DisplayState *ds)if (ds->surface ==NULL ) {return ; } -if (ds->surface->flags &QEMU_ALLOCATED_FLAG ) { -g_free (ds->surface->data); - } +qemu_pixman_image_unref (ds->surface->image);g_free (ds->surface); }
console.h +3 -0
@@ -2,6 +2,7 @@#define CONSOLE_H #include "qemu-char.h" +#include "qemu-pixman.h" #include "qdict.h" #include "notify.h" #include "monitor.h"
@@ -119,6 +120,8 @@ struct PixelFormat { };struct DisplaySurface { +pixman_format_code_t format; +pixman_image_t *image;uint8_t flags;int width;int height;
Signature · 1 line
1.7.1
PATCH 6/14 console: make qemu_alloc_display static
In reply to Gerd Hoffmann--- console.c | 48 ++++++++++++++++++++++++------------------------ console.h | 2 -- 2 files changed, 24 insertions(+), 26 deletions(-)
console.c +24 -24
@@ -1294,30 +1294,8 @@ static QemuConsole *new_console(DisplayState *ds, console_type_t console_type)return s; } -DisplaySurface *qemu_create_displaysurface (DisplayState *ds, -int width,int height) -{ -DisplaySurface *surface =g_new0 (DisplaySurface,1 ); - -int linesize = width *4 ; -qemu_alloc_display (surface, width, height, linesize, -qemu_default_pixelformat (32 ),0 ); -return surface; -} - -DisplaySurface *qemu_resize_displaysurface (DisplayState *ds, -int width,int height) -{ -int linesize = width *4 ; - -trace_displaysurface_resize (ds, ds->surface, width, height); -qemu_alloc_display (ds->surface, width, height, linesize, -qemu_default_pixelformat (32 ),0 ); -return ds->surface; -} - -void qemu_alloc_display (DisplaySurface *surface,int width,int height, -int linesize,PixelFormat pf,int newflags) +static void qemu_alloc_display (DisplaySurface *surface,int width,int height, +int linesize,PixelFormat pf,int newflags) { surface->width = width; surface->height = height;
@@ -1342,6 +1320,28 @@ void qemu_alloc_display(DisplaySurface *surface, int width, int height,#endif } +DisplaySurface *qemu_create_displaysurface (DisplayState *ds, +int width,int height) +{ +DisplaySurface *surface =g_new0 (DisplaySurface,1 ); + +int linesize = width *4 ; +qemu_alloc_display (surface, width, height, linesize, +qemu_default_pixelformat (32 ),0 ); +return surface; +} + +DisplaySurface *qemu_resize_displaysurface (DisplayState *ds, +int width,int height) +{ +int linesize = width *4 ; + +trace_displaysurface_resize (ds, ds->surface, width, height); +qemu_alloc_display (ds->surface, width, height, linesize, +qemu_default_pixelformat (32 ),0 ); +return ds->surface; +} +DisplaySurface *qemu_create_displaysurface_from (int width,int height,int bpp,int linesize,uint8_t *data) {
console.h +0 -2
@@ -190,8 +190,6 @@ void register_displaystate(DisplayState *ds);DisplayState *get_displaystate (void );DisplaySurface *qemu_create_displaysurface_from (int width,int height,int bpp,int linesize,uint8_t *data); -void qemu_alloc_display (DisplaySurface *surface,int width,int height, -int linesize,PixelFormat pf,int newflags);PixelFormat qemu_different_endianness_pixelformat (int bpp);PixelFormat qemu_default_pixelformat (int bpp);
Signature · 1 line
1.7.1
PATCH 7/14 console: don't set PixelFormat alpha fields for 32bpp
In reply to Gerd HoffmannCurrently it is inconstent, PixelFormat->amask is left unset whereas abits and amax and ashift are filled. As an alpha channel doesn't make sense for the vga framebuffer leave all alpha fields clear.
--- console.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
console.c +0 -3
@@ -1715,18 +1715,15 @@ PixelFormat qemu_default_pixelformat(int bpp) pf.rmask =0x00FF0000 ; pf.gmask =0x0000FF00 ; pf.bmask =0x000000FF ; - pf.amax =255 ; pf.rmax =255 ; pf.gmax =255 ; pf.bmax =255 ; - pf.ashift =24 ; pf.rshift =16 ; pf.gshift =8 ; pf.bshift =0 ; pf.rbits =8 ; pf.gbits =8 ; pf.bbits =8 ; - pf.abits =8 ;break ;default :break ;
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH 07/14] console: don't set PixelFormat alpha fields for 32bpp
Quoted 5 lines · Gerd Hoffmann
Currently it is inconstent,
PixelFormat->amaskis left unset whereas abits and amax and ashift are filled. As an alpha channel doesn't make sense for the vga framebuffer leave all alpha fields clear.Signed-off-by Gerd Hoffmann <[email protected]>
Actually the alpha mask was left to 0 on purpose to ignore it. At the same time we set amax, ashift and abits to signal the presence of an alpha byte in the pixel format.
Quoted 30 lines
console.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)console.c +0
-3@@ -1715,18 +1715,15 @@ PixelFormat qemu_default_pixelformat(int bpp) pf.rmask =0x00FF0000 ; pf.gmask =0x0000FF00 ; pf.bmask =0x000000FF ; - pf.amax =255 ; pf.rmax =255 ; pf.gmax =255 ; pf.bmax =255 ; - pf.ashift =24 ; pf.rshift =16 ; pf.gshift =8 ; pf.bshift =0 ; pf.rbits =8 ; pf.gbits =8 ; pf.bbits =8 ; - pf.abits =8 ;break ;default :break ;Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH 07/14] console: don't set PixelFormat alpha fields for 32bpp
Quoted 10 lines · Stefano Stabellini
Quoted 5 lines · Gerd Hoffmann
Currently it is inconstent,
PixelFormat->amaskis left unset whereas abits and amax and ashift are filled. As an alpha channel doesn't make sense for the vga framebuffer leave all alpha fields clear.Signed-off-by Gerd Hoffmann <[email protected]>Actually the alpha mask was left to 0 on purpose to ignore it. At the same time we set amax, ashift and abits to signal the presence of an alpha byte in the pixel format.
Hmm? I still don't see t he point of the current mix. Either the byte is alpha or it is unused ...
cheers,
Gerd
PATCH 8/14 qxl: stop direct access to DisplaySurface fields.
In reply to Gerd Hoffmann--- hw/qxl-render.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/qxl-render.c +1 -1
@@ -24,7 +24,7 @@static void qxl_blit (PCIQXLDevice *qxl,QXLRect *rect) {uint8_t *src; -uint8_t *dst = qxl->vga.ds->surface->data; +uint8_t *dst =ds_get_data (qxl->vga.ds);int len, i;if (is_buffer_shared (qxl->vga.ds->surface)) {
Signature · 1 line
1.7.1
PATCH 9/14 vga: stop direct access to DisplaySurface fields.
In reply to Gerd Hoffmann--- hw/vga.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
hw/vga.c +7 -2
@@ -1718,8 +1718,13 @@ static void vga_draw_graphic(VGACommonState *s, int full_update) s->last_depth = depth; full_update =1 ; }else if (is_buffer_shared (s->ds->surface) && - (full_update || s->ds->surface->data != s->vram_ptr + (s->start_addr *4 ))) { - s->ds->surface->data = s->vram_ptr + (s->start_addr *4 ); + (full_update ||ds_get_data (s->ds) != s->vram_ptr + + (s->start_addr *4 ))) { +qemu_free_displaysurface (s->ds); + s->ds->surface =qemu_create_displaysurface_from (disp_width, + height, depth, + s->line_offset, + s->vram_ptr + (s->start_addr *4 ));dpy_gfx_setdata (s->ds); }
Signature · 1 line
1.7.1
PATCH 10/14 pixman: switch screendump function.
In reply to Gerd Hoffmann--- hw/vga.c | 39 +++++++++++---------------------------- 1 files changed, 11 insertions(+), 28 deletions(-)
hw/vga.c +11 -28
@@ -2417,13 +2417,12 @@ void vga_init_vbe(VGACommonState *s, MemoryRegion *system_memory)void ppm_save (const char *filename,struct DisplaySurface *ds,Error **errp) { +int width =pixman_image_get_width (ds->image); +int height =pixman_image_get_height (ds->image);FILE *f; -uint8_t *d, *d1; -uint32_t v; -int y, x; -uint8_t r, g, b; +int y;int ret; -char *linebuf, *pbuf; +pixman_image_t *linebuf;trace_ppm_save (filename, ds); f =fopen (filename,"wb" );
@@ -2432,33 +2431,17 @@ void ppm_save(const char *filename, struct DisplaySurface *ds, Error **errp) strerror(errno));return ; } - ret =fprintf (f,"P6\n%d %d\n%d\n" , ds->width, ds->height,255 ); + ret =fprintf (f,"P6\n%d %d\n%d\n" , width, height,255 );if (ret <0 ) { linebuf =NULL ; goto write_err; } - linebuf =g_malloc (ds->width *3 ); - d1 = ds->data; -for (y =0 ; y < ds->height; y++) { - d = d1; - pbuf = linebuf; -for (x =0 ; x < ds->width; x++) { -if (ds->pf.bits_per_pixel ==32 ) - v = *(uint32_t *)d; -else - v = (uint32_t ) (*(uint16_t *)d); -/* Limited to 8 or fewer bits per channel: */ - r = ((v >> ds->pf.rshift) & ds->pf.rmax) << (8 - ds->pf.rbits); - g = ((v >> ds->pf.gshift) & ds->pf.gmax) << (8 - ds->pf.gbits); - b = ((v >> ds->pf.bshift) & ds->pf.bmax) << (8 - ds->pf.bbits); - *pbuf++ = r; - *pbuf++ = g; - *pbuf++ = b; - d += ds->pf.bytes_per_pixel; - } - d1 += ds->linesize; + linebuf =qemu_pixman_linebuf_create (PIXMAN_BE_r8g8b8, width); +for (y =0 ; y < height; y++) { +qemu_pixman_linebuf_fill (linebuf, ds->image, width, y);clearerr (f); - ret =fwrite (linebuf,1 , pbuf - linebuf, f); + ret =fwrite (pixman_image_get_data (linebuf),1 , +pixman_image_get_stride (linebuf), f); (void )ret;if (ferror (f)) { goto write_err;
@@ -2466,7 +2449,7 @@ void ppm_save(const char *filename, struct DisplaySurface *ds, Error **errp) } out: -g_free (linebuf); +qemu_pixman_image_unref (linebuf);fclose (f);return ;
Signature · 1 line
1.7.1
PATCH 11/14 pixman/vnc: use pixman images in vnc.
In reply to Gerd HoffmannThe vnc code uses *three* DisplaySurfaces:
First is the surface of the actual QemuConsole, usually the guest screen, but could also be a text console (monitor/serial reachable via Ctrl-Alt-<nr> keys). This is left as-is.
Second is the current server's view of the screen content. The vnc code uses this to figure which parts of the guest screen did _really_ change to reduce the amount of updates sent to the vnc clients. It is also used as data source when sending out the updates to the clients. This surface gets replaced by a pixman image. The format changes too, instead of using the guest screen format we'll use fixed 32bit rgb framebuffer and convert the pixels on the fly when comparing and updating the server framebuffer.
Third surface carries the format expected by the vnc client. That isn't used to store image data. This surface is switched to PixelFormat and a boolean for bigendian byte order.
--- ui/vnc-enc-hextile-template.h | 23 ++-- ui/vnc-enc-hextile.c | 45 ++++---- ui/vnc-enc-tight.c | 144 ++++++++++++------------- ui/vnc-enc-zrle.c | 18 ++-- ui/vnc-jobs.c | 3 +- ui/vnc.c | 235 +++++++++++++++++++++++------------------ ui/vnc.h | 19 +++- 7 files changed, 259 insertions(+), 228 deletions(-)
ui/vnc-enc-hextile-template.h +11 -12
@@ -14,7 +14,7 @@ static void CONCAT(send_hextile_tile_, NAME)(VncState *vs, int *has_bg, int *has_fg) { VncDisplay *vd = vs->vd; -uint8_t *row = vd->server->data + y *ds_get_linesize (vs->ds) + x *ds_get_bytes_per_pixel (vs->ds); +uint8_t *row =vnc_server_fb_ptr (vd, x, y);pixel_t *irow = (pixel_t *)row;int j, i;pixel_t *last_bg = (pixel_t *)last_bg_;
@@ -25,7 +25,7 @@ static void CONCAT(send_hextile_tile_, NAME)(VncState *vs,int bg_count =0 ;int fg_count =0 ;int flags =0 ; -uint8_t data[(vs->clientds.pf.bytes_per_pixel +2 ) *16 *16 ]; +uint8_t data[(vs->client_pf.bytes_per_pixel +2 ) *16 *16 ];int n_data =0 ;int n_subtiles =0 ;
@@ -58,7 +58,7 @@ static void CONCAT(send_hextile_tile_, NAME)(VncState *vs, }if (n_colors >2 )break ; - irow +=ds_get_linesize (vs->ds) /sizeof (pixel_t); + irow +=vnc_server_fb_stride (vd) /sizeof (pixel_t); }if (n_colors >1 && fg_count > bg_count) {
@@ -106,7 +106,7 @@ static void CONCAT(send_hextile_tile_, NAME)(VncState *vs, n_data +=2 ; n_subtiles++; } - irow +=ds_get_linesize (vs->ds) /sizeof (pixel_t); + irow +=vnc_server_fb_stride (vd) /sizeof (pixel_t); }break ;case 3 :
@@ -133,7 +133,7 @@ static void CONCAT(send_hextile_tile_, NAME)(VncState *vs, has_color =0 ;#ifdef GENERIC vnc_convert_pixel (vs, data + n_data, color); - n_data += vs->clientds.pf.bytes_per_pixel; + n_data += vs->client_pf.bytes_per_pixel;#else memcpy (data + n_data, &color,sizeof (color)); n_data +=sizeof (pixel_t);
@@ -153,7 +153,7 @@ static void CONCAT(send_hextile_tile_, NAME)(VncState *vs,if (has_color) {#ifdef GENERIC vnc_convert_pixel (vs, data + n_data, color); - n_data += vs->clientds.pf.bytes_per_pixel; + n_data += vs->client_pf.bytes_per_pixel;#else memcpy (data + n_data, &color,sizeof (color)); n_data +=sizeof (pixel_t);
@@ -162,7 +162,7 @@ static void CONCAT(send_hextile_tile_, NAME)(VncState *vs, n_data +=2 ; n_subtiles++; } - irow +=ds_get_linesize (vs->ds) /sizeof (pixel_t); + irow +=vnc_server_fb_stride (vd) /sizeof (pixel_t); }/* A SubrectsColoured subtile invalidates the foreground color */
@@ -190,18 +190,17 @@ static void CONCAT(send_hextile_tile_, NAME)(VncState *vs,vnc_write_u8 (vs, flags);if (n_colors <4 ) {if (flags &0x02 ) - vs->write_pixels (vs, &vd->server->pf, last_bg,sizeof (pixel_t)); + vs->write_pixels (vs, last_bg,sizeof (pixel_t));if (flags &0x04 ) - vs->write_pixels (vs, &vd->server->pf, last_fg,sizeof (pixel_t)); + vs->write_pixels (vs, last_fg,sizeof (pixel_t));if (n_subtiles) {vnc_write_u8 (vs, n_subtiles);vnc_write (vs, data, n_data); } }else {for (j =0 ; j < h; j++) { - vs->write_pixels (vs, &vd->server->pf, row, - w *ds_get_bytes_per_pixel (vs->ds)); - row +=ds_get_linesize (vs->ds); + vs->write_pixels (vs, row, w *4 ); + row +=vnc_server_fb_stride (vd); } } }
ui/vnc-enc-hextile.c +22 -23
60 lines not on this page · raw message
ui/vnc-enc-tight.c +68 -76
311 lines not on this page · raw message
ui/vnc-enc-zrle.c +9 -9
@@ -255,7 +255,7 @@ static void zrle_write_u8(VncState *vs, uint8_t value)static int zrle_send_framebuffer_update (VncState *vs,int x,int y,int w,int h) { -bool be = !!(vs->clientds.flags &QEMU_BIG_ENDIAN_FLAG ); +bool be = vs->client_be;size_t bytes;int zywrle_level;
@@ -277,13 +277,13 @@ static int zrle_send_framebuffer_update(VncState *vs, int x, int y,vnc_zrle_start (vs); -switch (vs->clientds.pf.bytes_per_pixel) { +switch (vs->client_pf.bytes_per_pixel) {case 1 :zrle_encode_8ne (vs, x, y, w, h, zywrle_level);break ;case 2 : -if (vs->clientds.pf.gmax >0x1F ) { +if (vs->client_pf.gmax >0x1F ) {if (be) {zrle_encode_16be (vs, x, y, w, h, zywrle_level); }else {
@@ -304,13 +304,13 @@ static int zrle_send_framebuffer_update(VncState *vs, int x, int y,bool fits_in_ms3bytes; fits_in_ls3bytes = - ((vs->clientds.pf.rmax << vs->clientds.pf.rshift) < (1 <<24 ) && - (vs->clientds.pf.gmax << vs->clientds.pf.gshift) < (1 <<24 ) && - (vs->clientds.pf.bmax << vs->clientds.pf.bshift) < (1 <<24 )); + ((vs->client_pf.rmax << vs->client_pf.rshift) < (1 <<24 ) && + (vs->client_pf.gmax << vs->client_pf.gshift) < (1 <<24 ) && + (vs->client_pf.bmax << vs->client_pf.bshift) < (1 <<24 )); - fits_in_ms3bytes = (vs->clientds.pf.rshift >7 && - vs->clientds.pf.gshift >7 && - vs->clientds.pf.bshift >7 ); + fits_in_ms3bytes = (vs->client_pf.rshift >7 && + vs->client_pf.gshift >7 && + vs->client_pf.bshift >7 );if ((fits_in_ls3bytes && !be) || (fits_in_ms3bytes && be)) {if (be) {
ui/vnc-jobs.c +2 -1
@@ -187,7 +187,8 @@ static void vnc_async_encoding_start(VncState *orig, VncState *local) local->vd = orig->vd; local->lossy_rect = orig->lossy_rect; local->write_pixels = orig->write_pixels; - local->clientds = orig->clientds; + local->client_pf = orig->client_pf; + local->client_be = orig->client_be; local->tight = orig->tight; local->zlib = orig->zlib; local->hextile = orig->hextile;
ui/vnc.c +132 -103
443 lines not on this page · raw message
ui/vnc.h +15 -4
@@ -69,7 +69,7 @@ typedef struct VncRectEntry VncRectEntry;typedef int VncReadEvent (VncState *vs,uint8_t *data,size_t len); -typedef void VncWritePixels (VncState *vs,struct PixelFormat *pf,void *data,int size); +typedef void VncWritePixels (VncState *vs,void *data,int size); typedef void VncSendHextileTile(VncState *vs, int x, int y, int w, int h,
@@ -117,7 +117,8 @@ struct VncSurfacestruct timeval last_freq_check;DECLARE_BITMAP (dirty[VNC_MAX_HEIGHT ],VNC_MAX_WIDTH /16 );VncRectStat stats[VNC_STAT_ROWS ][VNC_STAT_COLS ]; -DisplaySurface *ds; +pixman_image_t *fb; +pixman_format_code_t format; }; typedef enum VncShareMode {
@@ -151,7 +152,7 @@ struct VncDisplayuint8_t *cursor_mask;struct VncSurface guest;/* guest visible surface (aka ds->surface) */ -DisplaySurface *server;/* vnc server surface */ +pixman_image_t *server;/* vnc server surface */ char *display;char *password;
@@ -275,7 +276,9 @@ struct VncStateBuffer input;/* current output mode information */ VncWritePixels *write_pixels; -DisplaySurface clientds; +PixelFormat client_pf; +pixman_format_code_t client_format; +bool client_be;CaptureVoiceOut *audio_cap;struct audsettings as;
@@ -527,6 +530,14 @@ static inline uint32_t vnc_has_feature(VncState *vs, int feature) {void vnc_framebuffer_update (VncState *vs,int x,int y,int w,int h,int32_t encoding); +/* server fb is in PIXMAN_x8r8g8b8 */ +#define VNC_SERVER_FB_FORMAT PIXMAN_FORMAT(32, PIXMAN_TYPE_ARGB, 0, 8, 8, 8) +#define VNC_SERVER_FB_BITS (PIXMAN_FORMAT_BPP(VNC_SERVER_FB_FORMAT)) +#define VNC_SERVER_FB_BYTES ((VNC_SERVER_FB_BITS+7)/8) + +void *vnc_server_fb_ptr (VncDisplay *vd,int x,int y); +int vnc_server_fb_stride (VncDisplay *vd); +void vnc_convert_pixel (VncState *vs,uint8_t *buf,uint32_t v);double vnc_update_freq (VncState *vs,int x,int y,int w,int h);void vnc_sent_lossy_rect (VncState *vs,int x,int y,int w,int h);
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH 11/14] pixman/vnc: use pixman images in vnc.
Quoted 6 lines · Gerd Hoffmann
The vnc code uses *three* DisplaySurfaces:
First is the surface of the actual QemuConsole, usually the guest screen, but could also be a text console (monitor/serial reachable via Ctrl-Alt-<nr> keys). This is left as-is.
Quoted 8 lines
Second is the current server's view of the screen content. The vnc code uses this to figure which parts of the guest screen did _really_ change to reduce the amount of updates sent to the vnc clients. It is also used as data source when sending out the updates to the clients. This surface gets replaced by a pixman image. The format changes too, instead of using the guest screen format we'll use fixed 32bit rgb framebuffer and convert the pixels on the fly when comparing and updating the server framebuffer.
Is this really a good idea?
It is very common for a vnc client to ask for 16 or 8 bpp on slow connections.
Re: [Qemu-devel] [PATCH 11/14] pixman/vnc: use pixman images in vnc.
Quoted 16 lines · Stefano Stabellini
Quoted 6 lines · Gerd Hoffmann
The vnc code uses *three* DisplaySurfaces:
First is the surface of the actual QemuConsole, usually the guest screen, but could also be a text console (monitor/serial reachable via Ctrl-Alt-<nr> keys). This is left as-is.
Quoted 8 lines
Second is the current server's view of the screen content. The vnc code uses this to figure which parts of the guest screen did _really_ change to reduce the amount of updates sent to the vnc clients. It is also used as data source when sending out the updates to the clients. This surface gets replaced by a pixman image. The format changes too, instead of using the guest screen format we'll use fixed 32bit rgb framebuffer and convert the pixels on the fly when comparing and updating the server framebuffer.
Quoted 3 lines
Is this really a good idea?
It is very common for a vnc client to ask for 16 or 8 bpp on slow connections.
The 16bpp modes (guest video modes) are slowly dying, so I think it is best to operate at 32bpp internally. First because we don't need to convert when reading the guest framebuffer. Second the format is easy to deal with.
When sending out the data to the client we might have to convert, but that isn't new.
cheers,
Gerd
PATCH 12/14 pixman/vnc: remove rgb_prepare_row* functions
In reply to Gerd HoffmannLet pixman do it instead.
--- ui/vnc-enc-tight.c | 84 ++++++--------------------------------------------- 1 files changed, 10 insertions(+), 74 deletions(-)
ui/vnc-enc-tight.c +10 -74
@@ -1145,74 +1145,6 @@ static int send_palette_rect(VncState *vs, int x, int y,return (bytes >=0 ); } -#if defined(CONFIG_VNC_JPEG ) || defined(CONFIG_VNC_PNG ) -static void rgb_prepare_row24 (VncState *vs,uint8_t *dst,int x,int y, -int count) -{ -VncDisplay *vd = vs->vd; -uint32_t *fbptr; -uint32_t pix; - - fbptr =vnc_server_fb_ptr (vd, x, y); - -while (count--) { - pix = *fbptr++; - *dst++ = (uint8_t )(pix >> vs->ds->surface->pf.rshift); - *dst++ = (uint8_t )(pix >> vs->ds->surface->pf.gshift); - *dst++ = (uint8_t )(pix >> vs->ds->surface->pf.bshift); - } -} - -#define DEFINE_RGB_GET_ROW_FUNCTION (bpp) \ - \ - static void \ - rgb_prepare_row##bpp(VncState *vs, uint8_t *dst, \ - int x, int y, int count) \ - { \ - VncDisplay *vd = vs->vd; \ - uint##bpp##_t *fbptr; \ - uint##bpp##_t pix; \ - int r, g, b; \ - \ - fbptr = vnc_server_fb_ptr(vd, x, y); \ - \ - while (count--) { \ - pix = *fbptr++; \ - \ - r = (int)((pix >> vs->ds->surface->pf.rshift) \ - & vs->ds->surface->pf.rmax); \ - g = (int)((pix >> vs->ds->surface->pf.gshift) \ - & vs->ds->surface->pf.gmax); \ - b = (int)((pix >> vs->ds->surface->pf.bshift) \ - & vs->ds->surface->pf.bmax); \ - \ - *dst++ = (uint8_t)((r * 255 + vs->ds->surface->pf.rmax / 2) \ - / vs->ds->surface->pf.rmax); \ - *dst++ = (uint8_t)((g * 255 + vs->ds->surface->pf.gmax / 2) \ - / vs->ds->surface->pf.gmax); \ - *dst++ = (uint8_t)((b * 255 + vs->ds->surface->pf.bmax / 2) \ - / vs->ds->surface->pf.bmax); \ - } \ - } - -DEFINE_RGB_GET_ROW_FUNCTION(16) -DEFINE_RGB_GET_ROW_FUNCTION(32) - -static void rgb_prepare_row (VncState *vs,uint8_t *dst,int x,int y, -int count) -{ -if (VNC_SERVER_FB_BYTES ==4 ) { -if (1 ) { -rgb_prepare_row24 (vs, dst, x, y, count); - }else { -rgb_prepare_row32 (vs, dst, x, y, count); - } - }else { -rgb_prepare_row16 (vs, dst, x, y, count); - } -} -#endif /* CONFIG_VNC_JPEG or CONFIG_VNC_PNG */ -/* * JPEG compression stuff. */
@@ -1257,6 +1189,7 @@ static int send_jpeg_rect(VncState *vs, int x, int y, int w, int h, int quality)struct jpeg_compress_struct cinfo;struct jpeg_error_mgr jerr;struct jpeg_destination_mgr manager; +pixman_image_t *linebuf;JSAMPROW row[1 ];uint8_t *buf;int dy;
@@ -1285,13 +1218,14 @@ static int send_jpeg_rect(VncState *vs, int x, int y, int w, int h, int quality)jpeg_start_compress (&cinfo, true); - buf =g_malloc (w *3 ); + linebuf =qemu_pixman_linebuf_create (PIXMAN_BE_r8g8b8, w); + buf = (uint8_t *)pixman_image_get_data (linebuf); row[0 ] = buf;for (dy =0 ; dy < h; dy++) { -rgb_prepare_row (vs, buf, x, y + dy, w); +qemu_pixman_linebuf_fill (linebuf, vs->vd->server, w, dy);jpeg_write_scanlines (&cinfo, row,1 ); } -g_free (buf); +qemu_pixman_image_unref (linebuf);jpeg_finish_compress (&cinfo);jpeg_destroy_compress (&cinfo);
@@ -1370,6 +1304,7 @@ static int send_png_rect(VncState *vs, int x, int y, int w, int h,png_structp png_ptr;png_infop info_ptr;png_colorp png_palette =NULL ; +pixman_image_t *linebuf;int level = tight_png_conf[vs->tight.compression].png_zlib_level;int filters = tight_png_conf[vs->tight.compression].png_filters;uint8_t *buf;
@@ -1424,17 +1359,18 @@ static int send_png_rect(VncState *vs, int x, int y, int w, int h,png_write_info (png_ptr, info_ptr);buffer_reserve (&vs->tight.png,2048 ); - buf =g_malloc (w *3 ); + linebuf =qemu_pixman_linebuf_create (PIXMAN_BE_r8g8b8, w); + buf = (uint8_t *)pixman_image_get_data (linebuf);for (dy =0 ; dy < h; dy++) {if (color_type ==PNG_COLOR_TYPE_PALETTE ) {memcpy (buf, vs->tight.tight.buffer + (dy * w), w); }else { -rgb_prepare_row (vs, buf, x, y + dy, w); +qemu_pixman_linebuf_fill (linebuf, vs->vd->server, w, dy); }png_write_row (png_ptr, buf); } -g_free (buf); +qemu_pixman_image_unref (linebuf);png_write_end (png_ptr,NULL );
Signature · 1 line
1.7.1
PATCH 13/14 pixman/vnc: remove dead code.
In reply to Gerd HoffmannSwitching the vnc server framebuffer to use 32bpp unconditionally turns the code bits which handle 8 and 16 bpp into dead code. Remove them.
--- ui/vnc-enc-hextile.c | 32 ------------------------- ui/vnc-enc-tight.c | 64 +++++++++++++++++++++----------------------------- ui/vnc.c | 18 -------------- 3 files changed, 27 insertions(+), 87 deletions(-)
ui/vnc-enc-hextile.c +0 -32
@@ -32,31 +32,11 @@ static void hextile_enc_cord(uint8_t *ptr, int x, int y, int w, int h) ptr[1 ] = (((w -1 ) &0x0F ) <<4 ) | ((h -1 ) &0x0F ); } -#define BPP 8 -#include "vnc-enc-hextile-template.h" -#undef BPP - -#define BPP 16 -#include "vnc-enc-hextile-template.h" -#undef BPP -#define BPP 32#include "vnc-enc-hextile-template.h" #undef BPP#define GENERIC -#define BPP 8 -#include "vnc-enc-hextile-template.h" -#undef BPP -#undef GENERIC - -#define GENERIC -#define BPP 16 -#include "vnc-enc-hextile-template.h" -#undef BPP -#undef GENERIC - -#define GENERIC #define BPP 32#include "vnc-enc-hextile-template.h" #undef BPP
@@ -89,24 +69,12 @@ void vnc_hextile_set_pixel_conversion(VncState *vs, int generic) {if (!generic) {switch (VNC_SERVER_FB_BITS ) { -case 8 : - vs->hextile.send_tile = send_hextile_tile_8; -break ; -case 16 : - vs->hextile.send_tile = send_hextile_tile_16; -break ;case 32 : vs->hextile.send_tile = send_hextile_tile_32;break ; } }else {switch (VNC_SERVER_FB_BITS ) { -case 8 : - vs->hextile.send_tile = send_hextile_tile_generic_8; -break ; -case 16 : - vs->hextile.send_tile = send_hextile_tile_generic_16; -break ;case 32 : vs->hextile.send_tile = send_hextile_tile_generic_32;break ;
ui/vnc-enc-tight.c +27 -37
78 lines not on this page · raw message
ui/vnc.c +0 -18
@@ -666,24 +666,6 @@ static void vnc_write_pixels_generic(VncState *vs,vnc_convert_pixel (vs, buf, pixels[i]);vnc_write (vs, buf, vs->client_pf.bytes_per_pixel); } - }else if (VNC_SERVER_FB_BYTES ==2 ) { -uint16_t *pixels = pixels1; -int n, i; - n = size >>1 ; -for (i =0 ; i < n; i++) { -vnc_convert_pixel (vs, buf, pixels[i]); -vnc_write (vs, buf, vs->client_pf.bytes_per_pixel); - } - }else if (VNC_SERVER_FB_BYTES ==1 ) { -uint8_t *pixels = pixels1; -int n, i; - n = size; -for (i =0 ; i < n; i++) { -vnc_convert_pixel (vs, buf, pixels[i]); -vnc_write (vs, buf, vs->client_pf.bytes_per_pixel); - } - }else { -fprintf (stderr,"%s: VncState color depth not supported\n" , __func__); } }
Signature · 1 line
1.7.1
PATCH 14/14 pixman: drop obsolete fields from DisplaySurface
In reply to Gerd Hoffmann--- console.c | 9 --------- console.h | 23 +++++++++++++---------- 2 files changed, 13 insertions(+), 19 deletions(-)
console.c +0 -9
@@ -1297,14 +1297,10 @@ static QemuConsole *new_console(DisplayState *ds, console_type_t console_type)static void qemu_alloc_display (DisplaySurface *surface,int width,int height,int linesize,PixelFormat pf,int newflags) { - surface->width = width; - surface->height = height; - surface->linesize = linesize; surface->pf = pf;qemu_pixman_image_unref (surface->image); surface->image =NULL ; - surface->data =NULL ; surface->format =qemu_pixman_get_format (&pf);assert (surface->format !=0 );
@@ -1313,7 +1309,6 @@ static void qemu_alloc_display(DisplaySurface *surface, int width, int height, NULL, linesize);assert (surface->image !=NULL ); - surface->data = (uint8_t *)pixman_image_get_data (surface->image); surface->flags = newflags |QEMU_ALLOCATED_FLAG ;#ifdef HOST_WORDS_BIGENDIAN surface->flags |=QEMU_BIG_ENDIAN_FLAG ;
@@ -1347,9 +1342,6 @@ DisplaySurface *qemu_create_displaysurface_from(int width, int height, int bpp, {DisplaySurface *surface =g_new0 (DisplaySurface,1 ); - surface->width = width; - surface->height = height; - surface->linesize = linesize; surface->pf =qemu_default_pixelformat (bpp); surface->format =qemu_pixman_get_format (&surface->pf);
@@ -1362,7 +1354,6 @@ DisplaySurface *qemu_create_displaysurface_from(int width, int height, int bpp,#ifdef HOST_WORDS_BIGENDIAN surface->flags =QEMU_BIG_ENDIAN_FLAG ;#endif - surface->data = data;return surface; }
console.h +13 -10
@@ -123,10 +123,6 @@ struct DisplaySurface {pixman_format_code_t format;pixman_image_t *image;uint8_t flags; -int width; -int height; -int linesize;/* bytes per line */ -uint8_t *data;struct PixelFormat pf; };
@@ -346,32 +342,39 @@ static inline bool dpy_cursor_define_supported(struct DisplayState *s)static inline int ds_get_linesize (DisplayState *ds) { -return ds->surface->linesize; +return pixman_image_get_stride (ds->surface->image); }static inline uint8_t *ds_get_data (DisplayState *ds) { -return ds->surface->data; +return (void *)pixman_image_get_data (ds->surface->image); }static inline int ds_get_width (DisplayState *ds) { -return ds->surface->width; +return pixman_image_get_width (ds->surface->image); }static inline int ds_get_height (DisplayState *ds) { -return ds->surface->height; +return pixman_image_get_height (ds->surface->image); }static inline int ds_get_bits_per_pixel (DisplayState *ds) { -return ds->surface->pf.bits_per_pixel; +int bits =PIXMAN_FORMAT_BPP (ds->surface->format); +return bits; }static inline int ds_get_bytes_per_pixel (DisplayState *ds) { -return ds->surface->pf.bytes_per_pixel; +int bits =PIXMAN_FORMAT_BPP (ds->surface->format); +return (bits +7 ) /8 ; +} + +static inline pixman_format_code_t ds_get_format (DisplayState *ds) +{ +return ds->surface->format; }#ifdef CONFIG_CURSES
Signature · 1 line
1.7.1