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

Optimize Plotter Fills #1391

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

yuzawa-san
Copy link
Contributor

@yuzawa-san yuzawa-san commented Oct 24, 2024

fixes #1386

something about the polygon fills is not super efficient. i would imagine there is some sort of flood filling happening which is overkill since we know each pixels state. for this reason, i used drawPixel. i also go left to right row by row since that has the best performance. i also made the fill below a fillRect which is efficient for bulk regions.

image

UPDATE:
used vertical lines instead

@vladisslav2011
Copy link
Contributor

vladisslav2011 commented Oct 25, 2024

On my machine this strategy is a lot slower, than drawing the fill with fillRect per point: ~20 ms per spectrogram @ 64k FFT vs ~9ms per spectrogram with fillRect. Unfilled spectrogram draws in ~7ms. I'm still using the old plotter (slightly patched to improve performance and add features) on linux though.
I'm getting ~100FPS without fill/75FPS with fill @ 64k FFT, 4k using fillRect strategy and 60FPS with fill using drawLines strategy.

@yuzawa-san
Copy link
Contributor Author

i played around with fillRect and it appears to work nicely, so i'm putting that back. the only optimization i left was to do that bulk fill for the region below the lowest part of the polyline.

the bad performance before i believe was related to QT_THREAD_PARALLEL_FILLS being used, but something about the solid colors (instead of the alpha blending) seems to be avoiding that code path and making things faster. https://github.com/qt/qtbase/blob/b2e0ff4bca5d81205c8425cdc528e5c2a2988172/src/gui/painting/qdrawhelper.cpp#L3967

cc @markjfine

if this does not work, i'll just revert fully to whatever it was before.

@argilo
Copy link
Member

argilo commented Oct 28, 2024

The fill appears to be drawn one pixel too far to the right:

Screenshot from 2024-10-28 15-38-03

@yuzawa-san
Copy link
Contributor Author

@argilo i also checked 2.17.5 and found that it was actually also off by a pixel there too, but i have fixed this. once again points in polygons can be in the middle of pixels, but the rectangles cannot it appears.

2.17.5:
Screenshot 2024-10-28 at 5 31 04 PM

this branch:
Screenshot 2024-10-28 at 6 14 34 PM

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.

bf40e76 disrupts remote control on Mac build
3 participants