Skip to main content

ssplayer_wgpu/
lib.rs

1//! `ssplayer-wgpu` — a wgpu-based player for SpriteStudio animations.
2//!
3//! The player borrows the host's wgpu device, queue and render target rather
4//! than owning them, so it draws into any wgpu host — a standalone viewer, a
5//! browser canvas, or an engine like Bevy.
6//!
7//! Three types, split by how long their resources stay useful:
8//!
9//! * [`SSRenderer`] — one per **device**: pipelines, bind group layouts, the
10//!   sampler and the atlas textures. The host owns it and lends it.
11//! * [`SSScene`] — one per **render target**: the projection and the frame's
12//!   geometry.
13//! * [`SSPlayer`] — one per character: the playback tree. Holds no GPU resource.
14
15/// The filesystem behind [`SSPlayer::load`]. Needs the `embedded` feature (for
16/// the decoder) and a target that has a filesystem.
17#[cfg(all(feature = "embedded", not(target_arch = "wasm32")))]
18mod assets;
19/// Bulk atlas decoding for the loading path. Needs the `embedded` feature, which
20/// is what carries the decoder.
21#[cfg(feature = "embedded")]
22mod decode;
23mod events;
24// The three public modules carry their docs inside (`//!`), so the notes here are
25// plain comments: an outer `///` would print above them on the module's page, and
26// would make rustdoc resolve every link in the module's own docs from this file.
27//
28// The C-ABI face (`ffi` feature): a thin translation layer whose `ss_player_*`
29// entry points are exported from the cdylib/staticlib and described by the
30// generated `ssplayer_wgpu.h`. The work it delegates to lives in `host`.
31#[cfg(feature = "ffi")]
32pub mod ffi;
33// `fit` / `align` — placing an animation inside a box the host laid out. Pure
34// arithmetic, so every face inherits it.
35pub mod fit;
36mod frame;
37// A window-owning wgpu host (`ffi` feature), used by `ffi` and available to
38// Rust callers that have a raw window handle rather than a winit `Window`.
39#[cfg(feature = "ffi")]
40pub mod host;
41mod mask;
42mod metrics;
43mod pack;
44mod player;
45mod renderer;
46/// Generation-tagged slot storage for the handle-based hosts.
47#[cfg(any(feature = "ffi", feature = "web"))]
48mod roster;
49mod scene;
50// The swapchain the two faces that own their surface share.
51#[cfg(any(feature = "ffi", feature = "web"))]
52mod surface;
53#[cfg(feature = "web")]
54mod web;
55
56pub use events::{AudioEvent, SignalEvent, SignalParam, SignalValue, SsEvent, UserDataEvent};
57pub use fit::{Align, Fit, Placed, Placement, Rect};
58pub use frame::FrameView;
59pub use mask::{GeomKind, MaskOp, MaskWriter, MaskWriters, PartMaskFlags, ScopedWriter, StencilTest, plan_writers};
60pub use metrics::SceneStats;
61pub use pack::{EmbeddedImage, EmbeddedTexture, SSPack, TextureRef};
62pub use player::{AssetLoader, AtlasKeys, BlendOp, CrowdMember, MAX_CROWD_MEMBERS, MissingAsset, MissingKind, OverridePriority, PlaybackDirection, PlaybackStyle, SSPlayer};
63pub use renderer::{AlphaMode, Retention, SSRenderer};
64pub use scene::{BatchInfo, FrameChunk, IDENTITY_TRANSFORM, MaskBackend, NodeSlot, SSScene, SceneConfig};
65/// Re-exported from the runtime: how a track folds onto the tracks below it.
66pub use ssruntime::TrackBlend;
67/// Re-exported from the runtime: where the animations laid on a track start.
68pub use ssruntime::TrackSync;
69pub use ssruntime::error::SSRuntimeError;
70#[cfg(feature = "web")]
71pub use web::{SsContextWeb, SsPlayerWeb, SsSurfaceWeb};
72
73/// This player's version, `ssplayer-wgpu`'s own.
74pub const VERSION: &str = env!("CARGO_PKG_VERSION");
75
76/// The SpriteStudio-SDK version whose runtime this build links, written as
77/// its release tag (`v7.0.0`). `scripts/build.sh` names it from the
78/// submodule's version; a plain `cargo build` says `local`.
79pub const SDK_VERSION: &str = env!("SSPLAYER_SDK_VERSION");