I'm taking a stab at writing a VNC client in Self. Screenshot of progress so far is at:
http://bluishcoder.co.nz/self/self_vnc.png
So far the VNC morph displays the image from the VNC session. No interaction yet but I hope to get there soon.
I wasn't really able to find a performant way to paint the screen buffer. I can't use ui2Image to hold the data as that's limited to 255 colors. At the moment I have a pixmap canvas that the morph holds and it updates that in another Process. When it is complete it marks the morph as changed. The morph then paints that pixmap canvas onto the real canvas in its baseDrawOn method.
This helps stop the desktop UI from locking up during the draw. A 1024x768 image takes a fair while to do the updating. This is because I'm doing a 'canvas point: x@y Color: c' for each point in the image and each one of these involves creating a paint object for the color.
Is there a faster way of doing this? I could optimize it using a primitive in some way but for the first attempt I'm trying to avoid changing primitives.
Hi Chris, That's a great idea. But I can imagine writing out each pixel one by one would slow even the fastest VM down! I dont know of any primitives other than the ones exposed through canvas. I suppose I could suggest various hacks (eg keep image as grid of 8x8 256 colour pixmaps and draw changed ones to canvas as images not pixels?) but you've probably already thought of those and dismissed them... I don't suppose you feel like writing bindings to libSDL? Then we could abandon both Quartz and X.org :) Russell
On 18 Apr 2014, at 12:05 am, Chris Double chris.double@double.co.nz wrote:
I'm taking a stab at writing a VNC client in Self. Screenshot of progress so far is at:
http://bluishcoder.co.nz/self/self_vnc.png
So far the VNC morph displays the image from the VNC session. No interaction yet but I hope to get there soon.
I wasn't really able to find a performant way to paint the screen buffer. I can't use ui2Image to hold the data as that's limited to 255 colors. At the moment I have a pixmap canvas that the morph holds and it updates that in another Process. When it is complete it marks the morph as changed. The morph then paints that pixmap canvas onto the real canvas in its baseDrawOn method.
This helps stop the desktop UI from locking up during the draw. A 1024x768 image takes a fair while to do the updating. This is because I'm doing a 'canvas point: x@y Color: c' for each point in the image and each one of these involves creating a paint object for the color.
Is there a faster way of doing this? I could optimize it using a primitive in some way but for the first attempt I'm trying to avoid changing primitives.
Thanks for the thoughts Russell. I'll see how far I get with no primitive modifications and once it's working I'll look at what I can add to speed things up.
I wanted to do something 'in' Self rather than 'on' Self as it''s been awhile since I actually wrote anything reasonable sized in the environment. VNC is good for me since it will allow me to stay inside the Self world while running xterm and Firefox. It's also part of an exploration to see what's involved in using something else for the remote display functionality. If we rip out X then we lose that which I think is a nice feature.
I would like to see libSDL bindings too. That would give hardware acceleration and easier platform support on Android and Windows. With an alternative to the X11 stuff for the desktop sharing we'd be on the way to making Self look more modern.
On Fri, Apr 18, 2014 at 12:11 PM, Russell Allen mail@russell-allen.com wrote:
That's a great idea. But I can imagine writing out each pixel one by one would slow even the fastest VM down! I dont know of any primitives other than the ones exposed through canvas. I suppose I could suggest various hacks (eg keep image as grid of 8x8 256 colour pixmaps and draw changed ones to canvas as images not pixels?) but you've probably already thought of those and dismissed them... I don't suppose you feel like writing bindings to libSDL? Then we could abandon both Quartz and X.org :) Russell
On 18 Apr 2014, at 11:00 am, Chris Double chris.double@double.co.nz wrote:
Thanks for the thoughts Russell. I'll see how far I get with no primitive modifications and once it's working I'll look at what I can add to speed things up.
Makes sense
I wanted to do something 'in' Self rather than 'on' Self as it''s been awhile since I actually wrote anything reasonable sized in the environment. VNC is good for me since it will allow me to stay inside the Self world while running xterm and Firefox.
Another useful thing might be to start experimenting in keeping something out of the main Self tree ie put this code on GitHub but not in a self fork. This might tell us what needs to be changed in the transporter to properly support a multiple source environment
It's also part of an exploration to see what's involved in using something else for the remote display functionality. If we rip out X then we lose that which I think is a nice feature.
It's a great feature but the reliance on x makes it a bit hard to use at the moment. You will need a self vnc server though not client ;)
Russell
I would like to see libSDL bindings too. That would give hardware acceleration and easier platform support on Android and Windows. With an alternative to the X11 stuff for the desktop sharing we'd be on the way to making Self look more modern.
On Fri, Apr 18, 2014 at 12:11 PM, Russell Allen mail@russell-allen.com wrote:
That's a great idea. But I can imagine writing out each pixel one by one would slow even the fastest VM down! I dont know of any primitives other than the ones exposed through canvas. I suppose I could suggest various hacks (eg keep image as grid of 8x8 256 colour pixmaps and draw changed ones to canvas as images not pixels?) but you've probably already thought of those and dismissed them... I don't suppose you feel like writing bindings to libSDL? Then we could abandon both Quartz and X.org :) Russell
Updated demo as an animated GIF. The left hand side is a standard VNC client accessing a shared display. The right hand side is the VNC Morph in Self which mirrors, somewhat delayed, what the display shows. I haven't done anything to improve the speed yet. Partial screen updates are fairly quick though.
self-interest@lists.selflanguage.org