Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Speed Up Your firemonkey controls



Permlink Replies: 8 - Last Post: Feb 24, 2016 9:17 AM Last Post By: loki loki
loki loki

Posts: 787
Registered: 7/1/02
Speed Up Your firemonkey controls
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 23, 2016 4:21 PM
The fact: Painting of Firmonkey controls can be sometime slow, or say differently, not sufficiently fast for a fluid scrolling. For exemple if you simply look the basic Trectangle with round corners, the paint procedure can take around 3 ms! So if you have around 20 visible Trectangles on your screen, then it’s will cost you around 60 ms to repaint the full screen (and normally you don’t have only trectangle, you also have Tlabel, tcheckbox, etc..). After it’s just math, take 100ms to repaint the screen, so you can only do around 10 frames per seconds (in reality you will have much less even) so the scrolling can’t be fluid :(

The solution: I didn’t want to rebuild the firemonkey controls, it’s too huge job for me, and instead I try to find an intermediate solution. This what I find by adding “doublebuffered” property to the firemonkey controls. So instead to repaint and repaint (and repaint) the controls for every single pixels move of the scrollbox, I first paint the control on a “buffer” that I store directly in the GPU memory (through TTexture), and when the system ask me to repaint the controls instead of calling again the paint algorithm i simply redraw the buffer TTexture

The results: As I say before it’s took 3 ms just to paint a simple Trectangle with round corners. With my doublebuffered property it’s take now around 0.1 ms ! so now the scroll look much more fluid! It’s a success

The drawback: yes unfortunately there is some drawbacks :( First the speed to create the buffer TTexture is very slow (in the exemple of the Trectangle, it’s cost around 30ms). I think we can improve it, but right now didn’t find a way (http://stackoverflow.com/questions/35579440/delphi-android-iphone-cache-for-firemonkey-controls-using-opengl-texture ). This mean that the construction of theses buffer texture must be done during the startup of the application when the user will not really notice to wait 1 or 2 seconds more.

After the other problem, is of course the memory used by the Texture Buffer. It’s not huge amount of memory, but it’s some memory. I think we can compress the Texture using for exemple PNG (and this will make the memory insignificant for shape like Trectangle). I read that it’s possible in this article https://software.intel.com/en-us/articles/android-texture-compression-a-comparison-study-with-code-sample but they say to use Mipmap, and I learn that mipmaps it’s mostly for multi resolution image. Any help will be welcome :)

The demo: you can find the source on svn here: https://svn.code.sf.net/p/alcinoe/code/ after simply run demos/ALFmxControls/_source/ALFmxControls.dproj (you don’t need to install any package, just open the dproj and run it)

To finish: if you have any comments, helps, or suggestions, you are welcome! I didn’t do yet all the firmonkey controls, just few selected controls to check the “theory”. If you can also say me how much the speed (in the demo) is improved in you smartphone, I will be thanks too !
Gilbert Padilla

Posts: 315
Registered: 3/8/04
Re: Speed Up Your firemonkey controls
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 23, 2016 5:24 PM   in response to: loki loki in response to: loki loki
Are you using a 3Dform or a HDForm?
loki loki

Posts: 787
Registered: 7/1/02
Re: Speed Up Your firemonkey controls
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 24, 2016 2:57 AM   in response to: Gilbert Padilla in response to: Gilbert Padilla
Gilbert Padilla wrote:
Are you using a 3Dform or a HDForm?

HDForm why ?
Gilbert Padilla

Posts: 315
Registered: 3/8/04
Re: Speed Up Your firemonkey controls
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 24, 2016 8:48 AM   in response to: loki loki in response to: loki loki
HDForm why ?

I just think that you could get better performance on a 3DForm
loki loki

Posts: 787
Registered: 7/1/02
Re: Speed Up Your firemonkey controls
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 24, 2016 9:17 AM   in response to: Gilbert Padilla in response to: Gilbert Padilla
Gilbert Padilla wrote:
HDForm why ?

I just think that you could get better performance on a 3DForm

Why ? both use openGL ...
Eli M

Posts: 1,346
Registered: 11/9/13
Re: Speed Up Your firemonkey controls
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 24, 2016 6:49 AM   in response to: loki loki in response to: loki loki
loki loki

Posts: 787
Registered: 7/1/02
Re: Speed Up Your firemonkey controls
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 24, 2016 9:00 AM   in response to: Eli M in response to: Eli M

This didn't work at all with me :(
David Millington

Posts: 257
Registered: 5/29/05
Re: Speed Up Your firemonkey controls
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 24, 2016 6:49 AM   in response to: loki loki in response to: loki loki
This looks very interesting.

I think Simon Stuart wrote a framework to speed up FMX painting, also
using cached bitmaps - but since I haven't looked at the code, I don't
know if it was bitmaps or textures and at what level in the painting it
implemented the caching.

I'll be interested to hear where your project goes :)

Cheers,

David
loki loki

Posts: 787
Registered: 7/1/02
Re: Speed Up Your firemonkey controls
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 24, 2016 8:59 AM   in response to: David Millington in response to: David Millington
I'll be interested to hear where your project goes :)

thanks :) if you can try to compile the demo on android/iphone and say me how you find the scroll compare to the delphi original control i will be glad :)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02