Skip to content

Commit

Permalink
Fix blurred content of embedded windows
Browse files Browse the repository at this point in the history
  • Loading branch information
scgm0 committed Oct 2, 2024
1 parent f4af820 commit 7646cfa
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions scene/main/viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,23 +127,23 @@ int ViewportTexture::get_width() const {
_err_print_viewport_not_set();
return 0;
}
return vp->size.width;
return vp->get_visible_rect().size.width * vp->get_screen_transform().get_scale().width;
}

int ViewportTexture::get_height() const {
if (!vp) {
_err_print_viewport_not_set();
return 0;
}
return vp->size.height;
return vp->get_visible_rect().size.height * vp->get_screen_transform().get_scale().height;
}

Size2 ViewportTexture::get_size() const {
if (!vp) {
_err_print_viewport_not_set();
return Size2();
}
return vp->size;
return vp->get_visible_rect().size * vp->get_screen_transform().get_scale();
}

RID ViewportTexture::get_rid() const {
Expand Down Expand Up @@ -313,10 +313,14 @@ 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());
int scale = MIN(stretch_transform.get_scale().width, stretch_transform.get_scale().height);
Transform2D t = p_window->global_canvas_transform * scale;
Size2i s = p_window->get_size() * scale;
Rect2i r = Rect2i(p_window->get_position(), p_window->get_size());

RS::get_singleton()->canvas_item_clear(sw.canvas_item);
Rect2i r = Rect2i(p_window->get_position(), sw.window->get_size());
RS::get_singleton()->viewport_set_global_canvas_transform(p_window->get_viewport_rid(), t);
RS::get_singleton()->viewport_set_size(p_window->get_viewport_rid(), s.width, s.height);

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;
Expand Down

0 comments on commit 7646cfa

Please sign in to comment.