[fpc-pascal] Implementing AggPas with PtcGraph

James Richters james at productionautomation.net
Thu Jun 22 00:21:51 CEST 2017


>putimage can be accelerated, although it would still have to do a memory copy.

Like this?
https://github.com/Zaaphod/ptcpas/compare/Zaaphod_Custom?expand=1#diff-fb31461e009ff29fda5c35c5115978b4

This is amazingly faster.   I ran a test of just ptcgraph.putimage() in a loop, putting the same image over and over 1000 times and timing it.  The original ptcgraph.putimage() took 18.017 seconds.  After I applied this, the same loop took 1.056 seconds.  Quite an improvement!    It's still nowhere near as fast as just drawing stuff with ptcgraph directly, but for doing a memory copy of the entire screen, it's very fast

I have an idea on how I could speed it up even further.... 
If I set up a second array with 1 bit per pixel, then (somehow) aggpas could set bits in this array to 1 whenever it changed a corresponding bit.  Now by analyzing the 'pixel changed' array one word at a time, (or maybe longword or qword at a time)  I could just skip over all the words that =0 and when I come across a word that <> 0   I could do a binary search of that word to only change the pixels that need to be changed.  If very little on the screen has changed, this would be quite a bit faster because the pixel changed array would be 1/16 the size of the full buffer. 

The only way this would be of any benefit though is if aggpas set the bits in the 'pixel changed' array while it was changing the pixels of the buffer, because at that time it already has the array position and the fact that something changed available.  If I had to analyze the buffer separately and create the 'pixels changed' array, it would take too long.


James





More information about the fpc-pascal mailing list