소스 검색

linux-pipewire: Check for effective crop region

Some compositors send buffer crop information even when the crop
matches the buffer size. It doesn't really matter in practice,
but it's good hygiene to check for the effective crop instead of
simply checking if crop exists.
Georges Basile Stavracas Neto 2 년 전
부모
커밋
436787c1f4
1개의 변경된 파일16개의 추가작업 그리고 8개의 파일을 삭제
  1. 16 8
      plugins/linux-pipewire/pipewire.c

+ 16 - 8
plugins/linux-pipewire/pipewire.c

@@ -1020,43 +1020,51 @@ void obs_pipewire_hide(obs_pipewire *obs_pw)
 
 uint32_t obs_pipewire_get_width(obs_pipewire *obs_pw)
 {
+	bool has_crop;
+
 	if (!obs_pw->negotiated)
 		return 0;
 
+	has_crop = has_effective_crop(obs_pw);
+
 	switch (obs_pw->transform) {
 	case SPA_META_TRANSFORMATION_Flipped:
 	case SPA_META_TRANSFORMATION_None:
 	case SPA_META_TRANSFORMATION_Flipped180:
 	case SPA_META_TRANSFORMATION_180:
-		return obs_pw->crop.valid ? obs_pw->crop.width
-					  : obs_pw->format.info.raw.size.width;
+		return has_crop ? obs_pw->crop.width
+				: obs_pw->format.info.raw.size.width;
 	case SPA_META_TRANSFORMATION_Flipped90:
 	case SPA_META_TRANSFORMATION_90:
 	case SPA_META_TRANSFORMATION_Flipped270:
 	case SPA_META_TRANSFORMATION_270:
-		return obs_pw->crop.valid ? obs_pw->crop.height
-					  : obs_pw->format.info.raw.size.height;
+		return has_crop ? obs_pw->crop.height
+				: obs_pw->format.info.raw.size.height;
 	}
 }
 
 uint32_t obs_pipewire_get_height(obs_pipewire *obs_pw)
 {
+	bool has_crop;
+
 	if (!obs_pw->negotiated)
 		return 0;
 
+	has_crop = has_effective_crop(obs_pw);
+
 	switch (obs_pw->transform) {
 	case SPA_META_TRANSFORMATION_Flipped:
 	case SPA_META_TRANSFORMATION_None:
 	case SPA_META_TRANSFORMATION_Flipped180:
 	case SPA_META_TRANSFORMATION_180:
-		return obs_pw->crop.valid ? obs_pw->crop.height
-					  : obs_pw->format.info.raw.size.height;
+		return has_crop ? obs_pw->crop.height
+				: obs_pw->format.info.raw.size.height;
 	case SPA_META_TRANSFORMATION_Flipped90:
 	case SPA_META_TRANSFORMATION_90:
 	case SPA_META_TRANSFORMATION_Flipped270:
 	case SPA_META_TRANSFORMATION_270:
-		return obs_pw->crop.valid ? obs_pw->crop.width
-					  : obs_pw->format.info.raw.size.width;
+		return has_crop ? obs_pw->crop.width
+				: obs_pw->format.info.raw.size.width;
 	}
 }