sidorares/node-x11

Direct render node-canvas to a window

Closed this issue · 5 comments

Is there any initiative to use node-x11's window as render display for Automattic/node-canvas?

Yes, but not in this module. I'm actually using node-canvas together with this library for a video editor app ( had to re-create video generation script so needed frame-by frame 'inspect pixel color & get coords under cursor & compare with reference frame functionality' - about 50 lines of code using ffmpeg & node-x11 & node-canvas )

I'm implementing canvas api myself here - https://github.com/sidorares/ntk/blob/master/lib/renderingcontext_2d.js#L69 . It's very incomplete right now but much more coming very soon. I'll make ctx.drawImage(canvas) to accept node-canvas as well. My implementation is intended to be mostly wrapper around various XRender methods

I'm not sure if it's easy to make node-canvas draw content without sending whole image over the wire each time. It's definitely not possible right now, but might be doable if you tweak underlying cairo to use xcb surface. Alternatively, it might be possible to use local shared memory pixmap - this won't work for remote connections.

IMO It's best (from performance point of view) to mix node-canvas with Render ( wrapped with node-canvas like code ), pre-rendering complex images/shapes client side, upload them to server and compose server side with xrender

example code - https://gist.github.com/sidorares/becc0ae51d4027f67c3b#file-video-renderer-js-L113-L129 ( ctx.drawImage(canvas) is not implemented yet so I'm using putImageData ( which in turn does X PutImage request )

Great! I believe this canvas<->x11 improvement will be great for node on desktop.
Now i should try https://github.com/sidorares/ntk :-)

any feedback re ntk would be greatly appreciated :) please read source code and examples - there is no documentation at all ( mainly because API is very unstable and changes all the time ) but I think it's time to make it useable for others