From: Timm Bäder Date: Fri, 11 Oct 2019 08:15:58 +0000 (+0200) Subject: gl renderer: Fix glsl rounded rect shrinking X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~20^2~749 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0b999c73d1553b75a212e57686e3d1d1ac036681;p=gtk4.git gl renderer: Fix glsl rounded rect shrinking Previous code would add rounded corners to a rect with all 0 corners when growing. --- diff --git a/gsk/resources/glsl/gl3_common.fs.glsl b/gsk/resources/glsl/gl3_common.fs.glsl index fe360c4151..a7117c5fe8 100644 --- a/gsk/resources/glsl/gl3_common.fs.glsl +++ b/gsk/resources/glsl/gl3_common.fs.glsl @@ -80,8 +80,24 @@ RoundedRect rounded_rect_shrink (RoundedRect r, vec4 amount) { vec4 new_bounds = r.bounds + vec4(1.0,1.0,-1.0,-1.0) * amount.wxyz; - vec4 new_widths = max (r.corner_widths - amount.wyyw, 0.0); - vec4 new_heights = max (r.corner_heights - amount.xxzz, 0.0); + vec4 new_widths = vec4(0); + vec4 new_heights = vec4(0); + + // Left top + if (r.corner_widths.x > 0) new_widths.x = r.corner_widths.x - amount.w; + if (r.corner_heights.x > 0) new_heights.x = r.corner_heights.x - amount.x; + + // Top right + if (r.corner_widths.y > 0) new_widths.y = r.corner_widths.y - amount.y; + if (r.corner_heights.y > 0) new_heights.y = r.corner_heights.y - amount.x; + + // Bottom right + if (r.corner_widths.z > 0) new_widths.z = r.corner_widths.z - amount.y; + if (r.corner_heights.z > 0) new_heights.z = r.corner_heights.z - amount.z; + + // Bottom left + if (r.corner_widths.w > 0) new_widths.w = r.corner_widths.w - amount.w; + if (r.corner_heights.w > 0) new_heights.w = r.corner_heights.w - amount.z; return RoundedRect (new_bounds, new_widths, new_heights); }