|
30 | 30 |
|
31 | 31 | #include "style_box_flat.h" |
32 | 32 |
|
33 | | -#include "scene/main/scene_tree.h" |
34 | | -#include "scene/main/window.h" |
| 33 | +#include "scene/main/canvas_item.h" |
| 34 | +#include "scene/main/viewport.h" |
35 | 35 | #include "servers/rendering/rendering_server.h" |
36 | 36 |
|
37 | 37 | float StyleBoxFlat::get_style_margin(Side p_side) const { |
@@ -497,17 +497,18 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const { |
497 | 497 | real_t aa_size_scaled = 1.0f; |
498 | 498 | if (aa_on) { |
499 | 499 | real_t scale_factor = 1.0f; |
500 | | - const SceneTree *tree = Object::cast_to<SceneTree>(OS::get_singleton()->get_main_loop()); |
501 | | - if (tree) { |
502 | | - const Window *window = tree->get_root(); |
503 | | - const Vector2 stretch_scale = window->get_stretch_transform().get_scale(); |
504 | | - scale_factor = MIN(stretch_scale.x, stretch_scale.y); |
| 500 | + CanvasItem *ci = CanvasItem::get_current_item_drawn(); |
| 501 | + if (ci) { |
| 502 | + Viewport *vp = ci->get_viewport(); |
| 503 | + if (vp) { |
| 504 | + scale_factor = vp->get_oversampling(); |
| 505 | + } |
505 | 506 | } |
506 | 507 |
|
507 | 508 | // Adjust AA feather size to account for the 2D scale factor, so that |
508 | 509 | // antialiasing doesn't become blurry at viewport resolutions higher |
509 | 510 | // than the default when using the `canvas_items` stretch mode |
510 | | - // (or when using `content_scale_factor` values different than `1.0`). |
| 511 | + // (or when using `oversampling` values different than `1.0`). |
511 | 512 | aa_size_scaled = aa_size / scale_factor; |
512 | 513 | } |
513 | 514 |
|
|
0 commit comments