浏览代码

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
Robert Mader 2 年之前
父节点
当前提交
0a36dc9d80
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      plugins/linux-pipewire/pipewire.c

+ 5 - 2
plugins/linux-pipewire/pipewire.c

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