Re: Emacs canvas support

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Re: Emacs canvas support

arthur miller
Eli Zaretskii <[hidden email]> writes:

>> From: Arthur Miller <[hidden email]>
>> Cc: [hidden email],  [hidden email]
>> Date: Thu, 30 Apr 2020 16:58:10 +0200
>> > For example, if the window scrolls, wouldn't you want
>> > the graphics drawn by these pre/post-renderers to move on display as
>> > well, at least sometimes?  If you do, how can you do that without
>> > knowing some details about the scroll?
>> Of course. Wouldn't came out automatically, by redisplay engine as it
>> already is?
> No, of course not.
>> No I didn't, I had in mind to redraw stuff, so user can draw below or
>> above whatever Emacs normally draws.
>> Yeah sure if user chooses to draw two different text buffers on top of
>> each other it would be a mess, but I don't think that is an issue
>> because, normally, probably nobody want's to draw to text files on top
>> of each other.
> I think what you describe doesn't fit with how the redisplay works,
> but I'm probably missing something, since Stefan also thinks this
> could work.
To be honest I am not sure myself if it could or not work, that is why I
posed at as a question in my first mail. I am not so familiar with Emacs
internal but I do find it intersting to look at C code from time to time :-).

My idea is to make it as least intrusive on current pipeline as
possible. I see current drawing stuff as it draws to one (implicit)
layer: the current window (I mean OS window). The idea is to wrap it in
some way (as a callback) and call in it "per layer" each time, where
each layer would draw it's own bufer. This way no new objects are
needed, no new concepts, just to redraw buffers in same window once per
callback. It does not have to be a callback. Instead it could be a
list of buffers to draw just in ordinary list; a qeue to draw from
first to last. Same code it does now, just re-enter it again per each
buffer, and draw them on top of each other.

I am not sure where and how to fit it in. What this be per-buffer, or
per-window, or even-per frame? I was looking at Window and Buffer
structures, but I don't know myself, to be honest.

Then if we could get some graphics functions that draw to say XPixmap or
Cairo surface (which should be trivial to expose), we could draw
graphics to an image, and then display image in one layer and draw text
into another layer. It would give a "Canvas" like functionality and
layered rendering. How it would be usefull is up to users, but if we
look at what people do in Emacs, all this UML with Ditaa, vertical lines
with characters etc, obviosly there is some need for graphics in Emacs.
I am sure some powerline users would be happy to draw some cool graphics
to their modeline.

While drawing to image and layering stuff below/above text buffer is not
THE most efficient way, it could still be more efficient then drawing to
SVG (xml) and rendering svg and display it as image anway or doing
canvas with "put pixel" stuff. Also, not a perfect, but as rest of Emacs
implementation, probably *good enough* for many uses?