Skip to content

Commit

Permalink
Make test, web and android targets compile
Browse files Browse the repository at this point in the history
  • Loading branch information
maxammann committed Jul 3, 2024
1 parent 72cece5 commit e75bccf
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 26 deletions.
6 changes: 3 additions & 3 deletions .idea/runConfigurations/Run_demo__debug_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ members = [
"maplibre-winit",
"maplibre-build-tools",
"maplibre-demo",

"android",
"apple",
"web",

"benchmarks",
]

Expand Down Expand Up @@ -67,7 +65,6 @@ js-sys = "0.3"
log = "0.4.20"
lyon = { version = "1.0.1", features = [] }
naga = { version = "0.13.0", features = ["wgsl-in"] }
android-activity = "0.4.3"
android_logger = "0.13.3"
png = { version = "0.17.10" }
reqwest = { version = "0.11.20", default-features = false, features = ["rustls-tls", "gzip"] } # Use rusttls on android because cross compiling is difficult
Expand Down
3 changes: 1 addition & 2 deletions android/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ authors.workspace = true

[dependencies]
maplibre = { path = "../maplibre", features = ["thread-safe-futures"] }
maplibre-winit = { path = "../maplibre-winit", version = "0.1.0" }
maplibre-winit = { path = "../maplibre-winit", version = "0.1.0" }
env_logger.workspace = true
log.workspace = true
android_logger.workspace = true
android-activity.workspace = true
jni.workspace = true

[lib]
Expand Down
2 changes: 1 addition & 1 deletion android/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use jni::{objects::JClass, JNIEnv};
use log::Level;
use maplibre::render::settings::WgpuSettings;
use maplibre_winit::{run_headed_map, WinitMapWindowConfig};
use maplibre_winit::{android_activity, run_headed_map, WinitMapWindowConfig};

#[cfg(not(any(no_pendantic_os_check, target_os = "android")))]
compile_error!("android works only on android.");
Expand Down
2 changes: 1 addition & 1 deletion maplibre-winit/src/input/debug_handler.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::time::Duration;
use winit::keyboard::{KeyCode, PhysicalKey};

use maplibre::context::MapContext;
use winit::keyboard::{KeyCode, PhysicalKey};

use super::UpdateState;

Expand Down
2 changes: 1 addition & 1 deletion maplibre-winit/src/input/shift_handler.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::time::Duration;

use cgmath::{Vector2, Zero};
use winit::keyboard::{KeyCode, PhysicalKey};
use maplibre::context::MapContext;
use winit::keyboard::{KeyCode, PhysicalKey};

use super::UpdateState;

Expand Down
4 changes: 2 additions & 2 deletions maplibre-winit/src/input/zoom_handler.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::time::Duration;

use cgmath::Vector2;
use winit::keyboard::{KeyCode, PhysicalKey};
use maplibre::{context::MapContext, coords::Zoom};
use winit::keyboard::{KeyCode, PhysicalKey};

use super::UpdateState;

Expand Down Expand Up @@ -90,7 +90,7 @@ impl ZoomHandler {
};

