mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 06:38:03 +08:00
Use canvas as target for raster rendering (#1256)
* Implement ApplicationIo * Simplify output duplication logic * Fix let node initialization for ExtractImageFrame * Async macros * Use manual node registry impl * Fix canvas insertion into the dom
This commit is contained in:
committed by
Keavon Chambers
parent
57415b948b
commit
259dcdc628
@@ -871,6 +871,12 @@ impl Document {
|
||||
}
|
||||
Some(Vec::new())
|
||||
}
|
||||
Operation::SetSurface { path, surface_id } => {
|
||||
if let LayerDataType::Layer(layer) = &mut self.layer_mut(&path)?.data {
|
||||
layer.cached_output_data = CachedOutputData::SurfaceId(surface_id);
|
||||
}
|
||||
Some(Vec::new())
|
||||
}
|
||||
Operation::TransformLayerInScope { path, transform, scope } => {
|
||||
let transform = DAffine2::from_cols_array(&transform);
|
||||
let scope = DAffine2::from_cols_array(&scope);
|
||||
|
||||
@@ -5,6 +5,7 @@ use crate::LayerId;
|
||||
|
||||
use glam::{DAffine2, DMat2, DVec2};
|
||||
use graphene_core::vector::VectorData;
|
||||
use graphene_core::SurfaceId;
|
||||
use kurbo::{Affine, BezPath, Shape as KurboShape};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Write;
|
||||
@@ -15,6 +16,7 @@ pub enum CachedOutputData {
|
||||
None,
|
||||
BlobURL(String),
|
||||
VectorPath(Box<VectorData>),
|
||||
SurfaceId(SurfaceId),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
|
||||
@@ -76,6 +78,19 @@ impl LayerData for LayerLayer {
|
||||
matrix
|
||||
);
|
||||
}
|
||||
CachedOutputData::SurfaceId(SurfaceId(id)) => {
|
||||
// Render the image if it exists
|
||||
let _ = write!(
|
||||
svg,
|
||||
r#"
|
||||
<foreignObject width="{}" height="{}" transform="matrix({})"><div data-canvas-placeholder="canvas{}"></div></foreignObject>
|
||||
"#,
|
||||
width.abs(),
|
||||
height.abs(),
|
||||
matrix,
|
||||
id
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
// Render a dotted blue outline if there is no image or vector data
|
||||
let _ = write!(
|
||||
|
||||
@@ -76,6 +76,10 @@ pub enum Operation {
|
||||
path: Vec<LayerId>,
|
||||
vector_data: graphene_core::vector::VectorData,
|
||||
},
|
||||
SetSurface {
|
||||
path: Vec<LayerId>,
|
||||
surface_id: graphene_core::SurfaceId,
|
||||
},
|
||||
TransformLayerInScope {
|
||||
path: Vec<LayerId>,
|
||||
transform: [f64; 6],
|
||||
|
||||
Reference in New Issue
Block a user