From d91ad2e045a5ad04bff14fbadf3ea65e05f17150 Mon Sep 17 00:00:00 2001 From: Leo Date: Mon, 24 Jun 2024 04:21:27 +0900 Subject: [PATCH] ShadowEffect: Avoid painting inside the actor (#1954) --- lib/ShadowEffect.vala | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/ShadowEffect.vala b/lib/ShadowEffect.vala index 0ecf47db..909edb29 100644 --- a/lib/ShadowEffect.vala +++ b/lib/ShadowEffect.vala @@ -69,7 +69,7 @@ public class Gala.ShadowEffect : Clutter.Effect { } } - private Cogl.Texture? get_shadow (Cogl.Context context, int width, int height, int shadow_size, int shadow_spread = 0) { + private Cogl.Texture? get_shadow (Cogl.Context context, int width, int height, int shadow_size) { var old_key = current_key; current_key = "%ix%i:%i".printf (width, height, shadow_size); if (old_key == current_key) { @@ -90,10 +90,10 @@ public class Gala.ShadowEffect : Clutter.Effect { var buffer = new Drawing.BufferSurface (width, height); Drawing.Utilities.cairo_rounded_rectangle ( buffer.context, - shadow_size - shadow_spread, - shadow_size - shadow_spread, - width - shadow_size * 2 + shadow_spread * 2, - height - shadow_size * 2 + shadow_spread * 2, + shadow_size, + shadow_size, + width - shadow_size * 2, + height - shadow_size * 2, border_radius ); @@ -107,6 +107,13 @@ public class Gala.ShadowEffect : Clutter.Effect { cr.set_source_surface (buffer.surface, 0, 0); cr.paint (); + cr.save (); + cr.set_operator (Cairo.Operator.CLEAR); + var size = shadow_size * scale_factor; + Drawing.Utilities.cairo_rounded_rectangle (cr, size, size, actor.width, actor.height, border_radius); + cr.fill (); + cr.restore (); + try { var texture = new Cogl.Texture2D.from_data (context, width, height, Cogl.PixelFormat.BGRA_8888_PRE, surface.get_stride (), surface.get_data ()); @@ -147,7 +154,7 @@ public class Gala.ShadowEffect : Clutter.Effect { pipeline.set_color (alpha); - context.get_framebuffer ().draw_rectangle (pipeline, bounding_box.x1, bounding_box.y1 + shadow_size / 4, bounding_box.x2, bounding_box.y2 + shadow_size / 4); + context.get_framebuffer ().draw_rectangle (pipeline, bounding_box.x1, bounding_box.y1, bounding_box.x2, bounding_box.y2); actor.continue_paint (context); }