mirror of
https://github.com/maplibre/maplibre-rs.git
synced 2025-12-08 19:05:57 +00:00
Move root crate into maplibre-core
This commit is contained in:
parent
cb5c428e6a
commit
0530367791
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -1816,10 +1816,6 @@ dependencies = [
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "maplibre-core"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "maplibre-example"
|
||||
version = "0.1.0"
|
||||
|
||||
112
Cargo.toml
112
Cargo.toml
@ -15,115 +15,3 @@ members = [
|
||||
|
||||
"maplibre-example",
|
||||
]
|
||||
|
||||
[package]
|
||||
name = "maplibre"
|
||||
version = "0.1.0"
|
||||
authors = ["Maximilian Ammann <max@maxammann.org>"]
|
||||
edition = "2021"
|
||||
resolver = "2"
|
||||
build = "build.rs"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[package.metadata.wasm-pack.profile.release]
|
||||
wasm-opt = true
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
opt-level = 's'
|
||||
panic = "abort"
|
||||
|
||||
[profile.bench]
|
||||
debug = true
|
||||
|
||||
[features]
|
||||
web-webgl = ["wgpu/webgl"]
|
||||
# Enable tracing using tracy on desktop/mobile and the chrome profiler on web
|
||||
enable-tracing = [ "tracing-subscriber", "tracing-tracy", "tracy-client", "tracing-wasm"]
|
||||
default = []
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
console_error_panic_hook = "0.1"
|
||||
web-sys = { version = "0.3", features = [
|
||||
"Window",
|
||||
"Headers",
|
||||
"WorkerGlobalScope", "Request", "RequestInit", "RequestMode", "Response",
|
||||
"ErrorEvent", "DedicatedWorkerGlobalScope"
|
||||
] }
|
||||
js-sys = "0.3"
|
||||
wasm-bindgen = "0.2"
|
||||
wasm-bindgen-futures = "0.4"
|
||||
console_log = { version = "0.2", features = ["color"] }
|
||||
tracing-wasm = { version = "0.2", optional = true } # FIXME: Low quality dependency
|
||||
instant = { version = "0.1", features = ["wasm-bindgen"] } # FIXME: Untrusted dependency
|
||||
|
||||
[target.'cfg(any(target_os = "macos", target_os = "ios", target_os = "linux", target_os = "android"))'.dependencies]
|
||||
tokio = { version = "1.17", features = ["macros", "rt", "rt-multi-thread", "sync", "time"] }
|
||||
env_logger = "0.9"
|
||||
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "gzip"] }
|
||||
reqwest-middleware-cache = "0.1" # FIXME: Untrusted dependency
|
||||
reqwest-middleware = { version = "0.1" } # FIXME: Untrusted dependency
|
||||
tracing-tracy = { version = "0.8", optional = true }
|
||||
tracy-client = { version = "0.12.7", optional = true }
|
||||
|
||||
[target.'cfg(target_os = "android")'.dependencies]
|
||||
ndk-glue = "0.5.0" # version is required by winit
|
||||
winit = { version = "0.26", default-features = false }
|
||||
# Use rusttls on android because cross compiling is difficult
|
||||
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "gzip"] }
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
winit = { version = "0.26", default-features = false, features = ["x11", "wayland"] }
|
||||
|
||||
[dependencies]
|
||||
winit = { version = "0.26", default-features = false }
|
||||
|
||||
raw-window-handle = "0.4"
|
||||
|
||||
tracing = { version = "0.1" }
|
||||
tracing-subscriber = { version = "0.3", optional = true }
|
||||
|
||||
maplibre-style = { path = "./maplibre-style" }
|
||||
maplibre-tilejson = { path = "./maplibre-tilejson" }
|
||||
|
||||
cgmath = "0.18"
|
||||
|
||||
geo = { version = "0.19" }
|
||||
geo-types = { version = "0.7", features = ["use-rstar_0_9"] }
|
||||
rstar = { version = "0.9" }
|
||||
prost = "0.9"
|
||||
geozero = { git = "https://github.com/georust/geozero", rev = "373b731", default-features = false, features = ["with-mvt", "with-geo"]}
|
||||
|
||||
tile-grid = "0.3"
|
||||
|
||||
# Rendering
|
||||
wgpu = { version = "0.12" }
|
||||
lyon = { version = "0.17", features = [] }
|
||||
|
||||
# cached = "0.32"
|
||||
|
||||
# Logging
|
||||
log = "0.4"
|
||||
|
||||
# Utils
|
||||
bytemuck = "1.2.0"
|
||||
bytemuck_derive = "1.0"
|
||||
|
||||
include_dir = "0.7.2"
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = "0.3"
|
||||
|
||||
[build-dependencies]
|
||||
maplibre-build-tools = { path = "./maplibre-build-tools" }
|
||||
|
||||
[lib]
|
||||
crate-type = ["rlib", "cdylib", "staticlib"] # staticlib is used for apple
|
||||
|
||||
[package.metadata.android]
|
||||
apk_name = "maplibre-rs-demo"
|
||||
[[package.metadata.android.uses_permission]]
|
||||
name = "android.permission.INTERNET"
|
||||
[[package.metadata.android.uses_permission]]
|
||||
name = "android.permission.ACCESS_NETWORK_STATE"
|
||||
@ -6,3 +6,14 @@ categories = []
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
|
||||
[lib]
|
||||
crate-type = ["rlib", "cdylib"]
|
||||
|
||||
[package.metadata.android]
|
||||
apk_name = "maplibre-rs-demo"
|
||||
[[package.metadata.android.uses_permission]]
|
||||
name = "android.permission.INTERNET"
|
||||
[[package.metadata.android.uses_permission]]
|
||||
name = "android.permission.ACCESS_NETWORK_STATE"
|
||||
@ -6,3 +6,7 @@ categories = []
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
|
||||
[lib]
|
||||
crate-type = ["staticlib"]
|
||||
|
||||
@ -1,8 +1,99 @@
|
||||
[package]
|
||||
name = "maplibre-core"
|
||||
name = "maplibre"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
categories = []
|
||||
authors = ["Maximilian Ammann <max@maxammann.org>"]
|
||||
edition = "2021"
|
||||
resolver = "2"
|
||||
build = "build.rs"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
opt-level = 's'
|
||||
panic = "abort"
|
||||
|
||||
[profile.bench]
|
||||
debug = true
|
||||
|
||||
[features]
|
||||
web-webgl = ["wgpu/webgl"]
|
||||
# Enable tracing using tracy on desktop/mobile and the chrome profiler on web
|
||||
enable-tracing = [ "tracing-subscriber", "tracing-tracy", "tracy-client", "tracing-wasm"]
|
||||
default = []
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
console_error_panic_hook = "0.1"
|
||||
web-sys = { version = "0.3", features = [
|
||||
"Window",
|
||||
"Headers",
|
||||
"WorkerGlobalScope", "Request", "RequestInit", "RequestMode", "Response",
|
||||
"ErrorEvent", "DedicatedWorkerGlobalScope"
|
||||
] }
|
||||
js-sys = "0.3"
|
||||
wasm-bindgen = "0.2"
|
||||
wasm-bindgen-futures = "0.4"
|
||||
console_log = { version = "0.2", features = ["color"] }
|
||||
tracing-wasm = { version = "0.2", optional = true } # FIXME: Low quality dependency
|
||||
instant = { version = "0.1", features = ["wasm-bindgen"] } # FIXME: Untrusted dependency
|
||||
|
||||
[target.'cfg(any(target_os = "macos", target_os = "ios", target_os = "linux", target_os = "android"))'.dependencies]
|
||||
tokio = { version = "1.17", features = ["macros", "rt", "rt-multi-thread", "sync", "time"] }
|
||||
env_logger = "0.9"
|
||||
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "gzip"] }
|
||||
reqwest-middleware-cache = "0.1" # FIXME: Untrusted dependency
|
||||
reqwest-middleware = { version = "0.1" } # FIXME: Untrusted dependency
|
||||
tracing-tracy = { version = "0.8", optional = true }
|
||||
tracy-client = { version = "0.12.7", optional = true }
|
||||
|
||||
[target.'cfg(target_os = "android")'.dependencies]
|
||||
ndk-glue = "0.5.0" # version is required by winit
|
||||
winit = { version = "0.26", default-features = false }
|
||||
# Use rusttls on android because cross compiling is difficult
|
||||
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "gzip"] }
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
winit = { version = "0.26", default-features = false, features = ["x11", "wayland"] }
|
||||
|
||||
[dependencies]
|
||||
winit = { version = "0.26", default-features = false }
|
||||
|
||||
raw-window-handle = "0.4"
|
||||
|
||||
tracing = { version = "0.1" }
|
||||
tracing-subscriber = { version = "0.3", optional = true }
|
||||
|
||||
maplibre-style = { path = "../maplibre-style" }
|
||||
maplibre-tilejson = { path = "../maplibre-tilejson" }
|
||||
|
||||
cgmath = "0.18"
|
||||
|
||||
geo = { version = "0.19" }
|
||||
geo-types = { version = "0.7", features = ["use-rstar_0_9"] }
|
||||
rstar = { version = "0.9" }
|
||||
prost = "0.9"
|
||||
geozero = { git = "https://github.com/georust/geozero", rev = "373b731", default-features = false, features = ["with-mvt", "with-geo"]}
|
||||
|
||||
tile-grid = "0.3"
|
||||
|
||||
# Rendering
|
||||
wgpu = { version = "0.12" }
|
||||
lyon = { version = "0.17", features = [] }
|
||||
|
||||
# cached = "0.32"
|
||||
|
||||
# Logging
|
||||
log = "0.4"
|
||||
|
||||
# Utils
|
||||
bytemuck = "1.2.0"
|
||||
bytemuck_derive = "1.0"
|
||||
|
||||
include_dir = "0.7.2"
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = "0.3"
|
||||
|
||||
[build-dependencies]
|
||||
maplibre-build-tools = { path = "../maplibre-build-tools" }
|
||||
|
||||
|
||||
@ -0,0 +1,160 @@
|
||||
use crate::io::scheduler::Scheduler;
|
||||
|
||||
mod input;
|
||||
|
||||
pub(crate) mod coords;
|
||||
pub(crate) mod error;
|
||||
pub(crate) mod io;
|
||||
pub(crate) mod map_state;
|
||||
pub(crate) mod platform;
|
||||
pub(crate) mod render;
|
||||
pub(crate) mod tessellation;
|
||||
pub(crate) mod util;
|
||||
pub(crate) mod winit;
|
||||
|
||||
// Used for benchmarking
|
||||
pub mod benchmarking;
|
||||
pub mod window;
|
||||
|
||||
use crate::map_state::{MapState, Runnable};
|
||||
use crate::render::render_state::RenderState;
|
||||
use crate::window::{WindowFactory, WindowSize};
|
||||
pub use io::scheduler::ScheduleMethod;
|
||||
pub use platform::schedule_method::*;
|
||||
use maplibre_style::Style;
|
||||
|
||||
pub struct Map<W, E> {
|
||||
map_state: MapState<W>,
|
||||
event_loop: E,
|
||||
}
|
||||
|
||||
impl<W, E> Map<W, E>
|
||||
where
|
||||
MapState<W>: Runnable<E>,
|
||||
{
|
||||
pub fn run(self) {
|
||||
self.run_with_optionally_max_frames(None);
|
||||
}
|
||||
|
||||
pub fn run_with_max_frames(self, max_frames: u64) {
|
||||
self.run_with_optionally_max_frames(Some(max_frames));
|
||||
}
|
||||
|
||||
pub fn run_with_optionally_max_frames(self, max_frames: Option<u64>) {
|
||||
self.map_state.run(self.event_loop, max_frames);
|
||||
}
|
||||
}
|
||||
|
||||
pub struct UninitializedMap<W, E> {
|
||||
window: W,
|
||||
window_size: WindowSize,
|
||||
event_loop: E,
|
||||
scheduler: Scheduler,
|
||||
style: Style,
|
||||
}
|
||||
|
||||
impl<W, E> UninitializedMap<W, E>
|
||||
where
|
||||
W: raw_window_handle::HasRawWindowHandle,
|
||||
{
|
||||
pub async fn initialize(self) -> Map<W, E> {
|
||||
let render_state = RenderState::initialize(&self.window, self.window_size).await;
|
||||
Map {
|
||||
map_state: MapState::new(
|
||||
self.window,
|
||||
self.window_size,
|
||||
render_state,
|
||||
self.scheduler,
|
||||
self.style,
|
||||
),
|
||||
event_loop: self.event_loop,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
impl<W, E> UninitializedMap<W, E>
|
||||
where
|
||||
W: raw_window_handle::HasRawWindowHandle,
|
||||
MapState<W>: Runnable<E>,
|
||||
{
|
||||
pub fn run_sync(self) {
|
||||
self.run_sync_with_optionally_max_frames(None);
|
||||
}
|
||||
|
||||
pub fn run_sync_with_max_frames(self, max_frames: u64) {
|
||||
self.run_sync_with_optionally_max_frames(Some(max_frames))
|
||||
}
|
||||
|
||||
fn run_sync_with_optionally_max_frames(self, max_frames: Option<u64>) {
|
||||
tokio::runtime::Builder::new_multi_thread()
|
||||
.worker_threads(4)
|
||||
.enable_io()
|
||||
.enable_time()
|
||||
.on_thread_start(|| {
|
||||
#[cfg(feature = "enable-tracing")]
|
||||
tracy_client::set_thread_name("tokio-runtime-worker");
|
||||
})
|
||||
.build()
|
||||
.unwrap()
|
||||
.block_on(async {
|
||||
self.initialize()
|
||||
.await
|
||||
.run_with_optionally_max_frames(max_frames);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MapBuilder<W, E> {
|
||||
window_factory: Box<WindowFactory<W, E>>,
|
||||
schedule_method: Option<ScheduleMethod>,
|
||||
scheduler: Option<Scheduler>,
|
||||
style: Option<Style>,
|
||||
}
|
||||
|
||||
impl<W, E> MapBuilder<W, E>
|
||||
where
|
||||
MapState<W>: Runnable<E>,
|
||||
W: raw_window_handle::HasRawWindowHandle,
|
||||
{
|
||||
pub(crate) fn new(create_window: Box<WindowFactory<W, E>>) -> Self {
|
||||
Self {
|
||||
window_factory: create_window,
|
||||
schedule_method: None,
|
||||
scheduler: None,
|
||||
style: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_schedule_method(mut self, schedule_method: ScheduleMethod) -> Self {
|
||||
self.schedule_method = Some(schedule_method);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_existing_scheduler(mut self, scheduler: Scheduler) -> Self {
|
||||
self.scheduler = Some(scheduler);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_style(mut self, style: Style) -> Self {
|
||||
self.style = Some(style);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn build(self) -> UninitializedMap<W, E> {
|
||||
let (window, window_size, event_loop) = (self.window_factory)();
|
||||
|
||||
let scheduler = self
|
||||
.scheduler
|
||||
.unwrap_or_else(|| Scheduler::new(self.schedule_method.unwrap_or_default()));
|
||||
let style = self.style.unwrap_or_default();
|
||||
|
||||
UninitializedMap {
|
||||
window,
|
||||
window_size,
|
||||
event_loop,
|
||||
scheduler,
|
||||
style,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5,4 +5,10 @@ description = ""
|
||||
categories = []
|
||||
edition = "2021"
|
||||
|
||||
|
||||
[package.metadata.wasm-pack.profile.release]
|
||||
wasm-opt = true
|
||||
|
||||
[dependencies]
|
||||
|
||||
|
||||
|
||||
160
src/lib.rs
160
src/lib.rs
@ -1,160 +0,0 @@
|
||||
use crate::io::scheduler::Scheduler;
|
||||
|
||||
mod input;
|
||||
|
||||
pub(crate) mod coords;
|
||||
pub(crate) mod error;
|
||||
pub(crate) mod io;
|
||||
pub(crate) mod map_state;
|
||||
pub(crate) mod platform;
|
||||
pub(crate) mod render;
|
||||
pub(crate) mod tessellation;
|
||||
pub(crate) mod util;
|
||||
pub(crate) mod winit;
|
||||
|
||||
// Used for benchmarking
|
||||
pub mod benchmarking;
|
||||
pub mod window;
|
||||
|
||||
use crate::map_state::{MapState, Runnable};
|
||||
use crate::render::render_state::RenderState;
|
||||
use crate::window::{WindowFactory, WindowSize};
|
||||
pub use io::scheduler::ScheduleMethod;
|
||||
pub use platform::schedule_method::*;
|
||||
use maplibre_style::Style;
|
||||
|
||||
pub struct Map<W, E> {
|
||||
map_state: MapState<W>,
|
||||
event_loop: E,
|
||||
}
|
||||
|
||||
impl<W, E> Map<W, E>
|
||||
where
|
||||
MapState<W>: Runnable<E>,
|
||||
{
|
||||
pub fn run(self) {
|
||||
self.run_with_optionally_max_frames(None);
|
||||
}
|
||||
|
||||
pub fn run_with_max_frames(self, max_frames: u64) {
|
||||
self.run_with_optionally_max_frames(Some(max_frames));
|
||||
}
|
||||
|
||||
pub fn run_with_optionally_max_frames(self, max_frames: Option<u64>) {
|
||||
self.map_state.run(self.event_loop, max_frames);
|
||||
}
|
||||
}
|
||||
|
||||
pub struct UninitializedMap<W, E> {
|
||||
window: W,
|
||||
window_size: WindowSize,
|
||||
event_loop: E,
|
||||
scheduler: Scheduler,
|
||||
style: Style,
|
||||
}
|
||||
|
||||
impl<W, E> UninitializedMap<W, E>
|
||||
where
|
||||
W: raw_window_handle::HasRawWindowHandle,
|
||||
{
|
||||
pub async fn initialize(self) -> Map<W, E> {
|
||||
let render_state = RenderState::initialize(&self.window, self.window_size).await;
|
||||
Map {
|
||||
map_state: MapState::new(
|
||||
self.window,
|
||||
self.window_size,
|
||||
render_state,
|
||||
self.scheduler,
|
||||
self.style,
|
||||
),
|
||||
event_loop: self.event_loop,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
impl<W, E> UninitializedMap<W, E>
|
||||
where
|
||||
W: raw_window_handle::HasRawWindowHandle,
|
||||
MapState<W>: Runnable<E>,
|
||||
{
|
||||
pub fn run_sync(self) {
|
||||
self.run_sync_with_optionally_max_frames(None);
|
||||
}
|
||||
|
||||
pub fn run_sync_with_max_frames(self, max_frames: u64) {
|
||||
self.run_sync_with_optionally_max_frames(Some(max_frames))
|
||||
}
|
||||
|
||||
fn run_sync_with_optionally_max_frames(self, max_frames: Option<u64>) {
|
||||
tokio::runtime::Builder::new_multi_thread()
|
||||
.worker_threads(4)
|
||||
.enable_io()
|
||||
.enable_time()
|
||||
.on_thread_start(|| {
|
||||
#[cfg(feature = "enable-tracing")]
|
||||
tracy_client::set_thread_name("tokio-runtime-worker");
|
||||
})
|
||||
.build()
|
||||
.unwrap()
|
||||
.block_on(async {
|
||||
self.initialize()
|
||||
.await
|
||||
.run_with_optionally_max_frames(max_frames);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MapBuilder<W, E> {
|
||||
window_factory: Box<WindowFactory<W, E>>,
|
||||
schedule_method: Option<ScheduleMethod>,
|
||||
scheduler: Option<Scheduler>,
|
||||
style: Option<Style>,
|
||||
}
|
||||
|
||||
impl<W, E> MapBuilder<W, E>
|
||||
where
|
||||
MapState<W>: Runnable<E>,
|
||||
W: raw_window_handle::HasRawWindowHandle,
|
||||
{
|
||||
pub(crate) fn new(create_window: Box<WindowFactory<W, E>>) -> Self {
|
||||
Self {
|
||||
window_factory: create_window,
|
||||
schedule_method: None,
|
||||
scheduler: None,
|
||||
style: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_schedule_method(mut self, schedule_method: ScheduleMethod) -> Self {
|
||||
self.schedule_method = Some(schedule_method);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_existing_scheduler(mut self, scheduler: Scheduler) -> Self {
|
||||
self.scheduler = Some(scheduler);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_style(mut self, style: Style) -> Self {
|
||||
self.style = Some(style);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn build(self) -> UninitializedMap<W, E> {
|
||||
let (window, window_size, event_loop) = (self.window_factory)();
|
||||
|
||||
let scheduler = self
|
||||
.scheduler
|
||||
.unwrap_or_else(|| Scheduler::new(self.schedule_method.unwrap_or_default()));
|
||||
let style = self.style.unwrap_or_default();
|
||||
|
||||
UninitializedMap {
|
||||
window,
|
||||
window_size,
|
||||
event_loop,
|
||||
scheduler,
|
||||
style,
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user