[Lazarus] Fast drawing to canvas
Darius Blaszyk
dhkblaszyk at zeelandnet.nl
Fri Feb 10 20:13:51 CET 2012
>> Yes, I'm playing movie clips. But playing back images from a video codec
>> is besides the point.
> If you say so, but that is exactly what you are doing.
I know :) The streaming is actually pretty fast. Tests have shown that I'm able to get almost 90fps (for the complete drawing cycle) on 50%HD on windows which is perfect. However the same loop drops down to 11fps on mac. So the problem lies not in the streaming but in the drawing bit.
After I solve the drawing problems (perhaps by switching to OpenGL as you also mention) I will focus on the filecache. There's a tradeoff between compression/decompression and disc access times. I just don't know where the turning point is, but tests will show that later. For now I'll stick to raw pixel data, later I will use a movie file probably (with optional lossless compression).
>> I have implemented my own "simple" raw image codec
>> (filecache.pas) that reads pixels from disk. My problems lie with the
>> playback of video. It has proven to be very difficult to playback video
>> (on Mac) with an acceptable speed. Full HD images are played back @ 11fps
>> wich is just too slow.
> The fastest way should be using OpenGL. But not some naive implementation like it seems to be the case with the OpenGL tests performed by followers of this thread.
> The magic words are PBO and texture streaming. This approach reads the data directly into a buffer on the graphics card which you use as texture to display your images. You can even read the data in an other thread than the OpenGL one. Only the reading of the data is performed on the CPU and the data will go from disk straight to VRAM.
>
> hih
> R.
Your comments certainly help! I think you will probably be right for Mac. I expect that OpenGL will be more stable over the different platforms as the TCanvas implementation seems to be. However on Windows and Ubuntu OpenGL PBO does not win from TCanvas as demonstrated here:
http://wiki.lazarus.freepascal.org/Fast_direct_pixel_access#Speed_comparison
I was shocked to see this, but I confirmed this results at least on windows.
Regards, Darius
More information about the Lazarus
mailing list