comparison src/dispnew.c @ 34849:eac70be4cb58

(save_frame_matrix, restore_frame_matrix): Removed. (save_or_restore_current_matrix): New function for the same purpose, but more efficient. (adjust_frame_glyphs_for_frame_redisplay): Use it.
author Gerd Moellmann <gerd@gnu.org>
date Sat, 23 Dec 2000 17:22:22 +0000
parents 9512f05b60d1
children 4f47fc699608
comparison
equal deleted inserted replaced
34848:7be9f74cb2f4 34849:eac70be4cb58
118 }; 118 };
119 119
120 120
121 /* Function prototypes. */ 121 /* Function prototypes. */
122 122
123 static struct glyph_matrix *save_frame_matrix P_ ((struct glyph_matrix *)); 123 static void save_or_restore_current_matrix P_ ((struct frame *, int));
124 static void restore_frame_matrix P_ ((struct glyph_matrix *, struct glyph_matrix *));
125 static void fake_current_matrices P_ ((Lisp_Object)); 124 static void fake_current_matrices P_ ((Lisp_Object));
126 static void redraw_overlapping_rows P_ ((struct window *, int)); 125 static void redraw_overlapping_rows P_ ((struct window *, int));
127 static void redraw_overlapped_rows P_ ((struct window *, int)); 126 static void redraw_overlapped_rows P_ ((struct window *, int));
128 static int count_blanks P_ ((struct glyph *, int)); 127 static int count_blanks P_ ((struct glyph *, int));
129 static int count_match P_ ((struct glyph *, struct glyph *, 128 static int count_match P_ ((struct glyph *, struct glyph *,
2054 } 2053 }
2055 } 2054 }
2056 } 2055 }
2057 2056
2058 2057
2059 /* Return a glyph matrix that holds of copy of the glyph contents 2058 /* Save or restore the contents of frame F's current frame matrix.
2060 of frame matrix M. */ 2059 SAVE_P non-zero means save it. */
2061
2062 static struct glyph_matrix *
2063 save_frame_matrix (m)
2064 struct glyph_matrix *m;
2065 {
2066 struct glyph_matrix *copy;
2067 int i;
2068
2069 copy = (struct glyph_matrix *) xmalloc (sizeof *copy);
2070 *copy = *m;
2071 copy->rows = (struct glyph_row *) xmalloc (m->nrows * sizeof (*copy->rows));
2072
2073 for (i = 0; i < copy->nrows; ++i)
2074 {
2075 struct glyph_row *from = m->rows + i;
2076 struct glyph_row *to = copy->rows + i;
2077 size_t nbytes = from->used[TEXT_AREA] * sizeof (struct glyph);
2078 to->glyphs[TEXT_AREA] = (struct glyph *) xmalloc (nbytes);
2079 bcopy (from->glyphs[TEXT_AREA], to->glyphs[TEXT_AREA], nbytes);
2080 to->used[TEXT_AREA] = from->used[TEXT_AREA];
2081 }
2082
2083 return copy;
2084 }
2085
2086
2087 /* Restore the glyph contents of frame matrix M from the copy COPY,
2088 made by save_frame_matrix. Free memory allocated for COPY. */
2089 2060
2090 static void 2061 static void
2091 restore_frame_matrix (m, copy) 2062 save_or_restore_current_matrix (f, save_p)
2092 struct glyph_matrix *m, *copy; 2063 struct frame *f;
2093 { 2064 int save_p;
2094 int i; 2065 {
2095 2066 struct glyph_row *from, *to, *end;
2096 for (i = 0; i < copy->nrows; ++i) 2067
2097 { 2068 if (save_p)
2098 struct glyph_row *from = copy->rows + i; 2069 {
2099 struct glyph_row *to = m->rows + i; 2070 from = f->current_matrix->rows;
2071 end = from + f->current_matrix->nrows;
2072 to = f->desired_matrix->rows;
2073 }
2074 else
2075 {
2076 from = f->desired_matrix->rows;
2077 end = from + f->desired_matrix->nrows;
2078 to = f->current_matrix->rows;
2079 }
2080
2081 for (; from < end; ++from, ++to)
2082 {
2100 size_t nbytes = from->used[TEXT_AREA] * sizeof (struct glyph); 2083 size_t nbytes = from->used[TEXT_AREA] * sizeof (struct glyph);
2101 bcopy (from->glyphs[TEXT_AREA], to->glyphs[TEXT_AREA], nbytes); 2084 bcopy (from->glyphs[TEXT_AREA], to->glyphs[TEXT_AREA], nbytes);
2102 to->used[TEXT_AREA] = from->used[TEXT_AREA]; 2085 to->used[TEXT_AREA] = from->used[TEXT_AREA];
2103 xfree (from->glyphs[TEXT_AREA]); 2086 }
2104 }
2105
2106 xfree (copy->rows);
2107 xfree (copy);
2108 } 2087 }
2109 2088
2110 2089
2111 /* Allocate/reallocate glyph matrices of a single frame F for 2090 /* Allocate/reallocate glyph matrices of a single frame F for
2112 frame-based redisplay. */ 2091 frame-based redisplay. */
2194 if (display_completed 2173 if (display_completed
2195 && !FRAME_GARBAGED_P (f) 2174 && !FRAME_GARBAGED_P (f)
2196 && matrix_dim.width == f->current_matrix->matrix_w 2175 && matrix_dim.width == f->current_matrix->matrix_w
2197 && matrix_dim.height == f->current_matrix->matrix_h) 2176 && matrix_dim.height == f->current_matrix->matrix_h)
2198 { 2177 {
2199 struct glyph_matrix *saved = save_frame_matrix (f->current_matrix); 2178 save_or_restore_current_matrix (f, 1);
2200 adjust_glyph_matrix (NULL, f->current_matrix, 0, 0, matrix_dim); 2179 adjust_glyph_matrix (NULL, f->current_matrix, 0, 0, matrix_dim);
2201 restore_frame_matrix (f->current_matrix, saved); 2180 save_or_restore_current_matrix (f, 0);
2202 fake_current_matrices (FRAME_ROOT_WINDOW (f)); 2181 fake_current_matrices (FRAME_ROOT_WINDOW (f));
2203 } 2182 }
2204 else 2183 else
2205 { 2184 {
2206 adjust_glyph_matrix (NULL, f->current_matrix, 0, 0, matrix_dim); 2185 adjust_glyph_matrix (NULL, f->current_matrix, 0, 0, matrix_dim);