Skip to content

Commit

Permalink
Merge pull request #92731 from bruvzg/vp_oversmpling_upd
Browse files Browse the repository at this point in the history
Force canvas item update on oversampling change.
  • Loading branch information
akien-mga committed Jun 4, 2024
2 parents 2f26842 + 9fb9660 commit 241d45d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
5 changes: 3 additions & 2 deletions scene/main/viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion scene/main/viewport.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ class Viewport : public Node {
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;
Expand Down
11 changes: 8 additions & 3 deletions scene/main/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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) {
Expand Down

0 comments on commit 241d45d

Please sign in to comment.