From b037e5f024d1c6e7dea90daf4f8e31b95117d5ae Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 5 Dec 2022 22:10:33 +0100 Subject: [PATCH] Optimization: do not regenerate toolbar texture in each frame --- src/slic3r/GUI/GLCanvas3D.cpp | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 79370022b..b7988ea7c 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -5653,9 +5653,9 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale() collapse_toolbar.set_scale(sc); size *= m_retina_helper->get_scale_factor(); #else - m_main_toolbar.set_icons_size(size); - m_undoredo_toolbar.set_icons_size(size); - collapse_toolbar.set_icons_size(size); + m_main_toolbar.set_icons_size(int(size)); + m_undoredo_toolbar.set_icons_size(int(size)); + collapse_toolbar.set_icons_size(int(size)); #endif // ENABLE_RETINA_GL float top_tb_width = m_main_toolbar.get_width() + m_undoredo_toolbar.get_width() + collapse_toolbar.get_width(); @@ -5687,24 +5687,12 @@ void GLCanvas3D::_render_overlays() { glsafe(::glDisable(GL_DEPTH_TEST)); + // main toolbar and undoredo toolbar need to be both updated before rendering because both their sizes are needed + // to correctly place them _check_and_update_toolbar_icon_scale(); _render_gizmos_overlay(); - // main toolbar and undoredo toolbar need to be both updated before rendering because both their sizes are needed - // to correctly place them -#if ENABLE_RETINA_GL - const float scale = m_retina_helper->get_scale_factor() * wxGetApp().toolbar_icon_scale(/*true*/); - m_main_toolbar.set_scale(scale); - m_undoredo_toolbar.set_scale(scale); - wxGetApp().plater()->get_collapse_toolbar().set_scale(scale); -#else - const float size = int(GLToolbar::Default_Icons_Size * wxGetApp().toolbar_icon_scale(/*true*/)); - m_main_toolbar.set_icons_size(size); - m_undoredo_toolbar.set_icons_size(size); - wxGetApp().plater()->get_collapse_toolbar().set_icons_size(size); -#endif // ENABLE_RETINA_GL - _render_main_toolbar(); _render_undoredo_toolbar(); _render_collapse_toolbar();