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

Only submit XRGB buffers #53

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Only submit XRGB buffers #53

wants to merge 2 commits into from

Conversation

mstoeckl
Copy link
Collaborator

@mstoeckl mstoeckl commented Jan 1, 2023

These two commits resolve #26, by always submitting opaque buffers. This is done by painting the buffers submitted with a uniform color, before drawing the image on top. The default color is chosen to match Sway's default background color, so that most people invoking swaybg under Sway with a semi-transparent (or badly sized fit or center mode image) will see the same result as before.

I've been undecided about this change for a while, since there is an alternative which preserves the current behavior; to detect when the output image may be semi-transparent, as a function of the scaling mode, the image size, the presence of the --color flag, and whether the image has an alpha channel. However, I don't think allowing transparency in edge cases is a good behavior for a wallpaper program to have, and solving #26 while keeping the current behavior makes the buffer creation logic more complicated, making changes like submitting 10-bit buffers -- for which Cairo only supports the opaque RGB30 format -- harder to implement.

Copy link
Member

@rpigott rpigott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me. I don't see the utility in transparent backgrounds.

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.
@mstoeckl
Copy link
Collaborator Author

I've rebased this to a) fix a merge conflict b) update the first commit to ensure that single-pixel-buffers are always opaque. I don't think any other changes made over the last two years would affect this code, but just to be sure this should probably be re-reviewed.

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.

Submit XRGB buffers when backgrounds are opaque
2 participants