diff options
author | Will McKinnon <[email protected]> | 2023-04-07 00:26:23 -0400 |
---|---|---|
committer | Will McKinnon <[email protected]> | 2023-04-07 00:26:23 -0400 |
commit | f74c0fedb2e1cd8e23f52b6817d5819c4e66c843 (patch) | |
tree | 017cbf14eab8e484fc703f942957627b0e93a940 | |
parent | 3e6f2366e74f573d1e57d7a4cab5fb334d26bed5 (diff) |
minor shadow optimization
-rw-r--r-- | sway/desktop/render.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 3a3517c1..08b7f240 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include <stdio.h> #include <assert.h> #include <GLES2/gl2.h> @@ -9,14 +8,16 @@ #include <wlr/render/gles2.h> #include <wlr/render/wlr_renderer.h> #include <wlr/types/wlr_buffer.h> +#include <wlr/types/wlr_compositor.h> #include <wlr/types/wlr_damage_ring.h> #include <wlr/types/wlr_matrix.h> -#include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_output.h> -#include <wlr/types/wlr_compositor.h> +#include <wlr/types/wlr_output_layout.h> +#include <wlr/util/box.h> #include <wlr/util/region.h> -#include "log.h" + #include "config.h" +#include "log.h" #include "sway/config.h" #include "sway/desktop/fx_renderer/fx_renderer.h" #include "sway/input/input-manager.h" @@ -340,9 +341,20 @@ void render_box_shadow(struct sway_output *output, pixman_region32_t *output_dam box.height += 2 * blur_sigma; // Uses the outer radii of the window for a more realistic look - corner_radius = corner_radius + border_thickness; + corner_radius += border_thickness; pixman_region32_t damage = create_damage(box, output_damage); + + // don't damage area behind window since we dont render it anyway + struct wlr_box inner_box; + memcpy(&inner_box, _box, sizeof(struct wlr_box)); + inner_box.x += corner_radius; + inner_box.y += corner_radius; + inner_box.width -= 2 * corner_radius; + inner_box.height -= 2 * corner_radius; + pixman_region32_t inner_damage = create_damage(inner_box, output_damage); + pixman_region32_subtract(&damage, &damage, &inner_damage); + bool damaged = pixman_region32_not_empty(&damage); if (!damaged) { goto damage_finish; |