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

pipewire: Properly pass sizes to gs_draw_sprite_subregion #4985

Merged

Conversation

GeorgesStavracas
Copy link
Member

@GeorgesStavracas GeorgesStavracas commented Jul 7, 2021

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

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@GeorgesStavracas GeorgesStavracas force-pushed the gbsneto/fix-pipewire-crop branch from 7b37a2e to fd2c398 Compare July 7, 2021 14:31
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.

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

Fixes obsproject#4982
@GeorgesStavracas GeorgesStavracas force-pushed the gbsneto/fix-pipewire-crop branch from fd2c398 to a688d18 Compare July 7, 2021 14:46
@WizardCM WizardCM added Bug Fix Non-breaking change which fixes an issue Linux Affects Linux labels Jul 7, 2021
@jp9000 jp9000 merged commit ec3e814 into obsproject:master Jul 8, 2021
@GeorgesStavracas GeorgesStavracas deleted the gbsneto/fix-pipewire-crop branch July 8, 2021 16:54
@WizardCM WizardCM added this to the OBS Studio 27.1 milestone Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Fix Non-breaking change which fixes an issue Linux Affects Linux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants