[nautilus/wip/antoniof/hidpi-and-icons-cleanup: 123/126] file: Slightly soften thumbnail corners




commit 8a9eec97a745cfb8642ec2082cc8806453671560
Author: António Fernandes <antoniof gnome org>
Date:   Wed Aug 10 11:45:15 2022 +0100

    file: Slightly soften thumbnail corners
    
    Sharp corners stand out a unpolished. We've been trying to give the
    illusion of round corners using shadows, and it works somewhat, but
    now that we already use GtkSnapshot, actually clipping round corners
    is too easy not to do it.

 src/nautilus-file.c | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/src/nautilus-file.c b/src/nautilus-file.c
index f9fbfa187..daea26b3b 100644
--- a/src/nautilus-file.c
+++ b/src/nautilus-file.c
@@ -5103,6 +5103,7 @@ nautilus_file_get_thumbnail_icon (NautilusFile          *file,
         double height = gdk_pixbuf_get_height (pixbuf) / scale;
         g_autoptr (GdkTexture) texture = gdk_texture_new_for_pixbuf (pixbuf);
         g_autoptr (GtkSnapshot) snapshot = gtk_snapshot_new ();
+        GskRoundedRect rounded_rect;
 
         if (MAX (width, height) > size)
         {
@@ -5112,6 +5113,11 @@ nautilus_file_get_thumbnail_icon (NautilusFile          *file,
             height = height / scale_down_factor;
         }
 
+        gsk_rounded_rect_init_from_rect (&rounded_rect,
+                                         &GRAPHENE_RECT_INIT (0, 0, width, height),
+                                         2 /* radius*/);
+        gtk_snapshot_push_rounded_clip (snapshot, &rounded_rect);
+
         gdk_paintable_snapshot (GDK_PAINTABLE (texture),
                                 GDK_SNAPSHOT (snapshot),
                                 width, height);
@@ -5122,6 +5128,8 @@ nautilus_file_get_thumbnail_icon (NautilusFile          *file,
             nautilus_ui_frame_video (snapshot, width, height);
         }
 
+        gtk_snapshot_pop (snapshot); /* End rounded clip */
+
         DEBUG ("Returning thumbnailed image, at size %d %d",
                (int) (width), (int) (height));
         paintable = gtk_snapshot_to_paintable (snapshot, NULL);


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