summaryrefslogtreecommitdiff
path: root/rust/crates/compositor/src/frame.rs
diff options
context:
space:
mode:
authorMaze Winther <mazewinther@gmail.com>2026-04-13 04:40:29 +0200
committerMaze Winther <mazewinther@gmail.com>2026-04-13 05:01:51 +0200
commit8230faf082c405c9fd0fa640f4ce2284315782ae (patch)
treee00bf694a83b4d14d6d56942ba89ba92402d854e /rust/crates/compositor/src/frame.rs
parentdbd68ff1396bf498eb97f095810b78d2bddd0011 (diff)
downloadopencut-8230faf082c405c9fd0fa640f4ce2284315782ae.tar.gz
feat: wasm compositor
Made-with: Cursor
Diffstat (limited to 'rust/crates/compositor/src/frame.rs')
-rw-r--r--rust/crates/compositor/src/frame.rs83
1 files changed, 83 insertions, 0 deletions
diff --git a/rust/crates/compositor/src/frame.rs b/rust/crates/compositor/src/frame.rs
new file mode 100644
index 00000000..871a9759
--- /dev/null
+++ b/rust/crates/compositor/src/frame.rs
@@ -0,0 +1,83 @@
+use std::collections::HashMap;
+
+use serde::{Deserialize, Serialize};
+
+use crate::BlendMode;
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct FrameDescriptor {
+ pub width: u32,
+ pub height: u32,
+ pub clear: CanvasClearDescriptor,
+ pub items: Vec<FrameItemDescriptor>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct CanvasClearDescriptor {
+ pub color: [f32; 4],
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(tag = "type", rename_all = "camelCase")]
+pub enum FrameItemDescriptor {
+ Layer(LayerDescriptor),
+ SceneEffect {
+ effect_pass_groups: Vec<Vec<EffectPassDescriptor>>,
+ },
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct LayerDescriptor {
+ pub texture_id: String,
+ pub transform: QuadTransformDescriptor,
+ pub opacity: f32,
+ pub blend_mode: BlendMode,
+ #[serde(default)]
+ pub effect_pass_groups: Vec<Vec<EffectPassDescriptor>>,
+ pub mask: Option<LayerMaskDescriptor>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct QuadTransformDescriptor {
+ pub center_x: f32,
+ pub center_y: f32,
+ pub width: f32,
+ pub height: f32,
+ pub rotation_degrees: f32,
+ pub flip_x: bool,
+ pub flip_y: bool,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct LayerMaskDescriptor {
+ pub texture_id: String,
+ pub feather: f32,
+ pub inverted: bool,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct EffectPassDescriptor {
+ pub shader: String,
+ pub uniforms: HashMap<String, EffectUniformValueDescriptor>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(untagged)]
+pub enum EffectUniformValueDescriptor {
+ Number(f32),
+ Vector(Vec<f32>),
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct CanvasTextureDescriptor {
+ pub id: String,
+ pub width: u32,
+ pub height: u32,
+}