[gnome-games] game-thumbnail: Support HiDPI for icons as well



commit ab5e563550268d0b71eabe3723d154c4ec7b2182
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Sat Aug 17 15:28:27 2019 +0500

    game-thumbnail: Support HiDPI for icons as well
    
    I didn't notice the default icon was also blurry.
    
    Nintendo DS icons were too small, since cover and icon drawing code is
    shared.

 src/ui/game-thumbnail.vala | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/ui/game-thumbnail.vala b/src/ui/game-thumbnail.vala
index b7238735..3f53698d 100644
--- a/src/ui/game-thumbnail.vala
+++ b/src/ui/game-thumbnail.vala
@@ -155,7 +155,7 @@ private class Games.GameThumbnail : Gtk.DrawingArea {
                var color = context.style.get_color (context.state);
 
                var theme = Gtk.IconTheme.get_default ();
-               var size = int.min (context.width, context.height) * scale;
+               var size = int.min (context.width, context.height) * scale * scale_factor;
                try {
                        var icon_info = theme.lookup_icon (icon_name, (int) size, 
Gtk.IconLookupFlags.FORCE_SIZE);
                        emblem = icon_info.load_symbolic (color);
@@ -167,11 +167,16 @@ private class Games.GameThumbnail : Gtk.DrawingArea {
                if (emblem == null)
                        return;
 
-               double offset_x = context.width / 2.0 - emblem.width / 2.0;
-               double offset_y = context.height / 2.0 - emblem.height / 2.0;
+               double offset_x = context.width * scale_factor / 2.0 - emblem.width / 2.0;
+               double offset_y = context.height * scale_factor / 2.0 - emblem.height / 2.0;
+
+               context.cr.save ();
+               context.cr.scale (1.0 / scale_factor, 1.0 / scale_factor);
 
                Gdk.cairo_set_source_pixbuf (context.cr, emblem, offset_x, offset_y);
                context.cr.paint ();
+
+               context.cr.restore ();
        }
 
        private Gdk.Pixbuf? get_scaled_icon (DrawingContext context, GLib.Icon? icon, double scale) {
@@ -180,7 +185,7 @@ private class Games.GameThumbnail : Gtk.DrawingArea {
 
                var theme = Gtk.IconTheme.get_default ();
                var lookup_flags = Gtk.IconLookupFlags.FORCE_SIZE | Gtk.IconLookupFlags.FORCE_REGULAR;
-               var size = int.min (context.width, context.height) * scale;
+               var size = int.min (context.width, context.height) * scale * scale_factor;
                var icon_info = theme.lookup_by_gicon (icon, (int) size, lookup_flags);
 
                if (icon_info == null)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]