Skip to content

Commit

Permalink
Add support for iOS/tvOS/watchOS/visionOS (#234)
Browse files Browse the repository at this point in the history
Add support for iOS / UIKit, and clean up CoreGraphics impl
  • Loading branch information
madsmtm authored Sep 4, 2024
1 parent 1d7a48c commit dc4ae44
Show file tree
Hide file tree
Showing 8 changed files with 264 additions and 79 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- { target: x86_64-unknown-redox, os: ubuntu-latest, }
- { target: x86_64-unknown-freebsd, os: ubuntu-latest, }
- { target: x86_64-unknown-netbsd, os: ubuntu-latest, options: --no-default-features, features: "x11,x11-dlopen,wayland,wayland-dlopen" }
- { target: x86_64-apple-darwin, os: macos-latest, }
- { target: aarch64-apple-darwin, os: macos-latest, }
- { target: wasm32-unknown-unknown, os: ubuntu-latest, }
exclude:
# Orbital doesn't follow MSRV
Expand All @@ -56,6 +56,9 @@ jobs:
include:
- rust_version: nightly
platform: { target: wasm32-unknown-unknown, os: ubuntu-latest, options: "-Zbuild-std=panic_abort,std", rustflags: "-Ctarget-feature=+atomics,+bulk-memory" }
# Mac Catalyst is only Tier 2 since Rust 1.81
- rust_version: 'nightly'
platform: { target: aarch64-apple-ios-macabi, os: macos-latest }

env:
RUST_BACKTRACE: 1
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Unreleased

- Added support for iOS, tvOS, watchOS and visionOS (UIKit).
- Redo the way surfaces work on macOS to work directly with layers, which will allow initializing directly from a `CALayer` in the future.

# 0.4.5

- Make the `wayland-sys` dependency optional. (#223)
Expand Down
16 changes: 11 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,20 @@ x11rb = { version = "0.13.0", features = ["allow-unsafe-code", "shm"], optional
version = "0.59.0"
features = ["Win32_Graphics_Gdi", "Win32_UI_Shell", "Win32_UI_WindowsAndMessaging", "Win32_Foundation"]

[target.'cfg(target_os = "macos")'.dependencies]
[target.'cfg(target_vendor = "apple")'.dependencies]
bytemuck = { version = "1.12.3", features = ["extern_crate_alloc"] }
core-graphics = "0.24.0"
foreign-types = "0.5.0"
objc2 = "0.5.1"
objc2-foundation = { version = "0.2.0", features = ["dispatch", "NSThread"] }
objc2-app-kit = { version = "0.2.0", features = ["NSResponder", "NSView", "NSWindow"] }
objc2-quartz-core = { version = "0.2.0", features = ["CALayer", "CATransaction"] }
objc2 = "0.5.2"
objc2-foundation = { version = "0.2.2", features = [
"NSDictionary",
"NSGeometry",
"NSKeyValueObserving",
"NSString",
"NSThread",
"NSValue",
] }
objc2-quartz-core = { version = "0.2.2", features = ["CALayer", "CATransaction"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
js-sys = "0.3.63"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ For now, the priority for new platforms is:
|Android NDK||
| AppKit ||
| Orbital ||
| UIKit ||
| UIKit ||
| Wayland ||
| Web ||
| Win32 ||
Expand Down
4 changes: 2 additions & 2 deletions src/backend_dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ make_dispatch! {
Kms(Arc<backends::kms::KmsDisplayImpl<D>>, backends::kms::KmsImpl<D, W>, backends::kms::BufferImpl<'a, D, W>),
#[cfg(target_os = "windows")]
Win32(D, backends::win32::Win32Impl<D, W>, backends::win32::BufferImpl<'a, D, W>),
#[cfg(target_os = "macos")]
CG(D, backends::cg::CGImpl<D, W>, backends::cg::BufferImpl<'a, D, W>),
#[cfg(target_vendor = "apple")]
CoreGraphics(D, backends::cg::CGImpl<D, W>, backends::cg::BufferImpl<'a, D, W>),
#[cfg(target_arch = "wasm32")]
Web(backends::web::WebDisplayImpl<D>, backends::web::WebImpl<D, W>, backends::web::BufferImpl<'a, D, W>),
#[cfg(target_os = "redox")]
Expand Down
Loading

0 comments on commit dc4ae44

Please sign in to comment.