Optimization: do not regenerate toolbar texture in each frame

This commit is contained in:
Lukas Matena 2022-12-05 22:10:33 +01:00 committed by enricoturri1966
parent 05ee2a06ff
commit b037e5f024

View File

@ -5653,9 +5653,9 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale()
collapse_toolbar.set_scale(sc); collapse_toolbar.set_scale(sc);
size *= m_retina_helper->get_scale_factor(); size *= m_retina_helper->get_scale_factor();
#else #else
m_main_toolbar.set_icons_size(size); m_main_toolbar.set_icons_size(int(size));
m_undoredo_toolbar.set_icons_size(size); m_undoredo_toolbar.set_icons_size(int(size));
collapse_toolbar.set_icons_size(size); collapse_toolbar.set_icons_size(int(size));
#endif // ENABLE_RETINA_GL #endif // ENABLE_RETINA_GL
float top_tb_width = m_main_toolbar.get_width() + m_undoredo_toolbar.get_width() + collapse_toolbar.get_width(); 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)); 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(); _check_and_update_toolbar_icon_scale();
_render_gizmos_overlay(); _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_main_toolbar();
_render_undoredo_toolbar(); _render_undoredo_toolbar();
_render_collapse_toolbar(); _render_collapse_toolbar();