From 9fb96609122471e50a07478bd37b17d7c4482284 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Mon, 3 Jun 2024 19:46:49 +0300 Subject: [PATCH] Force canvas item update on oversampling change. --- scene/main/viewport.cpp | 5 +++-- scene/main/viewport.h | 2 +- scene/main/window.cpp | 11 ++++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 26128a08ab3..38bd7141c24 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -975,7 +975,7 @@ void Viewport::update_canvas_items() { _update_canvas_items(this); } -void Viewport::_set_size(const Size2i &p_size, const Size2i &p_size_2d_override, bool p_allocated) { +bool Viewport::_set_size(const Size2i &p_size, const Size2i &p_size_2d_override, bool p_allocated) { Transform2D stretch_transform_new = Transform2D(); if (is_size_2d_override_stretch_enabled() && p_size_2d_override.width > 0 && p_size_2d_override.height > 0) { Size2 scale = Size2(p_size) / Size2(p_size_2d_override); @@ -984,7 +984,7 @@ void Viewport::_set_size(const Size2i &p_size, const Size2i &p_size_2d_override, Size2i new_size = p_size.maxi(2); if (size == new_size && size_allocated == p_allocated && stretch_transform == stretch_transform_new && p_size_2d_override == size_2d_override) { - return; + return false; } size = new_size; @@ -1027,6 +1027,7 @@ void Viewport::_set_size(const Size2i &p_size, const Size2i &p_size_2d_override, sw->set_size(new_rect.size); } } + return true; } Size2i Viewport::_get_size() const { diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 2474b890b06..df09755d4f6 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -475,7 +475,7 @@ private: void _propagate_world_2d_changed(Node *p_node); protected: - void _set_size(const Size2i &p_size, const Size2i &p_size_2d_override, bool p_allocated); + bool _set_size(const Size2i &p_size, const Size2i &p_size_2d_override, bool p_allocated); Size2i _get_size() const; Size2i _get_size_2d_override() const; diff --git a/scene/main/window.cpp b/scene/main/window.cpp index 11c2d5b7afd..1c5f9cc6635 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -1096,7 +1096,7 @@ void Window::_update_viewport_size() { Size2i final_size; Size2i final_size_override; Rect2i attach_to_screen_rect(Point2i(), size); - float font_oversampling = 1.0; + double font_oversampling = 1.0; window_transform = Transform2D(); if (content_scale_stretch == Window::CONTENT_SCALE_STRETCH_INTEGER) { @@ -1215,7 +1215,7 @@ void Window::_update_viewport_size() { } bool allocate = is_inside_tree() && visible && (window_id != DisplayServer::INVALID_WINDOW_ID || embedder != nullptr); - _set_size(final_size, final_size_override, allocate); + bool ci_updated = _set_size(final_size, final_size_override, allocate); if (window_id != DisplayServer::INVALID_WINDOW_ID) { RenderingServer::get_singleton()->viewport_attach_to_screen(get_viewport_rid(), attach_to_screen_rect, window_id); @@ -1227,11 +1227,16 @@ void Window::_update_viewport_size() { if (!use_font_oversampling) { font_oversampling = 1.0; } - if (TS->font_get_global_oversampling() != font_oversampling) { + if (!Math::is_equal_approx(TS->font_get_global_oversampling(), font_oversampling)) { TS->font_set_global_oversampling(font_oversampling); + ci_updated = false; } } + if (!ci_updated) { + update_canvas_items(); + } + notification(NOTIFICATION_WM_SIZE_CHANGED); if (embedder) {