Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion packages/native/src/dioxus_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,20 @@ impl DioxusNativeWindowRenderer {
Self::with_inner_renderer(vello_renderer)
}

#[cfg(any(feature = "vello-hybrid", feature = "vello"))]
// Gated on the renderer the `cfg_if` above actually selected, not on
// whichever renderer features happen to be enabled. `vello-hybrid` being
// enabled does not mean it is selected: it is last in the chain, and it is
// a default feature, so any downstream crate that also asks for
// `vello-cpu-*` or `skia` has both. `Features`, `Limits` and
// `InnerRendererOptions` only exist in the two wgpu arms.
#[cfg(any(
feature = "vello",
all(
feature = "vello-hybrid",
not(feature = "vello-cpu-base"),
not(feature = "skia")
)
))]
pub fn with_features_and_limits(features: Option<Features>, limits: Option<Limits>) -> Self {
let mut options = InnerRendererOptions::default();
options.features = features;
Expand Down
57 changes: 49 additions & 8 deletions packages/native/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,24 @@ pub fn current_android_app() -> android_activity::AndroidApp {
#[cfg_attr(docsrs, doc(cfg(target_os = "android")))]
pub use android_activity::AndroidApp;

// These two re-exports need different conditions, so they cannot share one
// `pub use`. `wgpu_context` is the optional dependency that `vello` and
// `vello-hybrid` both enable, so `DeviceHandle` exists whenever either feature
// is on. `Features`/`Limits` come from `dioxus_renderer`, which only defines
// them in the arm its `cfg_if` selected - and `vello-hybrid` is last in that
// chain as well as a default feature, so being enabled is not being selected.
#[cfg(any(feature = "vello", feature = "vello-hybrid"))]
pub use {
dioxus_renderer::{Features, Limits},
wgpu_context::DeviceHandle,
};
pub use wgpu_context::DeviceHandle;

#[cfg(any(
feature = "vello",
all(
feature = "vello-hybrid",
not(feature = "vello-cpu-base"),
not(feature = "skia")
)
))]
pub use dioxus_renderer::{Features, Limits};

pub use blitz_dom::{FontContext, Widget, build_single_font_ctx};
pub use config::Config;
Expand Down Expand Up @@ -124,12 +137,26 @@ pub fn launch_cfg_with_props<P: Clone + 'static, M: 'static>(
}

// Read config values
#[cfg(any(feature = "vello", feature = "vello-hybrid"))]
#[cfg(any(
feature = "vello",
all(
feature = "vello-hybrid",
not(feature = "vello-cpu-base"),
not(feature = "skia")
)
))]
let (mut features, mut limits) = (None, None);
let mut window_attributes = None;
let mut config = None;
for mut cfg in configs {
#[cfg(any(feature = "vello", feature = "vello-hybrid"))]
#[cfg(any(
feature = "vello",
all(
feature = "vello-hybrid",
not(feature = "vello-cpu-base"),
not(feature = "skia")
)
))]
{
cfg = try_read_config!(cfg, features, Features);
cfg = try_read_config!(cfg, limits, Limits);
Expand Down Expand Up @@ -216,9 +243,23 @@ pub fn launch_cfg_with_props<P: Clone + 'static, M: 'static>(
..Default::default()
},
);
#[cfg(any(feature = "vello", feature = "vello-hybrid"))]
#[cfg(any(
feature = "vello",
all(
feature = "vello-hybrid",
not(feature = "vello-cpu-base"),
not(feature = "skia")
)
))]
let renderer = DioxusNativeWindowRenderer::with_features_and_limits(features, limits);
#[cfg(not(any(feature = "vello", feature = "vello-hybrid")))]
#[cfg(not(any(
feature = "vello",
all(
feature = "vello-hybrid",
not(feature = "vello-cpu-base"),
not(feature = "skia")
)
)))]
let renderer = DioxusNativeWindowRenderer::new();
let config = WindowConfig::with_attributes(
Box::new(doc) as _,
Expand Down