Force canvas item update on oversampling change.

This commit is contained in:
bruvzg 2024-06-03 19:46:49 +03:00
parent 0d11108a01
commit 9fb9660912
No known key found for this signature in database
GPG key ID: 7960FCF39844EC38
3 changed files with 12 additions and 6 deletions

View file

@ -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 {

View file

@ -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;

View file

@ -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) {