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

improved draw_text_mut performance #663

Merged
merged 1 commit into from
Jun 7, 2024
Merged

Conversation

Icekey
Copy link
Contributor

@Icekey Icekey commented Jun 7, 2024

I noticed during profiling that most of the time was spend just rounding numbers. It turned out that the min of the bounding box was rounded for every pixel in the "draw_text_mut" function.

In my testing the fix improved performace by a lot. For example drawing the text in the font.rs example 500000 times went from 22 sec down to 12 sec. The performance improvement is even better for texts with a larger font size. In one of my benchmarks the execution time went from 14.6 sec to 2.7 sec.

I also moved the "gv.clamp(0.0, 1.0)" into the if block, since it was not need before it, but this did not noticably change performance.

@theotherphil
Copy link
Contributor

Thanks!

(Aside: text drawing regression tests #244 would be really useful to help avoid breakages from refactoring in this area!)

@theotherphil theotherphil merged commit d156280 into image-rs:master Jun 7, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants