Improve rendering efficiency and add caching (#95)

Fixes #84

*Reduce heap allocations
* Add caching for rendering svgs
* Deduplicate UpdateCanvas Responses
This commit is contained in:
TrueDoctor
2021-05-02 21:21:39 +02:00
committed by Keavon Chambers
parent 457c465342
commit fc10575dfa
14 changed files with 123 additions and 73 deletions

View File

@@ -328,7 +328,7 @@ export default defineComponent({
},
},
mounted() {
registerResponseHandler(ResponseType["Document::UpdateCanvas"], (responseData) => {
registerResponseHandler(ResponseType["Tool::UpdateCanvas"], (responseData) => {
this.viewportSvg = responseData;
});
registerResponseHandler(ResponseType["Tool::SetActiveTool"], (responseData) => {

View File

@@ -9,7 +9,7 @@ declare global {
}
export enum ResponseType {
"Document::UpdateCanvas" = "Document::UpdateCanvas",
"Tool::UpdateCanvas" = "Tool::UpdateCanvas",
"Document::ExpandFolder" = "Document::ExpandFolder",
"Document::CollapseFolder" = "Document::CollapseFolder",
"Tool::SetActiveTool" = "Tool::SetActiveTool",

View File

@@ -31,7 +31,6 @@ fn handle_response(response: Response) {
let response_type = response.to_string();
match response {
Response::Document(doc) => match doc {
DocumentResponse::UpdateCanvas { document } => send_response(response_type, &[document]),
DocumentResponse::ExpandFolder { path, children } => {
let children = children
.iter()
@@ -41,7 +40,9 @@ fn handle_response(response: Response) {
send_response(response_type, &[path_to_string(path), children])
}
DocumentResponse::CollapseFolder { path } => send_response(response_type, &[path_to_string(path)]),
DocumentResponse::DocumentChanged => log::error!("Wasm wrapper got request to update the document"),
},
Response::Tool(ToolResponse::UpdateCanvas { document }) => send_response(response_type, &[document]),
Response::Tool(ToolResponse::SetActiveTool { tool_name }) => send_response(response_type, &[tool_name]),
}
}