Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic in the software renderer with clipped text and scale factor #3059

Merged
merged 4 commits into from Jul 7, 2023

Conversation

ogoffart
Copy link
Member

@ogoffart ogoffart commented Jul 6, 2023

We ended rendering glyphs with empty or even negative size, causing panics down the line.

I added a way in the screenshot tester to change the scale factor

CC: #2957

@ogoffart ogoffart added the a:renderer-software Software Renderer (mO,bF) label Jul 6, 2023
@ogoffart ogoffart requested a review from tronical July 6, 2023 16:04
We ended rendering glyphs with empty or even negative size, causing
panics down the line.

I added a way in the screenshot tester to change the scale factor

CC: #2957
In some case, when the clip is, eg on a 0.25 of a pixel, but the offset is 0.75,
(such that the begining of the glyph starts at 0.5) difference in
rounding in different computation can result in a width which is one
pixel bigger than the source image.
I couldn't reproduce this in a testcase, but this can be reproduced
while resizing or scrolling through a TextEdit

I think this fixes #2957

The panic fixed by this commit looks like this:
```
thread 'main' panicked at 'index out of bounds: the len is 131 but the index is 131', /home/olivier/slint/internal/core/software_renderer/draw_functions.rs:81:19
stack backtrace:
   3: i_slint_core::software_renderer::draw_functions::draw_texture_line
             at ./internal/core/software_renderer/draw_functions.rs:81:19
   4: <i_slint_core::software_renderer::RenderToBuffer<T> as i_slint_core::software_renderer::ProcessScene>::process_shared_image_buffer
             at ./internal/core/software_renderer.rs:1023:13
   5: i_slint_core::software_renderer::SceneBuilder<T>::draw_text_paragraph::{{closure}}
             at ./internal/core/software_renderer.rs:1404:37
   6: i_slint_core::textlayout::TextParagraphLayout<Font>::layout_lines::{{closure}}
             at ./internal/core/textlayout.rs:219:17
```
@ogoffart
Copy link
Member Author

ogoffart commented Jul 7, 2023

I added more commits that fixes more bugs.
I consider #2957 is fixed after that.

@ogoffart ogoffart merged commit 4a56531 into master Jul 7, 2023
26 checks passed
@ogoffart ogoffart deleted the olivier/swrenderer branch July 7, 2023 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:renderer-software Software Renderer (mO,bF)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants