[haiku-development] Re: Reading the Mouse Cursor and Dirty Screen

  • From: looncraz <looncraz@xxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sat, 28 Mar 2015 16:37:42 -0500

On 3/28/2015 15:02, Alexander G. M. Smith wrote:
looncraz <looncraz@xxxxxxxxxxx> wrote on Fri, 27 Mar 2015 12:10:21 -0500:
Do you try to calculate the changes in the screen, or you just send the
whole thing as fast as you can?
There's a dirty rectangle algorithm in the VNC library code that compares
rectangular areas from the current bitmap with the previously transmitted
data and only sends the changed pixels.  However, reading the whole screen
to find those dirty areas is slow on some video boards (it's actually done
in smaller segments to improve response time), and even slower with the
BScreen copy-the-whole-screen-to-a-bitmap technique.

Yes, that would be nasty. But I've implemented BScreenStream, it has some kinks, of course, but I'm working them out.

http://files.looncraz.net/BScreenStream.mkv
Just 10MB, a quick video of it in action ;-)

You can set a frame rate limit, and it only captures when you Update(). It captures only the changed areas of the screen, and also exposes the changed region for you. In addition, as you can see, you can mask out a region of the screen (I update it to just use the test window's frame). And, of course, you can hide or show the cursor from the captured image as you wish.

The frame latency is about 1ms on my system under emulation, updates are batched in the server and to the application, and update changes are double-buffered on the client side. It tries to synchronize with app_server updates when you call Update(), so you can freely just spin Update() in a tight loop and not use much CPU.

There's more to come! Such as always including BDirectWindow frames, and including cleanup regions.

I've also made this usable from the server side, and, with compositing, it can be used per-window.

--The loon

Other related posts: