mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-27 23:28:12 +08:00
Implement Infrastructure to reuse previous frames for brush drawing
Implement Infrastructuro to reuse the previous evaluation of the node graph to blend the new stroke with instead of drawing the entire trace from scratch. This does not transition to a blending based approach because that still caused regressions but allows the brush node to work with input data natively. Test Plan: - Use the brush tool in the editor and check for regressions - Evaluate the performance Reviewers: Keavon Pull Request: https://github.com/GraphiteEditor/Graphite/pull/1190
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
"build-wasm": "wasm-pack build ./wasm --dev --target=web",
|
||||
"build-wasm-prod": "wasm-pack build ./wasm --release --target=web",
|
||||
"tauri:build-wasm": "wasm-pack build ./wasm --release --target=web -- --features tauri",
|
||||
"watch:wasm": "cargo watch --postpone --workdir wasm --shell \"wasm-pack build . --dev --target=web -- --color always\"",
|
||||
"watch:wasm": "cargo watch --postpone --watch-when-idle --workdir wasm --shell \"wasm-pack build . --dev --target=web -- --color always\"",
|
||||
"--------------------": "",
|
||||
"print-building-help": "echo 'Graphite project failed to build. Did you remember to `npm install` the dependencies in `/frontend`?'",
|
||||
"print-linting-help": "echo 'Graphite project had lint errors, or may have otherwise failed. In the latter case, did you remember to `npm install` the dependencies in `/frontend`?'"
|
||||
|
||||
@@ -708,21 +708,26 @@ impl JsEditorHandle {
|
||||
|
||||
/// Returns the string representation of the nodes contents
|
||||
#[wasm_bindgen(js_name = introspectNode)]
|
||||
pub fn introspect_node(&self, node_path: Vec<NodeId>) -> Option<String> {
|
||||
pub fn introspect_node(&self, node_path: Vec<NodeId>) -> JsValue {
|
||||
let frontend_messages = EDITOR_INSTANCES.with(|instances| {
|
||||
// Mutably borrow the editors, and if successful, we can access them in the closure
|
||||
instances.try_borrow_mut().map(|mut editors| {
|
||||
// Get the editor instance for this editor ID, then dispatch the message to the backend, and return its response `FrontendMessage` queue
|
||||
editors
|
||||
let image = editors
|
||||
.get_mut(&self.editor_id)
|
||||
.expect("EDITOR_INSTANCES does not contain the current editor_id")
|
||||
.dispatcher
|
||||
.message_handlers
|
||||
.portfolio_message_handler
|
||||
.introspect_node(&node_path)
|
||||
.introspect_node(&node_path);
|
||||
let image = image?;
|
||||
let image = image.downcast_ref::<graphene_core::raster::ImageFrame<Color>>()?;
|
||||
let serializer = serde_wasm_bindgen::Serializer::new().serialize_large_number_types_as_bigints(true);
|
||||
let message_data = image.serialize(&serializer).expect("Failed to serialize FrontendMessage");
|
||||
Some(message_data)
|
||||
})
|
||||
});
|
||||
frontend_messages.unwrap()
|
||||
frontend_messages.unwrap().unwrap_or_default().into()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user