comparison src/popupwin.c @ 17843:9696c76f2213 v8.1.1918

patch 8.1.1918: redrawing popups is inefficient Commit: https://github.com/vim/vim/commit/e9a891f2559f0ef73596bce025e06bc36b092cbb Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 24 15:26:24 2019 +0200 patch 8.1.1918: redrawing popups is inefficient Problem: Redrawing popups is inefficient. Solution: Fix the logic to compute what window lines to redraw. Make it work below the last line. Remove redrawing all windows.
author Bram Moolenaar <Bram@vim.org>
date Sat, 24 Aug 2019 15:30:04 +0200
parents 9513821d9d8f
children b6acc24df7de
comparison
equal deleted inserted replaced
17842:594174882d61 17843:9696c76f2213
1226 || org_leftoff != wp->w_popup_leftoff 1226 || org_leftoff != wp->w_popup_leftoff
1227 || org_width != wp->w_width 1227 || org_width != wp->w_width
1228 || org_height != wp->w_height) 1228 || org_height != wp->w_height)
1229 { 1229 {
1230 redraw_win_later(wp, NOT_VALID); 1230 redraw_win_later(wp, NOT_VALID);
1231 redraw_all_later(SOME_VALID);
1232 status_redraw_all();
1233 if (wp->w_popup_flags & POPF_ON_CMDLINE) 1231 if (wp->w_popup_flags & POPF_ON_CMDLINE)
1234 clear_cmdline = TRUE; 1232 clear_cmdline = TRUE;
1235 popup_mask_refresh = TRUE; 1233 popup_mask_refresh = TRUE;
1236 } 1234 }
1237 } 1235 }
2814 may_update_popup_mask(int type) 2812 may_update_popup_mask(int type)
2815 { 2813 {
2816 win_T *wp; 2814 win_T *wp;
2817 short *mask; 2815 short *mask;
2818 int line, col; 2816 int line, col;
2819 int redraw_all = FALSE; 2817 int redraw_all_popups = FALSE;
2818 int redrawing_all_win;
2820 2819
2821 // Need to recompute when switching tabs. 2820 // Need to recompute when switching tabs.
2822 // Also recompute when the type is CLEAR or NOT_VALID, something basic 2821 // Also recompute when the type is CLEAR or NOT_VALID, something basic
2823 // (such as the screen size) must have changed. 2822 // (such as the screen size) must have changed.
2824 if (popup_mask_tab != curtab || type >= NOT_VALID) 2823 if (popup_mask_tab != curtab || type >= NOT_VALID)
2825 { 2824 {
2826 popup_mask_refresh = TRUE; 2825 popup_mask_refresh = TRUE;
2827 redraw_all = TRUE; 2826 redraw_all_popups = TRUE;
2828 } 2827 }
2829 if (!popup_mask_refresh) 2828 if (!popup_mask_refresh)
2830 { 2829 {
2831 // Check if any buffer has changed. 2830 // Check if any popup window buffer has changed.
2832 for (wp = first_popupwin; wp != NULL; wp = wp->w_next) 2831 for (wp = first_popupwin; wp != NULL; wp = wp->w_next)
2833 if (wp->w_popup_last_changedtick != CHANGEDTICK(wp->w_buffer)) 2832 if (wp->w_popup_last_changedtick != CHANGEDTICK(wp->w_buffer))
2834 popup_mask_refresh = TRUE; 2833 popup_mask_refresh = TRUE;
2835 for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next) 2834 for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next)
2836 if (wp->w_popup_last_changedtick != CHANGEDTICK(wp->w_buffer)) 2835 if (wp->w_popup_last_changedtick != CHANGEDTICK(wp->w_buffer))
2842 // Need to update the mask, something has changed. 2841 // Need to update the mask, something has changed.
2843 popup_mask_refresh = FALSE; 2842 popup_mask_refresh = FALSE;
2844 popup_mask_tab = curtab; 2843 popup_mask_tab = curtab;
2845 popup_visible = FALSE; 2844 popup_visible = FALSE;
2846 2845
2847 // If redrawing everything, just update "popup_mask". 2846 // If redrawing all windows, just update "popup_mask".
2848 // If redrawing only what is needed, update "popup_mask_next" and then 2847 // If redrawing only what is needed, update "popup_mask_next" and then
2849 // compare with "popup_mask" to see what changed. 2848 // compare with "popup_mask" to see what changed.
2850 if (type >= SOME_VALID) 2849 redrawing_all_win = TRUE;
2850 FOR_ALL_WINDOWS(wp)
2851 if (wp->w_redr_type < SOME_VALID)
2852 redrawing_all_win = FALSE;
2853 if (redrawing_all_win)
2851 mask = popup_mask; 2854 mask = popup_mask;
2852 else 2855 else
2853 mask = popup_mask_next; 2856 mask = popup_mask_next;
2854 vim_memset(mask, 0, screen_Rows * screen_Columns * sizeof(short)); 2857 vim_memset(mask, 0, screen_Rows * screen_Columns * sizeof(short));
2855 2858
2863 int height; 2866 int height;
2864 2867
2865 popup_visible = TRUE; 2868 popup_visible = TRUE;
2866 2869
2867 // Recompute the position if the text changed. 2870 // Recompute the position if the text changed.
2868 if (redraw_all 2871 if (redraw_all_popups
2869 || wp->w_popup_last_changedtick != CHANGEDTICK(wp->w_buffer)) 2872 || wp->w_popup_last_changedtick != CHANGEDTICK(wp->w_buffer))
2870 popup_adjust_position(wp); 2873 popup_adjust_position(wp);
2871 2874
2872 width = popup_width(wp); 2875 width = popup_width(wp);
2873 height = popup_height(wp); 2876 height = popup_height(wp);
2928 } 2931 }
2929 2932
2930 if (line_cp >= wp->w_height) 2933 if (line_cp >= wp->w_height)
2931 // In (or below) status line 2934 // In (or below) status line
2932 wp->w_redr_status = TRUE; 2935 wp->w_redr_status = TRUE;
2933 // compute the position in the buffer line from the
2934 // position on the screen
2935 else if (mouse_comp_pos(wp, &line_cp, &col_cp,
2936 &lnum, plines_cache))
2937 // past bottom
2938 wp->w_redr_status = TRUE;
2939 else 2936 else
2937 {
2938 // compute the position in the buffer line from
2939 // the position in the window
2940 mouse_comp_pos(wp, &line_cp, &col_cp,
2941 &lnum, plines_cache);
2940 redrawWinline(wp, lnum); 2942 redrawWinline(wp, lnum);
2943 }
2941 2944
2942 // This line is going to be redrawn, no need to 2945 // This line is going to be redrawn, no need to
2943 // check until the right side of the window. 2946 // check until the right side of the window.
2944 col_done = wp->w_wincol + wp->w_width - 1; 2947 col_done = wp->w_wincol + wp->w_width - 1;
2945 } 2948 }