Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update winit and wgpu which both target rwh 0.6 #303

Merged
merged 14 commits into from
Jul 4, 2024
Merged
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ perf.data*
frame_*.png

.direnv/

xcode/libs/*/**
3 changes: 2 additions & 1 deletion .idea/maplibre-rs.iml

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

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.

8 changes: 2 additions & 6 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 All @@ -36,7 +34,7 @@ rand = { version = "0.7.3", features = ["wasm-bindgen"] }
# FIXME: Untrusted dependency, 0.2.x doesn't compile with cache middleware
reqwest-middleware = "0.1.6"

winit = { version = "0.28.7", default-features = false }
winit = { version = "0.30", default-features = false, features = ["rwh_06"] }

#
# These dependencies should be updated to the latest version
Expand Down Expand Up @@ -67,10 +65,8 @@ 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" }
raw-window-handle = "0.5.2"
reqwest = { version = "0.11.20", default-features = false, features = ["rustls-tls", "gzip"] } # Use rusttls on android because cross compiling is difficult
reqwest-middleware-cache = "0.1.1" # FIXME: Untrusted dependency
rstar = "0.11.0"
Expand All @@ -91,7 +87,7 @@ wasm-bindgen = "=0.2.92"
wasm-bindgen-futures = "0.4"
wasm-bindgen-test = "0.3"
web-sys = "0.3" # Individual features are customized in each crate
wgpu = "0.18.0"
wgpu = "0.19.4"

[profile.release]
lto = true
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
9 changes: 5 additions & 4 deletions apple/MapLibreRs/Sources/MapLibreRsExample/main.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import maplibre_rs
import Metal
import AppKit
import QuartzCore
import SystemConfiguration
import Metal // Required by wgpu?
import AppKit // Required by ??
import QuartzCore // Required by ??
import SystemConfiguration // Required by reqwest?
import Carbon // Required by winit

maplibre_rs.MapLibre.start()

7 changes: 6 additions & 1 deletion apple/xcode/maplibre-rs.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
0B85D599281291A700906D21 /* maplibre_rs.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0B85D56B2812903700906D21 /* maplibre_rs.framework */; };
0B85D5A42812991100906D21 /* libmaplibre_apple.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0B85D5A32812987B00906D21 /* libmaplibre_apple.a */; };
5015FE4C2ACCB64600F8E4B6 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5015FE492ACCA78300F8E4B6 /* SystemConfiguration.framework */; };
53BD1F062C34FB12008DAA23 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 53BD1F052C34FB12008DAA23 /* Carbon.framework */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -32,6 +33,7 @@
0BE452D62812EEA8003BD2A5 /* example--iOS--Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "example--iOS--Info.plist"; sourceTree = "<group>"; };
5015FE472ACCA77900F8E4B6 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.0.sdk/System/Library/Frameworks/SystemConfiguration.framework; sourceTree = DEVELOPER_DIR; };
5015FE492ACCA78300F8E4B6 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
53BD1F052C34FB12008DAA23 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -56,6 +58,7 @@
buildActionMask = 2147483647;
files = (
5015FE4C2ACCB64600F8E4B6 /* SystemConfiguration.framework in Frameworks */,
53BD1F062C34FB12008DAA23 /* Carbon.framework in Frameworks */,
0B85D599281291A700906D21 /* maplibre_rs.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -97,6 +100,7 @@
0B85D573281290D400906D21 /* Frameworks */ = {
isa = PBXGroup;
children = (
53BD1F052C34FB12008DAA23 /* Carbon.framework */,
5015FE472ACCA77900F8E4B6 /* SystemConfiguration.framework */,
5015FE492ACCA78300F8E4B6 /* SystemConfiguration.framework */,
0B85D5A32812987B00906D21 /* libmaplibre_apple.a */,
Expand Down Expand Up @@ -259,6 +263,7 @@
/* Begin PBXShellScriptBuildPhase section */
0BE452D72812EFC1003BD2A5 /* Cargo Build */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand All @@ -273,7 +278,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/bash;
shellScript = "arch=\"unknown\"\nvendor=\"apple\"\nos_type=\"unknown\"\nenvironment_type=\"\"\n\nmode=\"\"\n\necho \"ARCH: $ARCHS\"\n\nif [[ $CONFIGURATION == \"Release\" ]]\nthen\n mode=\"--release\"\nfi\n\nif [[ $ARCHS == \"x86_64\" ]]\nthen\n arch=\"x86_64\"\nelif [[ $ARCHS == \"arm64\" ]]\nthen\n arch=\"aarch64\"\nfi\n\nif [[ $SDK_NAME == *\"iphoneos\"* ]]\nthen\n os_type=\"ios\"\nelif [[ $SDK_NAME == *\"macos\"* ]]\nthen\n os_type=\"darwin\"\nelif [[ $SDK_NAME == *\"iphonesimulator\"* ]]\nthen\n os_type=\"ios\"\n if [[ $ARCHS == \"arm64\" ]]\n then\n environment_type=\"sim\"\n fi\nfi\n\n\ntriplet=\"$arch-$vendor-$os_type\"\n\nif [ -n \"$environment_type\" ]\nthen\n triplet=\"$triplet-$environment_type\"\nfi\n\necho \"Mode: $mode\"\necho \"Triplet: $triplet\"\necho \"Shell: $SHELL\"\n\ncmd=$(cat << END\n export HOME=$HOME\n . $HOME/.cargo/env\n \n if [ -f \"/opt/homebrew/bin/brew\" ];\n then\n echo \"Homebrew support activated\"\n eval \"\\$(/opt/homebrew/bin/brew shellenv)\"\n fi\n \n cargo build -p apple $mode --target $triplet --lib\nEND\n)\n\necho \"Command: $cmd\"\n\nenv -i /bin/bash -c \"$cmd\"\n";
shellScript = "arch=\"unknown\"\nvendor=\"apple\"\nos_type=\"unknown\"\nenvironment_type=\"\"\n\nmode=\"\"\n\necho \"ARCH: $ARCHS\"\n\nif [[ $CONFIGURATION == \"Release\" ]]\nthen\n mode=\"--release\"\nfi\n\nif [[ $ARCHS == \"x86_64\" ]]\nthen\n arch=\"x86_64\"\nelif [[ $ARCHS == \"arm64\" ]]\nthen\n arch=\"aarch64\"\nfi\n\nif [[ $SDK_NAME == *\"iphoneos\"* ]]\nthen\n os_type=\"ios\"\nelif [[ $SDK_NAME == *\"macos\"* ]]\nthen\n os_type=\"darwin\"\nelif [[ $SDK_NAME == *\"iphonesimulator\"* ]]\nthen\n os_type=\"ios\"\n if [[ $ARCHS == \"arm64\" ]]\n then\n environment_type=\"sim\"\n fi\nfi\n\n\ntriplet=\"$arch-$vendor-$os_type\"\n\nif [ -n \"$environment_type\" ]\nthen\n triplet=\"$triplet-$environment_type\"\nfi\n\necho \"Mode: $mode\"\necho \"Triplet: $triplet\"\necho \"Shell: $SHELL\"\n\ncmd=$(cat << END\n export HOME=$HOME # Set home as this env is clean\n export PATH=\"\\$PATH:/usr/bin\" # We have a clean shell, so make /usr/bin available\n . $HOME/.cargo/env\n \n if [ -f \"/opt/homebrew/bin/brew\" ];\n then\n echo \"Homebrew support activated\"\n eval \"\\$(/opt/homebrew/bin/brew shellenv)\"\n fi\n \n cargo build -p apple $mode --target $triplet --lib\nEND\n)\n\necho \"Command: $cmd\"\n\n# Potentially improve this check for other systems\nif test -f /run/current-system/sw/bin/nix-shell; then\n env -i /run/current-system/sw/bin/nix-shell \"$PROJECT_DIR/../../shell.nix\" --run \"$cmd\"\nelse\n env -i /bin/bash -c \"$cmd\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down
5 changes: 1 addition & 4 deletions maplibre-winit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ authors.workspace = true
[target.'cfg(any(target_os = "macos", target_os = "ios", target_os = "linux", target_os = "android", target_os = "windows"))'.dependencies]
tokio.workspace = true

# FIXME: is this section needed? Seems to be identical to the default
#[target.'cfg(target_os = "android")'.dependencies]
#winit.wokrspace = true

[target.'cfg(target_os = "linux")'.dependencies]
winit = { workspace = true, features = ["x11", "wayland"] }

Expand All @@ -34,3 +30,4 @@ winit.workspace = true
cgmath.workspace = true
instant.workspace = true
log.workspace = true
thiserror.workspace = true
18 changes: 8 additions & 10 deletions maplibre-winit/src/input/debug_handler.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::time::Duration;

use maplibre::context::MapContext;
use winit::keyboard::Key;

use super::UpdateState;

Expand Down Expand Up @@ -35,30 +36,27 @@ impl UpdateState for DebugHandler {
}

impl DebugHandler {
pub fn process_key_press(
&mut self,
key: winit::event::VirtualKeyCode,
state: winit::event::ElementState,
) -> bool {
pub fn process_key_press(&mut self, key: &Key, state: winit::event::ElementState) -> bool {
let amount = if state == winit::event::ElementState::Pressed {
100.0
} else {
0.0
};
match key {
winit::event::VirtualKeyCode::V => {

match key.as_ref() {
Key::Character("v") => {
self.left_delta += amount;
true
}
winit::event::VirtualKeyCode::B => {
Key::Character("b") => {
self.top_delta += amount;
true
}
winit::event::VirtualKeyCode::N => {
Key::Character("n") => {
self.bottom_delta += amount;
true
}
winit::event::VirtualKeyCode::M => {
Key::Character("m") => {
self.right_delta += amount;
true
}
Expand Down
17 changes: 7 additions & 10 deletions maplibre-winit/src/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::time::Duration;

use cgmath::Vector2;
use maplibre::context::MapContext;
use winit::event::{DeviceEvent, KeyboardInput, TouchPhase, WindowEvent};
use winit::event::{DeviceEvent, KeyEvent, TouchPhase, WindowEvent};

use crate::input::{
camera_handler::CameraHandler, debug_handler::DebugHandler, pan_handler::PanHandler,
Expand Down Expand Up @@ -72,17 +72,14 @@ impl InputController {
true
}
WindowEvent::KeyboardInput {
input:
KeyboardInput {
state,
virtual_keycode: Some(key),
..
},
event: KeyEvent {
state, logical_key, ..
},
..
} => {
self.shift_handler.process_key_press(*key, *state)
|| self.debug_handler.process_key_press(*key, *state)
|| self.zoom_handler.process_key_press(*key, *state)
self.shift_handler.process_key_press(logical_key, *state)
|| self.debug_handler.process_key_press(logical_key, *state)
|| self.zoom_handler.process_key_press(logical_key, *state)
}
WindowEvent::Touch(touch) => match touch.phase {
TouchPhase::Started => {
Expand Down
17 changes: 7 additions & 10 deletions maplibre-winit/src/input/shift_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::time::Duration;

use cgmath::{Vector2, Zero};
use maplibre::context::MapContext;
use winit::keyboard::{Key, NamedKey};

use super::UpdateState;

Expand Down Expand Up @@ -41,30 +42,26 @@ impl ShiftHandler {
} * self.sensitivity;*/
}

pub fn process_key_press(
&mut self,
key: winit::event::VirtualKeyCode,
state: winit::event::ElementState,
) -> bool {
pub fn process_key_press(&mut self, key: &Key, state: winit::event::ElementState) -> bool {
let amount = if state == winit::event::ElementState::Pressed {
10.0 * self.sensitivity // left, right is the same as panning 10px
} else {
0.0
};
match key {
winit::event::VirtualKeyCode::W | winit::event::VirtualKeyCode::Up => {
match key.as_ref() {
Key::Character("w") | Key::Named(NamedKey::ArrowUp) => {
self.camera_translate.y -= amount;
true
}
winit::event::VirtualKeyCode::S | winit::event::VirtualKeyCode::Down => {
Key::Character("s") | Key::Named(NamedKey::ArrowDown) => {
self.camera_translate.y += amount;
true
}
winit::event::VirtualKeyCode::A | winit::event::VirtualKeyCode::Left => {
Key::Character("a") | Key::Named(NamedKey::ArrowLeft) => {
self.camera_translate.x -= amount;
true
}
winit::event::VirtualKeyCode::D | winit::event::VirtualKeyCode::Right => {
Key::Character("d") | Key::Named(NamedKey::ArrowRight) => {
self.camera_translate.x += amount;
true
}
Expand Down
13 changes: 5 additions & 8 deletions maplibre-winit/src/input/zoom_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::time::Duration;

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

use super::UpdateState;

Expand Down Expand Up @@ -77,23 +78,19 @@ impl ZoomHandler {
);
}

pub fn process_key_press(
&mut self,
key: winit::event::VirtualKeyCode,
state: winit::event::ElementState,
) -> bool {
pub fn process_key_press(&mut self, key: &Key, state: winit::event::ElementState) -> bool {
let amount = if state == winit::event::ElementState::Pressed {
0.1
} else {
0.0
};

match key {
winit::event::VirtualKeyCode::Plus | winit::event::VirtualKeyCode::I => {
match key.as_ref() {
Key::Character("i") | Key::Character("+") => {
self.update_zoom(amount);
true
}
winit::event::VirtualKeyCode::Minus | winit::event::VirtualKeyCode::K => {
Key::Character("k") | Key::Character("-") => {
self.update_zoom(-amount);
true
}
Expand Down
Loading
Loading