From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Third Newsgroups: gmane.emacs.devel Subject: Re: Linking to ImageMagick by default Date: Wed, 19 Dec 2018 16:03:08 +0000 Message-ID: <20181219160308.GA43504@breton.holly.idiocy.org> References: <20181205223901.GA5543@breton.holly.idiocy.org> <20181208183810.GA2465@breton.holly.idiocy.org> <20181210220944.GA4793@breton.holly.idiocy.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1545235448 10085 195.159.176.226 (19 Dec 2018 16:04:08 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 19 Dec 2018 16:04:08 +0000 (UTC) User-Agent: Mutt/1.10.1 (2018-07-13) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Dec 19 17:04:04 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gZeKK-0002Tp-3F for ged-emacs-devel@m.gmane.org; Wed, 19 Dec 2018 17:04:04 +0100 Original-Received: from localhost ([::1]:32803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZeMQ-0008Vs-Ku for ged-emacs-devel@m.gmane.org; Wed, 19 Dec 2018 11:06:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47007) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZeJg-0007ST-Cr for emacs-devel@gnu.org; Wed, 19 Dec 2018 11:03:25 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZeJa-0000jr-C3 for emacs-devel@gnu.org; Wed, 19 Dec 2018 11:03:24 -0500 Original-Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:40283) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gZeJY-0000e1-C9 for emacs-devel@gnu.org; Wed, 19 Dec 2018 11:03:18 -0500 Original-Received: by mail-wr1-x42f.google.com with SMTP id p4so20061767wrt.7 for ; Wed, 19 Dec 2018 08:03:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=sender:date:from:to:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=1ewMn//vKUMIU0z9Dt8p1kayDhpflHWdmd2/WW4gDPw=; b=exQv+hiaVzJA7gcOOl2YSVh+ZJTRM3CAjR35gelULkkzNOTiC5LawmWCACUONymLvD KN4P9+edPXRhnTPBmU6/InlCKSFvkMw/+xAvlcZItw/JAxeFPnraywUvdyeCPPc+Ogu4 Tsuqej73G1qCHJw/evzyWXiiB8qJAFdRXv7xHvvtKJjK+zPrnfhCzSMdiJy8kZzHhbGc 7wkzgDZDuSHAr7mmm1rIVHfQtQIOZRPdf9Pa+AulZnD7TKEIHuaGcmRoCfsJ+ygu2zwd soO1x7MJvMdLPhkMxXp3kfP/swTCi0BQAnePZYDhTSCvaXS3ikGd+MbtfFhRNv+ghs0M 8BAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=1ewMn//vKUMIU0z9Dt8p1kayDhpflHWdmd2/WW4gDPw=; b=T90LHR0hK34p2HE4Ax0RyWEZwBZSM3iga6OBmw9m7P6sdPS1j/rn5DwjJ82KSG1vnJ 9m6OI4qQSvQJXymElg5jk8XmExibwW0YoW1o+tPTyCm57q5QU4TV8iF0oLhMfpC+l/aU DHIFeaZkI05ip8QEDRBzMh5Yxla3S5e1GhxDUUGCGdNrawNcQOk1k4oAyiYViGvPuVoq ZICiD0N/jtG+vKePmYBAqp82p98k+wD4FOEEp02aOwpcCRV9sLDR7iI+T7BbLp7dVCU/ e6x/n5yzuewm1SV363yB8ioG+zTcUsYivz9SOfCZ2HjHqmjaxbRL+wWF6VrzMkimFlyX Oahg== X-Gm-Message-State: AA+aEWaYckgj8aYeM7XJ6teiSbnBAPqscTFSiGpT/gZk1ozWts4lbB/m U7fotPXTZgQ9LuwztLw7WMA9CZXYU+Y= X-Google-Smtp-Source: AFSGD/XXtr6X/DPl18eD2RSvJJuMuScnnjYBbEYh5s2SW39m5ziPUbXYdIXDNjb32nayp937IPvmMA== X-Received: by 2002:adf:9061:: with SMTP id h88mr18859731wrh.65.1545235391989; Wed, 19 Dec 2018 08:03:11 -0800 (PST) Original-Received: from breton.holly.idiocy.org (ip6-2001-08b0-03f8-8129-eceb-61a5-5200-3774.holly.idiocy.org. [2001:8b0:3f8:8129:eceb:61a5:5200:3774]) by smtp.gmail.com with ESMTPSA id f15sm4872217wrt.10.2018.12.19.08.03.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Dec 2018 08:03:11 -0800 (PST) Content-Disposition: inline In-Reply-To: <20181210220944.GA4793@breton.holly.idiocy.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42f X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:231923 Archived-At: On Mon, Dec 10, 2018 at 10:09:44PM +0000, Alan Third wrote: > > If we want to go with this method I’ll have to rewrite some of the > image handling code. At the moment we create one ‘struct image’ per > lisp image spec, and store the image in the image cache, but this > means if the same image is displayed twice at two different sizes we > load it twice and store it twice. OTOH, it’s the resized version > that’s stored, so that might save memory if we assume people are > mostly shrinking images. > > What I’ve done in the attached would work better if we only loaded the > image once and didn’t tie it to an image spec, so we’d only keep one > (full size) copy in memory, and just resize it on demand. I’m unsure > how we’d go about detangling the image data from the image spec. I’ve continued working on this and have something mostly working, but I’m rather stuck with the image cache. The image spec is a lisp list that looks something like this: '(image :file "image.png" :format png :height 10 :width 20) The image cache code stores this directly in the image struct and uses it to find matching images using Fequal. I want to strip out the properties that I’m going to use at display time, so that I can use the same cached image for different output sizes, while leaving other properties that I don’t know about in place. So I’d like to store the above as '(image :file "image.png" :format png) however I’m not sure how to go about filtering the list in C. I tried a few variations on this, but they all seg fault static Lisp_Object get_cache_spec (Lisp_Object spec) { Lisp_Object cache_spec, tail; cache_spec = Qnil; for (tail = XCDR (spec); CONSP (tail) && CONSP (XCDR (tail)); tail = XCDR (XCDR (tail))) { if (!EQ (XCAR (tail), Qwidth) && !EQ (XCAR (tail), QCheight) && !EQ (XCAR (tail), QCmax_width) && !EQ (XCAR (tail), QCmax_height) && !EQ (XCAR (tail), QCscale) && !EQ (XCAR (tail), QCmargin) && !EQ (XCAR (tail), QCascent) && !EQ (XCAR (tail), QCrelief)) cache_spec = list3 (XCAR (tail), XCAR (XCDR (tail)), cache_spec); } cache_spec = list2 (XCAR (spec), cache_spec); return cache_spec; } Any ideas or alternative approaches are appreciated. -- Alan Third