Missing draw_rectangle in experimental TargetPixelBuffer with VerticalLayout and HorizontalLayout #10380
-
Bug Description
draw_rectangle is not called for every rectangle that needs to be drawn in the scene
I have been implementing DMA2D support for STM32 micro controllers and came across some strange but reproducible behavior that appears to be a bug. In the two Slint code examples below, clicking the yellow square for the second time results in the 20x20px red rectangle not being drawn on the render pass in the "problematic" example but works correctly in the "no problems with rendering" example. If you implement TargetPixelBuffer and simply log the instructions and return false so that the SoftwareRenderer takes over you will notice this rectangle not being drawn. This has big implications for rendering on more complex guis but this is the simplest example I could come up with. Somewhat confusingly the logging behavior can be seen in both examples BUT the second example still renders correctly so the software renderer must be doing something extra behind the scenes I recon. Some of my theories about what is going on:
Run the two Slint code snippets. One shows the bug and the other shows it working correctly.
0.001297 [INFO ] fill_background_region: Rectangle { x: 0, y: 0, width: 800, height: 480 } [user clicks yellow square] 10.445149 [INFO ] fill_background_region: Rectangle { x: 0, y: 0, width: 800, height: 480 } [user clicks yellow square] 19.294291 [INFO ] fill_background_region: Rectangle { x: 0, y: 0, width: 60, height: 40 } Reproducible Code (if applicable)// problematic
export component MainWindow inherits Rectangle {
width: 800px;
height: 480px;
background: white;
VerticalLayout {
HorizontalLayout {
t := Text {
width: 60px;
font-size: 18px;
text: "y";
}
Rectangle {
width: 40px;
height: 40px;
Rectangle {
background: red;
width: 20px;
height: 20px;
}
}
}
Rectangle {
x: 0px;
height: 50px;
width: 100px;
background: yellow;
TouchArea {
clicked => {
t.text = t.text + "x";
}
}
}
}
}
// no problems with rendering
export component MainWindow inherits Rectangle {
width: 800px;
height: 480px;
background: white;
t := Text {
x: 0;
y: 0;
width: 60px;
font-size: 18px;
text: "y";
}
Rectangle {
x: 60px;
y: 0px;
width: 40px;
height: 40px;
Rectangle {
background: red;
width: 20px;
height: 20px;
}
}
Rectangle {
x: 0px;
y: 40px;
height: 50px;
width: 100px;
background: yellow;
TouchArea {
clicked => {
t.text = t.text + "x";
}
}
}
}Environment Details
Product Impact
Embedded touchscreen display
Blocker. I need to get the frame rate above 10fps to make the system usable. Therefore, I need to be able to implement DMA2D support. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
|
I tried to investigate this, but i don't see the bug. |
Beta Was this translation helpful? Give feedback.
-
|
If you could have a concrete application i could try that would help. |
Beta Was this translation helpful? Give feedback.
-
|
Is this bug still valid? |
Beta Was this translation helpful? Give feedback.
-
|
Hi, my apologies for dropping the ball on this one. I spent a couple of hours scratching around with this again and came up with the following example: https://github.com/ninjasource/slint_draw_rect just I see that the |
Beta Was this translation helpful? Give feedback.
Thanks for the example. I see what's going on.
I transformed this issue into a discussion because this is not a bug as far as i can tell.
The Problem is that your code ignores the clipping when drawing rectangle, and draw the background on the bounding rect.
The region is composed of two rectangle that are dirty.
The yellow one (because of the layout change) and the text, but the red rectangle is not considered as dirty and is not part of the region to be redrawn.
But since you use the bounding box to render the background instead of iterating over the clip rectangles, the background is painted over the red rectangle.
Would it help you if there was a way to configure the dirty region to h…