show previews for effects
This commit is contained in:
@@ -147,6 +147,7 @@ impl SrgbToLinearConverter {
|
||||
load: wgpu::LoadOp::Clear(wgpu::Color::TRANSPARENT),
|
||||
store: wgpu::StoreOp::Store,
|
||||
},
|
||||
depth_slice: None,
|
||||
})],
|
||||
depth_stencil_attachment: None,
|
||||
occlusion_query_set: None,
|
||||
|
||||
@@ -355,6 +355,7 @@ impl Compositor {
|
||||
load: load_op,
|
||||
store: wgpu::StoreOp::Store,
|
||||
},
|
||||
depth_slice: None,
|
||||
})],
|
||||
depth_stencil_attachment: None,
|
||||
occlusion_query_set: None,
|
||||
|
||||
@@ -293,6 +293,7 @@ impl EffectProcessor {
|
||||
load: wgpu::LoadOp::Load,
|
||||
store: wgpu::StoreOp::Store,
|
||||
},
|
||||
depth_slice: None,
|
||||
})],
|
||||
depth_stencil_attachment: None,
|
||||
occlusion_query_set: None,
|
||||
|
||||
@@ -33,6 +33,8 @@ pub enum PaneType {
|
||||
PresetBrowser,
|
||||
/// Asset library for browsing clips
|
||||
AssetLibrary,
|
||||
/// WGSL shader code editor for custom effects
|
||||
ShaderEditor,
|
||||
}
|
||||
|
||||
impl PaneType {
|
||||
@@ -49,6 +51,7 @@ impl PaneType {
|
||||
PaneType::NodeEditor => "Node Editor",
|
||||
PaneType::PresetBrowser => "Preset Browser",
|
||||
PaneType::AssetLibrary => "Asset Library",
|
||||
PaneType::ShaderEditor => "Shader Editor",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +70,7 @@ impl PaneType {
|
||||
PaneType::NodeEditor => "node-editor.svg",
|
||||
PaneType::PresetBrowser => "stage.svg", // TODO: needs own icon
|
||||
PaneType::AssetLibrary => "stage.svg", // TODO: needs own icon
|
||||
PaneType::ShaderEditor => "node-editor.svg", // TODO: needs own icon
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +88,7 @@ impl PaneType {
|
||||
"nodeeditor" => Some(PaneType::NodeEditor),
|
||||
"presetbrowser" => Some(PaneType::PresetBrowser),
|
||||
"assetlibrary" => Some(PaneType::AssetLibrary),
|
||||
"shadereditor" => Some(PaneType::ShaderEditor),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -101,6 +106,7 @@ impl PaneType {
|
||||
PaneType::VirtualPiano,
|
||||
PaneType::PresetBrowser,
|
||||
PaneType::AssetLibrary,
|
||||
PaneType::ShaderEditor,
|
||||
]
|
||||
}
|
||||
|
||||
@@ -117,6 +123,7 @@ impl PaneType {
|
||||
PaneType::NodeEditor => "nodeEditor",
|
||||
PaneType::PresetBrowser => "presetBrowser",
|
||||
PaneType::AssetLibrary => "assetLibrary",
|
||||
PaneType::ShaderEditor => "shaderEditor",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@ use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use uuid::Uuid;
|
||||
use vello::kurbo::Rect;
|
||||
use vello::peniko::{Blob, Fill, Image, ImageFormat};
|
||||
use vello::peniko::{Blob, Fill, ImageAlphaType, ImageBrush, ImageData, ImageFormat};
|
||||
use vello::Scene;
|
||||
|
||||
/// Cache for decoded image data to avoid re-decoding every frame
|
||||
pub struct ImageCache {
|
||||
cache: HashMap<Uuid, Arc<Image>>,
|
||||
cache: HashMap<Uuid, Arc<ImageBrush>>,
|
||||
}
|
||||
|
||||
impl ImageCache {
|
||||
@@ -35,7 +35,7 @@ impl ImageCache {
|
||||
}
|
||||
|
||||
/// Get or decode an image, caching the result
|
||||
pub fn get_or_decode(&mut self, asset: &ImageAsset) -> Option<Arc<Image>> {
|
||||
pub fn get_or_decode(&mut self, asset: &ImageAsset) -> Option<Arc<ImageBrush>> {
|
||||
if let Some(cached) = self.cache.get(&asset.id) {
|
||||
return Some(Arc::clone(cached));
|
||||
}
|
||||
@@ -64,8 +64,8 @@ impl Default for ImageCache {
|
||||
}
|
||||
}
|
||||
|
||||
/// Decode an image asset to peniko Image
|
||||
fn decode_image_asset(asset: &ImageAsset) -> Option<Image> {
|
||||
/// Decode an image asset to peniko ImageBrush
|
||||
fn decode_image_asset(asset: &ImageAsset) -> Option<ImageBrush> {
|
||||
// Get the raw file data
|
||||
let data = asset.data.as_ref()?;
|
||||
|
||||
@@ -73,13 +73,15 @@ fn decode_image_asset(asset: &ImageAsset) -> Option<Image> {
|
||||
let img = image::load_from_memory(data).ok()?;
|
||||
let rgba = img.to_rgba8();
|
||||
|
||||
// Create peniko Image
|
||||
Some(Image::new(
|
||||
Blob::from(rgba.into_raw()),
|
||||
ImageFormat::Rgba8,
|
||||
asset.width,
|
||||
asset.height,
|
||||
))
|
||||
// Create peniko ImageData then ImageBrush
|
||||
let image_data = ImageData {
|
||||
data: Blob::from(rgba.into_raw()),
|
||||
format: ImageFormat::Rgba8,
|
||||
width: asset.width,
|
||||
height: asset.height,
|
||||
alpha_type: ImageAlphaType::Alpha,
|
||||
};
|
||||
Some(ImageBrush::new(image_data))
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@@ -720,15 +722,17 @@ fn render_video_layer(
|
||||
// Cascade opacity: layer_opacity × animated opacity
|
||||
let final_opacity = (layer_opacity * opacity) as f32;
|
||||
|
||||
// Create peniko Image from video frame data (zero-copy via Arc clone)
|
||||
// Create peniko ImageBrush from video frame data (zero-copy via Arc clone)
|
||||
// Coerce Arc<Vec<u8>> to Arc<dyn AsRef<[u8]> + Send + Sync>
|
||||
let blob_data: Arc<dyn AsRef<[u8]> + Send + Sync> = frame.rgba_data.clone();
|
||||
let image = Image::new(
|
||||
vello::peniko::Blob::new(blob_data),
|
||||
vello::peniko::ImageFormat::Rgba8,
|
||||
frame.width,
|
||||
frame.height,
|
||||
);
|
||||
let image_data = ImageData {
|
||||
data: Blob::new(blob_data),
|
||||
format: ImageFormat::Rgba8,
|
||||
width: frame.width,
|
||||
height: frame.height,
|
||||
alpha_type: ImageAlphaType::Alpha,
|
||||
};
|
||||
let image = ImageBrush::new(image_data);
|
||||
|
||||
// Apply opacity
|
||||
let image_with_alpha = image.with_alpha(final_opacity);
|
||||
|
||||
Reference in New Issue
Block a user