Update "snapshot: linear-gradients cannot be affine-transformed"

This is a better fix for commit 7ed6c39862.

The linear-gradient-nonorthogonal-linear-gradient test tests this.

Related: !6692
This commit is contained in:
Benjamin Otte 2024-03-06 22:31:06 +01:00
parent 53786841cc
commit ed31da3730

View File

@ -2427,7 +2427,7 @@ gtk_snapshot_append_linear_gradient (GtkSnapshot *snapshot,
{
GskRenderNode *node;
graphene_rect_t real_bounds;
float dx, dy;
float scale_x, scale_y, dx, dy;
const GdkRGBA *first_color;
gboolean need_gradient = FALSE;
@ -2437,8 +2437,11 @@ gtk_snapshot_append_linear_gradient (GtkSnapshot *snapshot,
g_return_if_fail (stops != NULL);
g_return_if_fail (n_stops > 1);
gtk_snapshot_ensure_translate (snapshot, &dx, &dy);
graphene_rect_offset_r (bounds, dx, dy, &real_bounds);
gtk_snapshot_ensure_affine_with_flags (snapshot,
ENSURE_POSITIVE_SCALE | ENSURE_UNIFORM_SCALE,
&scale_x, &scale_y,
&dx, &dy);
gtk_graphene_rect_scale_affine (bounds, scale_x, scale_y, dx, dy, &real_bounds);
first_color = &stops[0].color;
for (gsize i = 0; i < n_stops; i ++)
@ -2454,10 +2457,10 @@ gtk_snapshot_append_linear_gradient (GtkSnapshot *snapshot,
{
graphene_point_t real_start_point, real_end_point;
real_start_point.x = start_point->x + dx;
real_start_point.y = start_point->y + dy;
real_end_point.x = end_point->x + dx;
real_end_point.y = end_point->y + dy;
real_start_point.x = scale_x * start_point->x + dx;
real_start_point.y = scale_y * start_point->y + dy;
real_end_point.x = scale_x * end_point->x + dx;
real_end_point.y = scale_y * end_point->y + dy;
node = gsk_linear_gradient_node_new (&real_bounds,
&real_start_point,
@ -2494,7 +2497,7 @@ gtk_snapshot_append_repeating_linear_gradient (GtkSnapshot *snapshot,
{
GskRenderNode *node;
graphene_rect_t real_bounds;
float dx, dy;
float scale_x, scale_y, dx, dy;
gboolean need_gradient = FALSE;
const GdkRGBA *first_color;
@ -2504,8 +2507,8 @@ gtk_snapshot_append_repeating_linear_gradient (GtkSnapshot *snapshot,
g_return_if_fail (stops != NULL);
g_return_if_fail (n_stops > 1);
gtk_snapshot_ensure_translate (snapshot, &dx, &dy);
graphene_rect_offset_r (bounds, dx, dy, &real_bounds);
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);
first_color = &stops[0].color;
for (gsize i = 0; i < n_stops; i ++)
@ -2521,10 +2524,10 @@ gtk_snapshot_append_repeating_linear_gradient (GtkSnapshot *snapshot,
{
graphene_point_t real_start_point, real_end_point;
real_start_point.x = start_point->x + dx;
real_start_point.y = start_point->y + dy;
real_end_point.x = end_point->x + dx;
real_end_point.y = end_point->y + dy;
real_start_point.x = scale_x * start_point->x + dx;
real_start_point.y = scale_y * start_point->y + dy;
real_end_point.x = scale_x * end_point->x + dx;
real_end_point.y = scale_y * end_point->y + dy;
node = gsk_repeating_linear_gradient_node_new (&real_bounds,
&real_start_point,