pipewire: Properly pass sizes to gs_draw_sprite_subregion #4985
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.
Description
Pass only width and height to
gs_draw_sprite_subregion()
, instead of adding x and y to them.Motivation and Context
The
gs_draw_sprite_subregion()
function is used when a cropping rectangle is received from PipeWire. It is usually used by compositors to implement window screencast - where a large and mostly empty frame is sent, the window contents are only a small part of it, and the crop rectangle tells us that.Recently the wlroots implementation of portals started to use it to implement cropping, and it exposed a bug in the PipeWire code in OBS Studio. The gs_draw_sprite_subregion() function takes a pair of integers representing position (x, y) and a pair of integers representing size (width, height). The PipeWire code, however, passes a second pair of positions (x2, y2) instead of sizes, and it causes overrendering the crop area.
This bug wasn't hit yet because both GNOME and KDE implementations always send (0, 0) as position, which practically never trigger this condition.
How Has This Been Tested?
You can follow the steps described at #4982, and notice that with this PR, the issue is no more.
Types of changes
Checklist: