summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorPouleyKetchoupp <pouleyketchoup@gmail.com>2020-01-05 10:54:24 +0100
committerPouleyKetchoupp <pouleyketchoup@gmail.com>2020-01-05 10:54:24 +0100
commita7a025531bc730dbe7e9bc535aeea74cc52be565 (patch)
tree16f7b0b88ea4a34c576ffe0b5879be8b979f1669 /scene
parenta18909f9452180c36b62f34dda07fbebb6c863ed (diff)
Fixed StyleBoxFlat antialiasing with aa size of 1
Also made aa size consistent when computing uv coordinates and fixed a warning about aa_border_width not initialized in some cases. fixes #34830
Diffstat (limited to 'scene')
-rw-r--r--scene/resources/style_box.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp
index c59fa8cab8..9408d1aa71 100644
--- a/scene/resources/style_box.cpp
+++ b/scene/resources/style_box.cpp
@@ -719,6 +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);
bool blend_on = blend_border && draw_border;
@@ -744,7 +745,6 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
Rect2 border_style_rect = style_rect;
if (aa_on) {
- float aa_size_grow = 0.5 * ((aa_size + 1) / 2);
for (int i = 0; i < 4; i++) {
if (border_width[i] > 0) {
border_style_rect = border_style_rect.grow_margin((Margin)i, -aa_size_grow);
@@ -789,7 +789,6 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
}
if (aa_on) {
- float aa_size_grow = 0.5 * ((aa_size + 1) / 2);
int aa_border_width[4];
int aa_fill_width[4];
if (draw_border) {
@@ -804,6 +803,7 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
}
} else {
for (int i = 0; i < 4; i++) {
+ aa_border_width[i] = 0;
aa_fill_width[i] = aa_size_grow;
}
}
@@ -844,7 +844,7 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
}
//COMPUTE UV COORDINATES
- Rect2 uv_rect = style_rect.grow(aa_on ? aa_size : 0);
+ Rect2 uv_rect = style_rect.grow(aa_on ? aa_size_grow : 0);
uvs.resize(verts.size());
for (int i = 0; i < verts.size(); i++) {
uvs.write[i].x = (verts[i].x - uv_rect.position.x) / uv_rect.size.width;