Fix blurred content of embedded windows

This commit is contained in:
scgm0 2024-10-03 01:10:42 +08:00
parent b3bcb2dc14
commit 4c481a35b8
2 changed files with 9 additions and 6 deletions

View file

@ -127,7 +127,7 @@ int ViewportTexture::get_width() const {
_err_print_viewport_not_set();
return 0;
}
return vp->size.width;
return get_size().width;
}
int ViewportTexture::get_height() const {
@ -135,7 +135,7 @@ int ViewportTexture::get_height() const {
_err_print_viewport_not_set();
return 0;
}
return vp->size.height;
return get_size().height;
}
Size2 ViewportTexture::get_size() const {
@ -143,7 +143,7 @@ Size2 ViewportTexture::get_size() const {
_err_print_viewport_not_set();
return Size2();
}
return vp->size;
return Size2(vp->size * vp->get_screen_transform().get_scale()).ceil();
}
RID ViewportTexture::get_rid() const {
@ -313,10 +313,8 @@ void Viewport::_sub_window_update(Window *p_window) {
SubWindow &sw = gui.sub_windows.write[index];
sw.pending_window_update = false;
Transform2D pos;
pos.set_origin(p_window->get_position());
RS::get_singleton()->canvas_item_clear(sw.canvas_item);
Rect2i r = Rect2i(p_window->get_position(), sw.window->get_size());
Rect2i r = Rect2i(p_window->get_position(), p_window->get_size());
if (!p_window->get_flag(Window::FLAG_BORDERLESS)) {
Ref<StyleBox> panel = gui.subwindow_focused == p_window ? p_window->theme_cache.embedded_border : p_window->theme_cache.embedded_unfocused_border;
@ -980,6 +978,7 @@ void Viewport::update_canvas_items() {
for (Viewport::SubWindow w : gui.sub_windows) {
if (w.window && !w.pending_window_update) {
w.pending_window_update = true;
w.window->_update_viewport_size();
callable_mp(this, &Viewport::_sub_window_update).call_deferred(w.window);
}
}

View file

@ -1231,6 +1231,10 @@ void Window::_update_viewport_size() {
notification(NOTIFICATION_WM_SIZE_CHANGED);
if (embedder) {
float scale = MIN(embedder->stretch_transform.get_scale().width, embedder->stretch_transform.get_scale().height);
Size2 s = Size2(final_size.width * scale, final_size.height * scale).ceil();
RS::get_singleton()->viewport_set_global_canvas_transform(get_viewport_rid(), global_canvas_transform * scale * content_scale_factor);
RS::get_singleton()->viewport_set_size(get_viewport_rid(), s.width, s.height);
embedder->_sub_window_update(this);
}
}