From 6f89d258b0f60fd336657d51a12dc4693afc4a1f Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 11 Sep 2023 05:17:56 +0200 Subject: [PATCH] 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 --- gsk/gl/resources/preamble.vs.glsl | 2 ++ .../gsk/compare/shrink-rounded-border.node | 19 ++++++++++++++++++ .../gsk/compare/shrink-rounded-border.png | Bin 0 -> 83 bytes testsuite/gsk/meson.build | 1 + 4 files changed, 22 insertions(+) create mode 100644 testsuite/gsk/compare/shrink-rounded-border.node create mode 100644 testsuite/gsk/compare/shrink-rounded-border.png diff --git a/gsk/gl/resources/preamble.vs.glsl b/gsk/gl/resources/preamble.vs.glsl index 758bca89d2..ff3d5bb5a7 100644 --- a/gsk/gl/resources/preamble.vs.glsl +++ b/gsk/gl/resources/preamble.vs.glsl @@ -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); } diff --git a/testsuite/gsk/compare/shrink-rounded-border.node b/testsuite/gsk/compare/shrink-rounded-border.node new file mode 100644 index 0000000000..15b662c048 --- /dev/null +++ b/testsuite/gsk/compare/shrink-rounded-border.node @@ -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; + } +} diff --git a/testsuite/gsk/compare/shrink-rounded-border.png b/testsuite/gsk/compare/shrink-rounded-border.png new file mode 100644 index 0000000000000000000000000000000000000000..82aacdaf6229c4b1fa52920bc300f89135035e71 GIT binary patch literal 83 zcmeAS@N?(olHy`uVBq!ia0vp^G9b*s1|*Ak?@s|zQl2i3As(G?4;nH8d50E!_0Q#q dUjSs*G4sSQFy0NhwhPE%@O1TaS?83{1OT=)6S@EZ literal 0 HcmV?d00001 diff --git a/testsuite/gsk/meson.build b/testsuite/gsk/meson.build index 53da9d1dcc..bbcefc9205 100644 --- a/testsuite/gsk/meson.build +++ b/testsuite/gsk/meson.build @@ -92,6 +92,7 @@ compare_render_tests = [ 'shadow-behind', 'shadow-in-opacity', 'shadow-opacity', + 'shrink-rounded-border', 'texture-scale-magnify-10000x', 'texture-scale-magnify-rotate', 'texture-scale-stripes', -- 2.30.2