[Lazarus] Fast drawing to canvas

dhkblaszyk at zeelandnet.nl dhkblaszyk at zeelandnet.nl
Fri Feb 10 11:34:20 CET 2012


  

Hi Sven, 

I just comitted a second version, which is also based on
a "simple image" as you put it. At 50% HD I get 88fps on windows and
19fps on Mac. Couldn't test on Linux as that machine refuses to work
properly. I have not used OpenGL but TImage instead. In other tests I
have never seen any actual speed improvements of OpenGL over a native
canvas, unless you create memory textures and can utilize the hardware
acceleration. 

The reason to stream directly form disk is that if I
would like to display a longer list of images I will not be able to
store them in memory. Say I have a movie clip @ 24fps for 60sec. This
would require (50%HD) 24 * 60 * 1.5 = 2GB of memory. What if I would
like to display 10min? No chance... Please note that I really need the
full resolution images here, so converting to jpeg to reduce memory
footprint is out of the question. Implementing a memory cache is also on
my list, but when playing the entire loop from start to end this will
not help as each frame is displayed only once of course. 

In the "fast"
version I stream data from a png and this is actually pretty fast now.
However I will implement native loading of the images to optimize the
process. But this is only optionally as my issue is not with the setup
of the file cache but more with the drawing speed. As said, on windows I
get 50%HD @ 88fps and full HD @35fps. Now Mac is worrying as it draws
full HD @ only 12fps. Maybe opengl can draw more efficienctly in this
case? I would also like to test SDL. 

Regards, Darius 

On 10 feb '12,
Sven Barth wrote: 

> Am 09.02.2012 19:41, schrieb Darius Blaszyk:
> 
>>
I've put up the test app on the CCR. All three methods draw at roughly
10fps on windows and 6fps on mac. I haven't tried linux yet. I challenge
everyone to find methods to speed up the the drawing using the current
implementation. May the best man win!
> 
> On Linux I have roughly 5 FPS
with all three methods... :(
> 
> I then tried to display the pictures
using the OpenGLContext. For this I 
> modified your code quite a bit:
>
* the images are converted to a "simple image" (a record consisting of

> width, height and the image data as an array of a record of 3 byte 
>
values (red, green, blue))
> * the images are kept in memory (no writing
to a cache on disk the use 
> of which I don't really understand...)
> *
draw the images to the OpenGLContext
> 
> With this I achieve roughly 25
FPS using the 50% HD images, but the 
> startup time (the conversion
from the PNG image to the simple image) is 
> around 5 to 10 minutes...
(maybe .Canvas.Pixel[...] access isn't that 
> good for that purpose
^^)
> 
> Regards,
> Sven
> 
> --
>
_______________________________________________
> Lazarus mailing list
>
Lazarus at lists.lazarus.freepascal.org [1]
>
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus [2]

 


Links:
------
[1] mailto:Lazarus at lists.lazarus.freepascal.org
[2]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20120210/9cafd3e1/attachment-0003.html>


More information about the Lazarus mailing list