Skip to content

libdmview: draw nothing beneath an opaque box of the root - #13

Merged
JohnAmadis merged 1 commit into
mainfrom
perf/occlusion
Oct 4, 2026
Merged

JohnAmadis merged 1 commit into
mainfrom
perf/occlusion

Conversation

@JohnAmadis

Copy link
Copy Markdown
Contributor

Summary

A redraw of the root used to draw everything, including what an opaque box drawn later hides. The usual case is an application window sliding over the home screen: the whole home screen was drawn on every animation frame, and then the window over most of it.

Now, before a redraw of the root:

  1. The view runs once without drawing (an empty clip). That finds where the boxes are this time, since a box may move with a variable ($win_y).
  2. The occluder is chosen from the opaque boxes of the root (OPAQUE, not translucent, visible): the one that hides the most of the redrawn area, as long as the rest is one rectangle. An example is a full-width box at the top or bottom of the area.
  3. In the real run, everything executed before the occluder's BOX is drawn only in the part that shows, and from that BOX on the full clip is back. Execution order matters, not position in the code, so subroutines called before the window are covered.

Views without opaque boxes of the root do not pay for the extra run. Partial redraws of a box are unchanged.

Testing

  • Same pixels: frames of the dmodOS example rendered on the host in RGB565, before and after the change, are byte-for-byte identical. That covers 9 frames, including the opening and closing animations at several points.
  • Tests: test_libdmview passes.
  • STM32F746G-DISCO: rendering a full-screen frame of the slide animation (DWT cycle counter) takes 13–24 ms, down from 40–47 ms. That includes the run without drawing (~0.5 ms).

🤖 Generated with Claude Code

A redraw of the root drew everything, also what an opaque box drawn later
hides - an application window sliding over the home screen. A run of the
view without drawing finds where the boxes are this time; the opaque box
of the root that hides the most of the area (leaving one rectangle) is
the occluder, and everything executed before its BOX is drawn only where
it shows. Views without opaque boxes of the root do not pay for the extra
run. The pixels are the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JohnAmadis
JohnAmadis merged commit 1e7f129 into main Oct 4, 2026
1 check 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.

1 participant