diff --git a/src/render/systems.rs b/src/render/systems.rs index 72dc2ca..c569b2e 100644 --- a/src/render/systems.rs +++ b/src/render/systems.rs @@ -348,44 +348,21 @@ pub fn render_settings_change_detection( /// Hide the render target canvas if there is nothing to render pub fn hide_when_empty( mut query_render_target: Option>>, - // TODO: Fix this monstrocity by having a resource that counts the amount of render items. - // ----- It would be useful for debugging purposes, too. - #[cfg(all(feature = "svg", feature = "lottie"))] render_items: Query< - (), - Or<( - With, - With, - With, - With, - )>, - >, - #[cfg(all(not(feature = "lottie"), not(feature = "svg")))] render_items: Query< - (), - Or<(With, With)>, - >, + #[cfg(feature = "svg")] render_svgs: Query<&VelloSvgHandle>, + #[cfg(feature = "lottie")] render_lotties: Query<&VelloLottieHandle>, + render_texts: Query<&VelloTextSection>, + render_scenes: Query<&VelloScene>, +) { + // TODO: Optimize by having a VelloDiagnostics resource which counts render objects both for introspection and quick determination of whether we have anything to render. + // See https://github.com/linebender/bevy_vello/issues/117 + let is_empty = render_texts.is_empty() && render_scenes.is_empty(); #[cfg(feature = "svg")] - #[cfg(not(feature = "lottie"))] - render_items: Query< - (), - Or<( - With, - With, - With, - )>, - >, + let is_empty = is_empty && render_svgs.is_empty(); #[cfg(feature = "lottie")] - #[cfg(not(feature = "svg"))] - render_items: Query< - (), - Or<( - With, - With, - With, - )>, - >, -) { + let is_empty = is_empty && render_lotties.is_empty(); + if let Some(visibility) = query_render_target.as_deref_mut() { - if render_items.is_empty() { + if is_empty { **visibility = Visibility::Hidden; } else { **visibility = Visibility::Inherited;