Skip to content

Commit

Permalink
Fixed StyleBoxFlat antialiasing to be applied only on corners
Browse files Browse the repository at this point in the history
After multiple changes to the transparent drawing used for AA, it ended up being consistently applied all around the borders inside and outside, which is not the intended behavior. This change makes sure border flat sides are solid instead of blurry.

Fixes godotengine#35279
  • Loading branch information
pouleyKetchoupp committed Jan 24, 2020
1 parent 8dc7f39 commit 59f3747
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions scene/resources/style_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {

bool rounded_corners = (corner_radius[0] > 0) || (corner_radius[1] > 0) || (corner_radius[2] > 0) || (corner_radius[3] > 0);
bool aa_on = rounded_corners && anti_aliased;
float aa_size_grow = 0.5 * ((float)aa_size + 1.0);
float aa_size_grow = 0.5 * ((aa_size + 1) / 2);

bool blend_on = blend_border && draw_border;

Expand Down Expand Up @@ -789,6 +789,8 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
}

if (aa_on) {
float aa_size_fill = 0.5 * ((float)aa_size + 1.0);

int aa_border_width[4];
int aa_fill_width[4];
if (draw_border) {
Expand All @@ -798,13 +800,13 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
aa_fill_width[i] = 0;
} else {
aa_border_width[i] = 0;
aa_fill_width[i] = aa_size_grow;
aa_fill_width[i] = aa_size_fill;
}
}
} else {
for (int i = 0; i < 4; i++) {
aa_border_width[i] = 0;
aa_fill_width[i] = aa_size_grow;
aa_fill_width[i] = aa_size_fill;
}
}

Expand Down

0 comments on commit 59f3747

Please sign in to comment.