summaryrefslogtreecommitdiff
path: root/sway/desktop/fx_renderer/fx_renderer.c
diff options
context:
space:
mode:
authorErik Reider <[email protected]>2023-12-17 01:00:22 +0100
committerGitHub <[email protected]>2023-12-17 01:00:22 +0100
commit5e866d0345449f34ac51c6590a3aac285cb2f8bf (patch)
tree265936af817b36e664f0499624517a72293a8e0a /sway/desktop/fx_renderer/fx_renderer.c
parentfd0f4ea54f5f79a01697226ebf103d357e90a1bc (diff)
Limit corner radius size to the smallest box dimension (#251)
One example would be the tiling indicator sometimes experiencing a "sharp" edge when the radii was larger than the height/width
Diffstat (limited to 'sway/desktop/fx_renderer/fx_renderer.c')
-rw-r--r--sway/desktop/fx_renderer/fx_renderer.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/sway/desktop/fx_renderer/fx_renderer.c b/sway/desktop/fx_renderer/fx_renderer.c
index d2fef6f1..07758325 100644
--- a/sway/desktop/fx_renderer/fx_renderer.c
+++ b/sway/desktop/fx_renderer/fx_renderer.c
@@ -481,6 +481,12 @@ void fx_renderer_stencil_mask_fini() {
bool fx_render_subtexture_with_matrix(struct fx_renderer *renderer, struct fx_texture *fx_texture,
const struct wlr_fbox *src_box, const struct wlr_box *dst_box, const float matrix[static 9],
struct decoration_data deco_data) {
+ // Fixes corner radii not being "round" when the radii is larger than
+ // the height/width
+ int min_size = MIN(dst_box->height, dst_box->width) * 0.5;
+ if (deco_data.corner_radius > min_size) {
+ deco_data.corner_radius = min_size;
+ }
struct tex_shader *shader = NULL;
@@ -630,6 +636,13 @@ void fx_render_rounded_rect(struct fx_renderer *renderer, const struct wlr_box *
}
assert(box->width > 0 && box->height > 0);
+ // Fixes corner radii not being "round" when the radii is larger than
+ // the height/width
+ int min_size = MIN(box->height, box->width) * 0.5;
+ if (radius > min_size) {
+ radius = min_size;
+ }
+
struct rounded_quad_shader *shader = NULL;
switch (corner_location) {
@@ -691,6 +704,13 @@ void fx_render_border_corner(struct fx_renderer *renderer, const struct wlr_box
}
assert(box->width > 0 && box->height > 0);
+ // Fixes corner radii not being "round" when the radii is larger than
+ // the height/width
+ int min_size = MIN(box->height, box->width) * 0.5;
+ if (radius > min_size) {
+ radius = min_size;
+ }
+
float gl_matrix[9];
wlr_matrix_multiply(gl_matrix, renderer->projection, matrix);
@@ -739,6 +759,13 @@ void fx_render_stencil_mask(struct fx_renderer *renderer, const struct wlr_box *
}
assert(box->width > 0 && box->height > 0);
+ // Fixes corner radii not being "round" when the radii is larger than
+ // the height/width
+ int min_size = MIN(box->height, box->width) * 0.5;
+ if (corner_radius > min_size) {
+ corner_radius = min_size;
+ }
+
// TODO: just pass gl_matrix?
float gl_matrix[9];
wlr_matrix_multiply(gl_matrix, renderer->projection, matrix);
@@ -779,6 +806,13 @@ void fx_render_box_shadow(struct fx_renderer *renderer, const struct wlr_box *bo
}
assert(box->width > 0 && box->height > 0);
+ // Fixes corner radii not being "round" when the radii is larger than
+ // the height/width
+ int min_size = MIN(box->height, box->width) * 0.5;
+ if (corner_radius > min_size) {
+ corner_radius = min_size;
+ }
+
float gl_matrix[9];
wlr_matrix_multiply(gl_matrix, renderer->projection, matrix);