mirror of
https://github.com/elementary/gala.git
synced 2024-11-25 03:06:14 +01:00
ShadowEffect: Avoid painting inside the actor (#1954)
This commit is contained in:
parent
6dd497e98f
commit
d91ad2e045
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user