perf: implement more DrawTarget methods to improve performance
#2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There's a couple of changes going on here:
I updated
vexDisplayCopyRectinvocations to properly add0x20for the header bar toy2as well asy1.I modified
<DisplayDriver as DrawTarget>::draw_iterto fill individual pixels. I think that was the intention ofembedded-graphicsand it vastly improves performance.I implemented
fill_contiguouswhich is intended to be used for copying images and such to usevexDisplayCopyRect. I re-used the slice inDisplayDriverto save allocations all the time, but it might be better to just dynamically allocate instead of allocating a buffer of the max size up front.I implemented
fill_solidto fill rectanges the usual way.I added methods to update the rendering mode of the display.
Essentially, the original implementation just copied the entire buffer over at once, which wasn't very good for performance since
embedded-graphicscallsdraw_iterseveral times per frame typically, making for slow frame rates on complex scenes.