renderer/utils: queue surface damage when the alpha multiplier changes#2064
Open
gaoyia wants to merge 1 commit into
Open
renderer/utils: queue surface damage when the alpha multiplier changes#2064gaoyia wants to merge 1 commit into
gaoyia wants to merge 1 commit into
Conversation
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
wp_alpha_modifiermultiplier inRendererSurfaceStateand queue full-surface damage fromupdate_buffer()when it changed, so compositors usingOutputDamageTrackerrepaint surfaces whose commit only carries a new multiplier.Problem
WaylandSurfaceRenderElementappliesAlphaModifierSurfaceCachedStateat draw time, but itsElement::current_commit()is tied to bufferDamageBagupdates only.When a client:
wp_alpha_modifier_surface_v1.set_multiplier, thenwl_surfacewithout attaching a new buffer or sendingwl_surface.damage,the cached multiplier updates correctly, yet
OutputDamageTrackersees no new damage for that element and may skip redrawing it. The on-screen pixels keep the previous opacity.This is visible with any client that drives opacity through
wp_alpha_modifier(or Chromium’szcr_alpha_compositingextension) on an incremental KMS/GL compositor.Solution
All in
backend/renderer/utils/wayland.rs:RendererSurfaceState::alpha_multiplierstoring the multiplier that was current at the last commit (reset together with the rest of the state).update_buffer()— whichon_commit_buffer_handlerruns for every surface in the tree on each commit — readAlphaModifierSurfaceCachedState::multiplier()from the current (post-merge) state and compare it with the stored value. On change, add a full-buffer rectangle to the surfaceDamageBag.Queueing the damage at commit time (rather than when the
set_multiplierrequest arrives) matches the double-buffered semantics of the protocol: the multiplier only takes effect onwl_surface.commit, and that is exactly when the damage is now recorded. Compositors need no extra calls;on_commit_buffer_handlercovers everything, including a multiplier set before the first buffer attach (the first buffer commit damages the whole surface anyway).Alternatives considered
set_multiplierrequest handler — simpler, but races with rendering: a frame drawn between the request and the commit consumes the damage while the old multiplier is still active, reintroducing the stale-opacity bug.WaylandSurfaceRenderElement::current_commitdirectly when the multiplier changes — affects all compositors’ damage semantics and still needs commit-time tracking.Test plan
smithaywithwayland_frontend+backend_egl(or your compositor feature set).AlphaModifierStateand usesOutputDamageTracker(e.g. Anvil, or a minimal test compositor).wl_shmbuffer,wp_alpha_modifier_surface_v1,set_multipliertou32::MAX / 2,wl_surface.damageor re-attach.set_multiplier(u32::MAX)anddestroyto confirm return to opaque / default.Optional:
WAYLAND_DEBUG=1and verifyset_multiplieris received; no protocol changes.Related
wp_alpha_modifierstaging protocol — multiplier is double-buffered onwl_surface.commit.zcr_alpha_compositing_v1— same rendering path viaAlphaModifierSurfaceCachedStatein downstream compositors that bridge the extension.