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




commit 8e16251932958ba1e76f26b1317ac8200a62ef14
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 6b4b2319a..02e8307b0 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]