Skip to content

Commit

Permalink
pipewire: Properly pass sizes to gs_draw_sprite_subregion
Browse files Browse the repository at this point in the history
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 floats representing position (x, y) and a pair of floats
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.

Pass only width and height to gs_draw_sprite_subregion(), instead
of summing them with x and y.

Fixes obsproject#4982
  • Loading branch information
GeorgesStavracas committed Jul 7, 2021
1 parent 4d9d7b7 commit 7b37a2e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions plugins/linux-capture/pipewire.c
Original file line number Diff line number Diff line change
Expand Up @@ -1200,9 +1200,8 @@ void obs_pipewire_video_render(obs_pipewire_data *obs_pw, gs_effect_t *effect)

if (has_effective_crop(obs_pw)) {
gs_draw_sprite_subregion(obs_pw->texture, 0, obs_pw->crop.x,
obs_pw->crop.y,
obs_pw->crop.x + obs_pw->crop.width,
obs_pw->crop.y + obs_pw->crop.height);
obs_pw->crop.y, obs_pw->crop.width,
obs_pw->crop.height);
} else {
gs_draw_sprite(obs_pw->texture, 0, 0, 0);
}
Expand Down

0 comments on commit 7b37a2e

Please sign in to comment.