@@ -3702,10 +3702,23 @@ static void ozone_draw_sidebar(
37023702
37033703 for (i = 0 ; i < horizontal_list_size ; i ++ )
37043704 {
3705+ float tab_y_screen ;
37053706 ozone_node_t * node = (ozone_node_t * )ozone -> horizontal_list .list [i ].userdata ;
37063707 float * col = NULL ;
37073708 bool selected = (ozone -> categories_selection_ptr == ozone -> system_tab_end + 1 + i );
37083709 uint32_t text_color = 0 ;
3710+
3711+ /* Cull off-screen sidebar entries */
3712+ tab_y_screen = y + ozone -> animations .scroll_y_sidebar ;
3713+ if (tab_y_screen + ozone -> dimensions .sidebar_entry_height < ozone -> dimensions .header_height )
3714+ goto console_iterate ;
3715+ if (tab_y_screen > (int )video_height - (int )ozone -> dimensions .footer_height )
3716+ {
3717+ /* All remaining entries are also below visible area */
3718+ y += (horizontal_list_size - i ) * (ozone -> dimensions .sidebar_entry_height + ozone -> dimensions .sidebar_entry_padding_vertical );
3719+ break ;
3720+ }
3721+
37093722 if (ozone -> theme )
37103723 text_color = COLOR_TEXT_ALPHA ((selected
37113724 ? ozone -> theme -> text_selected_rgba
@@ -5662,33 +5675,49 @@ static void ozone_compute_entries_position(ozone_handle_t *ozone,
56625675 menu_entry_t entry ;
56635676 ozone_node_t * node = NULL ;
56645677
5665- MENU_ENTRY_INITIALIZE ( entry );
5666- entry . flags |= MENU_ENTRY_FLAG_SUBLABEL_ENABLED ;
5667- menu_entry_get ( & entry , 0 , ( unsigned ) i , NULL , true) ;
5678+ /* Cache node first - if missing, skip without expensive menu_entry_get */
5679+ if (!( node = ( ozone_node_t * ) selection_buf -> list [ i ]. userdata ))
5680+ continue ;
56685681
5669- /* Empty playlist detection:
5670- only one item which icon is
5671- OZONE_ENTRIES_ICONS_TEXTURE_CORE_INFO */
5682+ node -> height = ozone -> dimensions .entry_height ;
5683+ node -> wrap = false;
5684+ node -> sublabel_lines = 0 ;
5685+
5686+ /* Empty playlist detection only needed when there is exactly one entry
5687+ * in a playlist - avoid the full entry fetch otherwise */
56725688 if ( (ozone -> flags & OZONE_FLAG_IS_PLAYLIST )
56735689 && (entries_end == 1 ))
56745690 {
5675- uintptr_t tex = ozone_entries_icon_get_texture (ozone ,
5691+ uintptr_t tex ;
5692+ MENU_ENTRY_INITIALIZE (entry );
5693+ entry .flags |= MENU_ENTRY_FLAG_SUBLABEL_ENABLED ;
5694+ menu_entry_get (& entry , 0 , (unsigned )i , NULL , true);
5695+
5696+ tex = ozone_entries_icon_get_texture (ozone ,
56765697 entry .enum_idx , entry .path , entry .label , entry .type , false);
56775698 if (tex == ozone -> icons_textures [OZONE_ENTRIES_ICONS_TEXTURE_CORE_INFO ])
56785699 ozone -> flags |= OZONE_FLAG_EMPTY_PLAYLIST ;
56795700 else
56805701 ozone -> flags &= ~OZONE_FLAG_EMPTY_PLAYLIST ;
56815702 }
56825703 else
5704+ {
56835705 ozone -> flags &= ~OZONE_FLAG_EMPTY_PLAYLIST ;
56845706
5685- /* Cache node */
5686- if (!(node = (ozone_node_t * )selection_buf -> list [i ].userdata ))
5707+ if (menu_show_sublabels )
5708+ {
5709+ MENU_ENTRY_INITIALIZE (entry );
5710+ entry .flags |= MENU_ENTRY_FLAG_SUBLABEL_ENABLED ;
5711+ menu_entry_get (& entry , 0 , (unsigned )i , NULL , true);
5712+ goto compute_sublabel ;
5713+ }
5714+
5715+ node -> position_y = ozone -> entries_height ;
5716+ ozone -> entries_height += node -> height ;
56875717 continue ;
5718+ }
56885719
5689- node -> height = ozone -> dimensions .entry_height ;
5690- node -> wrap = false;
5691- node -> sublabel_lines = 0 ;
5720+ compute_sublabel :
56925721
56935722 if (menu_show_sublabels )
56945723 {
@@ -5802,6 +5831,8 @@ static void ozone_draw_entries(
58025831 alpha_uint32 = (uint32_t )(alpha * 255.0f );
58035832
58045833 /* Borders layer */
5834+ /* Cache alpha to avoid redundant set_alpha calls each entry */
5835+ float last_border_alpha = -1.0f ;
58055836 for (i = 0 ; i < entries_end ; i ++ )
58065837 {
58075838 bool entry_selected = selection == i ;
@@ -5825,13 +5856,22 @@ static void ozone_draw_entries(
58255856 if (y + scroll_y + node -> height + 20 * scale_factor < ozone -> dimensions .header_height + ozone -> dimensions .entry_padding_vertical )
58265857 goto border_iterate ;
58275858 else if (y + scroll_y - node -> height - 20 * scale_factor > bottom_boundary )
5828- goto border_iterate ;
5859+ {
5860+ /* All remaining entries are also below the boundary - stop iterating */
5861+ if (node )
5862+ y += node -> height ;
5863+ break ;
5864+ }
58295865
58305866 border_start_x = (unsigned )ozone -> dimensions_sidebar_width + x_offset + entry_padding ;
58315867 border_start_y = y + scroll_y ;
58325868
5833- gfx_display_set_alpha (ozone -> theme_dynamic .entries_border , alpha );
5834- gfx_display_set_alpha (ozone -> theme_dynamic .entries_checkmark , alpha );
5869+ if (alpha != last_border_alpha )
5870+ {
5871+ gfx_display_set_alpha (ozone -> theme_dynamic .entries_border , alpha );
5872+ gfx_display_set_alpha (ozone -> theme_dynamic .entries_checkmark , alpha );
5873+ last_border_alpha = alpha ;
5874+ }
58355875
58365876 /* Borders */
58375877 gfx_display_draw_quad (
@@ -5956,8 +5996,8 @@ static void ozone_draw_entries(
59565996 }
59575997 else if (y + scroll_y - node -> height - 20 * scale_factor > bottom_boundary )
59585998 {
5959- y += node -> height ;
5960- continue ;
5999+ /* All remaining entries are also below the boundary - stop iterating */
6000+ break ;
59616001 }
59626002
59636003 entry_selected = selection == i ;
0 commit comments