linux-pipewire: Clear cursor texture on empty bitmap

If we receive an empty cursor bitmap - one without valid size - we
should hide the cursor. Do so by clearing the texture.

This fixes visible cursors when recording various games with Wayland
compositors.

Closes https://github.com/obsproject/obs-studio/issues/4895
This commit is contained in:
Robert Mader
2023-03-14 13:28:20 +01:00
committed by Georges Basile Stavracas Neto
parent b31344d82e
commit 0a36dc9d80

View File

@@ -719,6 +719,10 @@ read_metadata:
bitmap = SPA_MEMBER(cursor, cursor->bitmap_offset,
struct spa_meta_bitmap);
if (bitmap)
g_clear_pointer(&obs_pw->cursor.texture,
gs_texture_destroy);
if (bitmap && bitmap->size.width > 0 &&
bitmap->size.height > 0 &&
lookup_format_info_from_spa_format(
@@ -732,8 +736,7 @@ read_metadata:
obs_pw->cursor.width = bitmap->size.width;
obs_pw->cursor.height = bitmap->size.height;
g_clear_pointer(&obs_pw->cursor.texture,
gs_texture_destroy);
assert(obs_pw->cursor.texture == NULL);
obs_pw->cursor.texture = gs_texture_create(
obs_pw->cursor.width, obs_pw->cursor.height,
gs_format, 1, &bitmap_data, GS_DYNAMIC);