Skip to content

Commit

Permalink
Fix WASM compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Apr 13, 2022
1 parent 3efe681 commit 4e9bb87
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct AppState {
context_panel: crate::context_panel::ContextPanel,
time_panel: crate::time_panel::TimePanel,

#[cfg(feature = "puffin")]
#[cfg(all(feature = "puffin", not(target_arch = "wasm32")))]
#[serde(skip)]
profiler: crate::misc::profiler::Profiler,
}
Expand Down Expand Up @@ -90,7 +90,7 @@ impl AppState {
ui.close_menu();
}

#[cfg(feature = "puffin")]
#[cfg(all(feature = "puffin", not(target_arch = "wasm32")))]
if ui
.button("Profile viewer")
.on_hover_text(
Expand Down Expand Up @@ -125,7 +125,7 @@ impl AppState {
space_view,
context_panel,
time_panel,
#[cfg(feature = "puffin")]
#[cfg(all(feature = "puffin", not(target_arch = "wasm32")))]
profiler: _,
} = self;

Expand Down
4 changes: 2 additions & 2 deletions viewer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub use web::start;
#[macro_export]
macro_rules! profile_function {
($($arg: tt)*) => {
#[cfg(feature = "puffin")]
#[cfg(all(feature = "puffin", not(target_arch = "wasm32")))]
puffin::profile_function!($($arg)*);
};
}
Expand All @@ -44,7 +44,7 @@ macro_rules! profile_function {
#[macro_export]
macro_rules! profile_scope {
($($arg: tt)*) => {
#[cfg(feature = "puffin")]
#[cfg(all(feature = "puffin", not(target_arch = "wasm32")))]
puffin::profile_scope!($($arg)*);
};
}
2 changes: 1 addition & 1 deletion viewer/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod clipboard;
mod image_cache;
pub(crate) mod log_db;
pub(crate) mod mesh_loader;
#[cfg(feature = "puffin")]
#[cfg(all(feature = "puffin", not(target_arch = "wasm32")))]
pub(crate) mod profiler;
pub(crate) mod time_axis;
mod time_control;
Expand Down
2 changes: 1 addition & 1 deletion viewer/src/misc/clipboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl Clipboard {
}
}

#[cfg(feature = "puffin")] // only used sometimes
#[cfg(all(feature = "puffin", not(target_arch = "wasm32")))] // only used sometimes
pub fn set_text(&mut self, text: String) {
if let Some(clipboard) = &mut self.arboard {
if let Err(err) = clipboard.set_text(text) {
Expand Down
3 changes: 3 additions & 0 deletions viewer/src/ui/context_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ pub(crate) fn show_detailed_log_msg(context: &mut ViewerContext, ui: &mut egui::
}
}

#[cfg(not(target_arch = "wasm32"))]
fn image_options(ui: &mut egui::Ui, image: &log_types::Image) {
// TODO: support copying images on web
#[cfg(not(target_arch = "wasm32"))]
Expand Down Expand Up @@ -167,6 +168,7 @@ fn image_options(ui: &mut egui::Ui, image: &log_types::Image) {
}
}

#[cfg(not(target_arch = "wasm32"))]
fn to_rgba_unultiplied(image: &log_types::Image) -> Vec<u8> {
match image.format {
log_types::ImageFormat::Luminance8 => {
Expand All @@ -175,6 +177,7 @@ fn to_rgba_unultiplied(image: &log_types::Image) -> Vec<u8> {
}
}

#[cfg(not(target_arch = "wasm32"))]
fn to_image_image(image: &log_types::Image) -> Option<image::DynamicImage> {
let [w, h] = image.size;
match image.format {
Expand Down

0 comments on commit 4e9bb87

Please sign in to comment.