cancel
Showing results for 
Search instead for 
Did you mean: 

When are invalidated areas re-rendered?

scottSD
Lead

I am running an experiment to try to see how I can improve RENDER_TIME performance. In this experiment I have two items on the screen close to each other on the screen.

One is a circle who's start and end angles are changed. The other item is a text area who's value coincides with the circle's value.

When they touch (even just edges) the invalidated rectangle encompasses a large area (seen by pressing F2 when running the simulator).

In my handleTickEvent() function, I am updating one item in that tick event only. The next event I update the other item only. I didn't think it would redraw a large rectangle because they would be rendered at different times, but it is. I slowed it down so that it only updated every 30 ticks. I also placed a touchgfx_printf() in each item's update code to verify only one item is updated at a time.

When are invalidated areas re-renedered? It appears that they aren't re-rendered at separate times but at the same time.

5 REPLIES 5

Hi Scott.

I have created an example with a circle and a text. I hope it is similar to your setup.

I will try to explain the re-rendering process.

Here is a screen shot from the Designer. The TextArea widgets is inside the big circle widget. The "t:0" TextArea in the upper left corner shows the current frame number.

I have lowered the framerate on my simulator to 1Hz. Do this by adding one line to simulator/main.cpp (after the call to setupSimulator):

static_cast<HALSDL2&>(hal).setVsyncInterval(1000);

I have implemented a handleTickEvent method in my screen to do some invalidation:

void Screen1View::handleTickEvent()

{

  //press F2 to show invalidated areas

  tickCount++;

  Unicode::itoa(tickCount % 100, textAreaTickBuffer, TEXTAREATICK_SIZE, 10);

  textAreaTick.invalidate();

  switch(tickCount)

  { 

  case 5:

    circle.updateArcStart(94);

    break;

  case 10:

    textArea.setColor(touchgfx::Color::getColorFrom24BitRGB(0xF7, 0xC0, 0xC0));

    textArea.invalidate();

    break;

  case 15:

    circle.updateArcStart(98);

    circle.updateArcEnd(314);

    break;

  }

}

I also use F2 to get the invalidated areas highlighted.

The first frame looks like this (the whole frame is invalidated):

0690X000009ZcO9QAK.bmp The second frame looks the same:

0690X000009ZcOEQA0.bmp

The reason for this second full update is that I am using double buffering. The whole updates done on the previous framebuffer must be applied on the second buffer also.

In frame 5, we update the start angle on the circle. Again we get updates in two frames:

0690X000009ZcOOQA0.bmp

0690X000009ZcOYQA0.bmp

Only the little piece of the circle was redrawn.

In frame 10 I change the color of the TextArea and invalidate that:

0690X000009ZcOiQAK.bmp

0690X000009ZcOnQAK.bmp

In frame 15 I change both the start angle and the end angle of the circle:

0690X000009ZcOsQAK.bmp

0690X000009ZcOxQAK.bmp

The TextArea is not invalidated here.

If you have seen that invalidating the Circle also redraws the TextArea, it could be because of double buffering, that requires the framework to repeat a change in the first buffer also in the next buffer.

I hope this helps. Otherwise please provide more information.

Regards

Flemming

Flemming,

Thanks for your reply. I am using the STM32H750-Discovery kit and have not changed any of the configuration. From what I see in the file BoardConfiguration.cpp, it is set up for double buffering:

0690X000009Zd8lQAC.png

However, I do not think this is the issue. I made a project like yours (including changing the Vsync interval on the simulator). It appeared to work like yours until I did one thing. I commented out the invalidation of the textAreaTick because mine will not have this:

0690X000009Zd8bQAC.png

When I did this, I was seeing the same thing that I was with my project (tickCount not being invalidated):

0690X000009Zd9PQAS.png

And, interestingly, when I added a textAreaTick to my project, it started behaving as I think it should (alternation of renders).

Why is the invalidation of the textAreaTick aiding the alternation of rendering of the other two items?

Is this only an issue with the simulator or will it also behave like this on the target (I am not sure how to determine this on the target)?

Hi

The algorithm is the same on the target and simulator.

​The invalidation of the tick text area causes the framebuffers to be fully drawn in the first two frames. Otherwise nothing will happen until you invalidate the circle or center TextArea.

If you have two invalidated areas that overlap then they will be replaces by a single area large enough to contain them both. I think this is why you get the large rectangle in your example above. This happens to reduce the number of area. Normally it is not a problem.

Try to check what you are invalidating in this frame and the previous.

Regards

I understand that if it's a big block and overlaps, it needs to redraw all of it. This is the reason I am alternating the invalidation of the different items. The issue I am seeing is that they are invalidating at the same time when they should be alternating. The code is the same exact as yours as I copy/pasted your handleTickEvent() into my Screen1View.cpp file. The rendering alternates as expected. However, If I comment out the invalidation of the textAreaTick, it does NOT alternate but happens at the same time.

I reduced the size of the inside text area to ensure there are no overlaps and ran it again (with the invalidation of the textAreaTick commented out) and as you can see, they are happening at the same time (even with no overlaps):

0690X000009ZdEUQA0.png

Would it be possible to for you to comment out the call textAreaTick.invalidate() in your code to see if this happens for you as well?

​Hi Scott

Yes, if you do not invalidate the TickTextArea in every tick, then you get the TextArea and Circle redrawn in the same frame. This is due to double buffering.

In frame 10 we invalidate the textArea. This causes the textArea to be redrawn in the current framebuffer (call it FB_A).

In frame 11, 12, 13, and 14, nothing is invalidated, so TouchGFX does not draw anything.

In frame 15 we invalidate the circle in both ends. This causes the circle ends to be redrawn in the current framebuffer (FB_B). Since the textArea is not correct in FB_B (was updated in FB_A), it is also redrawn in frame 15.

You can disable double buffering on the simulator by clearing a variable: HAL::USE_DOUBLE_BUFFERING = false;

The essential parts of my main.cpp is now:

HAL& hal = touchgfx_generic_init<HALSDL2>(dma, lcd, tc, SIM_WIDTH, SIM_HEIGHT, 0, 0);

setupSimulator(argc, argv, hal);

static_cast<HALSDL2&>(hal).setVsyncInterval(1000);

HAL::USE_DOUBLE_BUFFERING = false;

Hope this helps.