[libadwaita/libadwaita-1-1] avatar: Fix draw_to_texture() with rectangular avatars



commit 4a2fc9fd14aa953f4159325ec26ad1fb2edd0168
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Mon Aug 1 15:38:55 2022 +0400

    avatar: Fix draw_to_texture() with rectangular avatars
    
    Avatar contents center itself if the widget's allocation is not square.
    However, we weren't doing the same in draw_to_texture().
    
    
    (cherry picked from commit 9e1687aeb8e32604940cb989f9cd9f4b6eda7890)

 src/adw-avatar.c | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/src/adw-avatar.c b/src/adw-avatar.c
index ee75900d..f9748c0a 100644
--- a/src/adw-avatar.c
+++ b/src/adw-avatar.c
@@ -743,14 +743,20 @@ adw_avatar_draw_to_texture (AdwAvatar *self,
   GtkNative *native;
   GskRenderer *renderer;
   int size;
+  graphene_matrix_t transform;
 
   g_return_val_if_fail (ADW_IS_AVATAR (self), NULL);
   g_return_val_if_fail (scale_factor > 0, NULL);
 
   size = self->size * scale_factor;
 
+  g_assert (gtk_widget_compute_transform (GTK_WIDGET (self),
+                                          self->gizmo,
+                                          &transform));
+
   snapshot = gtk_snapshot_new ();
   gtk_snapshot_scale (snapshot, scale_factor, scale_factor);
+  gtk_snapshot_transform_matrix (snapshot, &transform);
   GTK_WIDGET_GET_CLASS (self)->snapshot (GTK_WIDGET (self), snapshot);
 
   node = gtk_snapshot_free_to_node (snapshot);


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