match key {
PhysicalKey::Code(KeyCode::KeyI)=> {
PhysicalKey::Code(KeyCode::KeyI) => {
self.update_zoom(amount);
true
}
Expand Down
8 changes: 5 additions & 3 deletions maplibre-winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ use maplibre::{
window::{HeadedMapWindow, MapWindowConfig, PhysicalSize},
};
use winit::{
event::{ElementState, Event, WindowEvent},
event::{ElementState, Event, KeyEvent, WindowEvent},
keyboard::{Key, NamedKey},
};
use winit::event::KeyEvent;
use winit::keyboard::{Key, NamedKey};

use crate::input::{InputController, UpdateState};

pub mod input;

#[cfg(target_os = "android")]
pub use winit::platform::android::activity as android_activity;

pub type RawWinitWindow = winit::window::Window;
pub type RawWinitEventLoop<ET> = winit::event_loop::EventLoop<ET>;
pub type RawEventLoopProxy<ET> = winit::event_loop::EventLoopProxy<ET>;
Expand Down
2 changes: 1 addition & 1 deletion maplibre-winit/src/noweb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::{WinitEnvironment, WinitEventLoop};
pub struct WinitMapWindowConfig<ET> {
title: String,
#[cfg(target_os = "android")]
android_app: winit::platform::android::activity::AndroidApp,
android_app: crate::android_activity::AndroidApp,

phantom_et: PhantomData<ET>,
}
Expand Down
8 changes: 5 additions & 3 deletions maplibre-winit/src/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ impl<ET: 'static + Clone> MapWindowConfig for WinitMapWindowConfig<ET> {
type MapWindow = WinitMapWindow<ET>;

fn create(&self) -> Self::MapWindow {
let raw_event_loop = winit::event_loop::EventLoopBuilder::<ET>::with_user_event().build();
let raw_event_loop = winit::event_loop::EventLoopBuilder::<ET>::with_user_event()
.build()
.unwrap(); // TODO

let window: winit::window::Window = WindowBuilder::new()
.with_canvas(Some(get_canvas(&self.canvas_id)))
.build(&raw_event_loop)
.unwrap();

let size = get_body_size().unwrap();
window.set_inner_size(size);
window.request_inner_size(size);
Self::MapWindow {
window,
event_loop: Some(WinitEventLoop {
Expand All @@ -47,7 +49,7 @@ impl<ET: 'static> MapWindow for WinitMapWindow<ET> {
fn size(&self) -> PhysicalSize {
let size = self.window.inner_size();

PhysicalSize::new(size.width, size.height).expect("failed to get window dimensions.")
PhysicalSize::new(size.width, size.height).unwrap_or(PhysicalSize::new(1, 1).unwrap())
}
}

Expand Down
9 changes: 6 additions & 3 deletions maplibre/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ impl Renderer {
gles_minor_version: Default::default(),
});

let surface: wgpu::Surface = unsafe { instance.create_surface_unsafe(wgpu::SurfaceTargetUnsafe::from_window(&window.handle())?)? };
let surface: wgpu::Surface = unsafe {
instance
.create_surface_unsafe(wgpu::SurfaceTargetUnsafe::from_window(&window.handle())?)?
};

let (adapter, device, queue) = Self::request_device(
&instance,
Expand Down Expand Up @@ -487,8 +490,8 @@ mod tests {
.request_device(
&wgpu::DeviceDescriptor {
label: None,
features: wgpu::Features::default(),
limits: wgpu::Limits::default(),
required_features: wgpu::Features::default(),
required_limits: wgpu::Limits::default(),
},
None,
)
Expand Down
5 changes: 4 additions & 1 deletion maplibre/src/render/resource/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ impl WindowHead {
where
MW: MapWindow + HeadedMapWindow,
{
self.surface = unsafe { instance.create_surface_unsafe(wgpu::SurfaceTargetUnsafe::from_window(&window.handle())?)? };
self.surface = unsafe {
instance
.create_surface_unsafe(wgpu::SurfaceTargetUnsafe::from_window(&window.handle())?)?
};
Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion maplibre/src/vector/process_vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub fn process_vector_tile<T: VectorTransferables, C: Context>(
) -> Result<(), ProcessVectorError> {
// Decode

let mut tile = geozero::mvt::Tile::decode(data).expect("failed to load tile");
let mut tile = geozero::mvt::Tile::decode(data).expect("failed to load tile"); // TODO handle

// Available

Expand Down
2 changes: 2 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ pkgs.mkShell {
unstable.flatbuffers
unstable.protobuf

pkgs.jdk17

unstable.xorg.libXrandr
unstable.xorg.libXi
unstable.xorg.libXcursor
Expand Down
2 changes: 1 addition & 1 deletion web/demo/src/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body style="margin: 0; padding: 0; width:100%; height: 100%; max-height: 100%;">
<canvas id="maplibre" style="position:absolute;"></canvas>
<canvas id="maplibre" style="position:absolute;" width="100" height="100"></canvas>
</body>
</html>

0 comments on commit e75bccf

Please sign in to comment.