From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Arthur Miller Newsgroups: gmane.emacs.devel Subject: Re: Rethinking the design of xwidgets Date: Wed, 14 Oct 2020 17:04:07 +0200 Message-ID: References: <864kmzupp0.fsf@akirakyle.com> <835z7e2ouj.fsf@gnu.org> <86v9fet5sg.fsf@akirakyle.com> <83imbe1040.fsf@gnu.org> <86pn5luak4.fsf@akirakyle.com> <83362g27y6.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5801"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Akira Kyle , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Oct 14 17:21:52 2020 Return-path: Envelope-to: ged-emacs-devel@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 1kSib8-0001KP-OD for ged-emacs-devel@m.gmane-mx.org; Wed, 14 Oct 2020 17:21:50 +0200 Original-Received: from localhost ([::1]:37018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kSib7-0000cX-Pj for ged-emacs-devel@m.gmane-mx.org; Wed, 14 Oct 2020 11:21:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSiKA-0000lb-1P for emacs-devel@gnu.org; Wed, 14 Oct 2020 11:04:18 -0400 Original-Received: from mail-db8eur06olkn2028.outbound.protection.outlook.com ([40.92.51.28]:20897 helo=EUR06-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSiK4-0001sR-KQ; Wed, 14 Oct 2020 11:04:16 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CmbuKf4V69bN7iAlb9MkpcPsAtl+AnCbP2IUhTE0emicHe7r7fftZs0kVlSotVhT1kr7vPkkV0W8OLAuOpsIOtdm7eNr/UmY1UIJaxtcpIWOOjYO7P9Bzrk+9W3q97lZmMwIWmYGAfi1TsfuSnEtP4cwdu9EO/qFTSjbHAK38uSXacUe19vMmxc9rKppeR9Wrk5V2oAtG0SmGDxNBGvCKXPDNn0g98BnJqc0MVSH+xKNGk3gh6vP7zerbznnB/RccteDpuY8V3JUxdxGfsOhuPQn1dF/8rRuKlaa1B7VaF1PgQ/K1BSp8AP0Mvgfcr2RzPJwdcJlj2jMNjEK09OoEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5t5nvsEmu72GDPurEZf6yV48/Vevu8MTh6KgY9RjyRc=; b=UtPMNIHleItk8JlM18P6+QVHTkymEJA+D9nvytSZiKBBWms7x4tezrVTYbSyJiYdJTYLsNMTIJOJ/lYLo3LrYKCRMVMW0HJcJFcPhwtDndjFnsm+TU+mkR0TFP/XpbhGjcpV4DRHuvYSOVWXulUY7BglqAmFjtRiDxNK0TUJyB0dmkjhsdUBGMNWs1Gi7icuoYzGLu6VOTiY9nlJoi1G3eFT/yR8e318o++swcYRSXkUNMWt/Ukx8726BHc+TbxTiN+tavYcx8L0DAByn1SpjVj874551NcTEw+Sx2RFXEOgLFRNNXz9OJVOHy+lwZqf5FeTCmZc+fwpe3Msjfi6pQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5t5nvsEmu72GDPurEZf6yV48/Vevu8MTh6KgY9RjyRc=; b=PzQ4OTR4B1U5rbjNpxXMQdf1si8yh/CPEmGFdflsrqHJYTFlFcswQPCwk+VEaKZrz94bGVj/qYR0HZNNNRKhPRFPS9rwmuQwWtAXXvZnI/J94atXcoSi742TdkBZ5dVhGDDimLAcTyatlPwaV+Gca/7bFMwyYBrBf9EarC2iYkkmwIC+ivecdapS053H8nYeDmqfecgJrTyH+JuxrpS0DhJWdngKASCXhhLz7QbOfQQs9cgUn1vCnJKap3ucDikTAtNaVqb06yTtWtKCmQkR/ywYfFwav3uO5k8j8NYbHhhIwlN96rtri1EggXRUvGoujS6NM/If0bEV7n8814gTaQ== Original-Received: from DB8EUR06FT049.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc35::4f) by DB8EUR06HT142.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc35::71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21; Wed, 14 Oct 2020 15:04:08 +0000 Original-Received: from VI1PR06MB4526.eurprd06.prod.outlook.com (2a01:111:e400:fc35::4c) by DB8EUR06FT049.mail.protection.outlook.com (2a01:111:e400:fc35::84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21 via Frontend Transport; Wed, 14 Oct 2020 15:04:08 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:04E295588B5E60639737B26AEBE69841CEBDCD550C92AB14B7C2B025DA91BC6C; UpperCasedChecksum:87FC5CAFC5071635937475F6A972FFE0667404730E1E95090CF2380942B83CF1; SizeAsReceived:8713; Count:47 Original-Received: from VI1PR06MB4526.eurprd06.prod.outlook.com ([fe80::b547:51cd:16c5:4487]) by VI1PR06MB4526.eurprd06.prod.outlook.com ([fe80::b547:51cd:16c5:4487%7]) with mapi id 15.20.3455.031; Wed, 14 Oct 2020 15:04:08 +0000 In-Reply-To: <83362g27y6.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 14 Oct 2020 17:33:37 +0300") X-TMN: [Cxw4QJB0qd92/SkuTI4ESdrOQhK8rLK2] X-ClientProxiedBy: BEXP281CA0014.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10::24) To VI1PR06MB4526.eurprd06.prod.outlook.com (2603:10a6:803:ac::17) X-Microsoft-Original-Message-ID: <87eem0yhlk.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from pascal.homepc (90.230.29.56) by BEXP281CA0014.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.11 via Frontend Transport; Wed, 14 Oct 2020 15:04:07 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 57df12a6-584c-466c-dddb-08d870526679 X-MS-TrafficTypeDiagnostic: DB8EUR06HT142: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FXnfTvQdNYLsnK9UfH5I5SL0itKk6RsnH6kQwk3PepCAxpYhrmLF+k+3XbQ1Wxfya462ctHpqlvg4KG9PnVfSjP8UBJrKBneWAOm5gyAYtYJ5eGI1UTX4191BDVxvjYKIRfS+57RHWfmCcuncfTbzUF4XeNvH4ig+RpwjQIzMC/kV3qg1af206RxGR5No44RtlQ+A53LcjRaU1saBfjQzQ== X-MS-Exchange-AntiSpam-MessageData: nq0hwhr72bhLyGDENi3F6v9zY7C/JoxNTkmqLJAQBbiymrJ9Ubto2QRi54sqAYFFnHZGN1Y7lMlyW8H4MNBqUfhQS/zCFcfULtd9VOxGTkR03v0cBn4BqusaNgVHkAjXvhgKsnOMQFZ6NIxwjANsjg== X-OriginatorOrg: live.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57df12a6-584c-466c-dddb-08d870526679 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2020 15:04:08.5355 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: DB8EUR06FT049.eop-eur06.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8EUR06HT142 Received-SPF: pass client-ip=40.92.51.28; envelope-from=arthur.miller@live.com; helo=EUR06-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/14 11:04:09 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:257647 Archived-At: Eli Zaretskii writes: >> From: Akira Kyle >> Cc: emacs-devel@gnu.org >> Date: Tue, 13 Oct 2020 14:37:31 -0600 >>=20 >> > I'll need to read up on those two topics, but in general, as=20 >> > someone >> > already pointed out, the Emacs display of images supports >> > interactivity by letting you call functions triggered by mouse >> > gestures on the varipous spots on the image. If such a function >> > produces a zoomed-in/out image and displays it instead of the=20 >> > original >> > one, wouldn't that fulfill the need? E.g., we already support >> > animated GIF images and zoom-in/out by mouse scroll, so it is >> > inaccurate to say that we can only display static images. >>=20 >> Can actions be triggered on a click and drag as one would do to=20 >> pan within a plot? > > I didn't have time to try that, but just looking at the code, I don't > see anything that makes the clocks on images special, so I'd expect > the same modifiers and drag-detection code to work. And if it > doesn't, I seed no reason why we couldn't teach it to do so. > >> As far as I know there are really only two FLOSS PDF libraries out=20 >> there: poppler and muPDF. Between them poppler supports more PDF=20 >> features and seems to be more widely used. I agree this isn't=20 >> really as compelling of a use case for xwidgets, but I seems like=20 >> it would be easier to achieve better PDF rendering via xwidgets. > > I can see how that is tempting: the image handling is taken care of. > What I'm saying is that this advantage should be carefully weighed > against the disadvantages and difficulties in integrating such > self-managing objects into the Emacs display code. > >> > E.g., the kludge in dispnew.c around line 4365. It disables one >> > of the most important redisplay optimizations in Emacs, once you >> > build with xwidgets enabled. >>=20 >> Ah, I had briefly looked at that but I wasn't sure how important=20 >> it was. I may be able to make some progress on that but it's hard=20 >> to understand the context for that function. It seems like that=20 >> function is responsible for an optimization that avoids redrawing=20 >> glyphs if the window is being scrolled by copying them > > Not only if the window is scrolled, but also if the previous display > can be converted into the current display by scrolling some of the > stuff that is already on the glass. the algorithm is a basic > comparison of the current and desired display, similar to what the > Diff utility does. > >> however I couldn't find where or how the glyphs are actually copied? > > See the calls to rif->scroll_run_hook. > >> > I'm not trying to scare you, mind you, just point out that the >> > ideas you have should probably be talked through in mode detail, >> > to see that they are workable. For example, did you study the >> > various window-redisplay optimizations, and if so, did you think >> > how the widgets will adapt to them? >>=20 >> I'm just starting to dig my teeth into some of that. However I'm=20 >> wondering if anyone has more recently tried to quantify the=20 >> improvements the various redisplay optimizations make to both=20 >> actual and perceived render time of Emacs. For example the comment=20 >> on the scrolling_window function in dispnew.c that you pointed me=20 >> too references that it is implementing an algorithm from 1978,=20 >> perhaps it would be worth exploring if there are any algorithmic=20 >> advances? > > I don't think that algorithm is less optimal nowadays than it was back > then; the really interesting question is how much it saves us when > compared to simply redisplaying all those lines. > >> It strikes me that perhaps some optimizations may no longer be as >> necessary on modern hardware or on GUI displays as they were when >> running emacs in a VT on 20 year hardware. > > Those are very good questions. I'm not aware of any such > investigations since the current redisplay optimizations were > implemented around 20 years ago: at that time, Gerd M=C3=B6llmann, who > developed the current display engine, did add optimizations one by one > until he got reasonable redisplay performance. In case where there is a discret gfx card (i.e. Nvidia/AMD) it is probably faster to send everything to GPU and ask it to render a=20 giant texture and then use it as XWindow pixmap, or something similar then to figure out on CPU all the stuff that should not be displayed. But Emacs will maybe run on some slow devices (atmel Emacs anyone?), so you probably don't want to ditch away all that disp stuff. > Measuring the speedups from each of the several optimizations is an > important job, but it's a large job. For starters, one needs to come > up with a large enough and representative enough sample of redisplay > use cases, and that is not easy. So I'd encourage you (or anyone > else, actually) to do this important job, but be aware that it could > take non-trivial time and effort. > >> Conversely there may be further optimization that could be done by >> taking advantage of more recent hardware advances such as offloading >> to a GPU or utilizing vectorized instructions. > > We try not to use machine-dependent code in Emacs, because that's a > maintenance burden, what with today's fast pace of chip development > and obsolescence. Vectorization is generally left to optimizing > compilers, and relying on special hardware, such as GPU, is not > something we should depend on directly. We should instead hope that > the GUI toolkits and display systems we use will do that for us. Would it be considered too machine-dependent if you rendered into off-screen OpenGL surface as your rendering target? Should be avialable on Nvidia/AMD/Intels gpus. With offscreen egl you would have relatively OS independent code too; but that would require explicit linking to proprietary libs. I mean X11/Win32 already does that when proprietary drivers are installed, so Emacs (and any other software) "implicitly" links to those, but I don't how it is viewed if you would to explicitly when present. You could maybe also expose egl-surface to elisp as an "image format" and enable rendering to an image directly instead of going through external process.