From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Manuel Giraud via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#68006: 30.0.50; Image-mode speed Date: Sat, 06 Jan 2024 14:07:37 +0100 Message-ID: <87a5pid2zq.fsf@ledu-giraud.fr> References: <87le9jlfd6.fsf@ledu-giraud.fr> <83mstt5hrk.fsf@gnu.org> <87frzjvpb5.fsf@ledu-giraud.fr> <83le9a3kqs.fsf@gnu.org> <83zfxnzyrb.fsf@gnu.org> <87mstnafie.fsf@ledu-giraud.fr> <83r0izzn1p.fsf@gnu.org> <87le95rqoh.fsf@ledu-giraud.fr> <83plyhvvso.fsf@gnu.org> <87h6jtrlci.fsf@ledu-giraud.fr> <83jzopvsgj.fsf@gnu.org> <87bka0hpto.fsf@ledu-giraud.fr> <83il48x4a8.fsf@gnu.org> <875y08gikv.fsf@ledu-giraud.fr> <831qawvx7q.fsf@gnu.org> <871qavhpxf.fsf@ledu-giraud.fr> <83edevvqyj.fsf@gnu.org> <87v887g85d.fsf@ledu-giraud.fr> <83a5pjvo3s.fsf@gnu.org> Reply-To: Manuel Giraud Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21645"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: stefankangas@gmail.com, 68006@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 06 14:08:04 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rM6PD-0005OG-NX for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 06 Jan 2024 14:08:03 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rM6P8-0003Gv-Oz; Sat, 06 Jan 2024 08:07:58 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rM6P7-0003Gl-DA for bug-gnu-emacs@gnu.org; Sat, 06 Jan 2024 08:07:57 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rM6P7-0003B2-4j for bug-gnu-emacs@gnu.org; Sat, 06 Jan 2024 08:07:57 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rM6PB-00052f-O0 for bug-gnu-emacs@gnu.org; Sat, 06 Jan 2024 08:08:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Manuel Giraud Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 06 Jan 2024 13:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68006 X-GNU-PR-Package: emacs Original-Received: via spool by 68006-submit@debbugs.gnu.org id=B68006.170454647019358 (code B ref 68006); Sat, 06 Jan 2024 13:08:01 +0000 Original-Received: (at 68006) by debbugs.gnu.org; 6 Jan 2024 13:07:50 +0000 Original-Received: from localhost ([127.0.0.1]:58796 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rM6Oz-00052A-RG for submit@debbugs.gnu.org; Sat, 06 Jan 2024 08:07:50 -0500 Original-Received: from ledu-giraud.fr ([51.159.28.247]:37099) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rM6Ow-000520-CO for 68006@debbugs.gnu.org; Sat, 06 Jan 2024 08:07:48 -0500 DKIM-Signature: v=1; a=ed25519-sha256; c=simple/simple; s=ed25519; bh=1IfwkwgZ VJETuKGxa8APc0L9Q2tMahpnURz3xcU8IOo=; h=date:references:in-reply-to: subject:cc:to:from; d=ledu-giraud.fr; b=k3VUWy7LVxjIJ6mhojOeC5zf/+8R0B ihiuUiyENdf5Ri8vWBZkie9d4+lRAXU4om3aG6mtRq9IIIDP7ywJKnDw== DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=rsa; bh=1IfwkwgZVJETuKGx a8APc0L9Q2tMahpnURz3xcU8IOo=; h=date:references:in-reply-to:subject: cc:to:from; d=ledu-giraud.fr; b=bLGtgFfjWmRm3m/fB8oWzNGAtOdJoaRRKEiBFJ 35UzuCLeasunOG6Xx8FN7GSpgX+VC7PUznxLzwiRUbne1E6HQvG+mJixgor8mo9BVWbpgF +GlAgs6x1zeD6Y38XFnoSMtceL5natiuRCUQaTyiVAWPEpXLrVGvmmZ4ZuYS4RTCpbZ05O RVeXkIbc3dPp4l7vABXytTPb6JZCb1yTwvGCORBGQ2nwnMiHjrHqsLc6mJQDtfYvwDcZOj hzJmI1rSwxo3/R0/r5YGuNjdfQ3SF1f96UiFdR0pKZ9X1JUJoIiLssdYbEXFB/+A28cwvO J3KAZmygA5plAvzpPt4IpuRQ== Original-Received: from computer ( [10.1.1.1]) by ledu-giraud.fr (OpenSMTPD) with ESMTPSA id 9842ea9d (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sat, 6 Jan 2024 14:07:39 +0100 (CET) In-Reply-To: <83a5pjvo3s.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 05 Jan 2024 16:41:59 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:277461 Archived-At: Hi, Here is a diff of where I'm headed to. 'user-image-cache' is not used at all yet. I imagine that a user could fill it with a call to 'make-image-cache' (when it exists). Anyway, WDYT? diff --git a/src/image.c b/src/image.c index 252b83da992..27d564fb49c 100644 --- a/src/image.c +++ b/src/image.c @@ -2086,7 +2086,7 @@ image_alloc_image_color (struct frame *f, struct image *img, Image Cache ***********************************************************************/ -static void cache_image (struct frame *f, struct image *img); +static void cache_image (struct image_cache **pc, struct image *img); /* Return a new, initialized image cache that is allocated from the heap. Call free_image_cache to free an image cache. */ @@ -2103,15 +2103,14 @@ make_image_cache (void) return c; } -/* Find an image matching SPEC in the cache, and return it. If no +/* Find an image matching SPEC in the cache C, and return it. If no image is found, return NULL. */ static struct image * -search_image_cache (struct frame *f, Lisp_Object spec, EMACS_UINT hash, +search_image_cache (struct image_cache *c, Lisp_Object spec, EMACS_UINT hash, unsigned long foreground, unsigned long background, int font_size, char *font_family, bool ignore_colors) { struct image *img; - struct image_cache *c = FRAME_IMAGE_CACHE (f); int i = hash % IMAGE_CACHE_BUCKETS_SIZE; if (!c) return NULL; @@ -2185,12 +2184,13 @@ uncache_image (struct frame *f, Lisp_Object spec) { struct image *img; EMACS_UINT hash = sxhash (filter_image_spec (spec)); + struct image_cache *cache = FRAME_IMAGE_CACHE (f); /* Because the background colors are based on the current face, we can have multiple copies of an image with the same spec. We want to remove them all to ensure the user doesn't see an old version of the image when the face changes. */ - while ((img = search_image_cache (f, spec, hash, 0, 0, 0, NULL, true))) + while ((img = search_image_cache (cache, spec, hash, 0, 0, 0, NULL, true))) { free_image (f, img); /* As display glyphs may still be referring to the image ID, we @@ -3359,6 +3359,7 @@ lookup_image (struct frame *f, Lisp_Object spec, int face_id) unsigned long background = face->background; int font_size = face->font->pixel_size; char *font_family = SSDATA (face->lface[LFACE_FAMILY_INDEX]); + struct image_cache *cache; /* F must be a window-system frame, and SPEC must be a valid image specification. */ @@ -3367,7 +3368,13 @@ lookup_image (struct frame *f, Lisp_Object spec, int face_id) /* Look up SPEC in the hash table of the image cache. */ hash = sxhash (filter_image_spec (spec)); - img = search_image_cache (f, spec, hash, foreground, background, + + if (!NILP (Vuser_image_cache)) + cache = XUNTAG (Vuser_image_cache, Lisp_Vectorlike, struct image_cache); + else + cache = FRAME_IMAGE_CACHE (f); + + img = search_image_cache (cache, spec, hash, foreground, background, font_size, font_family, false); if (img && img->load_failed_p) { @@ -3380,7 +3387,7 @@ lookup_image (struct frame *f, Lisp_Object spec, int face_id) { block_input (); img = make_image (spec, hash); - cache_image (f, img); + cache_image (&cache, img); img->face_foreground = foreground; img->face_background = background; img->face_font_size = font_size; @@ -3470,16 +3477,17 @@ lookup_image (struct frame *f, Lisp_Object spec, int face_id) } -/* Cache image IMG in the image cache of frame F. */ +/* Cache image IMG in the image cache C. */ static void -cache_image (struct frame *f, struct image *img) +cache_image (struct image_cache **pc, struct image *img) { - struct image_cache *c = FRAME_IMAGE_CACHE (f); + struct image_cache *c; ptrdiff_t i; - if (!c) - c = FRAME_IMAGE_CACHE (f) = make_image_cache (); + if (!*pc) + *pc = make_image_cache (); + c = *pc; /* Find a free slot in c->images. */ for (i = 0; i < c->used; ++i) @@ -12975,6 +12983,10 @@ syms_of_image (void) The function `clear-image-cache' disregards this variable. */); Vimage_cache_eviction_delay = make_fixnum (300); + + DEFVAR_LISP ("user-image-cache", Vuser_image_cache, + doc: /* TBD. */); + Vuser_image_cache = Qnil; #ifdef HAVE_IMAGEMAGICK DEFVAR_INT ("imagemagick-render-type", imagemagick_render_type, doc: /* Integer indicating which ImageMagick rendering method to use. -- Manuel Giraud