qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Gerd Hoffmann" <kraxel@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>
Subject: [Qemu-devel] [PATCH 3/3] sdl: add support for high resolution window icon
Date: Tue, 18 Dec 2018 14:26:29 +0000	[thread overview]
Message-ID: <20181218142629.15943-4-berrange@redhat.com> (raw)
In-Reply-To: <20181218142629.15943-1-berrange@redhat.com>

Modern desktop environments can render icons at very large sizes,
especially with high DPI screens. Providing a 32x32 pixel bitmap is
nowhere near sufficient anymore.

When displayed in GNOME shell the QEMU icon looks awful, having been
scaled up to at least x4 its base size. This is compounded by the fact
that the BMP file doesn't do transparency, so while we've removed white
pixels, we still have anti-aliased nearly-white pixels which make the
logo look appalling on black backgrounds.

Loading a high resolution PNG icon addresses both problems, but requires
use of the extra SDL2_image library.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 configure         | 23 +++++++++++++++++++++++
 include/ui/sdl2.h |  3 +++
 ui/sdl2.c         | 14 ++++++++++----
 3 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index 96c948166c..1ed3643ecb 100755
--- a/configure
+++ b/configure
@@ -346,6 +346,7 @@ fdt=""
 netmap="no"
 sdl=""
 sdlabi=""
+sdl_image=""
 virtfs=""
 mpath=""
 vnc="yes"
@@ -2962,6 +2963,7 @@ sdl_probe ()
       feature_not_found "sdl" "Install SDL2-devel"
     fi
     sdl=no
+    sdl_image=no
     # no need to do the rest
     return
   fi
@@ -2992,6 +2994,21 @@ EOF
       sdl=yes
     fi
 
+    if $pkg_config SDL2_image --exists; then
+	if test "$static" = "yes"; then
+	    sdl_image_libs=$($pkg_config SDL2_image --libs --static 2>/dev/null)
+	else
+	    sdl_image_libs=$($pkg_config SDL2_image --libs 2>/dev/null)
+	fi
+	sdl_image_cflags=$($pkg_config SDL2_image --cflags 2>/dev/null)
+	sdl_image=yes
+
+	sdl_cflags="$sdl_cflags $sdl_image_cflags"
+	sdl_libs="$sdl_libs $sdl_image_libs"
+    else
+	sdl_image=no
+    fi
+
     # static link with sdl ? (note: sdl.pc's --static --libs is broken)
     if test "$sdl" = "yes" -a "$static" = "yes" ; then
       if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
@@ -3002,6 +3019,7 @@ EOF
 	:
       else
         sdl=no
+        sdl_image=no
       fi
     fi # static link
   else # sdl not found
@@ -3009,6 +3027,7 @@ EOF
       feature_not_found "sdl" "Install SDL devel"
     fi
     sdl=no
+    sdl_image=no
   fi # sdl compile test
 }
 
@@ -6022,6 +6041,7 @@ if test "$darwin" = "yes" ; then
     echo "Cocoa support     $cocoa"
 fi
 echo "SDL support       $sdl $(echo_version $sdl $sdlversion)"
+echo "SDL image support $sdl_image"
 echo "GTK support       $gtk $(echo_version $gtk $gtk_version)"
 echo "GTK GL support    $gtk_gl"
 echo "VTE support       $vte $(echo_version $vte $vteversion)"
@@ -6362,6 +6382,9 @@ if test "$sdl" = "yes" ; then
   echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
   echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
   echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
+  if test "$sdl_image" = "yes" ; then
+      echo "CONFIG_SDL_IMAGE=y" >> $config_host_mak
+  fi
 fi
 if test "$cocoa" = "yes" ; then
   echo "CONFIG_COCOA=y" >> $config_host_mak
diff --git a/include/ui/sdl2.h b/include/ui/sdl2.h
index f43eecdbd6..f6db642b65 100644
--- a/include/ui/sdl2.h
+++ b/include/ui/sdl2.h
@@ -6,6 +6,9 @@
 
 #include <SDL.h>
 #include <SDL_syswm.h>
+#ifdef CONFIG_SDL_IMAGE
+# include <SDL_image.h>
+#endif
 
 #ifdef CONFIG_OPENGL
 # include "ui/egl-helpers.h"
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 4c0d5db473..c24b99af94 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -764,6 +764,7 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
     uint8_t data = 0;
     int i;
     SDL_SysWMinfo info;
+    SDL_Surface *icon = NULL;
 
     assert(o->type == DISPLAY_TYPE_SDL);
 
@@ -835,13 +836,18 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
 #endif
     }
 
+#ifdef CONFIG_SDL_IMAGE
+    icon = IMG_Load(CONFIG_QEMU_ICONDIR "/hicolor/128x128/apps/qemu.png");
+#else
     /* Load a 32x32x4 image. White pixels are transparent. */
-    SDL_Surface *image = SDL_LoadBMP(CONFIG_QEMU_ICONDIR
-                                     "/hicolor/32x32/apps/qemu.bmp");
-    if (image) {
+    icon = SDL_LoadBMP(CONFIG_QEMU_ICONDIR "/hicolor/32x32/apps/qemu.bmp");
+#endif
+    if (icon) {
+#ifndef CONFIG_SDL_IMAGE
         uint32_t colorkey = SDL_MapRGB(image->format, 255, 255, 255);
         SDL_SetColorKey(image, SDL_TRUE, colorkey);
-        SDL_SetWindowIcon(sdl2_console[0].real_window, image);
+#endif
+        SDL_SetWindowIcon(sdl2_console[0].real_window, icon);
     }
 
     gui_grab = 0;
-- 
2.19.2

  parent reply	other threads:[~2018-12-18 14:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-18 14:26 [Qemu-devel] [PATCH 0/3] Fix & improve icon display on GTK and SDL frontends Daniel P. Berrangé
2018-12-18 14:26 ` [Qemu-devel] [PATCH 1/3] ui: install logo icons to $prefix/share/icons Daniel P. Berrangé
2018-12-19  7:20   ` Gerd Hoffmann
2018-12-19 10:03     ` Daniel P. Berrangé
2018-12-19 10:19       ` Gerd Hoffmann
2018-12-19 10:23         ` Daniel P. Berrangé
2018-12-18 14:26 ` [Qemu-devel] [PATCH 2/3] ui: fix icon display for GTK frontend under GNOME Shell with Wayland Daniel P. Berrangé
2018-12-18 14:26 ` Daniel P. Berrangé [this message]
2018-12-25  1:34 ` [Qemu-devel] [PATCH 0/3] Fix & improve icon display on GTK and SDL frontends no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181218142629.15943-4-berrange@redhat.com \
    --to=berrange@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).