gl: Change rounded_rect_shrink()

The code now follows gsk_rounded_rect_shrink() and with it the behavior
of the Cairo renderer and Webkit.

The old code did what the GL renderer and Cairo do, but I consider that
wrong.

I did not test Chrome.

Test attached
This commit is contained in:
Benjamin Otte 2023-09-11 05:17:56 +02:00
parent 9aaec91f95
commit e9089f65e3
4 changed files with 22 additions and 0 deletions

View File

@ -28,6 +28,8 @@ gsk_rounded_rect_shrink (GskRoundedRect r, vec4 amount)
if (r.corner_points1.zw == r.bounds.zy) new_corner_points1.zw = new_bounds.zy;
if (r.corner_points2.xy == r.bounds.zw) new_corner_points2.xy = new_bounds.zw;
if (r.corner_points2.zw == r.bounds.xw) new_corner_points2.zw = new_bounds.xw;
new_corner_points1 = clamp (new_corner_points1, new_bounds.xyxy, new_bounds.zwzw);
new_corner_points2 = clamp (new_corner_points2, new_bounds.xyxy, new_bounds.zwzw);
return GskRoundedRect (new_bounds, new_corner_points1, new_corner_points2);
}

View File

@ -0,0 +1,19 @@
/* We clip out the transparent region inside the
border so we can check that the shrinking of
the inside works properly.
Comment out the clip to see the actual border
*/
clip {
/* blame sqrt(2) for those numbers:
The shrunkrect should be 40 40 70 70 / 70 0
70/sqrt(2) = 49.4974747...
40 + 49 = 89 and 40 + 70 - 49 = 61,
giving you:
*/
clip: 61 61 28 28;
child: border {
outline: 0 0 150 150 / 150 0 150 0;
widths: 40;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 B

View File

@ -94,6 +94,7 @@ compare_render_tests = [
'shadow-behind',
'shadow-in-opacity',
'shadow-opacity',
'shrink-rounded-border',
'stroke',
'texture-scale-magnify-10000x',
'texture-scale-magnify-rotate',