overlays/sdf: Clamp rounded-rect border radius to never exceed the box sides

- If the radius exceeds any half-dimension then the box-shrink subtraction yields a negative.
  That negative introduces a second transition boundary when the classification happens as it transitions back to positive.
  Normally not a big deal but when rendering borders at the transition points it can introduce artifacts.
This commit is contained in:
kd-11 2026-03-23 01:38:57 +03:00 committed by kd-11
parent 5acc263b73
commit c19d22ce88
6 changed files with 15 additions and 12 deletions

View File

@ -84,7 +84,7 @@ namespace rsx::overlays
void switchbox::set_size(u16 w, u16 h)
{
const u16 dim = std::max<u16>(std::min(w, h), 14) & ~1u;
const u16 dim = std::max<u16>(std::min(w, h), 14);
box_layout::set_size(w, h);
clear_items();
@ -99,7 +99,7 @@ namespace rsx::overlays
ellipse_part->set_size(dim * 2, dim);
ellipse_part->set_padding(1);
ellipse_part->set_pos(0, 0);
ellipse_part->radius = (dim - 2) / 2;
ellipse_part->border_radius = (dim - 2) / 2;
circle_part->set_size(dim, dim);
circle_part->set_padding(4);

View File

@ -68,7 +68,10 @@ namespace rsx
br *= scale_av;
bw *= scale_av;
// Account for flipped viewport
// Border radius clamp
br = std::min({ br, hx, hy });
// Compute the function's origin. Account for flipped viewports as well.
if (target_viewport.x2 < target_viewport.x1)
{
cx = target_viewport.width() - (cx * scale_x) + target_viewport.x2;
@ -1171,7 +1174,7 @@ namespace rsx
overlay_element::get_compiled();
auto& config = compiled_resources.draw_commands.front().config;
configure_sdf(config, sdf_function::rounded_box);
config.sdf_config.br = radius;
config.sdf_config.br = std::min({ static_cast<f32>(border_radius), config.sdf_config.hx, config.sdf_config.hy });
m_is_compiled = true;
return compiled_resources;

View File

@ -350,7 +350,7 @@ namespace rsx
struct rounded_rect : public overlay_element
{
u8 radius = 5;
u16 border_radius = 5;
using overlay_element::overlay_element;
compiled_resource& get_compiled() override;

View File

@ -17,7 +17,7 @@ namespace rsx
scroll_indicator_grip->set_pos(1, 0);
scroll_indicator_grip->set_size(5, 5);
scroll_indicator_grip->radius = 2;
scroll_indicator_grip->border_radius = 2;
scroll_indicator_track->set_size(7, height);
m_scroll_indicator = std::make_unique<box_layout>();

View File

@ -144,7 +144,7 @@ namespace rsx::overlays
auto background = std::make_unique<rounded_rect>();
background->set_size(w, h);
background->radius = std::min(h / 4, 5);
background->border_radius = std::min(h / 4, 5);
background->back_color = color4f(0.3f, 0.3f, 0.3f, 1.0f);
const u16 arrow_size = std::min<u16>(h / 2, max_dropdown_arrow_dimension);

View File

@ -34,22 +34,22 @@ namespace rsx::overlays
auto min_label = std::make_unique<label>();
auto max_label = std::make_unique<label>();
indicator->radius = slider_indicator_radius;
indicator->border_radius = slider_indicator_radius;
indicator->set_size(slider_indicator_dia + 2, slider_indicator_dia + 2);
indicator->set_padding(2);
indicator->set_pos(0, -2);
indicator->back_color = color4f(1.f);
background->radius = slider_rail_thickness / 2;
background->border_radius = slider_rail_thickness / 2;
background->back_color = this->back_color;
background->back_color.a = 1.f;
background->set_size(w, slider_rail_thickness);
background->set_pos(0, (slider_indicator_dia / 2) - background->radius);
background->set_pos(0, (slider_indicator_dia / 2) - background->border_radius);
foreground->radius = slider_cover_thickness / 2;
foreground->border_radius = slider_cover_thickness / 2;
foreground->back_color = this->fore_color;
foreground->set_size(0, slider_cover_thickness);
foreground->set_pos(0, (slider_indicator_dia / 2) - foreground->radius);
foreground->set_pos(0, (slider_indicator_dia / 2) - foreground->border_radius);
value_label->set_padding(2);
value_label->set_font(slider_label_font_family, slider_label_font_size);