Godot Engine – Multi-platform 2D and 3D game engine
adjust size adapting to account for aa
Samvkes1e9ea17bea99
diff --git a/scene/resources/style_box_flat.cpp b/scene/resources/style_box_flat.cppindex 24d784d9227..2870d83cdab 100644--- a/scene/resources/style_box_flat.cpp+++ b/scene/resources/style_box_flat.cpp@@ -479,9 +479,24 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {Color border_color_blend = (draw_center ? bg_color : border_color_alpha);Color border_color_inner = blend_on ? border_color_blend : border_color;+ real_t aa_size_scaled = 1.0f;+ if (aa_on) {+ real_t scale_factor = TextServer::get_current_drawn_item_oversampling();+ if (scale_factor == 0.0) {+ scale_factor = 1.0;+ }++ // Adjust AA feather size to account for the 2D scale factor, so that+ // antialiasing doesn't become blurry at viewport resolutions higher+ // than the default when using the `canvas_items` stretch mode+ // (or when using `oversampling` values different than `1.0`).+ aa_size_scaled = aa_size / scale_factor;+ }+// Adapt borders (prevent weird overlapping/glitchy drawings).- real_t width = MAX(style_rect.size.width, 0);- real_t height = MAX(style_rect.size.height, 0);+ real_t aa_shrink = aa_on ? aa_size_scaled * 2 : 0;+ real_t width = MAX(style_rect.size.width - aa_shrink, 0);+ real_t height = MAX(style_rect.size.height - aa_shrink, 0);real_t adapted_border[4] = { 1000000.0, 1000000.0, 1000000.0, 1000000.0 };adapt_values(SIDE_TOP, SIDE_BOTTOM, adapted_border, border_width, height, height, height);adapt_values(SIDE_LEFT, SIDE_RIGHT, adapted_border, border_width, width, width, width);@@ -497,20 +512,6 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {Rect2 border_style_rect = style_rect;- real_t aa_size_scaled = 1.0f;- if (aa_on) {- real_t scale_factor = TextServer::get_current_drawn_item_oversampling();- if (scale_factor == 0.0) {- scale_factor = 1.0;- }-- // Adjust AA feather size to account for the 2D scale factor, so that- // antialiasing doesn't become blurry at viewport resolutions higher- // than the default when using the `canvas_items` stretch mode- // (or when using `oversampling` values different than `1.0`).- aa_size_scaled = aa_size / scale_factor;- }-if (aa_on) {for (int i = 0; i < 4; i++) {if (border_width[i] > 0) {