From b770ea606aeaea66504649f665e01ac31bfdef44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Thu, 11 Mar 2021 22:57:35 +0100 Subject: [PATCH] background-content: Optimize rounded clipping shader a bit We're using the gtk4 shader for rounded rect clipping here, and gtk just introduced a small optimization to make this shader a bit faster, so let's do the same. See https://gitlab.gnome.org/GNOME/gtk/-/commit/57e354c297e1703079c2bc6fb51211b24d884ac3 Part-of: --- src/compositor/meta-background-content.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/compositor/meta-background-content.c b/src/compositor/meta-background-content.c index 73db45440..3afeca482 100644 --- a/src/compositor/meta-background-content.c +++ b/src/compositor/meta-background-content.c @@ -175,16 +175,24 @@ typedef enum " p.x >= bounds.z || p.y >= bounds.w) \n"\ " return 0.0; \n"\ " \n"\ -" vec2 rad_tl = corner_centers_1.xy - bounds.xy; \n"\ -" vec2 rad_tr = corner_centers_1.zw - bounds.zy; \n"\ -" vec2 rad_br = corner_centers_2.xy - bounds.zw; \n"\ -" vec2 rad_bl = corner_centers_2.zw - bounds.xw; \n"\ -" \n"\ " vec2 ref_tl = corner_centers_1.xy; \n"\ " vec2 ref_tr = corner_centers_1.zw; \n"\ " vec2 ref_br = corner_centers_2.xy; \n"\ " vec2 ref_bl = corner_centers_2.zw; \n"\ " \n"\ +" if (p.x >= ref_tl.x && p.x >= ref_bl.x && \n"\ +" p.x <= ref_tr.x && p.x <= ref_br.x) \n"\ +" return 1.0; \n"\ +" \n"\ +" if (p.y >= ref_tl.y && p.y >= ref_tr.y && \n"\ +" p.y <= ref_bl.y && p.y <= ref_br.y) \n"\ +" return 1.0; \n"\ +" \n"\ +" vec2 rad_tl = corner_centers_1.xy - bounds.xy; \n"\ +" vec2 rad_tr = corner_centers_1.zw - bounds.zy; \n"\ +" vec2 rad_br = corner_centers_2.xy - bounds.zw; \n"\ +" vec2 rad_bl = corner_centers_2.zw - bounds.xw; \n"\ +" \n"\ " float d_tl = ellipsis_coverage(p, ref_tl, rad_tl); \n"\ " float d_tr = ellipsis_coverage(p, ref_tr, rad_tr); \n"\ " float d_br = ellipsis_coverage(p, ref_br, rad_br); \n"\