I have implemented a new version of the Emacs canvas patch. Refreshing avoids redrawing or even checking the entire buffer. Only the single glyph where the canvas is attached as display property is redrawn.

I welcome help with testing or porting to other platforms than Cairo/Pgtk or X. @divyaranjan ported his Pale library to the new version of the canvas API, with good results.

Canvas patch and test program:
https://github.com/minad/emacs-canvas-patch

Discussion on the bug tracker:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=80281

GitHub - minad/emacs-canvas-patch

Contribute to minad/emacs-canvas-patch development by creating an account on GitHub.

GitHub

@minad In the latest exchanges, Eli asked for performance on older machines. The oldest machine I currently have access to is a Thinkpad T440p with i5 4th gen.

Are there any #Emacs users with older machines, say core 2 duo and the like, who would be interested in testing this patch out?

@divyaranjan @minad Why not run it in an (underclocked) VM?
@pkal @minad Indeed, I've started testing it there. I'll also ask Eli for clarification on whether VMs are comparable or not.
@divyaranjan @minad In a month or so I'll be visiting my parents and will be able to try running this on an old Thinkpad x41, if you still need the data by then.
@pkal @minad That would be great. Thank you, Philip.
@divyaranjan @minad @pkal i have access to a t400. it already has some old Emacs version installed. if you are able to explain the steps to test it (ideally alongside existing emacs install), i could poss do so this week. (explain the steps, as in, to layfolk; i love (e)lisp but i am no pro)

@mousebot @minad @pkal

Here are the steps:

1. Clone the following fork of Emacs:
https://codeberg.org/monadicsheep/emacs

And then build it with `make bootstrap` and then `make -j`.

2. Test that the above works by opening `src/emacs -Q`.

3. Clone the following, switch to `canvas` branch and do a `make all`:
https://codeberg.org/monadicsheep/pale

4. Do `src/emacs -q -L /path/to/pale/`.

5. Then, in the new Emacs' scratch buffer, evaluate:

```
(setq video-player (pale-create-canvas 1280 720 'canvas-id))
(switch-to-buffer "*pale-video*")
(pale-display video-player)
(pale-video-play video-player "/path/to/video")
```
You can change the dimensions, and the canvas id as you see fit.

Try rendering both an usual 720p 30fps videos, and then push towards 60fps videos. See how the CPU responds. Also compare it with how mpv's performance is, whether Emacs takes more CPU.

emacs

GNU Emacs, the extensible, customizable, self-documenting real-time display editor, with the canvas patch set. See: https://lists.gnu.org/archive/html/bug-gnu-emacs/2026-01/msg01995.html

Codeberg.org

@divyaranjan while waiting for guix pull on the old machine, i'm unable to build pale.

i get

pale.el:29:1:Error: Module could not be opened: "/home/mouse/code/elisp/pale/pale-module.so", "libEGL.so.1: cannot open shared object file: No such file or directory

i have libegl and libegl-dev packages installed, so not sure what i'm missing?

@mousebot Do you have `mesa`?
@divyaranjan i have libegl-mesa0 and libegl1-mesa-dev. i have none of the libegl-nvidia packages. i guess i'm running old debian stable. the mesa versions are 20.3.5-1.
@mousebot That is weird, you got no errors when compiling pale?
@divyaranjan that is the error that i get, make errors and pale doesn't build. i cloned then called `make all` in the directory. if there's something else i need to do maybe walk me thru it, unforch i have close to zero experience compiling C programmes.

@divyaranjan here is the full output i see after calling make all:

gcc -O3 -g -fPIC -DUSE_PALE_GPU -D_GNU_SOURCE -c libpale.c -o libpale.o
gcc -O3 -g -fPIC -DUSE_PALE_GPU -D_GNU_SOURCE -c pale-video.c -o pale-video.o
gcc -O3 -g -fPIC -DUSE_PALE_GPU -D_GNU_SOURCE -c pale-diag.c -o pale-diag.o
gcc -O3 -g -fPIC -DUSE_PALE_GPU -D_GNU_SOURCE -c elisp-helpers.c -o elisp-helpers.o
gcc -O3 -g -fPIC -DUSE_PALE_GPU -D_GNU_SOURCE -c pale-gpu.c -o pale-gpu.o
gcc -O3 -g -fPIC -DUSE_PALE_GPU -D_GNU_SOURCE -shared \
pale-module.c libpale.o pale-video.o pale-diag.o elisp-helpers.o pale-gpu.o -o pale-module.so -lEGL -lGL -lpthread -ldl
emacs --batch -Q --eval '(setq enable-dir-local-variables nil)' -L . -f batch-byte-compile pale.el

In toplevel form:
pale.el:29:1:Error: Module could not be opened: "/path/to/pale/pale-module.so", "libEGL.so.1: cannot open shared object file: No such file or directory"
make: *** [Makefile:84: pale.elc] Error 1

@mousebot That's pretty much all you need to do. So GCC is able to link with EGL but somehow the resulted shared object can't find libEGL.
@divyaranjan i just built it fine on my daily driver, so there's something broken with it on the old machine only...
@mousebot On debian can you install the libegl1 package and then try?
@mousebot And/or libgl1 package
@divyaranjan i have both installed it seems. i don't have the "transitional dummy package" versions tho, e.g. `libegl1-mesa`, or `libgl1-mesa-glx`
@mousebot I see, I have zero idea how debian works with these things...
@divyaranjan @mousebot BTW don't you want them to test the canvas branch. Which, AFAIA, doesn't require mesa?
@tusharhero @mousebot Oh, right. Slipped from my mind. Yes @mousebot if you switch to the canvas branch and then rebuild Pale you should be able to render stuff.
@divyaranjan @mousebot you should edit the instructions.
@divyaranjan @tusharhero same error trying to build it with branch canvas checked out
@divyaranjan @minad I know dennis have a lot of old architechtures-computers. https://www.genunix.com/
This is a UNIX™ System.

Libera Chat

A next-generation IRC network for FOSS projects collaboration!

Libera Chat
@virag @minad not sure I understood what this meant. What is "blastwave"?
@minad @divyaranjan What's the main project link? This looks interesting
GNU Emacs - GNU Project

@benleis @divyaranjan
But maybe you're looking for Pale instead?

https://codeberg.org/MonadicSheep/pale

pale

Picture and Animation Library for Emacs

Codeberg.org
@minad @divyaranjan
No I thought it was a separate package rather than built into the emacs main code.
@benleis @minad Yeah so we have a small patch which enables this sort of thing and then we build on top of it.

@minad For those who wish to try this patch out, but do not want to go through the trouble of recompiling #Emacs and the mess. You can do the following:

1. If you are on #Guix, simply add my Guix channel to your `channels.scm`, my channel is the following:

https://codeberg.org/divyaranjan/divya-lambda

Then you can simply do `guix install emacs-canvas`.

2. If you are not on Guix, you can download the following tarball that is created using the fantastic `guix pack` command in #Guix:

https://codeberg.org/MonadicSheep/-/packages/generic/emacs-canvas/31.0.50

The binary inside this will be compiled from our fork that maintains the latest patch and rebases it regularly on top of Emacs' `master`,

divya-lambda

Divya's Guix Channel for packages that might eventually make it upstream, or not.

Codeberg.org
@mousebot You can try this too if you'd like to skip the part of cloning and locally building Emacs from source with the patch.