Implement Graphene base graph UI

This commit is contained in:
Timon committed 2026-12-06 17:57:47 +00:00
1 parent 13bb1687b9
commit df1434ddff
50 files changed
+1858 -4480

No files matched your search

@@ -11,7 +11,7 @@ async fn compile_and_run(editor: &mut EditorTestUtils) {
let (executor, documents) = (&mut portfolio.executor, &mut portfolio.documents);
let document = documents.get_mut(&document_id).unwrap();
executor
.submit_node_graph_evaluation(document, document_id, UVec2::ONE, 1., TimingInformation::default(), Vec::new(), true, DVec2::ZERO)
.submit_node_graph_evaluation(document, document_id, UVec2::ONE, 1., TimingInformation::default(), Vec::new(), true, DVec2::ZERO, None)
.unwrap();
editor.runtime.update();
editor.runtime.run().await;
+126 -40
View File
@@ -8,6 +8,7 @@ use graph_craft::document::value::{RenderOutput, RenderOutputType, TaggedValue};
use graph_craft::document::{NodeId, NodeNetwork};
use graph_craft::graphene_compiler::{CompileError, CompiledNetwork, Compiler};
use graph_craft::proto::GraphErrors;
use graph_ui::scene::{GraphUiScene, GraphUiSceneDelta};
use graphene_hash::CacheHash;
use graphene_std::application_io::{ApplicationIo, ExportFormat, Texture};
use graphene_std::ops::ConvertAsync;
@@ -18,7 +19,7 @@ use graphene_std::runtime::AsyncRuntime;
use graphene_std::vector::style::RenderMode;
use graphene_std::{Context, NodeError, Poll};
use interpreted_executor::dynamic_executor::{DynamicExecutor, OutputHandle};
use interpreted_executor::util::wrap_network_with_render_node_in_scope;
use interpreted_executor::util::{wrap_network_in_scope, wrap_network_with_render_node_in_scope};
use observer::Observer;
pub use observer::{InspectResult, InspectedContext, Observation, ObservedConnector, ObservedValue};
use std::sync::Arc;
@@ -71,7 +72,6 @@ pub struct NodeRuntime {
thumbnails: Thumbnails,
observer: Observer<ObservationKey>,
/// Whether an observation changed since its results were last sent.
observations_changed: bool,
preprocessor: preprocessor::Preprocessor,
@@ -87,6 +87,12 @@ pub struct NodeRuntime {
/// The latest rendered overlays.
overlays_texture: Option<Texture>,
graph_ui_scene: GraphUiScene,
graph_ui_output: OutputHandle,
graph_ui_network_hash: Option<u64>,
graph_ui_texture: Option<Texture>,
graph_ui_redrawn: bool,
/// Cached surface for Wasm viewport rendering (reused across frames)
#[cfg(all(target_family = "wasm", feature = "wasm"))]
wasm_canvas_cache: CanvasSurfaceHandle,
@@ -113,6 +119,7 @@ pub enum GraphRuntimeRequest {
},
ThumbnailsInView {
layers: HashSet<NodeId>,
layers_panel: HashSet<NodeId>,
document_id: DocumentId,
},
RenderOverlays(OverlayContext),
@@ -120,6 +127,7 @@ pub enum GraphRuntimeRequest {
key: ObservationKey,
observation: Option<Observation>,
},
GraphUi(GraphUiSceneDelta),
}
#[derive(Debug)]
@@ -192,6 +200,12 @@ impl NodeRuntime {
overlays_canvas: VelloCanvas::default(),
overlays_texture: None,
graph_ui_scene: GraphUiScene::default(),
graph_ui_output: OutputHandle::default(),
graph_ui_network_hash: None,
graph_ui_texture: None,
graph_ui_redrawn: false,
#[cfg(all(target_family = "wasm", feature = "wasm"))]
wasm_canvas_cache: CanvasSurfaceHandle::new(),
}
@@ -254,8 +268,8 @@ impl NodeRuntime {
None => self.send_export(id, ExecutionResult::Uncompiled),
}
}
GraphRuntimeRequest::ThumbnailsInView { layers, document_id } => {
self.thumbnails.set_in_view(layers);
GraphRuntimeRequest::ThumbnailsInView { layers, layers_panel, document_id } => {
self.thumbnails.set_in_view(layers, layers_panel);
self.pending_thumbnails = Some(document_id);
}
GraphRuntimeRequest::Observe { key, observation } => {
@@ -266,13 +280,13 @@ impl NodeRuntime {
self.overlays = Some(context);
self.overlays_stale = true;
}
GraphRuntimeRequest::GraphUi(delta) => self.graph_ui_scene.apply(delta),
}
}
}
pub async fn run(&mut self) -> Option<Texture> {
let dirty = self.dirty.swap(false, Ordering::Acquire);
let mut texture = None;
if dirty {
for (id, render_config, output) in std::mem::take(&mut self.exports) {
@@ -287,7 +301,10 @@ impl NodeRuntime {
&& self.output.is_some()
{
let mut responses = VecDeque::new();
self.thumbnails.render_stale(&self.executor, &self.editor_api, &mut responses).await;
let rendered = self.thumbnails.render_stale(&self.executor, &self.editor_api, &mut responses).await;
if rendered && let Some(request) = self.pending.filter(|request| request.graph_ui_config.is_some()) {
self.draw_graph_ui(request);
}
if !responses.is_empty() {
self.sender.send(NodeGraphUpdate::Thumbnails { responses, document_id }).expect("Failed to send response");
}
@@ -306,10 +323,7 @@ impl NodeRuntime {
self.run_viewport(viewport).await;
}
// Overlays that changed without new artwork are drawn over the artwork already shown
if self.overlays_stale {
texture = self.composite_viewport_frame();
}
let texture = self.composite_viewport_frame();
(self.editor_wake)();
texture
@@ -340,11 +354,65 @@ impl NodeRuntime {
}
self.respond(request, result, observations).await;
self.draw_graph_ui(request);
}
fn draw_graph_ui(&mut self, request: ExecutionRequest) {
self.graph_ui_redrawn = true;
let Some(mut config) = request.graph_ui_config else {
self.graph_ui_texture = None;
self.graph_ui_network_hash = None;
self.graph_ui_output = OutputHandle::default();
return;
};
if !matches!(self.viewport_artwork, Some(ViewportArtwork::Texture(_))) {
config.fade_artwork = 1.;
}
let scene = self.graph_ui_scene.clone();
let thumbnails = self.thumbnails.graphics();
let graph_ui_network = graph_ui::network(&scene, &config, &thumbnails);
let hash = graph_ui_network.current_hash();
if self.graph_ui_network_hash != Some(hash) {
let mut graph_ui_network = wrap_network_in_scope(graph_ui_network, self.editor_api.clone(), self.async_runtime().handle());
self.preprocessor.preprocess(&mut graph_ui_network, &|_| None).expect("The network of the node graph preprocesses");
let graph_ui_network = Compiler {}.compile_single(graph_ui_network).expect("The network of the node graph compiles").network;
let replaced = std::mem::take(&mut self.graph_ui_output);
self.graph_ui_output = self.executor.replace(replaced, graph_ui_network).expect("The network of the node graph is typed");
self.graph_ui_network_hash = Some(hash);
self.async_runtime().update_sources(self.executor.sources());
}
let context = graph_ui::render_config(config.view, request.render_config).into_context();
self.graph_ui_texture = match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| self.executor.execute(&self.graph_ui_output, context))) {
Ok(Ok(Poll::Final(TaggedValue::RenderOutput(RenderOutput {
data: RenderOutputType::Texture(frame),
..
})))) => Some(frame),
Ok(Ok(Poll::Error(error))) => {
log::error!("Failed to draw the node graph: {}", error.error());
None
}
Ok(Ok(_)) => None,
Ok(Err(error)) => {
log::error!("Failed to draw the node graph: {error}");
None
}
Err(payload) => {
let message = payload.downcast_ref::<&str>().copied().or_else(|| payload.downcast_ref::<String>().map(String::as_str));
log::error!("Panicked while drawing the node graph: {}", message.unwrap_or("no message"));
None
}
};
}
/// Draws the latest overlays over the viewport's artwork, or alone above SVG artwork, presenting the frame on web.
fn composite_viewport_frame(&mut self) -> Option<Texture> {
let artwork = self.viewport_artwork.as_ref()?;
if !std::mem::take(&mut self.graph_ui_redrawn) && !self.overlays_stale {
return None;
}
if self.viewport_artwork.is_none() && self.graph_ui_texture.is_none() {
return None;
}
let executor = self.editor_api.application_io.as_ref().and_then(|application_io| application_io.gpu_executor())?;
if std::mem::take(&mut self.overlays_stale)
@@ -356,24 +424,34 @@ impl NodeRuntime {
.ok();
}
let frame = match (artwork, &self.overlays_texture) {
(ViewportArtwork::Texture(artwork), Some(overlays)) => {
let (width, height) = (artwork.width(), artwork.height());
let artwork = match &self.viewport_artwork {
Some(ViewportArtwork::Texture(artwork)) => Some(artwork),
Some(ViewportArtwork::Svg) | None => None,
};
let overlays = self.overlays_texture.as_ref().filter(|_| self.graph_ui_texture.is_none());
let frame = match (artwork, &self.graph_ui_texture, overlays) {
(None, None, None) => return None,
(Some(frame), None, None) | (None, Some(frame), None) | (None, None, Some(frame)) => frame.clone(),
(artwork, graph_ui, overlays) => {
// The node graph is drawn at the viewport's size, which artwork from before a resize doesn't have
let base = graph_ui.as_ref().or(artwork).or(overlays)?;
let (width, height) = (base.width(), base.height());
let max_texture_size = executor.context().device.limits().max_texture_dimension_2d;
let overlays_to_artwork = kurbo::Affine::scale_non_uniform(width as f64 / overlays.width() as f64, height as f64 / overlays.height() as f64);
let mut scene = VelloSceneBuilder::new(width as u16, height as u16, kurbo::Affine::IDENTITY, max_texture_size);
scene.draw_texture(artwork.clone(), ImageSampler::new(), kurbo::Affine::IDENTITY);
scene.draw_texture(overlays.clone(), ImageSampler::new(), overlays_to_artwork);
for layer in [artwork, graph_ui.as_ref()].into_iter().flatten() {
scene.draw_texture(layer.clone(), ImageSampler::new(), kurbo::Affine::IDENTITY);
}
if let Some(overlays) = overlays {
let overlays_to_frame = kurbo::Affine::scale_non_uniform(width as f64 / overlays.width() as f64, height as f64 / overlays.height() as f64);
scene.draw_texture(overlays.clone(), ImageSampler::new(), overlays_to_frame);
}
executor
.render_vello_scene_on_canvas(&mut self.overlays_canvas, scene)
.inspect_err(|error| log::error!("Failed to draw the overlays over the artwork: {error:?}"))
.unwrap_or_else(|_| artwork.clone())
.inspect_err(|error| log::error!("Failed to draw the viewport's frame: {error:?}"))
.unwrap_or_else(|_| base.clone())
}
(ViewportArtwork::Texture(artwork), None) => artwork.clone(),
(ViewportArtwork::Svg, Some(overlays)) => overlays.clone(),
(ViewportArtwork::Svg, None) => return None,
};
#[cfg(all(target_family = "wasm", feature = "wasm"))]
@@ -418,10 +496,14 @@ impl NodeRuntime {
}
fn evaluate(&mut self, output: &OutputHandle, request: ExecutionRequest) -> Option<ExecutionResult> {
let ExecutionRequest { execution_id, mut render_config } = request;
let ExecutionRequest {
execution_id,
mut render_config,
graph_ui_config,
} = request;
// Render via the SVG pipeline even though raster was requested if SVG Preview render mode is active
if render_config.export_format == ExportFormat::Raster && render_config.render_mode == RenderMode::SvgPreview {
// Render via the SVG pipeline even though raster was requested if SVG Preview render mode is active and the graph, isn't open
if render_config.export_format == ExportFormat::Raster && render_config.render_mode == RenderMode::SvgPreview && graph_ui_config.is_none() {
render_config.export_format = ExportFormat::Svg;
}
@@ -483,7 +565,7 @@ impl NodeRuntime {
RenderOutputType::Svg { .. } => request.render_config.export_format == ExportFormat::Raster,
RenderOutputType::Buffer { .. } => false,
},
None => false,
None => request.graph_ui_config.is_some(),
})
.then(|| ViewportCanvasInfo {
id: self.wasm_canvas_cache.id(),
@@ -502,14 +584,6 @@ impl NodeRuntime {
self.sender.send(NodeGraphUpdate::ExecutionResponse(Box::new(response))).expect("Failed to send response");
}
/// Reads one observation from the last evaluation, apart from the observations the runtime keeps.
#[cfg(test)]
pub(crate) fn observe(&self, observation: Observation) -> Option<ObservedValue> {
let mut observer = Observer::default();
observer.set((), Some(observation));
observer.evaluate(&self.executor, self.old_graph.as_ref()).remove(&())?.data
}
async fn read_back(&self, texture: Texture) -> Raster<CPU> {
let application_io = self.editor_api.application_io.as_ref().unwrap();
let executor = application_io.gpu_executor().expect("GPU executor should be available when we receive a texture");
@@ -581,6 +655,14 @@ impl NodeRuntime {
dropped_thumbnails
}
/// Reads one observation from the last evaluation, apart from the observations the runtime keeps.
#[cfg(test)]
pub(crate) fn observe(&self, observation: Observation) -> Option<ObservedValue> {
let mut observer = Observer::default();
observer.set((), Some(observation));
observer.evaluate(&self.executor, self.old_graph.as_ref()).remove(&())?.data
}
}
impl ExecutionResult {
@@ -677,12 +759,16 @@ mod tests {
/// Sends a network update and a request to evaluate it at a viewport of `resolution` pixels.
fn send_update_at(editor: &mut EditorTestUtils, resolution: UVec2) {
send_update_with_graph_ui(editor, resolution, None);
}
fn send_update_with_graph_ui(editor: &mut EditorTestUtils, resolution: UVec2, graph_ui_config: Option<GraphUiConfig>) {
let portfolio = editor.portfolio_message_handler_mut();
let document_id = portfolio.active_document_id.unwrap();
let (executor, documents) = (&mut portfolio.executor, &mut portfolio.documents);
let document = documents.get_mut(&document_id).unwrap();
executor
.submit_node_graph_evaluation(document, document_id, resolution, 1., Default::default(), Vec::new(), true, DVec2::ZERO)
.submit_node_graph_evaluation(document, document_id, resolution, 1., Default::default(), Vec::new(), true, DVec2::ZERO, graph_ui_config)
.unwrap();
}
@@ -763,7 +849,7 @@ mod tests {
let document = portfolio.documents.get_mut(&document_id).unwrap();
portfolio
.executor
.submit_current_node_graph_evaluation(document, document_id, UVec2::ONE, 1., Default::default(), DVec2::ZERO)
.submit_current_node_graph_evaluation(document, document_id, UVec2::ONE, 1., Default::default(), DVec2::ZERO, None)
.unwrap();
}
@@ -774,7 +860,7 @@ mod tests {
/// The ID of the viewport request the runtime evaluates, which only changes once it has read a newer one.
fn last_request(editor: &EditorTestUtils) -> Option<u64> {
editor.runtime.pending.map(|request| request.execution_id)
editor.runtime.pending.as_ref().map(|request| request.execution_id)
}
fn respond_to_last_request(editor: &mut EditorTestUtils, result: ExecutionResult) -> Vec<FrontendMessage> {
@@ -831,7 +917,7 @@ mod tests {
let (executor, documents) = (&mut portfolio.executor, &mut portfolio.documents);
let document = documents.get_mut(&document_id).unwrap();
let message = executor
.submit_current_node_graph_evaluation(document, document_id, UVec2::ONE, scale, Default::default(), DVec2::ZERO)
.submit_current_node_graph_evaluation(document, document_id, UVec2::ONE, scale, Default::default(), DVec2::ZERO, None)
.unwrap();
editor.dispatch(message);
}
@@ -911,7 +997,7 @@ mod tests {
let mut editor = editor().await;
let layer = editor.active_document().metadata().all_layers().next().unwrap().to_node();
editor.runtime.thumbnails.set_in_view(HashSet::from([layer]));
editor.runtime.thumbnails.set_in_view(HashSet::from([layer]), HashSet::from([layer]));
send_update(&mut editor);
assert!(!thumbnail_stale(&mut editor, layer).await);
@@ -17,7 +17,7 @@ use graphene_std::transform::Footprint;
use graphene_std::vector::Vector;
use graphene_std::{Artboard, Color, Context, ContextFeatures, Graphic};
use interpreted_executor::dynamic_executor::DynamicExecutor;
use std::collections::{HashMap, HashSet, VecDeque};
use std::collections::{BTreeMap, HashMap, HashSet, VecDeque};
use std::sync::Arc;
mod atlas;
@@ -40,22 +40,17 @@ pub struct Thumbnails {
sources: HashMap<NodeId, NodeId>,
/// The layers whose content changed since their thumbnail was last rendered.
stale: HashSet<NodeId>,
/// The layers whose thumbnails the frontend shows, the only ones rendered.
unshown: HashSet<NodeId>,
in_view: HashSet<NodeId>,
in_layers_panel: HashSet<NodeId>,
/// The device pixel ratio thumbnails are rendered at.
scale: f64,
#[cfg(all(target_family = "wasm", feature = "wasm"))]
canvases: HashMap<NodeId, ThumbnailCanvases>,
canvases: HashMap<NodeId, CanvasHandle>,
/// The layers whose thumbnails were sent to a page that can't show the runtime's canvases.
#[cfg(not(all(target_family = "wasm", feature = "wasm")))]
sent: HashSet<NodeId>,
}
/// A layer's thumbnail is shown in both the Layers panel and the node graph, but a canvas element can only be in one place.
#[cfg(all(target_family = "wasm", feature = "wasm"))]
struct ThumbnailCanvases {
layers_panel: CanvasHandle,
node_graph: CanvasHandle,
graphics: Arc<BTreeMap<NodeId, Graphic>>,
}
impl Thumbnails {
@@ -63,8 +58,14 @@ impl Thumbnails {
Self { scale: 1., ..Default::default() }
}
pub fn set_in_view(&mut self, layers: HashSet<NodeId>) {
pub fn set_in_view(&mut self, layers: HashSet<NodeId>, layers_panel: HashSet<NodeId>) {
self.stale.extend(self.unshown.extract_if(|layer| layers_panel.contains(layer)));
self.in_view = layers;
self.in_layers_panel = layers_panel;
}
pub fn graphics(&self) -> Arc<BTreeMap<NodeId, Graphic>> {
self.graphics.clone()
}
/// Whether the layer's thumbnail is waiting to be rendered.
@@ -90,6 +91,7 @@ impl Thumbnails {
let changed = sources.iter().filter(|(layer, source)| self.sources.get(layer) != Some(source));
self.stale.extend(changed.map(|(layer, _)| *layer));
self.stale.retain(|layer| sources.contains_key(layer));
self.unshown.retain(|layer| sources.contains_key(layer));
self.sources = sources;
}
@@ -111,11 +113,13 @@ impl Thumbnails {
#[cfg(not(all(target_family = "wasm", feature = "wasm")))]
self.sent.retain(|layer| keep_sourced(layer));
Arc::make_mut(&mut self.graphics).retain(|layer, _| sources.contains_key(layer));
dropped
}
/// Renders the thumbnails of the layers in view whose content changed since they were last rendered, keeping the others stale until they come into view.
pub async fn render_stale(&mut self, executor: &DynamicExecutor, editor_api: &PlatformEditorApi, responses: &mut VecDeque<FrontendMessage>) {
pub async fn render_stale(&mut self, executor: &DynamicExecutor, editor_api: &PlatformEditorApi, responses: &mut VecDeque<FrontendMessage>) -> bool {
let mut contents = HashMap::new();
for layer in std::mem::take(&mut self.stale) {
let Some(&source) = self.sources.get(&layer) else { continue };
@@ -132,10 +136,12 @@ impl Thumbnails {
contents.insert(layer, content);
}
if contents.is_empty() {
return;
return false;
}
self.unshown.extend(contents.keys().filter(|layer| !self.in_layers_panel.contains(layer)));
self.render_with_vello(&contents, editor_api, responses).await;
true
}
/// Renders the thumbnails into atlases with Vello and shows them.
@@ -163,39 +169,55 @@ impl Thumbnails {
}
};
self.show_atlas(&layout, texture, executor, responses).await;
self.keep_cells(&layout, &texture, executor);
let shown: Vec<(usize, NodeId)> = layout.layers.iter().copied().enumerate().filter(|(_, layer)| self.in_layers_panel.contains(layer)).collect();
if !shown.is_empty() {
self.show_atlas(&layout, &shown, texture, executor, responses).await;
}
}
}
/// Reads the atlas back and draws each cell into the canvases the layer's rows show.
/// Copies each layer's cell out of the atlas into a texture of its own for the node graph.
fn keep_cells(&mut self, layout: &ThumbnailAtlasLayout, atlas: &Texture, executor: &wgpu_executor::WgpuExecutor) {
let mut encoder = executor.context().device.create_command_encoder(&Default::default());
for (index, &layer) in layout.layers.iter().enumerate() {
let cell = executor.request_texture(layout.cell_size);
let mut source = atlas.as_image_copy();
let origin = layout.cell_origin(index);
(source.origin.x, source.origin.y) = (origin.x, origin.y);
encoder.copy_texture_to_texture(source, cell.as_image_copy(), cell.size());
Arc::make_mut(&mut self.graphics).insert(layer, Graphic::RasterGPU(Item::new_from_element(Raster::new_gpu(cell))));
}
executor.context().queue.submit([encoder.finish()]);
}
/// Reads the atlas back and draws each shown cell into the canvas the layer's row in the Layers panel shows.
#[cfg(all(target_family = "wasm", feature = "wasm"))]
async fn show_atlas(&mut self, layout: &ThumbnailAtlasLayout, atlas: Texture, executor: &wgpu_executor::WgpuExecutor, responses: &mut VecDeque<FrontendMessage>) {
async fn show_atlas(&mut self, layout: &ThumbnailAtlasLayout, shown: &[(usize, NodeId)], atlas: Texture, executor: &wgpu_executor::WgpuExecutor, responses: &mut VecDeque<FrontendMessage>) {
let raster = Raster::new_gpu(atlas).convert(Footprint::BOUNDLESS, executor.clone()).await;
let (pixels, _, _) = raster.to_flat_u8();
for (index, &layer) in layout.layers.iter().enumerate() {
for &(index, layer) in shown {
let cell_pixels = layout.cell_pixels(&pixels, index);
let Ok(image) = web_sys::ImageData::new_with_u8_clamped_array_and_sh(wasm_bindgen::Clamped(&cell_pixels), layout.cell_size.x, layout.cell_size.y) else {
continue;
};
let canvases = self.canvases(layer);
for canvas in [&mut canvases.layers_panel, &mut canvases.node_graph] {
canvas.set_resolution(layout.cell_size);
let _ = canvas.context().put_image_data(&image, 0, 0);
}
let canvas = self.canvas(layer);
canvas.set_resolution(layout.cell_size);
let _ = canvas.context().put_image_data(&image, 0, 0);
responses.push_back(canvases.update_message(layer));
responses.push_back(canvas_message(layer, canvas));
}
}
/// Reads the atlas back for a page that can't show the runtime's canvases, like the desktop app's, and sends each layer its cell's pixels.
/// Reads the atlas back for a page that can't show the runtime's canvases, like the desktop app's, and sends each shown layer its cell's pixels.
#[cfg(not(all(target_family = "wasm", feature = "wasm")))]
async fn show_atlas(&mut self, layout: &ThumbnailAtlasLayout, atlas: Texture, executor: &wgpu_executor::WgpuExecutor, responses: &mut VecDeque<FrontendMessage>) {
async fn show_atlas(&mut self, layout: &ThumbnailAtlasLayout, shown: &[(usize, NodeId)], atlas: Texture, executor: &wgpu_executor::WgpuExecutor, responses: &mut VecDeque<FrontendMessage>) {
let raster = Raster::new_gpu(atlas).convert(Footprint::BOUNDLESS, executor.clone()).await;
let (pixels, _, _) = raster.to_flat_u8();
for (index, &layer) in layout.layers.iter().enumerate() {
for &(index, layer) in shown {
self.sent.insert(layer);
responses.push_back(FrontendMessage::UpdateNodeThumbnailPixels {
id: layer,
@@ -207,23 +229,14 @@ impl Thumbnails {
}
#[cfg(all(target_family = "wasm", feature = "wasm"))]
fn canvases(&mut self, layer: NodeId) -> &mut ThumbnailCanvases {
self.canvases.entry(layer).or_insert_with(|| ThumbnailCanvases {
layers_panel: CanvasHandle::new(),
node_graph: CanvasHandle::new(),
})
fn canvas(&mut self, layer: NodeId) -> &mut CanvasHandle {
self.canvases.entry(layer).or_insert_with(CanvasHandle::new)
}
}
#[cfg(all(target_family = "wasm", feature = "wasm"))]
impl ThumbnailCanvases {
fn update_message(&mut self, layer: NodeId) -> FrontendMessage {
FrontendMessage::UpdateNodeThumbnailCanvases {
id: layer,
layers_panel_canvas_id: self.layers_panel.id(),
node_graph_canvas_id: self.node_graph.id(),
}
}
fn canvas_message(layer: NodeId, canvas: &mut CanvasHandle) -> FrontendMessage {
FrontendMessage::UpdateNodeThumbnailCanvas { id: layer, canvas_id: canvas.id() }
}
enum ThumbnailContent {
@@ -368,7 +381,7 @@ mod tests {
let (executor, documents) = (&mut portfolio.executor, &mut portfolio.documents);
let document = documents.get_mut(&document_id).unwrap();
executor
.submit_node_graph_evaluation(document, document_id, UVec2::ONE, 1., TimingInformation::default(), Vec::new(), true, DVec2::ZERO)
.submit_node_graph_evaluation(document, document_id, UVec2::ONE, 1., TimingInformation::default(), Vec::new(), true, DVec2::ZERO, None)
.unwrap();
editor.runtime.update();
editor.runtime.run().await;