Repository navigation
feat(stlxgfx): added a straight alpha surface flag - #606
Merged
Merged
Conversation
Every blend makes its pixel opaque, so a picture drawn onto a transparent surface loses the coverage it needs to be blended again. A flagged surface keeps each pixel's coverage in its alpha, as a host test in CI checks.
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.
Summary
Every blend in libstlxgfx, userland's 2D drawing library, makes its pixel opaque, so a picture drawn onto a
transparent surface loses its coverage (the share of each pixel it covers), which it needs to be blended onto the
screen later, and a surface flag keeps that coverage.
Changes
flagsfield holdsSTLXGFX_SURFACE_STRAIGHT_ALPHA, theblending calls (
stlxgfx_blend_coverage,stlxgfx_fill_rect_blend,stlxgfx_blit_alpha,stlxgfx_blit_rounded_alpha,stlxgfx_blit_arc_cornerandstlxgfx_draw_text) store straight alpha (a color notmultiplied by its alpha), so a draw onto a transparent pixel stores its color and alpha. A draw onto a partly
covered pixel stores the coverage of both draws together, rounded up, with the mean of both colors weighted by the
coverage each shows, while opaque pixels, like every surface without the flag, blend exactly as before.
make host-testbuilds libstlxgfx's tests in userland/lib/libstlxgfx/tests/ with thebuild machine's clang and runs them there, outside Stellux, and a "Host tests" workflow runs the target on every
pull request.
stlxgfx_blit_arc_cornercasts its 8-bit coverage touint32_tbefore shifting it 24 bits left, since C promotes it to a signed
int, which the shift overflows for coverageabove 127.
and alpha, that picture blended once onto an opaque surface matches the same draw made there, a draw onto alpha 1 to
254 follows the rule that
stlxgfx_blend_straightstates, with each channel between both colors, and one onto alpha255 matches an unflagged surface. In QEMU on x86_64 and aarch64, with a terminal, the demo app windemo and the
settings app open, the desktop below the top bar is byte-identical to the base commit's, b36caf7 (the landing
record's reviews/gpu-compositor/14a2-desktop-x86_64.png and -aarch64.png show both desktops, the base on the left,
and 14a2-buttons-x86_64.png and -aarch64.png the settings app's buttons zoomed 4 times, the base above).