Skip to content

Commit 12e60f7

Browse files
openscreen-botsepion02
authored andcommitted
feat(compositor): scaffold macOS Metal+VideoToolbox port
Branch off the CPU-backend seam established by PR #162 and split the compositor crate into per-platform directories. Windows behaviour is byte-identical (81 tests pass) and the macOS stubs that follow this commit in the stack expose the same public surface (Backend, Gpu, Compositor, Decoder, VideoEncoder, ExportCodec, ClipSource, LiveParams, LayerCB...) and Err from every operation. Renames + cfg dispatch: - crates/compositor/src/d3d_windows.rs (from d3d.rs) - crates/compositor/src/cpu_frames_windows.rs (from cpu_frames.rs) - crates/compositor/src/compositor_windows.rs (from compositor.rs) - crates/compositor/src/pipeline_windows.rs (from pipeline.rs) - crates/compositor/src/text_windows.rs (from text.rs) - crates/compositor/wrapper_windows.h (from wrapper.h) lib.rs cfg-dispatches 'd3d', 'cpu_frames', 'compositor', 'text' across the per-platform modules so call-sites stay portable. live.rs: Win32 harness (run_standalone, host_proc, wide, client_size) moved into a #[cfg(windows)] pub mod standalone_harness with a dev-only on Windows). Cargo.toml: macOS deps (metal, objc, block, core-foundation) added under [target.cfg(target_os = macos).dependencies]; windows dep gated to cfg(windows). compositor-view-napi mirrors the gate. crates/.cargo/config.toml: target-specific env block for macOS (LIBCLANG_PATH not needed, MAC_FFMPEG_DIR falls back via build.rs). build.rs: selects wrapper_windows.h vs wrapper_macos.h on CARGO_CFG_TARGET_OS, sets bindgen --target=aarch64-apple-darwin + -isysroot on macOS, finds MAC_FFMPEG_DIR or vendored thirdparty/ffmpeg-n8.1.2-macos64-lgpl-shared. Stacked on feat/d3d-warp-fallback (PR #162).
1 parent d0a091a commit 12e60f7

14 files changed

Lines changed: 415 additions & 47 deletions

File tree

.github/workflows/ci.yml

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,60 @@ jobs:
8989
- uses: ./.github/actions/setup
9090
- run: npm run test
9191

92-
build:
92+
build:
9393
name: Build
9494
runs-on: ubuntu-latest
9595
steps:
9696
- uses: actions/checkout@v4
9797
- uses: ./.github/actions/setup
9898
- run: npx vite build
9999

100+
# PR #189 — port macOS du compositor (Metal + VideoToolbox).
101+
#
102+
# Compile check on a `macos-14` runner (Apple Silicon). Verifies that the
103+
# scaffold + engine-layer code added by #189 actually compiles for
104+
# `aarch64-apple-darwin` — bindgen + cc on macOS produce the ffmpeg FFI
105+
# bindings + the VideoToolbox context that the Rust crate statically
106+
# references, and the `metal`/`objc`/`block`/`core-foundation` crates need
107+
# their macOS system frameworks (Metal/CoreVideo/CoreMedia) linked.
108+
#
109+
# ffmpeg via Homebrew: this job installs `ffmpeg` from homebrew-core on the
110+
# runner to satisfy bindgen + the cargo:rustc-link-lib lines for avformat/
111+
# avcodec/avutil/swscale/swresample. NB: homebrew's `ffmpeg` is GPL-3.0 (it
112+
# bundles x264/x265/svt-av1 etc.) — that is fine for a CI compile-check, but
113+
# the dev/runtime story is different: `scripts/fetch-ffmpeg.mjs` documents
114+
# that BtbN publishes no macOS build, so a pinned LGPL macOS dylib has to
115+
# land separately before we can ship. The vendored `electron/native/bin/
116+
# darwin-*/` directory is the runtime pin and is empty today.
117+
#
118+
# Why this job runs at all today: every commit on #189 that touches
119+
# compositor_macos.rs / pipeline_macos.rs / mac_frames.rs / shaders.metal /
120+
# d3d_macos.rs / text_macos.rs is unverifiable from Windows (cross-compile
121+
# requires the macOS SDK + headers, which we don't have). This job is the
122+
# only signal that the macOS-side Rust still type-checks.
123+
rust-macos-compositor-check:
124+
name: Rust check (macOS compositor)
125+
runs-on: macos-14
126+
steps:
127+
- uses: actions/checkout@v4
128+
- name: Install Rust toolchain
129+
run: |
130+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --target aarch64-apple-darwin
131+
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
132+
- name: Install ffmpeg (homebrew-core) and verify headers/libs
133+
run: |
134+
brew update
135+
brew install ffmpeg
136+
ls /opt/homebrew/opt/ffmpeg/include | head -5
137+
ls /opt/homebrew/opt/ffmpeg/lib | head -5
138+
/opt/homebrew/opt/ffmpeg/bin/ffmpeg -hide_banner -version | head -1
139+
- name: cargo check (compositor + napi addon, aarch64-apple-darwin)
140+
env:
141+
MAC_FFMPEG_DIR: /opt/homebrew/opt/ffmpeg
142+
run: |
143+
cd crates
144+
cargo check --target aarch64-apple-darwin -p openscreen-compositor -p compositor-view-napi
145+
100146
semantic-pr:
101147
name: Validate PR title (semantic)
102148
runs-on: ubuntu-latest

crates/.cargo/config.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,10 @@
1111
[env]
1212
FFMPEG_DIR = { value = "thirdparty/ffmpeg-n8.1.2-win64-lgpl-shared", relative = true }
1313
LIBCLANG_PATH = "C:\\Program Files\\LLVM\\bin"
14+
15+
# macOS : BtbN ne publie pas de build macOS (cf. scripts/fetch-ffmpeg.mjs), donc on
16+
# laisse `crates/compositor/build.rs` chercher MAC_FFMPEG_DIR (env var explicite posée
17+
# par la CI macOS ou par le dev local) ou un répertoire attendu sous `thirdparty/`.
18+
# LIBCLANG_PATH est inutile sur macOS (clang est dans CommandLineTools), on ne le
19+
# pose donc pas.
20+
[target.'cfg(target_os = "macos")'.env]

crates/Cargo.lock

Lines changed: 131 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/compositor-view-napi/Cargo.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "compositor-view-napi"
33
version.workspace = true
44
edition.workspace = true
5-
description = "Addon napi-rs : expose openscreen_compositor::live::LiveView (fenêtre D3D enfant) à Electron. C'est CE crate qui produit compositor_view.node, le binaire packagé dans l'app."
5+
description = "Addon napi-rs : expose openscreen_compositor::live::LiveView (vue offscreen multiplateforme) à Electron. C'est CE crate qui produit compositor_view.node, le binaire packagé dans l'app."
66

77
[lib]
88
crate-type = ["cdylib"]
@@ -14,9 +14,13 @@ napi-derive = "2"
1414
openscreen-compositor.workspace = true
1515
anyhow.workspace = true
1616

17-
[dependencies.windows]
17+
# Le crate n'utilise pas directement l'API Windows — c'est transitif via le
18+
# moteur de composition (qui expose la même surface publique cross-platform via
19+
# la ré-export cfg dans `openscreen_compositor::lib`). On garde la dépendance
20+
# cfg-conditionnelle pour que le crate compile sur macOS.
21+
[target.'cfg(windows)'.dependencies.windows]
1822
version = "0.58"
1923
features = ["Win32_Foundation"]
2024

2125
[build-dependencies]
22-
napi-build = "2"
26+
napi-build = "2"

0 commit comments

Comments
 (0)