[libadwaita/wip/exalm/avatar-draw: 2/2] avatar: Fix draw_to_texture() with rectangular avatars




commit 9e1687aeb8e32604940cb989f9cd9f4b6eda7890
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().

 src/adw-avatar.c | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/src/adw-avatar.c b/src/adw-avatar.c
index 6898e8b8..f5bffef2 100644
--- a/src/adw-avatar.c
+++ b/src/adw-avatar.c
@@ -733,14 +733,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]