Skip to content

Add fast path for stripping rectangles #900

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

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open

Add fast path for stripping rectangles #900

wants to merge 20 commits into from

Conversation

LaurenzV
Copy link
Contributor

@LaurenzV LaurenzV commented Apr 6, 2025

This re-adds my previously implemented fast path for rectangles. In my test scene with 20000 rectangles, this reduces the rendering time from around 37ms to 19ms!

@LaurenzV LaurenzV requested a review from tomcur April 6, 2025 09:33
Copy link
Member

@tomcur tomcur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An initial thought inline, I'll look more in-depth in the coming days.

Copy link
Member

@tomcur tomcur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most tests with rectangles call RenderContext::fill_rect, which now uses the specialized path for rectangles. It would be good to continue exercising the general case as well.

I don't know what the best solution looks like. Perhaps performing multiple tests against the same snapshot could work, though we'd have to be robust against small rounding errors.

@LaurenzV
Copy link
Contributor Author

I've added a few more test cases which check against the same snapshot as the rectangle case, I feel like this should already be an improvement? As you mentioned, there are few other test cases with rectangles, but there's also only so many ways to draw a rectangle. :P So I think this should already be a good coverage.

Copy link
Contributor

@taj-p taj-p left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! This was a great read! Certainly adding a fast path for rects makes sense and I can see how it is so much faster.

edit: If it isn't clear, please don't let any of my comments block this from merging!

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.

5 participants