mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 06:38:03 +08:00
Insert pasted images as layers in document graph (#1418)
Changes: Graph is evaluated on every viewport change move all navigation logic into the viewport reduce the number of js roundtrips add canvas rendering enable image pasting various cleanups Fix cache nodes being reset every evaluation
This commit is contained in:
committed by
Keavon Chambers
parent
d82f133514
commit
833f41bccb
@@ -294,6 +294,9 @@ impl GraphicElementRendered for ImageFrame<Color> {
|
||||
}
|
||||
ImageRenderMode::Base64 => {
|
||||
let image = &self.image;
|
||||
if image.data.is_empty() {
|
||||
return;
|
||||
}
|
||||
let (flat_data, _, _) = image.clone().into_flat_u8();
|
||||
let mut output = Vec::new();
|
||||
let encoder = image::codecs::png::PngEncoder::new(&mut output);
|
||||
@@ -303,13 +306,12 @@ impl GraphicElementRendered for ImageFrame<Color> {
|
||||
let preamble = "data:image/png;base64,";
|
||||
let mut base64_string = String::with_capacity(preamble.len() + output.len() * 4);
|
||||
base64_string.push_str(preamble);
|
||||
log::debug!("len: {}", image.data.len());
|
||||
base64::engine::general_purpose::STANDARD.encode_string(output, &mut base64_string);
|
||||
|
||||
render.leaf_tag("image", |attributes| {
|
||||
attributes.push("width", image.width.to_string());
|
||||
attributes.push("width", 1.to_string());
|
||||
|
||||
attributes.push("height", image.height.to_string());
|
||||
attributes.push("height", 1.to_string());
|
||||
attributes.push("preserveAspectRatio", "none");
|
||||
attributes.push("transform", transform);
|
||||
attributes.push("href", base64_string)
|
||||
|
||||
@@ -94,7 +94,8 @@ impl PartialEq for TypeDescriptor {
|
||||
match (self.id, other.id) {
|
||||
(Some(id), Some(other_id)) => id == other_id,
|
||||
_ => {
|
||||
warn!("TypeDescriptor::eq: comparing types without ids based on name");
|
||||
// TODO: Add a flag to disable this warning
|
||||
//warn!("TypeDescriptor::eq: comparing types without ids based on name");
|
||||
self.name == other.name
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user