Break apart and improve the JS for rasterizing SVGs and downloading files (#786)

It now uses a blob URL instead of a data URL in the download process, which is cleaner and better performance.
This commit is contained in:
Keavon Chambers
2022-10-08 11:34:31 -07:00
parent dccff784c5
commit 35877a3fd9
9 changed files with 76 additions and 46 deletions

View File

@@ -91,7 +91,7 @@ impl MessageHandler<DialogMessage, &PortfolioMessageHandler> for DialogMessageHa
DialogMessage::RequestNewDocumentDialog => {
self.new_document_dialog = NewDocumentDialogMessageHandler {
name: portfolio.generate_new_document_name(),
infinite: true,
infinite: false,
dimensions: glam::UVec2::new(1920, 1080),
};
self.new_document_dialog.register_properties(responses, LayoutTarget::DialogDetails);

View File

@@ -63,7 +63,7 @@ pub enum FrontendMessage {
TriggerOpenDocument,
TriggerPaste,
TriggerRasterDownload {
document: String,
svg: String,
name: String,
mime: String,
size: (f64, f64),

View File

@@ -314,7 +314,7 @@ impl MessageHandler<DocumentMessage, (&InputPreprocessorMessageHandler, &FontCac
self.graphene_document.root.transform = DAffine2::IDENTITY;
GrapheneDocument::mark_children_as_dirty(&mut self.graphene_document.root);
// Calculates the bounding box of the region to be exported
// Calculate the bounding box of the region to be exported
use crate::messages::frontend::utility_types::ExportBounds;
let bbox = match bounds {
ExportBounds::AllArtwork => self.all_layer_bounds(font_cache),
@@ -345,7 +345,7 @@ impl MessageHandler<DocumentMessage, (&InputPreprocessorMessageHandler, &FontCac
} else {
let mime = file_type.to_mime().to_string();
let size = (size * scale_factor).into();
responses.push_back(FrontendMessage::TriggerRasterDownload { document, name, mime, size }.into());
responses.push_back(FrontendMessage::TriggerRasterDownload { svg: document, name, mime, size }.into());
}
}
FlipSelectedLayers { flip_axis } => {