Thumbnails for the layer node (#1210)

* Thumbnails for the layer node

* Raster node graph frames

* Downscale to a random resolution

* Cleanup and bug fixes

* Generate paths before duplicating outputs

* Fix stable id test

* Code review changes

* Code review pass with minor changes

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
0HyperCube 2023-05-18 05:12:50 +01:00 committed by Keavon Chambers
parent 727e5bdeb1
commit 6400953af5
24 changed files with 609 additions and 131 deletions

View file

@ -32,8 +32,8 @@ pub fn set_random_seed(seed: u64) {
/// This avoids creating a json with a list millions of numbers long.
#[wasm_bindgen(module = "/../src/wasm-communication/editor.ts")]
extern "C" {
fn updateImage(path: Vec<u64>, mime: String, imageData: &[u8], transform: js_sys::Float64Array, document_id: u64);
fn fetchImage(path: Vec<u64>, mime: String, document_id: u64, identifier: String);
fn updateImage(path: Vec<u64>, nodeId: Option<u64>, mime: String, imageData: &[u8], transform: js_sys::Float64Array, document_id: u64);
fn fetchImage(path: Vec<u64>, nodeId: Option<u64>, mime: String, document_id: u64, identifier: String);
//fn dispatchTauri(message: String) -> String;
fn dispatchTauri(message: String);
}
@ -122,10 +122,13 @@ impl JsEditorHandle {
} else {
js_sys::Float64Array::default()
};
updateImage(image.path, image.mime, &image.image_data, transform, document_id);
updateImage(image.path, image.node_id, image.mime, &image.image_data, transform, document_id);
}
#[cfg(feature = "tauri")]
fetchImage(image.path.clone(), image.mime, document_id, format!("http://localhost:3001/image/{:?}_{}", &image.path, document_id));
{
let identifier = format!("http://localhost:3001/image/{:?}_{}", image.path, document_id);
fetchImage(image.path, image.node_id, image.mime, document_id, identifier);
}
}
return;
}
@ -504,11 +507,12 @@ impl JsEditorHandle {
/// Sends the blob URL generated by JS to the Image layer
#[wasm_bindgen(js_name = setImageBlobURL)]
pub fn set_image_blob_url(&self, document_id: u64, layer_path: Vec<LayerId>, blob_url: String, width: f64, height: f64, transform: Option<js_sys::Float64Array>) {
pub fn set_image_blob_url(&self, document_id: u64, layer_path: Vec<LayerId>, node_id: Option<NodeId>, blob_url: String, width: f64, height: f64, transform: Option<js_sys::Float64Array>) {
let resolution = (width, height);
let message = PortfolioMessage::SetImageBlobUrl {
document_id,
layer_path: layer_path.clone(),
node_id,
blob_url,
resolution,
};