mirror of
https://github.com/maplibre/maplibre-rs.git
synced 2025-12-08 19:05:57 +00:00
Clippy fixes (#197)
* Apply clippy fixes * Use nightly for android * Use nightly for web * Fix feature usage * Deny unused imports * Add ios and web fixup * Exit with non-zero exit code * Add no_pendantic_os_check cfg flag
This commit is contained in:
parent
0b17bc83d4
commit
1444ae7782
@ -7,7 +7,7 @@ edition = "2021"
|
|||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
maplibre = { path = "../maplibre" }
|
maplibre = { path = "../maplibre", features = ["thread-safe-futures"] }
|
||||||
maplibre-winit = { path = "../maplibre-winit", version = "0.0.1" }
|
maplibre-winit = { path = "../maplibre-winit", version = "0.0.1" }
|
||||||
env_logger = "0.9.0"
|
env_logger = "0.9.0"
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
|
|||||||
@ -1,14 +1,12 @@
|
|||||||
|
#![deny(unused_imports)]
|
||||||
|
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
|
|
||||||
use jni::{objects::JClass, JNIEnv};
|
use jni::{objects::JClass, JNIEnv};
|
||||||
use log::Level;
|
use log::Level;
|
||||||
use maplibre::{
|
use maplibre_winit::run_headed_map;
|
||||||
platform::{http_client::ReqwestHttpClient, run_multithreaded, scheduler::TokioScheduler},
|
|
||||||
render::settings::{Backends, WgpuSettings},
|
|
||||||
};
|
|
||||||
use maplibre_winit::{run_headed_map, WinitMapWindowConfig};
|
|
||||||
|
|
||||||
#[cfg(not(target_os = "android"))]
|
#[cfg(not(any(no_pendantic_os_check, target_os = "android")))]
|
||||||
compile_error!("android works only on android.");
|
compile_error!("android works only on android.");
|
||||||
|
|
||||||
#[cfg_attr(target_os = "android", ndk_glue::main(backtrace = "on"))]
|
#[cfg_attr(target_os = "android", ndk_glue::main(backtrace = "on"))]
|
||||||
|
|||||||
@ -7,7 +7,7 @@ edition = "2021"
|
|||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
maplibre = { path = "../maplibre" }
|
maplibre = { path = "../maplibre", features = ["thread-safe-futures"] }
|
||||||
maplibre-winit = { path = "../maplibre-winit", version = "0.0.1" }
|
maplibre-winit = { path = "../maplibre-winit", version = "0.0.1" }
|
||||||
|
|
||||||
env_logger = "0.9.0"
|
env_logger = "0.9.0"
|
||||||
|
|||||||
@ -1,12 +1,8 @@
|
|||||||
use maplibre::{
|
#![deny(unused_imports)]
|
||||||
io::apc::SchedulerAsyncProcedureCall,
|
|
||||||
platform::{http_client::ReqwestHttpClient, run_multithreaded, scheduler::TokioScheduler},
|
|
||||||
};
|
|
||||||
use maplibre_winit::{
|
|
||||||
run_headed_map, WinitEnvironment, WinitEventLoop, WinitMapWindow, WinitMapWindowConfig,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
|
use maplibre_winit::run_headed_map;
|
||||||
|
|
||||||
|
#[cfg(not(any(no_pendantic_os_check, target_os = "macos", target_os = "ios")))]
|
||||||
compile_error!("apple works only on macOS and iOS.");
|
compile_error!("apple works only on macOS and iOS.");
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|||||||
@ -6,7 +6,7 @@ categories = []
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
maplibre = { path = "../maplibre", features = ["headless", "embed-static-tiles"] }
|
maplibre = { path = "../maplibre", features = ["headless", "embed-static-tiles", "thread-safe-futures"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
criterion = { version = "0.3.6", features = ["async_tokio"] }
|
criterion = { version = "0.3.6", features = ["async_tokio"] }
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
use std::{collections::HashSet, io::Cursor};
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use criterion::{criterion_group, criterion_main, Criterion};
|
use criterion::{criterion_group, criterion_main, Criterion};
|
||||||
use maplibre::{
|
use maplibre::{
|
||||||
benchmarking::{io::static_tile_fetcher::StaticTileFetcher, tessellation::Tessellated},
|
benchmarking::io::static_tile_fetcher::StaticTileFetcher,
|
||||||
coords::{TileCoords, WorldTileCoords, ZoomLevel},
|
coords::{TileCoords, ZoomLevel},
|
||||||
io::{
|
io::{
|
||||||
pipeline::{PipelineContext, PipelineProcessor, Processable},
|
pipeline::{PipelineContext, PipelineProcessor, Processable},
|
||||||
tile_pipelines::{ParseTile, TessellateLayer},
|
tile_pipelines::{ParseTile, TessellateLayer},
|
||||||
|
|||||||
@ -1,28 +1,10 @@
|
|||||||
use std::collections::HashSet;
|
|
||||||
|
|
||||||
use criterion::{criterion_group, criterion_main, Criterion};
|
use criterion::{criterion_group, criterion_main, Criterion};
|
||||||
use maplibre::{
|
use maplibre::{
|
||||||
coords::{WorldTileCoords, ZoomLevel},
|
coords::{WorldTileCoords, ZoomLevel},
|
||||||
error::Error,
|
error::Error,
|
||||||
headless::{
|
headless::{create_headless_renderer, map::HeadlessMap},
|
||||||
create_headless_renderer, environment::HeadlessEnvironment, map::HeadlessMap,
|
platform::run_multithreaded,
|
||||||
window::HeadlessMapWindowConfig,
|
|
||||||
},
|
|
||||||
io::{
|
|
||||||
apc::SchedulerAsyncProcedureCall,
|
|
||||||
pipeline::{PipelineContext, Processable},
|
|
||||||
source_client::HttpSourceClient,
|
|
||||||
tile_pipelines::build_vector_tile_pipeline,
|
|
||||||
TileRequest,
|
|
||||||
},
|
|
||||||
kernel::{Kernel, KernelBuilder},
|
|
||||||
platform::{http_client::ReqwestHttpClient, run_multithreaded, scheduler::TokioScheduler},
|
|
||||||
render::{
|
|
||||||
builder::{InitializedRenderer, RendererBuilder},
|
|
||||||
settings::{RendererSettings, TextureFormat},
|
|
||||||
},
|
|
||||||
style::Style,
|
style::Style,
|
||||||
window::WindowSize,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
fn headless_render(c: &mut Criterion) {
|
fn headless_render(c: &mut Criterion) {
|
||||||
@ -30,7 +12,7 @@ fn headless_render(c: &mut Criterion) {
|
|||||||
let (mut map, tile) = run_multithreaded(async {
|
let (mut map, tile) = run_multithreaded(async {
|
||||||
let (kernel, renderer) = create_headless_renderer(1000, None).await;
|
let (kernel, renderer) = create_headless_renderer(1000, None).await;
|
||||||
let style = Style::default();
|
let style = Style::default();
|
||||||
let mut map = HeadlessMap::new(style, renderer, kernel).unwrap();
|
let map = HeadlessMap::new(style, renderer, kernel).unwrap();
|
||||||
|
|
||||||
let tile = map
|
let tile = map
|
||||||
.fetch_tile(
|
.fetch_tile(
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
|
#![deny(unused_imports)]
|
||||||
|
|||||||
17
justfile
17
justfile
@ -44,17 +44,22 @@ nightly-install-clippy:
|
|||||||
|
|
||||||
|
|
||||||
fixup:
|
fixup:
|
||||||
cargo clippy --no-deps -p maplibre --fix
|
cargo clippy --allow-dirty --no-deps -p maplibre --fix
|
||||||
cargo clippy --allow-dirty --no-deps -p maplibre-winit --fix
|
cargo clippy --allow-dirty --no-deps -p maplibre-winit --fix
|
||||||
cargo clippy --allow-dirty --no-deps -p maplibre-demo --fix
|
cargo clippy --allow-dirty --no-deps -p maplibre-demo --fix
|
||||||
cargo clippy --allow-dirty --no-deps -p benchmarks --fix
|
cargo clippy --allow-dirty --no-deps -p benchmarks --fix
|
||||||
# Web
|
# Web
|
||||||
cargo clippy --allow-dirty --no-deps -p web --target wasm32-unknown-unknown --fix
|
RUSTUP_TOOLCHAIN=$NIGHTLY_TOOLCHAIN cargo clippy --allow-dirty --no-deps -p web --target wasm32-unknown-unknown --fix
|
||||||
cargo clippy --allow-dirty --no-deps -p maplibre --target wasm32-unknown-unknown --fix
|
RUSTUP_TOOLCHAIN=$NIGHTLY_TOOLCHAIN RUSTFLAGS='-C target-feature=+atomics,+bulk-memory,+mutable-globals --cfg=web_sys_unstable_apis' cargo clippy --allow-dirty --no-deps -p web --target wasm32-unknown-unknown --fix -Z build-std=std,panic_abort
|
||||||
cargo clippy --allow-dirty --no-deps -p maplibre-winit --target wasm32-unknown-unknown --fix
|
RUSTUP_TOOLCHAIN=$NIGHTLY_TOOLCHAIN cargo clippy --allow-dirty --no-deps -p maplibre --target wasm32-unknown-unknown --fix
|
||||||
|
RUSTUP_TOOLCHAIN=$NIGHTLY_TOOLCHAIN cargo clippy --allow-dirty --no-deps -p maplibre-winit --target wasm32-unknown-unknown --fix
|
||||||
# Android
|
# Android
|
||||||
cargo clippy --allow-dirty --no-deps -p maplibre-winit --target x86_64-linux-android --fix
|
env "AR_x86_64-linux-android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" "CC_x86_64-linux-android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android30-clang" RUSTUP_TOOLCHAIN=$NIGHTLY_TOOLCHAIN cargo clippy --allow-dirty --no-deps -p maplibre --target x86_64-linux-android --fix
|
||||||
cargo clippy --allow-dirty --no-deps -p maplibre-android --target x86_64-linux-android --fix
|
env "AR_x86_64-linux-android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" "CC_x86_64-linux-android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android30-clang" RUSTUP_TOOLCHAIN=$NIGHTLY_TOOLCHAIN cargo clippy --allow-dirty --no-deps -p maplibre-winit --target x86_64-linux-android --fix
|
||||||
|
env "AR_x86_64-linux-android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" "CC_x86_64-linux-android=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android30-clang" RUSTUP_TOOLCHAIN=$NIGHTLY_TOOLCHAIN cargo clippy --allow-dirty --no-deps -p maplibre-android --target x86_64-linux-android --fix
|
||||||
|
# macOS/iOS
|
||||||
|
RUSTFLAGS="--cfg no_pendantic_os_check" cargo clippy --allow-dirty --no-deps -p apple --fix
|
||||||
|
# TODO check maplibre and maplibre-winit for apple targets
|
||||||
|
|
||||||
check PROJECT ARCH: stable-install-clippy
|
check PROJECT ARCH: stable-install-clippy
|
||||||
cargo clippy --no-deps -p {{PROJECT}} --target {{ARCH}}
|
cargo clippy --no-deps -p {{PROJECT}} --target {{ARCH}}
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
#![deny(unused_imports)]
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
#[cfg(feature = "sqlite")]
|
||||||
pub mod mbtiles;
|
pub mod mbtiles;
|
||||||
pub mod wgsl;
|
pub mod wgsl;
|
||||||
|
|||||||
@ -14,7 +14,7 @@ trace = ["maplibre/trace"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
env_logger = "0.9.0"
|
env_logger = "0.9.0"
|
||||||
maplibre = { path = "../maplibre", version = "0.0.2", features = ["headless"] }
|
maplibre = { path = "../maplibre", version = "0.0.2", features = ["headless", "thread-safe-futures"] }
|
||||||
maplibre-winit = { path = "../maplibre-winit", version = "0.0.1" }
|
maplibre-winit = { path = "../maplibre-winit", version = "0.0.1" }
|
||||||
|
|
||||||
tile-grid = "0.3"
|
tile-grid = "0.3"
|
||||||
|
|||||||
@ -1,19 +1,9 @@
|
|||||||
use maplibre::{
|
use maplibre::{
|
||||||
coords::{LatLon, WorldTileCoords},
|
coords::{LatLon, WorldTileCoords},
|
||||||
error::Error,
|
headless::{create_headless_renderer, map::HeadlessMap},
|
||||||
headless::{create_headless_renderer, map::HeadlessMap, window::HeadlessMapWindowConfig},
|
|
||||||
io::apc::SchedulerAsyncProcedureCall,
|
|
||||||
kernel::KernelBuilder,
|
|
||||||
platform::{http_client::ReqwestHttpClient, scheduler::TokioScheduler},
|
|
||||||
render::{
|
|
||||||
builder::RendererBuilder,
|
|
||||||
settings::{RendererSettings, TextureFormat},
|
|
||||||
},
|
|
||||||
style::Style,
|
style::Style,
|
||||||
util::grid::google_mercator,
|
util::grid::google_mercator,
|
||||||
window::WindowSize,
|
|
||||||
};
|
};
|
||||||
use maplibre_winit::WinitEnvironment;
|
|
||||||
use tile_grid::{extent_wgs84_to_merc, Extent, GridIterator};
|
use tile_grid::{extent_wgs84_to_merc, Extent, GridIterator};
|
||||||
|
|
||||||
pub async fn run_headless(tile_size: u32, min: LatLon, max: LatLon) {
|
pub async fn run_headless(tile_size: u32, min: LatLon, max: LatLon) {
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
#![deny(unused_imports)]
|
||||||
|
|
||||||
use std::io::ErrorKind;
|
use std::io::ErrorKind;
|
||||||
|
|
||||||
use clap::{builder::ValueParser, Parser, Subcommand};
|
use clap::{builder::ValueParser, Parser, Subcommand};
|
||||||
@ -18,7 +20,7 @@ struct Cli {
|
|||||||
|
|
||||||
fn parse_lat_long(env: &str) -> Result<LatLon, std::io::Error> {
|
fn parse_lat_long(env: &str) -> Result<LatLon, std::io::Error> {
|
||||||
let split = env.split(',').collect::<Vec<_>>();
|
let split = env.split(',').collect::<Vec<_>>();
|
||||||
if let (Some(latitude), Some(longitude)) = (split.get(0), split.get(1)) {
|
if let (Some(latitude), Some(longitude)) = (split.first(), split.get(1)) {
|
||||||
Ok(LatLon::new(
|
Ok(LatLon::new(
|
||||||
latitude.parse::<f64>().unwrap(),
|
latitude.parse::<f64>().unwrap(),
|
||||||
longitude.parse::<f64>().unwrap(),
|
longitude.parse::<f64>().unwrap(),
|
||||||
|
|||||||
@ -18,7 +18,7 @@ wasm-bindgen = "0.2.81"
|
|||||||
wasm-bindgen-futures = "0.4.31"
|
wasm-bindgen-futures = "0.4.31"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
maplibre = { path = "../maplibre", version = "0.0.2", default-features = false }
|
maplibre = { path = "../maplibre", version = "0.0.2" }
|
||||||
winit = { version = "0.27.2", default-features = false }
|
winit = { version = "0.27.2", default-features = false }
|
||||||
cgmath = "0.18.0"
|
cgmath = "0.18.0"
|
||||||
instant = { version = "0.1.12", features = ["wasm-bindgen"] } # TODO: Untrusted dependency
|
instant = { version = "0.1.12", features = ["wasm-bindgen"] } # TODO: Untrusted dependency
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use cgmath::{Deg, Rad, Zero};
|
use cgmath::{Deg, Zero};
|
||||||
use maplibre::world::ViewState;
|
use maplibre::world::ViewState;
|
||||||
|
|
||||||
use super::UpdateState;
|
use super::UpdateState;
|
||||||
|
|||||||
@ -1,24 +1,14 @@
|
|||||||
pub mod input;
|
#![deny(unused_imports)]
|
||||||
|
|
||||||
use std::{cell::RefCell, fmt::Debug, marker::PhantomData, ops::Deref, rc::Rc};
|
use std::{fmt::Debug, marker::PhantomData};
|
||||||
|
|
||||||
use instant::Instant;
|
use instant::Instant;
|
||||||
use log::info;
|
|
||||||
use maplibre::{
|
use maplibre::{
|
||||||
environment::Environment,
|
environment::Environment,
|
||||||
error::Error,
|
error::Error,
|
||||||
event_loop::{EventLoop, EventLoopProxy},
|
event_loop::{EventLoop, EventLoopProxy},
|
||||||
io::{
|
io::{apc::AsyncProcedureCall, scheduler::Scheduler, source_client::HttpClient},
|
||||||
apc::{AsyncProcedureCall, Message},
|
|
||||||
scheduler::Scheduler,
|
|
||||||
source_client::HttpClient,
|
|
||||||
transferables::{DefaultTransferables, Transferables},
|
|
||||||
},
|
|
||||||
map::Map,
|
map::Map,
|
||||||
render::{
|
|
||||||
builder::RendererBuilder,
|
|
||||||
settings::{Backends, WgpuSettings},
|
|
||||||
},
|
|
||||||
window::{HeadedMapWindow, MapWindowConfig},
|
window::{HeadedMapWindow, MapWindowConfig},
|
||||||
};
|
};
|
||||||
use winit::{
|
use winit::{
|
||||||
@ -28,6 +18,8 @@ use winit::{
|
|||||||
|
|
||||||
use crate::input::{InputController, UpdateState};
|
use crate::input::{InputController, UpdateState};
|
||||||
|
|
||||||
|
pub mod input;
|
||||||
|
|
||||||
pub type RawWinitWindow = winit::window::Window;
|
pub type RawWinitWindow = winit::window::Window;
|
||||||
pub type RawWinitEventLoop<ET> = winit::event_loop::EventLoop<ET>;
|
pub type RawWinitEventLoop<ET> = winit::event_loop::EventLoop<ET>;
|
||||||
pub type RawEventLoopProxy<ET> = winit::event_loop::EventLoopProxy<ET>;
|
pub type RawEventLoopProxy<ET> = winit::event_loop::EventLoopProxy<ET>;
|
||||||
@ -77,7 +69,7 @@ pub struct WinitEventLoop<ET: 'static> {
|
|||||||
impl<ET: 'static + PartialEq + Debug> EventLoop<ET> for WinitEventLoop<ET> {
|
impl<ET: 'static + PartialEq + Debug> EventLoop<ET> for WinitEventLoop<ET> {
|
||||||
type EventLoopProxy = WinitEventLoopProxy<ET>;
|
type EventLoopProxy = WinitEventLoopProxy<ET>;
|
||||||
|
|
||||||
fn run<E>(mut self, mut map: Map<E>, max_frames: Option<u64>)
|
fn run<E>(self, mut map: Map<E>, max_frames: Option<u64>)
|
||||||
where
|
where
|
||||||
E: Environment,
|
E: Environment,
|
||||||
<E::MapWindowConfig as MapWindowConfig>::MapWindow: HeadedMapWindow,
|
<E::MapWindowConfig as MapWindowConfig>::MapWindow: HeadedMapWindow,
|
||||||
@ -88,16 +80,18 @@ impl<ET: 'static + PartialEq + Debug> EventLoop<ET> for WinitEventLoop<ET> {
|
|||||||
let mut input_controller = InputController::new(0.2, 100.0, 0.1);
|
let mut input_controller = InputController::new(0.2, 100.0, 0.1);
|
||||||
|
|
||||||
self.event_loop
|
self.event_loop
|
||||||
.run(move |event, window_target, control_flow| {
|
.run(move |event, _window_target, control_flow| {
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
if !map.has_renderer() && event == Event::Resumed {
|
if !map.has_renderer() && event == Event::Resumed {
|
||||||
use tokio::{runtime::Handle, task};
|
use tokio::{runtime::Handle, task};
|
||||||
|
use maplibre::render::settings::WgpuSettings;
|
||||||
|
use maplibre::render::builder::RendererBuilder;
|
||||||
|
|
||||||
task::block_in_place(|| {
|
task::block_in_place(|| {
|
||||||
Handle::current().block_on(async {
|
Handle::current().block_on(async {
|
||||||
map.initialize_renderer(RendererBuilder::new()
|
map.initialize_renderer(RendererBuilder::new()
|
||||||
.with_wgpu_settings(WgpuSettings {
|
.with_wgpu_settings(WgpuSettings {
|
||||||
backends: Some(Backends::VULKAN), // FIXME: Change
|
backends: Some(maplibre::render::settings::Backends::VULKAN), // FIXME: Change
|
||||||
..WgpuSettings::default()
|
..WgpuSettings::default()
|
||||||
})).await.unwrap();
|
})).await.unwrap();
|
||||||
})
|
})
|
||||||
|
|||||||
@ -11,16 +11,12 @@ use maplibre::{
|
|||||||
kernel::{Kernel, KernelBuilder},
|
kernel::{Kernel, KernelBuilder},
|
||||||
map::Map,
|
map::Map,
|
||||||
platform::{http_client::ReqwestHttpClient, run_multithreaded, scheduler::TokioScheduler},
|
platform::{http_client::ReqwestHttpClient, run_multithreaded, scheduler::TokioScheduler},
|
||||||
render::{
|
|
||||||
builder::{InitializationResult, InitializedRenderer, RendererBuilder},
|
|
||||||
settings::{Backends, RendererSettings, WgpuSettings},
|
|
||||||
},
|
|
||||||
style::Style,
|
style::Style,
|
||||||
window::{HeadedMapWindow, MapWindow, MapWindowConfig, WindowSize},
|
window::{MapWindow, MapWindowConfig, WindowSize},
|
||||||
};
|
};
|
||||||
use winit::window::WindowBuilder;
|
use winit::window::WindowBuilder;
|
||||||
|
|
||||||
use super::{RawWinitEventLoop, RawWinitWindow, WinitMapWindow};
|
use super::WinitMapWindow;
|
||||||
use crate::{WinitEnvironment, WinitEventLoop};
|
use crate::{WinitEnvironment, WinitEventLoop};
|
||||||
|
|
||||||
pub struct WinitMapWindowConfig<ET> {
|
pub struct WinitMapWindowConfig<ET> {
|
||||||
@ -90,8 +86,10 @@ pub fn run_headed_map(cache_path: Option<String>) {
|
|||||||
|
|
||||||
#[cfg(not(target_os = "android"))]
|
#[cfg(not(target_os = "android"))]
|
||||||
{
|
{
|
||||||
|
use maplibre::render::{builder::RendererBuilder, settings::WgpuSettings};
|
||||||
|
|
||||||
map.initialize_renderer(RendererBuilder::new().with_wgpu_settings(WgpuSettings {
|
map.initialize_renderer(RendererBuilder::new().with_wgpu_settings(WgpuSettings {
|
||||||
backends: Some(Backends::VULKAN), // FIXME: Change
|
backends: Some(maplibre::render::settings::Backends::VULKAN), // FIXME: Change
|
||||||
..WgpuSettings::default()
|
..WgpuSettings::default()
|
||||||
}))
|
}))
|
||||||
.await
|
.await
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
use maplibre::window::{HeadedMapWindow, MapWindow, MapWindowConfig, WindowSize};
|
use maplibre::window::{MapWindow, MapWindowConfig, WindowSize};
|
||||||
use winit::{platform::web::WindowBuilderExtWebSys, window::WindowBuilder};
|
use winit::{platform::web::WindowBuilderExtWebSys, window::WindowBuilder};
|
||||||
|
|
||||||
use super::{RawWinitEventLoop, RawWinitWindow, WinitMapWindow};
|
use super::WinitMapWindow;
|
||||||
use crate::WinitEventLoop;
|
use crate::WinitEventLoop;
|
||||||
|
|
||||||
pub struct WinitMapWindowConfig<ET> {
|
pub struct WinitMapWindowConfig<ET> {
|
||||||
|
|||||||
@ -9,7 +9,7 @@ description = "Native Maps for Web, Mobile and Desktop"
|
|||||||
readme = "../README.md"
|
readme = "../README.md"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["thread-safe-futures"]
|
default = []
|
||||||
web-webgl = ["wgpu/webgl"]
|
web-webgl = ["wgpu/webgl"]
|
||||||
# Enable tracing using tracy on desktop/mobile and the chrome profiler on web
|
# Enable tracing using tracy on desktop/mobile and the chrome profiler on web
|
||||||
trace = ["tracing-subscriber", "tracing-tracy", "tracy-client"]
|
trace = ["tracing-subscriber", "tracing-tracy", "tracy-client"]
|
||||||
|
|||||||
@ -1,8 +1,4 @@
|
|||||||
use crate::{
|
use crate::{render::Renderer, style::Style, world::World};
|
||||||
render::Renderer,
|
|
||||||
style::Style,
|
|
||||||
world::{ViewState, World},
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Stores the context of the map.
|
/// Stores the context of the map.
|
||||||
pub struct MapContext {
|
pub struct MapContext {
|
||||||
|
|||||||
@ -32,7 +32,7 @@ const fn create_zoom_bounds<const DIM: usize>() -> [u32; DIM] {
|
|||||||
let mut result: [u32; DIM] = [0; DIM];
|
let mut result: [u32; DIM] = [0; DIM];
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
while i < DIM {
|
while i < DIM {
|
||||||
result[i as usize] = 2u32.pow(i as u32);
|
result[i] = 2u32.pow(i as u32);
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
result
|
result
|
||||||
|
|||||||
@ -1,14 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
event_loop::EventLoopConfig,
|
io::{apc::AsyncProcedureCall, scheduler::Scheduler, source_client::HttpClient},
|
||||||
io::{
|
|
||||||
apc::AsyncProcedureCall,
|
|
||||||
scheduler::Scheduler,
|
|
||||||
source_client::{HttpClient, HttpSourceClient, SourceClient},
|
|
||||||
transferables::{
|
|
||||||
DefaultTessellatedLayer, DefaultTileTessellated, DefaultUnavailableLayer, Transferables,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
kernel::Kernel,
|
|
||||||
window::MapWindowConfig,
|
window::MapWindowConfig,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
//! Errors which can happen in various parts of the library.
|
//! Errors which can happen in various parts of the library.
|
||||||
|
|
||||||
use std::{borrow::Cow, fmt, fmt::Formatter, sync::mpsc::SendError};
|
use std::{borrow::Cow, sync::mpsc::SendError};
|
||||||
|
|
||||||
use lyon::tessellation::TessellationError;
|
use lyon::tessellation::TessellationError;
|
||||||
|
|
||||||
use crate::render::{error::RenderError, graph::RenderGraphError};
|
use crate::render::error::RenderError;
|
||||||
|
|
||||||
/// Enumeration of errors which can happen during the operation of the library.
|
/// Enumeration of errors which can happen during the operation of the library.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|||||||
@ -11,19 +11,17 @@ use crate::{
|
|||||||
io::{
|
io::{
|
||||||
pipeline::{PipelineContext, PipelineProcessor, Processable},
|
pipeline::{PipelineContext, PipelineProcessor, Processable},
|
||||||
tile_pipelines::build_vector_tile_pipeline,
|
tile_pipelines::build_vector_tile_pipeline,
|
||||||
tile_repository::{StoredLayer, StoredTile, TileStatus},
|
tile_repository::{StoredLayer, StoredTile},
|
||||||
RawLayer, TileRequest,
|
RawLayer, TileRequest,
|
||||||
},
|
},
|
||||||
kernel::Kernel,
|
kernel::Kernel,
|
||||||
render::{
|
render::{
|
||||||
builder::UninitializedRenderer, create_default_render_graph, draw_graph,
|
create_default_render_graph, draw_graph, eventually::Eventually,
|
||||||
error::RenderError, eventually::Eventually, register_default_render_stages, resource::Head,
|
register_default_render_stages, stages::RenderStageLabel, Renderer, ShaderVertex,
|
||||||
stages::RenderStageLabel, Renderer, ShaderVertex,
|
|
||||||
},
|
},
|
||||||
schedule::{Schedule, Stage},
|
schedule::{Schedule, Stage},
|
||||||
style::Style,
|
style::Style,
|
||||||
tessellation::{IndexDataType, OverAlignedVertexBuffer},
|
tessellation::{IndexDataType, OverAlignedVertexBuffer},
|
||||||
window::WindowSize,
|
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -6,10 +6,7 @@ use crate::{
|
|||||||
io::apc::SchedulerAsyncProcedureCall,
|
io::apc::SchedulerAsyncProcedureCall,
|
||||||
kernel::{Kernel, KernelBuilder},
|
kernel::{Kernel, KernelBuilder},
|
||||||
platform::{http_client::ReqwestHttpClient, scheduler::TokioScheduler},
|
platform::{http_client::ReqwestHttpClient, scheduler::TokioScheduler},
|
||||||
render::{
|
render::{builder::RendererBuilder, Renderer},
|
||||||
builder::{InitializedRenderer, RendererBuilder},
|
|
||||||
Renderer,
|
|
||||||
},
|
|
||||||
window::{MapWindowConfig, WindowSize},
|
window::{MapWindowConfig, WindowSize},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
|
||||||
future::Future,
|
future::Future,
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
sync::{
|
sync::{
|
||||||
@ -11,7 +10,6 @@ use std::{
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
coords::WorldTileCoords,
|
|
||||||
error::Error,
|
error::Error,
|
||||||
io::{
|
io::{
|
||||||
scheduler::Scheduler,
|
scheduler::Scheduler,
|
||||||
@ -120,7 +118,7 @@ pub struct SchedulerContext<T: Transferables, HC: HttpClient> {
|
|||||||
|
|
||||||
impl<T: Transferables, HC: HttpClient> Context<T, HC> for SchedulerContext<T, HC> {
|
impl<T: Transferables, HC: HttpClient> Context<T, HC> for SchedulerContext<T, HC> {
|
||||||
fn send(&self, data: Message<T>) -> Result<(), Error> {
|
fn send(&self, data: Message<T>) -> Result<(), Error> {
|
||||||
self.sender.send(data).map_err(|e| Error::APC)
|
self.sender.send(data).map_err(|_e| Error::APC)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn source_client(&self) -> &SourceClient<HC> {
|
fn source_client(&self) -> &SourceClient<HC> {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
use downcast_rs::{impl_downcast, Downcast};
|
use downcast_rs::Downcast;
|
||||||
use geozero::mvt::tile;
|
use geozero::mvt::tile;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|||||||
@ -27,7 +27,7 @@ pub trait Scheduler: 'static {
|
|||||||
pub struct NopScheduler;
|
pub struct NopScheduler;
|
||||||
|
|
||||||
impl Scheduler for NopScheduler {
|
impl Scheduler for NopScheduler {
|
||||||
fn schedule<T>(&self, future_factory: impl FnOnce() -> T + Send + 'static) -> Result<(), Error>
|
fn schedule<T>(&self, _future_factory: impl FnOnce() -> T + Send + 'static) -> Result<(), Error>
|
||||||
where
|
where
|
||||||
T: Future<Output = ()> + 'static,
|
T: Future<Output = ()> + 'static,
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
//! Tile cache.
|
//! Tile cache.
|
||||||
|
|
||||||
use std::collections::{btree_map, BTreeMap, HashSet};
|
use std::collections::{btree_map, BTreeMap};
|
||||||
|
|
||||||
use geozero::mvt::tile;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
coords::{Quadkey, WorldTileCoords},
|
coords::{Quadkey, WorldTileCoords},
|
||||||
@ -112,7 +110,7 @@ impl TileRepository {
|
|||||||
.map(|key| self.tree.entry(key))
|
.map(|key| self.tree.entry(key))
|
||||||
{
|
{
|
||||||
match entry {
|
match entry {
|
||||||
btree_map::Entry::Vacant(entry) => {
|
btree_map::Entry::Vacant(_entry) => {
|
||||||
panic!("Can not add a tessellated layer if no request has been started before.")
|
panic!("Can not add a tessellated layer if no request has been started before.")
|
||||||
}
|
}
|
||||||
btree_map::Entry::Occupied(mut entry) => {
|
btree_map::Entry::Occupied(mut entry) => {
|
||||||
@ -155,7 +153,11 @@ impl TileRepository {
|
|||||||
|
|
||||||
/// Checks if a layer has been fetched.
|
/// Checks if a layer has been fetched.
|
||||||
pub fn has_tile(&self, coords: &WorldTileCoords) -> bool {
|
pub fn has_tile(&self, coords: &WorldTileCoords) -> bool {
|
||||||
if let Some(_) = coords.build_quad_key().and_then(|key| self.tree.get(&key)) {
|
if coords
|
||||||
|
.build_quad_key()
|
||||||
|
.and_then(|key| self.tree.get(&key))
|
||||||
|
.is_some()
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
|
|||||||
@ -16,6 +16,8 @@
|
|||||||
//! maplibre = "0.0.2"
|
//! maplibre = "0.0.2"
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
|
#![deny(unused_imports)]
|
||||||
|
|
||||||
// Internal modules
|
// Internal modules
|
||||||
pub(crate) mod tessellation;
|
pub(crate) mod tessellation;
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ use std::rc::Rc;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
context::MapContext,
|
context::MapContext,
|
||||||
coords::{LatLon, WorldCoords, Zoom, TILE_SIZE},
|
coords::{LatLon, Zoom},
|
||||||
environment::Environment,
|
environment::Environment,
|
||||||
error::Error,
|
error::Error,
|
||||||
kernel::Kernel,
|
kernel::Kernel,
|
||||||
@ -11,13 +11,11 @@ use crate::{
|
|||||||
InitializationResult, InitializedRenderer, RendererBuilder, UninitializedRenderer,
|
InitializationResult, InitializedRenderer, RendererBuilder, UninitializedRenderer,
|
||||||
},
|
},
|
||||||
create_default_render_graph, register_default_render_stages,
|
create_default_render_graph, register_default_render_stages,
|
||||||
settings::{RendererSettings, WgpuSettings},
|
|
||||||
Renderer,
|
|
||||||
},
|
},
|
||||||
schedule::{Schedule, Stage},
|
schedule::{Schedule, Stage},
|
||||||
stages::register_stages,
|
stages::register_stages,
|
||||||
style::Style,
|
style::Style,
|
||||||
window::{HeadedMapWindow, MapWindow, MapWindowConfig, WindowSize},
|
window::{HeadedMapWindow, MapWindow, MapWindowConfig},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -47,7 +45,7 @@ where
|
|||||||
|
|
||||||
register_stages::<E>(&mut schedule, kernel.clone());
|
register_stages::<E>(&mut schedule, kernel.clone());
|
||||||
|
|
||||||
let mut window = kernel.map_window_config().create();
|
let window = kernel.map_window_config().create();
|
||||||
|
|
||||||
let map = Self {
|
let map = Self {
|
||||||
kernel,
|
kernel,
|
||||||
@ -78,13 +76,13 @@ where
|
|||||||
let world = World::new_at(
|
let world = World::new_at(
|
||||||
window_size,
|
window_size,
|
||||||
LatLon::new(center[0], center[1]),
|
LatLon::new(center[0], center[1]),
|
||||||
style.zoom.map(|zoom| Zoom::new(zoom)).unwrap_or_default(),
|
style.zoom.map(Zoom::new).unwrap_or_default(),
|
||||||
cgmath::Deg::<f64>(style.pitch.unwrap_or_default()),
|
cgmath::Deg::<f64>(style.pitch.unwrap_or_default()),
|
||||||
);
|
);
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
InitializationResult::Initialized(InitializedRenderer { renderer, .. }) => {
|
InitializationResult::Initialized(InitializedRenderer { renderer, .. }) => {
|
||||||
*&mut self.map_context = MapContextState::Ready(MapContext {
|
self.map_context = MapContextState::Ready(MapContext {
|
||||||
world,
|
world,
|
||||||
style: std::mem::take(style),
|
style: std::mem::take(style),
|
||||||
renderer,
|
renderer,
|
||||||
|
|||||||
@ -40,7 +40,8 @@ impl ReqwestHttpClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[cfg_attr(not(feature = "thread-safe-futures"), async_trait(?Send))]
|
||||||
|
#[cfg_attr(feature = "thread-safe-futures", async_trait)]
|
||||||
impl HttpClient for ReqwestHttpClient {
|
impl HttpClient for ReqwestHttpClient {
|
||||||
async fn fetch(&self, url: &str) -> Result<Vec<u8>, Error> {
|
async fn fetch(&self, url: &str) -> Result<Vec<u8>, Error> {
|
||||||
let response = self.client.get(url).send().await?;
|
let response = self.client.get(url).send().await?;
|
||||||
|
|||||||
@ -12,6 +12,7 @@ impl TokioScheduler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Scheduler for TokioScheduler {
|
impl Scheduler for TokioScheduler {
|
||||||
|
#[cfg(feature = "thread-safe-futures")]
|
||||||
fn schedule<T>(&self, future_factory: impl FnOnce() -> T + Send + 'static) -> Result<(), Error>
|
fn schedule<T>(&self, future_factory: impl FnOnce() -> T + Send + 'static) -> Result<(), Error>
|
||||||
where
|
where
|
||||||
T: Future<Output = ()> + Send + 'static,
|
T: Future<Output = ()> + Send + 'static,
|
||||||
@ -19,4 +20,13 @@ impl Scheduler for TokioScheduler {
|
|||||||
tokio::task::spawn((future_factory)());
|
tokio::task::spawn((future_factory)());
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Provide a working implementation
|
||||||
|
#[cfg(not(feature = "thread-safe-futures"))]
|
||||||
|
fn schedule<T>(&self, _future_factory: impl FnOnce() -> T + 'static) -> Result<(), Error>
|
||||||
|
where
|
||||||
|
T: Future<Output = ()> + 'static,
|
||||||
|
{
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +1,10 @@
|
|||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
environment::Environment,
|
|
||||||
error::Error,
|
error::Error,
|
||||||
kernel::Kernel,
|
|
||||||
render::{
|
render::{
|
||||||
settings::{RendererSettings, WgpuSettings},
|
settings::{RendererSettings, WgpuSettings},
|
||||||
Renderer,
|
Renderer,
|
||||||
},
|
},
|
||||||
style::Style,
|
window::{HeadedMapWindow, MapWindowConfig},
|
||||||
window::{HeadedMapWindow, MapWindow, MapWindowConfig},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct RendererBuilder {
|
pub struct RendererBuilder {
|
||||||
@ -94,7 +89,7 @@ impl UninitializedRenderer {
|
|||||||
let renderer = Renderer::initialize(
|
let renderer = Renderer::initialize(
|
||||||
existing_window,
|
existing_window,
|
||||||
self.wgpu_settings.clone(),
|
self.wgpu_settings.clone(),
|
||||||
self.renderer_settings.clone(),
|
self.renderer_settings,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(InitializationResult::Initialized(InitializedRenderer {
|
Ok(InitializationResult::Initialized(InitializedRenderer {
|
||||||
|
|||||||
@ -141,8 +141,8 @@ impl Camera {
|
|||||||
let oz = min_depth;
|
let oz = min_depth;
|
||||||
let pz = max_depth - min_depth;
|
let pz = max_depth - min_depth;
|
||||||
Matrix4::from_cols(
|
Matrix4::from_cols(
|
||||||
Vector4::new(self.width as f64 / 2.0, 0.0, 0.0, 0.0),
|
Vector4::new(self.width / 2.0, 0.0, 0.0, 0.0),
|
||||||
Vector4::new(0.0, -self.height as f64 / 2.0, 0.0, 0.0),
|
Vector4::new(0.0, -self.height / 2.0, 0.0, 0.0),
|
||||||
Vector4::new(0.0, 0.0, pz, 0.0),
|
Vector4::new(0.0, 0.0, pz, 0.0),
|
||||||
Vector4::new(ox, oy, oz, 1.0),
|
Vector4::new(ox, oy, oz, 1.0),
|
||||||
)
|
)
|
||||||
@ -181,11 +181,11 @@ impl Camera {
|
|||||||
|
|
||||||
let x = 0.0;
|
let x = 0.0;
|
||||||
let y = 0.0;
|
let y = 0.0;
|
||||||
let ox = x + self.width as f64 / 2.0;
|
let ox = x + self.width / 2.0;
|
||||||
let oy = y + self.height as f64 / 2.0;
|
let oy = y + self.height / 2.0;
|
||||||
let oz = min_depth;
|
let oz = min_depth;
|
||||||
let px = self.width as f64;
|
let px = self.width;
|
||||||
let py = self.height as f64;
|
let py = self.height;
|
||||||
let pz = max_depth - min_depth;
|
let pz = max_depth - min_depth;
|
||||||
let xd = ndc.x;
|
let xd = ndc.x;
|
||||||
let yd = ndc.y;
|
let yd = ndc.y;
|
||||||
|
|||||||
@ -412,10 +412,7 @@ impl Renderer {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{
|
use crate::window::{MapWindow, MapWindowConfig, WindowSize};
|
||||||
render::{settings::RendererSettings, RenderState},
|
|
||||||
window::{MapWindow, MapWindowConfig, WindowSize},
|
|
||||||
};
|
|
||||||
|
|
||||||
pub struct HeadlessMapWindowConfig {
|
pub struct HeadlessMapWindowConfig {
|
||||||
size: WindowSize,
|
size: WindowSize,
|
||||||
@ -445,7 +442,8 @@ mod tests {
|
|||||||
use log::LevelFilter;
|
use log::LevelFilter;
|
||||||
|
|
||||||
use crate::render::{
|
use crate::render::{
|
||||||
graph::RenderGraph, graph_runner::RenderGraphRunner, resource::Surface,
|
graph::RenderGraph, graph_runner::RenderGraphRunner, resource::Surface, RenderState,
|
||||||
|
RendererSettings,
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = env_logger::builder()
|
let _ = env_logger::builder()
|
||||||
|
|||||||
@ -247,7 +247,7 @@ impl<Q: Queue<B>, B, V: Pod, I: Pod, TM: Pod, FM: Pod> BufferPool<Q, B, V, I, TM
|
|||||||
style_layer,
|
style_layer,
|
||||||
buffer_vertices: self.vertices.make_room(vertices_bytes, &mut self.index),
|
buffer_vertices: self.vertices.make_room(vertices_bytes, &mut self.index),
|
||||||
buffer_indices: self.indices.make_room(indices_bytes, &mut self.index),
|
buffer_indices: self.indices.make_room(indices_bytes, &mut self.index),
|
||||||
usable_indices: geometry.usable_indices as u32,
|
usable_indices: geometry.usable_indices,
|
||||||
buffer_layer_metadata: self
|
buffer_layer_metadata: self
|
||||||
.layer_metadata
|
.layer_metadata
|
||||||
.make_room(layer_metadata_bytes, &mut self.index),
|
.make_room(layer_metadata_bytes, &mut self.index),
|
||||||
|
|||||||
@ -12,7 +12,7 @@ pub struct VertexBufferLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Describes the fragment process in a render pipeline.
|
/// Describes the fragment process in a render pipeline.
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct FragmentState {
|
pub struct FragmentState {
|
||||||
/// The shader source
|
/// The shader source
|
||||||
pub source: &'static str,
|
pub source: &'static str,
|
||||||
|
|||||||
@ -52,7 +52,7 @@ impl Default for WgpuSettings {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut features = Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES;
|
let features = Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES;
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
device_label: Default::default(),
|
device_label: Default::default(),
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
context::MapContext,
|
context::MapContext,
|
||||||
coords::ViewRegion,
|
|
||||||
render::{eventually::Eventually::Initialized, RenderState, Renderer},
|
render::{eventually::Eventually::Initialized, RenderState, Renderer},
|
||||||
schedule::Stage,
|
schedule::Stage,
|
||||||
world::World,
|
world::World,
|
||||||
|
|||||||
@ -6,7 +6,7 @@ use crate::{
|
|||||||
platform::MIN_WEBGL_BUFFER_SIZE,
|
platform::MIN_WEBGL_BUFFER_SIZE,
|
||||||
render::{
|
render::{
|
||||||
resource::{FragmentState, RenderPipeline, RenderPipelineDescriptor, VertexState},
|
resource::{FragmentState, RenderPipeline, RenderPipelineDescriptor, VertexState},
|
||||||
settings::{Msaa, RendererSettings},
|
settings::RendererSettings,
|
||||||
shaders::ShaderGlobals,
|
shaders::ShaderGlobals,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@ -41,7 +41,7 @@ impl TileShape {
|
|||||||
coords,
|
coords,
|
||||||
zoom_factor: zoom.scale_to_tile(&coords),
|
zoom_factor: zoom.scale_to_tile(&coords),
|
||||||
transform: coords.transform_for_zoom(zoom),
|
transform: coords.transform_for_zoom(zoom),
|
||||||
buffer_range: index as u64 * STRIDE..(index as u64 + 1) * STRIDE,
|
buffer_range: index * STRIDE..(index + 1) * STRIDE,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,31 +1,20 @@
|
|||||||
//! [Stages](Stage) for requesting and preparing data
|
//! [Stages](Stage) for requesting and preparing data
|
||||||
|
|
||||||
use std::{
|
use std::{marker::PhantomData, rc::Rc};
|
||||||
cell::RefCell,
|
|
||||||
marker::PhantomData,
|
|
||||||
rc::Rc,
|
|
||||||
sync::{mpsc, Arc, Mutex},
|
|
||||||
};
|
|
||||||
|
|
||||||
use geozero::{mvt::tile, GeozeroDatasource};
|
use geozero::mvt::tile;
|
||||||
use request_stage::RequestStage;
|
use request_stage::RequestStage;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
coords::{WorldCoords, WorldTileCoords, Zoom, ZoomLevel},
|
coords::WorldTileCoords,
|
||||||
environment::Environment,
|
environment::Environment,
|
||||||
error::Error,
|
error::Error,
|
||||||
io::{
|
io::{
|
||||||
apc::{AsyncProcedureCall, Context, Message},
|
apc::{Context, Message},
|
||||||
geometry_index::{GeometryIndex, IndexedGeometry, TileIndex},
|
geometry_index::IndexedGeometry,
|
||||||
pipeline::{PipelineContext, PipelineProcessor, Processable},
|
pipeline::PipelineProcessor,
|
||||||
source_client::{HttpClient, HttpSourceClient},
|
source_client::HttpClient,
|
||||||
tile_pipelines::build_vector_tile_pipeline,
|
transferables::{TessellatedLayer, TileTessellated, Transferables, UnavailableLayer},
|
||||||
transferables::{
|
|
||||||
DefaultTessellatedLayer, DefaultTileTessellated, DefaultTransferables,
|
|
||||||
DefaultUnavailableLayer, TessellatedLayer, TileTessellated, Transferables,
|
|
||||||
UnavailableLayer,
|
|
||||||
},
|
|
||||||
TileRequest,
|
|
||||||
},
|
},
|
||||||
kernel::Kernel,
|
kernel::Kernel,
|
||||||
render::ShaderVertex,
|
render::ShaderVertex,
|
||||||
@ -87,8 +76,8 @@ impl<'c, T: Transferables, HC: HttpClient, C: Context<T, HC>> PipelineProcessor
|
|||||||
|
|
||||||
fn layer_indexing_finished(
|
fn layer_indexing_finished(
|
||||||
&mut self,
|
&mut self,
|
||||||
coords: &WorldTileCoords,
|
_coords: &WorldTileCoords,
|
||||||
geometries: Vec<IndexedGeometry<f64>>,
|
_geometries: Vec<IndexedGeometry<f64>>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
// FIXME (wasm-executor): Readd
|
// FIXME (wasm-executor): Readd
|
||||||
/* if let Ok(mut geometry_index) = self.state.geometry_index.lock() {
|
/* if let Ok(mut geometry_index) = self.state.geometry_index.lock() {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
//! Receives data from async threads and populates the [`crate::io::tile_repository::TileRepository`].
|
//! Receives data from async threads and populates the [`crate::io::tile_repository::TileRepository`].
|
||||||
|
|
||||||
use std::{borrow::BorrowMut, cell::RefCell, ops::Deref, rc::Rc};
|
use std::rc::Rc;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
context::MapContext,
|
context::MapContext,
|
||||||
|
|||||||
@ -1,26 +1,15 @@
|
|||||||
//! Requests tiles which are currently in view
|
//! Requests tiles which are currently in view
|
||||||
|
|
||||||
use std::{
|
use std::{collections::HashSet, rc::Rc};
|
||||||
borrow::Borrow,
|
|
||||||
cell::RefCell,
|
|
||||||
collections::{HashMap, HashSet},
|
|
||||||
future::Future,
|
|
||||||
ops::Deref,
|
|
||||||
pin::Pin,
|
|
||||||
process::Output,
|
|
||||||
rc::Rc,
|
|
||||||
str::FromStr,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
context::MapContext,
|
context::MapContext,
|
||||||
coords::{ViewRegion, WorldTileCoords, ZoomLevel},
|
coords::{ViewRegion, WorldTileCoords},
|
||||||
environment::Environment,
|
environment::Environment,
|
||||||
error::Error,
|
error::Error,
|
||||||
io::{
|
io::{
|
||||||
apc::{AsyncProcedureCall, AsyncProcedureFuture, Context, Input, Message},
|
apc::{AsyncProcedureCall, AsyncProcedureFuture, Context, Input, Message},
|
||||||
pipeline::{PipelineContext, Processable},
|
pipeline::{PipelineContext, Processable},
|
||||||
source_client::{HttpSourceClient, SourceClient},
|
|
||||||
tile_pipelines::build_vector_tile_pipeline,
|
tile_pipelines::build_vector_tile_pipeline,
|
||||||
tile_repository::TileRepository,
|
tile_repository::TileRepository,
|
||||||
transferables::{Transferables, UnavailableLayer},
|
transferables::{Transferables, UnavailableLayer},
|
||||||
|
|||||||
@ -1,11 +1,7 @@
|
|||||||
//! Utilities for the window system.
|
//! Utilities for the window system.
|
||||||
|
|
||||||
use std::{cell::RefCell, rc::Rc};
|
|
||||||
|
|
||||||
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
|
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
|
||||||
|
|
||||||
use crate::environment::Environment;
|
|
||||||
|
|
||||||
/// Window of a certain [`WindowSize`]. This can either be a proper window or a headless one.
|
/// Window of a certain [`WindowSize`]. This can either be a proper window or a headless one.
|
||||||
pub trait MapWindow {
|
pub trait MapWindow {
|
||||||
fn size(&self) -> WindowSize;
|
fn size(&self) -> WindowSize;
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
|
|
||||||
use cgmath::{Angle, Point3};
|
use cgmath::Angle;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
context::MapContext,
|
|
||||||
coords::{LatLon, ViewRegion, WorldCoords, Zoom, ZoomLevel, TILE_SIZE},
|
coords::{LatLon, ViewRegion, WorldCoords, Zoom, ZoomLevel, TILE_SIZE},
|
||||||
io::tile_repository::TileRepository,
|
io::tile_repository::TileRepository,
|
||||||
render::camera::{Camera, Perspective, ViewProjection},
|
render::camera::{Camera, Perspective, ViewProjection},
|
||||||
|
|||||||
@ -19,7 +19,7 @@ crate-type = ["cdylib", "rlib"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
async-trait = "0.1.56"
|
async-trait = "0.1.56"
|
||||||
maplibre = { path = "../maplibre", default-features = false, features = [] }
|
maplibre = { path = "../maplibre" }
|
||||||
maplibre-winit = { path = "../maplibre-winit", version = "0.0.1" }
|
maplibre-winit = { path = "../maplibre-winit", version = "0.0.1" }
|
||||||
|
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
|
|||||||
@ -260,6 +260,7 @@ const start = async () => {
|
|||||||
emitTypeScript();
|
emitTypeScript();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Failed to start building: " + e.message)
|
console.error("Failed to start building: " + e.message)
|
||||||
|
process.exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,15 +1,12 @@
|
|||||||
|
#![deny(unused_imports)]
|
||||||
#![feature(allocator_api, new_uninit)]
|
#![feature(allocator_api, new_uninit)]
|
||||||
|
|
||||||
use std::{borrow::BorrowMut, cell::RefCell, mem, ops::Deref, rc::Rc};
|
|
||||||
|
|
||||||
use maplibre::{
|
use maplibre::{
|
||||||
event_loop::EventLoop,
|
event_loop::EventLoop,
|
||||||
io::{apc::SchedulerAsyncProcedureCall, scheduler::NopScheduler},
|
|
||||||
kernel::{Kernel, KernelBuilder},
|
kernel::{Kernel, KernelBuilder},
|
||||||
map::Map,
|
map::Map,
|
||||||
render::builder::{InitializedRenderer, RendererBuilder},
|
render::builder::RendererBuilder,
|
||||||
style::Style,
|
style::Style,
|
||||||
window::MapWindowConfig,
|
|
||||||
};
|
};
|
||||||
use maplibre_winit::{WinitEnvironment, WinitMapWindowConfig};
|
use maplibre_winit::{WinitEnvironment, WinitMapWindowConfig};
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
@ -19,7 +16,7 @@ use crate::platform::http_client::WHATWGFetchHttpClient;
|
|||||||
mod error;
|
mod error;
|
||||||
mod platform;
|
mod platform;
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(any(no_pendantic_os_check, target_arch = "wasm32")))]
|
||||||
compile_error!("web works only on wasm32.");
|
compile_error!("web works only on wasm32.");
|
||||||
|
|
||||||
#[cfg(feature = "trace")]
|
#[cfg(feature = "trace")]
|
||||||
@ -48,7 +45,7 @@ pub fn wasm_bindgen_start() {
|
|||||||
|
|
||||||
#[cfg(not(target_feature = "atomics"))]
|
#[cfg(not(target_feature = "atomics"))]
|
||||||
type CurrentEnvironment = WinitEnvironment<
|
type CurrentEnvironment = WinitEnvironment<
|
||||||
NopScheduler,
|
maplibre::io::scheduler::NopScheduler,
|
||||||
WHATWGFetchHttpClient,
|
WHATWGFetchHttpClient,
|
||||||
platform::singlethreaded::apc::PassingAsyncProcedureCall,
|
platform::singlethreaded::apc::PassingAsyncProcedureCall,
|
||||||
(),
|
(),
|
||||||
@ -91,7 +88,7 @@ pub async fn run_maplibre(new_worker: js_sys::Function) {
|
|||||||
{
|
{
|
||||||
kernel_builder = kernel_builder
|
kernel_builder = kernel_builder
|
||||||
.with_apc(platform::singlethreaded::apc::PassingAsyncProcedureCall::new(new_worker, 4))
|
.with_apc(platform::singlethreaded::apc::PassingAsyncProcedureCall::new(new_worker, 4))
|
||||||
.with_scheduler(NopScheduler);
|
.with_scheduler(maplibre::io::scheduler::NopScheduler);
|
||||||
}
|
}
|
||||||
|
|
||||||
let kernel: Kernel<WinitEnvironment<_, _, _, ()>> = kernel_builder.build();
|
let kernel: Kernel<WinitEnvironment<_, _, _, ()>> = kernel_builder.build();
|
||||||
|
|||||||
@ -1,6 +1,3 @@
|
|||||||
use std::future::Future;
|
|
||||||
|
|
||||||
use maplibre::error::Error;
|
|
||||||
pub mod http_client;
|
pub mod http_client;
|
||||||
|
|
||||||
#[cfg(target_feature = "atomics")]
|
#[cfg(target_feature = "atomics")]
|
||||||
|
|||||||
@ -2,13 +2,13 @@
|
|||||||
//! web workers which can be used to execute work.
|
//! web workers which can be used to execute work.
|
||||||
//! Adopted from [wasm-bindgen example](https://github.com/rustwasm/wasm-bindgen/blob/0eba2efe45801b71f8873bc368c58a8ed8e894ff/examples/raytrace-parallel/src/pool.rs)
|
//! Adopted from [wasm-bindgen example](https://github.com/rustwasm/wasm-bindgen/blob/0eba2efe45801b71f8873bc368c58a8ed8e894ff/examples/raytrace-parallel/src/pool.rs)
|
||||||
|
|
||||||
use std::{borrow::BorrowMut, cell::RefCell, future::Future, rc::Rc};
|
use std::{cell::RefCell, rc::Rc};
|
||||||
|
|
||||||
use js_sys::Promise;
|
use js_sys::Promise;
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
use wasm_bindgen::{prelude::*, JsCast};
|
use wasm_bindgen::prelude::*;
|
||||||
use wasm_bindgen_futures::JsFuture;
|
use wasm_bindgen_futures::JsFuture;
|
||||||
use web_sys::{DedicatedWorkerGlobalScope, ErrorEvent, Event, MessageEvent, Worker};
|
use web_sys::Worker;
|
||||||
|
|
||||||
#[wasm_bindgen()]
|
#[wasm_bindgen()]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -91,10 +91,7 @@ impl WorkerPool {
|
|||||||
/// message is sent to it.
|
/// message is sent to it.
|
||||||
fn worker(&self) -> Result<Worker, JsValue> {
|
fn worker(&self) -> Result<Worker, JsValue> {
|
||||||
let workers = self.state.workers.borrow();
|
let workers = self.state.workers.borrow();
|
||||||
let result = match workers.choose(&mut thread_rng()) {
|
let result = workers.choose(&mut thread_rng());
|
||||||
Some(worker) => Some(worker),
|
|
||||||
None => None,
|
|
||||||
};
|
|
||||||
|
|
||||||
if result.is_none() {
|
if result.is_none() {
|
||||||
self.spawn()?;
|
self.spawn()?;
|
||||||
|
|||||||
@ -1,12 +1,10 @@
|
|||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
|
|
||||||
use log::warn;
|
|
||||||
use maplibre::{error::Error, io::scheduler::Scheduler};
|
use maplibre::{error::Error, io::scheduler::Scheduler};
|
||||||
use wasm_bindgen::{prelude::*, JsCast};
|
use wasm_bindgen::{prelude::*, JsCast};
|
||||||
use web_sys::Worker;
|
use web_sys::Worker;
|
||||||
|
|
||||||
use super::pool::WorkerPool;
|
use super::pool::WorkerPool;
|
||||||
use crate::CurrentEnvironment;
|
|
||||||
|
|
||||||
pub struct WebWorkerPoolScheduler {
|
pub struct WebWorkerPoolScheduler {
|
||||||
pool: WorkerPool,
|
pool: WorkerPool,
|
||||||
|
|||||||
@ -1,41 +1,23 @@
|
|||||||
use std::{
|
use std::{cell::RefCell, mem, rc::Rc};
|
||||||
any::TypeId,
|
|
||||||
borrow::Borrow,
|
|
||||||
cell::RefCell,
|
|
||||||
collections::HashMap,
|
|
||||||
marker::PhantomData,
|
|
||||||
mem,
|
|
||||||
mem::{size_of, MaybeUninit},
|
|
||||||
ops::Deref,
|
|
||||||
pin::Pin,
|
|
||||||
rc::Rc,
|
|
||||||
sync::{
|
|
||||||
mpsc,
|
|
||||||
mpsc::{Receiver, Sender},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
use js_sys::Uint8Array;
|
use js_sys::Uint8Array;
|
||||||
use log::info;
|
use log::info;
|
||||||
use maplibre::{
|
use maplibre::{
|
||||||
environment::Environment,
|
|
||||||
error::Error,
|
error::Error,
|
||||||
io::{
|
io::{
|
||||||
apc::{AsyncProcedure, AsyncProcedureCall, Context, Input, Message},
|
apc::{AsyncProcedure, AsyncProcedureCall, Context, Input, Message},
|
||||||
scheduler::Scheduler,
|
source_client::{HttpSourceClient, SourceClient},
|
||||||
source_client::{HttpClient, HttpSourceClient, SourceClient},
|
|
||||||
transferables::Transferables,
|
transferables::Transferables,
|
||||||
},
|
},
|
||||||
kernel::Kernel,
|
|
||||||
};
|
};
|
||||||
use wasm_bindgen::{prelude::*, JsCast, JsValue};
|
use wasm_bindgen::{prelude::*, JsCast, JsValue};
|
||||||
use web_sys::{console::info, DedicatedWorkerGlobalScope, Worker};
|
use web_sys::{DedicatedWorkerGlobalScope, Worker};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
platform::singlethreaded::transferables::{
|
platform::singlethreaded::transferables::{
|
||||||
InnerData, LinearTessellatedLayer, LinearTransferables,
|
InnerData, LinearTessellatedLayer, LinearTransferables,
|
||||||
},
|
},
|
||||||
CurrentEnvironment, MapType, WHATWGFetchHttpClient,
|
WHATWGFetchHttpClient,
|
||||||
};
|
};
|
||||||
|
|
||||||
type UsedTransferables = LinearTransferables;
|
type UsedTransferables = LinearTransferables;
|
||||||
@ -100,9 +82,8 @@ impl SerializableMessage for Message<LinearTransferables> {
|
|||||||
data: unsafe {
|
data: unsafe {
|
||||||
let mut uninit = Box::<InnerData>::new_zeroed();
|
let mut uninit = Box::<InnerData>::new_zeroed();
|
||||||
data.raw_copy_to_ptr(uninit.as_mut_ptr() as *mut u8);
|
data.raw_copy_to_ptr(uninit.as_mut_ptr() as *mut u8);
|
||||||
let x = uninit.assume_init();
|
|
||||||
|
|
||||||
x
|
uninit.assume_init()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -135,11 +116,11 @@ impl Context<UsedTransferables, UsedHttpClient> for PassingContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let global: DedicatedWorkerGlobalScope =
|
let global: DedicatedWorkerGlobalScope =
|
||||||
js_sys::global().dyn_into().map_err(|e| Error::APC)?;
|
js_sys::global().dyn_into().map_err(|_e| Error::APC)?;
|
||||||
let array = js_sys::Array::new();
|
let array = js_sys::Array::new();
|
||||||
array.push(&JsValue::from(tag as u32));
|
array.push(&JsValue::from(tag as u32));
|
||||||
array.push(&serialized_array_buffer);
|
array.push(&serialized_array_buffer);
|
||||||
global.post_message(&array).map_err(|e| Error::APC)
|
global.post_message(&array).map_err(|_e| Error::APC)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn source_client(&self) -> &SourceClient<UsedHttpClient> {
|
fn source_client(&self) -> &SourceClient<UsedHttpClient> {
|
||||||
@ -235,7 +216,7 @@ pub unsafe fn singlethreaded_main_entry(
|
|||||||
data: Uint8Array,
|
data: Uint8Array,
|
||||||
) -> Result<(), JsValue> {
|
) -> Result<(), JsValue> {
|
||||||
// FIXME (wasm-executor): Can we make this call safe? check if it was cloned before?
|
// FIXME (wasm-executor): Can we make this call safe? check if it was cloned before?
|
||||||
let mut received: Rc<ReceivedType> = Rc::from_raw(received_ptr);
|
let received: Rc<ReceivedType> = Rc::from_raw(received_ptr);
|
||||||
|
|
||||||
let message = Message::<UsedTransferables>::deserialize(
|
let message = Message::<UsedTransferables>::deserialize(
|
||||||
SerializedMessageTag::from_u32(type_id).unwrap(),
|
SerializedMessageTag::from_u32(type_id).unwrap(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user