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

Draft: Optionally submit 10 bit buffers #54

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mstoeckl
Copy link
Collaborator

@mstoeckl mstoeckl commented Jan 8, 2023

This PR builds on top of !53, and makes Swaybg submit 10-bit buffers when the background image it is given is a 16-bit deep PNG file. (#53 is necessary since Cairo does not have an equivalent to CAIRO_FORMAT_RGB30 with an alpha channel; without #53, this code would render transparent 8-bit PNGs with alpha and 16-bit PNGs without.)

Note: loading 16-bit PNG images gave incorrect results with Cairo 1.17.2 through 1.17.5. Since 16 bit PNG images are rare, and most distributions either use stable releases (latest 1.16.0), or development snapshots (latest 1.17.6), this bug is unlikely to affect anyone. Cairo versions before 1.17.2 reduce 16-bit PNG files to 8-bit on loading; swaybg will continue to submit 8-bit buffers for these.

This ensures that the background is always opaque.

This is a significant change; before, if no background color was
specified, images were drawn onto an initially transparent buffer,
leaving some of the content behind swaybg visible if the image was
alpha transparent or if the 'fit' or 'center' scaling modes were used
and the image aspect ratio did not match, or the image was not large
enough. As the purpose of a wallpaper/background program is to draw
the pixels behind all other interface items, this transparency is
neither a required nor a very useful behavior.

The new color is close to the result of blending the old default
background color (#00000000 = transparent) with the color Sway uses
to clear the background ([0.25,0.25,0.25,1.0] = mid gray). Users of
other compositors may need to adjust their images or specify the
--color flag on the command line.
This lets the compositor avoid needing to clear and blend the
pixels behind the background surface made by swaybg.
This requires that the compositor support either XRGB2101010 or XBGR2101010,
and that the background image is a 16-bit PNG.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant