Optimize display list walk to one pass - #21
Merged
Merged
Conversation
To find how far an item may draw from a pixel, every renderer called *_find_max_line_len(), which scanned all the items above the drawn one again. Each draw call walked the item list twice, and a long display list cost time proportional to the square of its length on every run of pixels. The item loop in the DCS LCD, mono, e-paper and SDL renderers now keeps that limit as a running minimum while it walks the items once: an item above that starts further right on the row shortens the run, as before. The output is unchanged. The *_find_max_line_len() functions are removed. The scaled_cropped_image renderers also stop reducing the item width to the remaining source image, since the parser already does so. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Tom Hoenderdos <tomhoenderdos@gmail.com>
bettio
approved these changes
Oct 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Split out of #18.
To find how far an item may draw from a pixel, every renderer called
*_find_max_line_len(), which scanned all the items above the drawn one again. Each draw call walked the item list twice, so a long display list cost time proportional to the square of its length on every run of pixels.The item loop in the DCS LCD, mono, e-paper and SDL renderers now keeps that limit as a running minimum while it walks the items once. It considers the same items as before (those above the drawn one that start further right on the row), so the output is unchanged. The
*_find_max_line_len()functions are removed.The
scaled_cropped_imagerenderers also stop reducing the item width to the remaining source image, since the parser does that since #19.Testing:
tests/items(ASan + UBSan, against AtomVM release-0.7): all 396 checks pass, including the pixel checks of images under occluding rects.🤖 Generated with Claude Code