Merge branch 'wip/otte/for-main' into 'main'

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

See merge request GNOME/gtk!6989
This commit is contained in:
Benjamin Otte
2024-03-06 22:44:48 +00:00

View File

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