Monday, January 22nd 2018, 11:05am UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

giusloq

Beginner

Date of registration: Feb 5th 2015

Posts: 60

1

Saturday, May 9th 2015, 3:34pm

Why I see flickering during redrawing a transparent IMAGE widget that is created with WM_CF_MEMDEV_ON_REDRAW flag?

I'm using emWin with a ILI9341-based TFT connected to the MCU through a 16-bits parallel bus.
I don't have too much RAM, so I can't use a display data cache. Moreover, I usually don't use memory devices for windows (the library wouldn't be able to find sufficient memory space for memory device, so enabling this functionality for all windows isn't useful).

But I have some small transparent images and I'd like to use memory devices when redrawing them. I specify WM_CF_MEMDEV_ON_REDRAW in IMAGE_CreateEx().

Only for test, I call IMAGE_SetBitmap() every 1 second, same IMAGE handle, same transparent bitmap. I noticed some flickering on this image on the display.

I understood that the library, for transparent image, must redraw firstly the background and after the transparent image. I think this is the cause of the flicker.
But these two-steps drawing should be done in a memory device in RAM. Only the result should be written to the framebuffer on the external controller.

So the question is: why I see flickering during redrawing a transparent IMAGE widget that is created with WM_CF_MEMDEV_ON_REDRAW flag?
How could I be sure a memory device is really used during redrawing operations on that widget?

SEGGER - Thorsten

Super Moderator

Date of registration: Apr 28th 2015

Posts: 38

2

Monday, May 11th 2015, 5:03pm

Hello,

In your case a Memory Device will not be used. Please make sure that the window below
the transparent IMAGE widget is created using the create flag
WM_CF_MEMDEV_ON_REDRAW, because transparent windows are rendered while
the below window is drawn, no matter if Memory Devices are used or not.
Memory Devices will be used for drawing in case the according window (or
widget) was created using the create flag WM_CF_MEMDEV_ON_REDRAW.

We will update the emWin user manual in order to make this clear in a future manual revision.

Best regards
Thorsten

giusloq

Beginner

Date of registration: Feb 5th 2015

Posts: 60

3

Tuesday, May 12th 2015, 10:09am

Hello Thorsten,

thank you for your answer, but I have some doubts yet.

Suppose I have Window1 100x100 and one child Image1 10x10 that is transparent. Only Image1 is created with WM_CF_MEMDEV_ON_REDRAW.
By calling IMAGE_SetBitmap(Image1, ...), the full 10x10 Image1 window is flagged as invalid. Because it is transparent, also the 10x10 rectangle of Window1 is flagged as invalid.
On next GUI_Exec(), WM_PAINT for Window1 is raised and only the small 10x10 rectangle is really updated. Because Window1 doesn't use memory devices, it is updated immediately on the framebuffer. After that, WM_PAINT for Image1 is raised and the transparent image is drawn (if the image is true-color with alpha channel, read operations are involved during drawing). These two-steps drawing operations (first the small rectangle of Window1, next the full Image1) cause flickering.

Now suppose both windows are created with WM_CF_MEMDEV_ON_REDRAW flag. I'm not sure what really happens. If I understood correctly, there are always two different WM_PAINT messages and the fickering is always present. The only difference is in the drawing process of Window1. If there were multiple drawing function calls (lines, circles and so on) in the WM_PAINT of Window1, only the final result is really written on the framebuffer. But the flickering caused by the two WM_PAINT messages is still present.

If this is correct, is there another method to avoid the flickering?

SEGGER - Adrian

Super Moderator

Date of registration: May 26th 2009

Posts: 1,022

4

Tuesday, May 12th 2015, 12:10pm

Hello,

Please note that the Memory Device setting transparent windows are actually meaningless. In case the below window is drawn using Memory Devices the transparent window is drawn into the same device. Otherwise both windows are drawn directly into the frame buffer.

We recommend you to enable Memory Device usage for the below window. This should resolve the flickering problem.

Best regards,
Adrian