Copyright © 2002-2009 MultiMedia Soft 
Return to index  
 
How to speed up buttons rendering 
 
As you may understand, the rendering of complex 3D buttons requires more CPU ticks than the rendering of default Windows flat square buttons: many applications (for example touch-screen or kiosk applications) may require to create, over their forms, a consistent number of buttons and, due to the fact that each of them requires a certain amount of time to be rendered, this could cause a slow down when loading highly populated forms. 
Starting from version 2 of the SDK, a new "buttons caching system" has been provided in order to speed up buttons rendering, with great benefit for the time required to load your forms. This system is based on the assumption that if a button surface has already been created for a button it can be reused by other buttons having the same morphological characteristics
Just to make a small sample of what we are speaking about, take a look to the following forms 
 
 
 
As you can see, the two forms above display the same number of buttons, but while the first one has all of the buttons different from each other the second one has all the same buttons (we can say that all of the buttons have the same "morphological characteristics"): which of them will load faster? 
Without the "caching system" their loading would require exactly the same amount of time but, thanks to the "caching system", Form2 will load much faster because it will have to calculate only the first button and then use it for all of the other buttons (note that the presence of texts over the button doesn't affect the load time). 
Furthermore, if you should close the form, the button will be maintained in cache so, if the form should be opened a second time, the button would be already available and could be used immediately without the need of recalculating it, affecting again the loading time that will be faster than it was the first time. 
So, which are the "morphological characteristics" that buttons must have in common, in order to ease the "caching system" work? 
  • Size (intended as horizontal and vertical dimensions) 
  • All of the settings available inside the "How to change the button shape" section. 
  • All of the settings available inside the "How to change the button colors" section. 
  • All of the settings available inside the "How to apply a texture to the button surface" section. 
  • The FocusMode property. 
  • The UseAntialiasing property. 
  • As you can see, text settings and picture settings will not affect the caching system, so you will have enough ways to distinguish buttons from each other. 
    If for any reason you should decide that you need more memory for your application, you could use the abmClearButtonCache function in order to free all the memory dedicated to the cached buttons storage; note that the cache size starts growing only when the first button is created: no amount of memory is pre-allocated. 
    Obviously this section goal is not to tell you how to design your application user interface, but it gives you a mean to speed up your user interface loading time. 
    IMPORTANT NOTES
  • Buttons with alpha channel transparency (set through the SurfaceTransparentFactor property or abmSetTotalTransparentFactor function) will not be stored in cache. 
  • If controls are placed inside a form with a background picture, the caching system will not be effective: controls need to anti-alias their external border with the underlying portion of the picture so each control will have a different bitmap: if you need a fast rendering speed avoid the use of background pictures in your forms or, in alternative, set the UseAntialiasing property to FALSE and the SurfaceTransparentFactor property to 0. 
  • If for any reason you should decide that you need more memory for your application, you could use the abmClearButtonCache function in order to free all the memory dedicated to the cached buttons storage; note that the cache size starts growing only when the first button is created: no amount of memory is pre-allocated. At any time, you can know the amount of memory used by the caching system calling the abmGetButtonCacheSize method. 
  • The caching system is enabled by default: if you need more memory for your application, you can disable the caching system through the abmEnableButtonCache function. 
  •  
     
     
     
     
     
     
     
     
     
     
     
    Copyright © 2002-2009 MultiMedia Soft 
    Return to index