How to improve alpha blending efficency ?

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • How to improve alpha blending efficency ?

    Hi everyone,

    I create the following effect by using alpha blending, it looks alright in simulator, yet in hardware environment I can see very obvious flickering ( when the message box is about to popup, I can see clearly of the drawing process of the mask window) , it seems the alpha blending effect has brought in a lot workload to CPU. Any suggestion on how to reduce the flickering ?



    Thanks & BR !

    Zhiying.
  • Hello Zhiying,

    I would recommend using Multiple Buffering or a driver cache, in case Multiple Buffering is not supported by the driver you use. Please find detailed information on how to do so in the chapter "Display Driver" and "Multiple Buffering" in the emWin user manual.

    Best regards,
    Adrian
  • Thanks Adrian,

    The driver I'm using is GUIDRV_Lin_32, I tried the "multiple buffering" and the flickering is gone, but I need to wait approximately 1 sec to see the popup msg window. It's rather slow compared to other widgets' response.
    I'm considering to remove the mask window effect :(
  • Hello Zhiying,

    The alpha-blending feature is already highly optimized, so I would recommend "faking" the actual effect. You can try to do the following:

    Overwrite the paint event of the parent dialog using a callback function. Create a variable (e.g. PopUpIsActive) which enables you determine if a popup window is active. In case the popup window has to be displayed, set the PopUpIsActive to 1 and invalidate the parent dialog. In the paint event do the same drawing but use a different (darker) color set for the displayed items. Once the popup window is removed again, set the variable PopUpIsActive to 0 and invalidate the parent dialog again.

    Best regards,
    Adrian
  • Hello Zhiying,

    An additional note on dimming. The next emWin version V5.22 will provide the functionality for blurring and dimming. This will actually do the task you want to achieve here. Please also note that there is currently no fixed release date.

    Best regards,
    Adrian
  • More information about Adrian's advice

    Hi, I am facing the same problem described in this thread and I would appreciate more information about how to implement the 'faking' effect. After overwritting the paint function how can I change the color of the widgets?

    C Source Code

    1. case WM_PAINT:
    2. {
    3. // Default painting.
    4. WM_DefaultProc(pMsg);
    5. // Custom painting.
    6. // What now?
    7. }
    8. break;

    The post was edited 2 times, last by RodolfoDias ().

  • Hi,

    Maybe this is something you are looking for.

    In this example we create some buttons. On a press on the center button we copy the some of the screen content into a memory device. Now we start an animation and each time the animation gets executed we change the color of the device and write it to the screen. The result is a fading effect for the buttons.

    Depending on the size of the area to be copied this can be quite memory consuming.

    Regards,
    Sven
    Files
    • FadeWindow.zip

      (8.51 kB, downloaded 422 times, last: )
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.