Merge branch 'more-scaled-texture-fixes' into 'main'

Fix gtk_snapshot_append_scaled_texture

See merge request GNOME/gtk!5638
This commit is contained in:
Matthias Clasen 2023-03-13 08:58:58 +00:00
commit 413abef01d
2 changed files with 6 additions and 11 deletions

View File

@ -56,7 +56,6 @@ demo3_widget_snapshot (GtkWidget *widget,
Demo3Widget *self = DEMO3_WIDGET (widget);
int x, y, width, height;
double w, h, w2, h2;
GskRenderNode *node;
width = gtk_widget_get_width (widget);
height = gtk_widget_get_height (widget);
@ -81,11 +80,10 @@ demo3_widget_snapshot (GtkWidget *widget,
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (w2 / 2, h2 / 2));
gtk_snapshot_rotate (snapshot, self->angle);
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (- w / 2, - h / 2));
node = gsk_texture_scale_node_new (self->texture,
&GRAPHENE_RECT_INIT (0, 0, w, h),
self->filter);
gtk_snapshot_append_node (snapshot, node);
gsk_render_node_unref (node);
gtk_snapshot_append_scaled_texture (snapshot,
self->texture,
self->filter,
&GRAPHENE_RECT_INIT (0, 0, w, h));
gtk_snapshot_restore (snapshot);
gtk_snapshot_pop (snapshot);
}

View File

@ -2054,16 +2054,13 @@ gtk_snapshot_append_scaled_texture (GtkSnapshot *snapshot,
const graphene_rect_t *bounds)
{
GskRenderNode *node;
graphene_rect_t real_bounds;
float scale_x, scale_y, dx, dy;
g_return_if_fail (snapshot != NULL);
g_return_if_fail (GDK_IS_TEXTURE (texture));
g_return_if_fail (bounds != NULL);
gtk_snapshot_ensure_affine (snapshot, &scale_x, &scale_y, &dx, &dy);
gtk_graphene_rect_scale_affine (bounds, scale_x, scale_y, dx, dy, &real_bounds);
node = gsk_texture_scale_node_new (texture, &real_bounds, filter);
gtk_snapshot_ensure_identity (snapshot);
node = gsk_texture_scale_node_new (texture, bounds, filter);
gtk_snapshot_append_node_internal (snapshot, node);
}