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




commit 322d87c6476b46b50bea9d65cbd6f1c8f7071863
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 4ad2c83de..0f59e9d37 100644
--- a/src/nautilus-file.c
+++ b/src/nautilus-file.c
@@ -5092,6 +5092,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)
         {
@@ -5101,6 +5102,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);
@@ -5111,6 +5117,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]