1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

Correctly cache images when frames vary in their font metrics

* src/alloc.c (mark_frame): Mark this frame's image cache, if it
exist.
(mark_terminals): Cease marking T->image_cache.

* src/androidfns.c (unwind_create_frame, Fx_create_frame)
(android_create_tip_frame):

* src/haikufns.c (unwind_create_frame, haiku_create_frame)
(haiku_create_tip_frame):

* src/nsfns.m (unwind_create_frame):

* src/pgtkfns.c (unwind_create_frame, Fx_create_frame)
(x_create_tip_frame):

* src/xfns.c (unwind_create_frame, Fx_create_frame)
(x_create_tip_frame):

* src/w32fns.c (unwind_create_frame, Fx_create_frame)
(w32_create_tip_frame): Remove adjustments of the frame image
cache's reference count rendered redundant by the assignment of
image caches to individual frames rather than terminals.

* src/dispextern.h (struct image_cache) <scaling_col_width>: New
field.

* src/frame.c (gui_set_font): In lieu of clearing F's image
cache unconditionally, establish whether the column width as
considered by compute_image_size has changed, and if so, adjust
or reassign the frame's image cache.
(make_frame): Clear F->image_cache.

* src/frame.h (struct frame) <image_cache>: New field.
(FRAME_IMAGE_CACHE): Return F->image_cache.

* src/image.c (make_image_cache): Clear C->scaling_col_width.
(cache_image): Adjust to new means of assigning image caches to
frames.

* src/termhooks.h (struct terminal) <image_cache>: Delete field.

* src/xfaces.c (init_frame_faces): Do image cache assignment
with all new frames.
This commit is contained in:
Po Lu 2024-06-20 17:03:36 +08:00
parent 374f4235d5
commit cebca072c3
13 changed files with 92 additions and 160 deletions

View file

@ -32,9 +32,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#ifndef ANDROID_STUBIFY
/* Some kind of reference count for the image cache. */
static ptrdiff_t image_cache_refcount;
/* The frame of the currently visible tooltip, or nil if none. */
static Lisp_Object tip_frame;
@ -654,17 +651,6 @@ unwind_create_frame (Lisp_Object frame)
/* If frame is ``official'', nothing to do. */
if (NILP (Fmemq (frame, Vframe_list)))
{
/* If the frame's image cache refcount is still the same as our
private shadow variable, it means we are unwinding a frame
for which we didn't yet call init_frame_faces, where the
refcount is incremented. Therefore, we increment it here, so
that free_frame_faces, called in x_free_frame_resources
below, will not mistakenly decrement the counter that was not
incremented yet to account for this new frame. */
if (FRAME_IMAGE_CACHE (f) != NULL
&& FRAME_IMAGE_CACHE (f)->refcount == image_cache_refcount)
FRAME_IMAGE_CACHE (f)->refcount++;
android_free_frame_resources (f);
free_glyphs (f);
return Qt;
@ -944,10 +930,6 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
register_font_driver (&androidfont_driver, f);
register_font_driver (&android_sfntfont_driver, f);
image_cache_refcount = (FRAME_IMAGE_CACHE (f)
? FRAME_IMAGE_CACHE (f)->refcount
: 0);
gui_default_parameter (f, parms, Qfont_backend, Qnil,
"fontBackend", "FontBackend", RES_TYPE_STRING);
@ -2023,9 +2005,6 @@ android_create_tip_frame (struct android_display_info *dpyinfo,
register_font_driver (&androidfont_driver, f);
register_font_driver (&android_sfntfont_driver, f);
image_cache_refcount
= FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0;
gui_default_parameter (f, parms, Qfont_backend, Qnil,
"fontBackend", "FontBackend", RES_TYPE_STRING);