[mutter] background-content: Anti-alias texels that intersect the circle boundary



commit 858b5c12b1f55043964c2e2bd30de8cf112e76d2
Author: Daniel van Vugt <daniel van vugt canonical com>
Date:   Mon Nov 22 18:23:08 2021 +0800

    background-content: Anti-alias texels that intersect the circle boundary
    
    Previously we chose to only anti-alias texels inside the boundary
    (`clip_radius - 1.0`) but zoomed in you could see it was slightly smaller
    than the correct curve (#2024).
    
    Similarly if you choose to only anti-alias texels outside that edge
    (`clip_radius + 1.0`) then you'd get an overly convex curve that doesn't
    match up with the straight line sections.
    
    So now we anti-alias texels that intersect the circle boundary, regardless
    of which side they are mostly on. For efficiency we define "intersect" to
    mean any texel whose center is within 0.5 of the theoretical edge.
    
    Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2024
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2102>

 src/compositor/meta-background-content.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/src/compositor/meta-background-content.c b/src/compositor/meta-background-content.c
index eeae41c62b..49f5885ca7 100644
--- a/src/compositor/meta-background-content.c
+++ b/src/compositor/meta-background-content.c
@@ -169,16 +169,17 @@ typedef enum
 "  float dist_squared = dot (delta, delta);                               \n"\
 "                                                                         \n"\
 "  // Fully outside the circle                                            \n"\
-"  if (dist_squared >= (clip_radius * clip_radius))                       \n"\
+"  float outer_radius = clip_radius + 0.5;                                \n"\
+"  if (dist_squared >= (outer_radius * outer_radius))                     \n"\
 "    return 0.0;                                                          \n"\
 "                                                                         \n"\
 "  // Fully inside the circle                                             \n"\
-"  float inner_radius = clip_radius - 1.0;                                \n"\
+"  float inner_radius = clip_radius - 0.5;                                \n"\
 "  if (dist_squared <= (inner_radius * inner_radius))                     \n"\
 "    return 1.0;                                                          \n"\
 "                                                                         \n"\
 "  // Only pixels on the edge of the curve need expensive antialiasing    \n"\
-"  return clip_radius - sqrt (dist_squared);                              \n"\
+"  return outer_radius - sqrt (dist_squared);                             \n"\
 "}                                                                        \n"
 
 #define ROUNDED_CLIP_FRAGMENT_SHADER_CODE                                    \


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]