From f5a82152394fde4d8f740f664ab7737b82861618 Mon Sep 17 00:00:00 2001 From: cashmere Date: Tue, 28 Jul 2026 19:41:16 +0200 Subject: feat: GPUI desktop port foundation - scene crate: full project/scene/element model, serde round-trip proven against the web SerializedProject shape - transfer crate: .ocp zip container, cross-compat with web fflate archives proven in both directions - storage crate: filesystem project store replacing IndexedDB, .ocp import/export - media crate: ffmpeg-next 8 decoder (frames, audio, thumbnails, waveform summaries) - playback crate: wall-clock anchored, frame-rounded playback clock - gpu crate: native texture readback; compositor renders headless offscreen on Vulkan (spike test) - flake devshell: rust toolchain, GPUI native deps, ffmpeg dev, bindgen clang args; GPUI hello-world builds - port plan in notes/gpui-port.md --- rust/crates/scene/src/animation.rs | 127 +++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 rust/crates/scene/src/animation.rs (limited to 'rust/crates/scene/src/animation.rs') diff --git a/rust/crates/scene/src/animation.rs b/rust/crates/scene/src/animation.rs new file mode 100644 index 00000000..d09dd3de --- /dev/null +++ b/rust/crates/scene/src/animation.rs @@ -0,0 +1,127 @@ +use serde::{Deserialize, Serialize}; +use std::collections::BTreeMap; +use time::MediaTime; + +use crate::params::ParamValue; + +pub const ANIMATION_PROPERTY_PATHS: &[&str] = &[ + "transform.positionX", + "transform.positionY", + "transform.scaleX", + "transform.scaleY", + "transform.rotate", + "opacity", + "volume", + "color", + "background.color", + "background.paddingX", + "background.paddingY", + "background.offsetX", + "background.offsetY", + "background.cornerRadius", +]; + +#[derive(Serialize, Deserialize, Clone, Copy, Debug, Eq, PartialEq)] +#[serde(rename_all = "camelCase")] +pub enum ScalarSegmentType { + Step, + Linear, + Bezier, +} + +#[derive(Serialize, Deserialize, Clone, Copy, Debug, Eq, PartialEq)] +#[serde(rename_all = "camelCase")] +pub enum TangentMode { + Auto, + Aligned, + Broken, + Flat, +} + +#[derive(Serialize, Deserialize, Clone, Copy, Debug, Eq, PartialEq)] +#[serde(rename_all = "camelCase")] +pub enum ChannelExtrapolationMode { + Hold, + Linear, +} + +#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq)] +pub struct CurveHandle { + pub dt: MediaTime, + pub dv: f64, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] +#[serde(rename_all = "camelCase")] +pub struct ScalarAnimationKey { + pub id: String, + pub time: MediaTime, + pub value: f64, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub left_handle: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub right_handle: Option, + pub segment_to_next: ScalarSegmentType, + pub tangent_mode: TangentMode, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] +#[serde(untagged)] +pub enum DiscreteValue { + Bool(bool), + String(String), +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] +#[serde(rename_all = "camelCase")] +pub struct DiscreteAnimationKey { + pub id: String, + pub time: MediaTime, + pub value: DiscreteValue, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] +#[serde(rename_all = "camelCase")] +pub struct ChannelExtrapolation { + pub before: ChannelExtrapolationMode, + pub after: ChannelExtrapolationMode, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] +pub struct ScalarChannel { + pub keys: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub extrapolation: Option, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] +pub struct DiscreteChannel { + pub keys: Vec, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] +#[serde(untagged)] +pub enum AnimationChannel { + Scalar(ScalarChannel), + Discrete(DiscreteChannel), +} + +pub type CompositeChannelData = BTreeMap; + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] +#[serde(untagged)] +pub enum ChannelData { + Single(AnimationChannel), + Composite(CompositeChannelData), +} + +pub type ElementAnimations = BTreeMap; + +impl From for ParamValue { + fn from(value: DiscreteValue) -> Self { + match value { + DiscreteValue::Bool(b) => ParamValue::Bool(b), + DiscreteValue::String(s) => ParamValue::String(s), + } + } +} -- cgit v1.3.1