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/mask.rs | 128 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 rust/crates/scene/src/mask.rs (limited to 'rust/crates/scene/src/mask.rs') diff --git a/rust/crates/scene/src/mask.rs b/rust/crates/scene/src/mask.rs new file mode 100644 index 00000000..12f026d2 --- /dev/null +++ b/rust/crates/scene/src/mask.rs @@ -0,0 +1,128 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize, Clone, Copy, Debug, Eq, PartialEq)] +#[serde(rename_all = "camelCase")] +pub enum StrokeAlign { + Inside, + Center, + Outside, +} + +#[derive(Serialize, Deserialize, Clone, Copy, Debug, Eq, PartialEq)] +pub enum TextFontWeight { + #[serde(rename = "normal")] + Normal, + #[serde(rename = "bold")] + Bold, +} + +#[derive(Serialize, Deserialize, Clone, Copy, Debug, Eq, PartialEq)] +pub enum TextFontStyle { + #[serde(rename = "normal")] + Normal, + #[serde(rename = "italic")] + Italic, +} + +#[derive(Serialize, Deserialize, Clone, Copy, Debug, Eq, PartialEq)] +pub enum TextDecoration { + #[serde(rename = "none")] + None, + #[serde(rename = "underline")] + Underline, + #[serde(rename = "line-through")] + LineThrough, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] +#[serde(rename_all = "camelCase")] +pub struct FreeformPathPoint { + pub id: String, + pub x: f64, + pub y: f64, + pub in_x: f64, + pub in_y: f64, + pub out_x: f64, + pub out_y: f64, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] +#[serde(rename_all = "camelCase")] +pub struct SplitMaskParams { + pub feather: f64, + pub inverted: bool, + pub stroke_color: String, + pub stroke_width: f64, + pub stroke_align: StrokeAlign, + pub center_x: f64, + pub center_y: f64, + pub rotation: f64, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] +#[serde(rename_all = "camelCase")] +pub struct RectangleMaskParams { + pub feather: f64, + pub inverted: bool, + pub stroke_color: String, + pub stroke_width: f64, + pub stroke_align: StrokeAlign, + pub center_x: f64, + pub center_y: f64, + pub width: f64, + pub height: f64, + pub rotation: f64, + pub scale: f64, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] +#[serde(rename_all = "camelCase")] +pub struct TextMaskParams { + pub feather: f64, + pub inverted: bool, + pub stroke_color: String, + pub stroke_width: f64, + pub stroke_align: StrokeAlign, + pub content: String, + pub font_size: f64, + pub font_family: String, + pub font_weight: TextFontWeight, + pub font_style: TextFontStyle, + pub text_decoration: TextDecoration, + pub letter_spacing: f64, + pub line_height: f64, + pub center_x: f64, + pub center_y: f64, + pub rotation: f64, + pub scale: f64, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] +#[serde(rename_all = "camelCase")] +pub struct FreeformPathMaskParams { + pub feather: f64, + pub inverted: bool, + pub stroke_color: String, + pub stroke_width: f64, + pub stroke_align: StrokeAlign, + pub path: Vec, + pub closed: bool, + pub center_x: f64, + pub center_y: f64, + pub rotation: f64, + pub scale: f64, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] +#[serde(tag = "type", rename_all = "kebab-case")] +pub enum Mask { + Split { id: String, params: SplitMaskParams }, + CinematicBars { id: String, params: RectangleMaskParams }, + Rectangle { id: String, params: RectangleMaskParams }, + Ellipse { id: String, params: RectangleMaskParams }, + Heart { id: String, params: RectangleMaskParams }, + Diamond { id: String, params: RectangleMaskParams }, + Star { id: String, params: RectangleMaskParams }, + Text { id: String, params: TextMaskParams }, + Freeform { id: String, params: FreeformPathMaskParams }, +} -- cgit v1.3.1