Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .branding
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
https://github.com/Keavon/graphite-branded-assets/archive/70b260c21afad29140bbc63ddab952fec3dd024c.tar.gz
5b05e7f4449b5f962755542e9b156891bbf2e0a87b7fc90798b8352d9225757d
https://github.com/Keavon/graphite-branded-assets/archive/38176c494d7cf0bde3bdf45e6a318ae6a9d89229.tar.gz
2ae24506ff786b2b684f5d23bd326a69f5f4551855f19e4ef2b0324f9ec14e5d
5 changes: 5 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions desktop/src/render/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub(crate) struct RenderState {
ui_texture: Option<wgpu::Texture>,
bind_group: Option<wgpu::BindGroup>,
#[derivative(Debug = "ignore")]
overlays_scene: Option<VelloSceneBuilder>,
overlays_scene: Option<VelloSceneBuilder<'static>>,
#[derivative(Debug = "ignore")]
overlays_canvas: VelloCanvas,
surface_outdated: bool,
Expand Down Expand Up @@ -220,7 +220,7 @@ impl RenderState {
self.viewport_offset = offset;
}

pub(crate) fn set_overlays_scene(&mut self, scene: VelloSceneBuilder) {
pub(crate) fn set_overlays_scene(&mut self, scene: VelloSceneBuilder<'static>) {
self.surface_outdated = true;
self.overlays_scene = Some(scene);
}
Expand Down
2 changes: 1 addition & 1 deletion desktop/wrapper/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub enum DesktopFrontendMessage {
WindowUpdateDirectInput {
enabled: bool,
},
UpdateOverlays(Box<wgpu_executor::VelloSceneBuilder>),
UpdateOverlays(Box<wgpu_executor::VelloSceneBuilder<'static>>),
PersistenceUpdatePreferences {
preferences: Preferences,
},
Expand Down
3 changes: 3 additions & 0 deletions document/migrations/nodes/src/blending_nodes/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//! Migrations of the nodes in `blending_nodes`.

mod renames;
5 changes: 5 additions & 0 deletions document/migrations/nodes/src/blending_nodes/renames.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//! Nodes that only moved to a new identifier.
use migration_core::rename;

rename!("raster_nodes::filter::BlurNode"@1 => "blending_nodes::effects::BlurNode"@2);
1 change: 1 addition & 0 deletions document/migrations/nodes/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Node migrations, in a module per node crate and a file per step, each registering itself. Scaffold one with
//! `cargo run migration new <identifier>` after bumping a node's `version(N)`.
mod blending_nodes;
mod graphene_core;
mod math_nodes;
mod raster_nodes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use graphene_std::vector::style::{
DashPattern, FillChoice, GradientForm, GradientHueDirection, GradientInterpolation, GradientRamp, GradientSettings, GradientSpace, GradientSpread, StrokeAlign, StrokeCap, StrokeJoin,
};
use graphene_std::vector::{CurveType, Path, PointId, QRCodeErrorCorrectionLevel, SegmentId, Vector};
use graphene_std::{Appearance, Artboard, Color, ContextFeatures, ContextOverrides, Cover, Coverage, Graphic};
use graphene_std::{Appearance, Artboard, Color, ContextFeatures, ContextOverrides, Cover, Coverage, Effect, EffectKind, Effects, Graphic};
use kurbo::BezPath;
use std::any::Any;
use std::ops::Range;
Expand Down Expand Up @@ -792,6 +792,45 @@ impl TableItemLayout for Coverage {
}
}

impl TableItemLayout for Effects {
fn type_name() -> &'static str {
"Effects"
}
fn identifier(&self) -> String {
"Effects".to_string()
}
// The wrapping `Item` already contributes the breadcrumb; the inner list supplies the next level
fn layout_with_breadcrumb(&self, data: &mut LayoutData) -> Vec<LayoutGroup> {
self.value_page(data)
}
// Label the spreadsheet's element button with the inner list's identifier, like Appearance
fn value_widgets(&self, target: PathStep, data: &LayoutData) -> Vec<WidgetInstance> {
self.0.value_widgets(target, data)
}
fn value_page(&self, data: &mut LayoutData) -> Vec<LayoutGroup> {
self.0.layout_with_breadcrumb(data)
}
}

impl TableItemLayout for Effect {
fn type_name() -> &'static str {
"Effect"
}
fn identifier(&self) -> String {
"Effect".to_string()
}
// The wrapping row already contributes the breadcrumb; the inner item supplies the next level
fn layout_with_breadcrumb(&self, data: &mut LayoutData) -> Vec<LayoutGroup> {
self.value_page(data)
}
fn value_widgets(&self, target: PathStep, data: &LayoutData) -> Vec<WidgetInstance> {
self.0.value_widgets(target, data)
}
fn value_page(&self, data: &mut LayoutData) -> Vec<LayoutGroup> {
self.0.layout_with_breadcrumb(data)
}
}

impl TableItemLayout for TransferCurve {
fn type_name() -> &'static str {
"TransferCurve"
Expand Down Expand Up @@ -1213,6 +1252,7 @@ macro_rules! impl_table_item_layout_for_choice_enum {
impl_table_item_layout_for_choice_enum!(
BlendMode,
Cover,
EffectKind,
GradientForm,
GradientSpread,
GradientSpace,
Expand Down Expand Up @@ -1383,6 +1423,9 @@ macro_rules! known_item_types {
Appearance,
Coverage,
Cover,
Effects,
Effect,
EffectKind,
DashPattern,
BoxCorners,
TransferCurve,
Expand Down
3 changes: 3 additions & 0 deletions editor/src/messages/portfolio/document/document_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ pub enum DocumentMessage {
UpdateAppearanceAttributes {
appearance_attributes: HashMap<NodeId, Arc<Appearance>>,
},
UpdateEffectsReach {
Comment thread
Keavon marked this conversation as resolved.
Resolved
effects_reach: HashMap<NodeId, f64>,
},
Undo,
UngroupSelectedLayers,
UngroupLayer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1915,6 +1915,14 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
.collect();
self.network_interface.update_appearance_attributes(layer_appearance_attributes);
}
DocumentMessage::UpdateEffectsReach { effects_reach } => {
let layer_effects_reach = effects_reach
.into_iter()
.filter(|(node_id, _)| self.network_interface.document_network().nodes.contains_key(node_id) && self.network_interface.is_layer(node_id, &[]))
.map(|(node_id, reach)| (LayerNodeIdentifier::new(node_id, &self.network_interface), reach))
.collect();
self.network_interface.update_effects_reach(layer_effects_reach);
}
DocumentMessage::Undo => {
if self.network_interface.transaction_status() != TransactionStatus::Finished {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ impl OverlayContext {
}
}

pub fn take_scene(self) -> VelloSceneBuilder {
pub fn take_scene(self) -> VelloSceneBuilder<'static> {
let mut internal = self.internal.lock().expect("Failed to lock internal overlay context");
let empty_scene = overlay_scene(&internal.viewport);
std::mem::replace(&mut internal.scene, empty_scene)
Expand Down Expand Up @@ -486,13 +486,13 @@ pub enum DrawHandles {
}

pub(super) struct OverlayContextInternal {
scene: VelloSceneBuilder,
scene: VelloSceneBuilder<'static>,
viewport: ViewportMessageHandler,
visibility_settings: OverlaysVisibilitySettings,
}

/// An empty scene covering the viewport's physical pixels, matching the resolution the viewport renders at.
fn overlay_scene(viewport: &ViewportMessageHandler) -> VelloSceneBuilder {
fn overlay_scene(viewport: &ViewportMessageHandler) -> VelloSceneBuilder<'static> {
// The smallest texture size limit WebGL2 guarantees, which only matters for the overlays' tiny pattern images
const MAX_TEXTURE_SIZE: u32 = 2048;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ pub struct DocumentMetadata {
pub layer_vector_data: HashMap<LayerNodeIdentifier, Arc<Item<Vector>>>,
/// Per-layer `ATTR_APPEARANCE` attribute, exposed so message handlers can read paint information that lives on the list.
pub layer_appearance_attributes: HashMap<LayerNodeIdentifier, Arc<Appearance>>,
/// How far each layer's effects paint past its content, in document pixels, for the layers with effects.
pub layer_effects_reach: HashMap<LayerNodeIdentifier, f64>,
/// Transform from document space to viewport space.
pub document_to_viewport: DAffine2,
/// The transform from document space to viewport space that the latest render was made with, which is the one `upstream_footprints` include.
Expand Down Expand Up @@ -347,9 +349,9 @@ impl DocumentMetadata {
}

/// Get the bounding box of the specified layer in document space, expanded to include the actual rendered
/// stroke geometry when the layer is a vector with a stroke style. Only the first item of a layer's vector data
/// is recorded, so the others count through the click-target-based bounds, without their strokes.
pub fn bounding_box_document_with_stroke(&self, layer: LayerNodeIdentifier) -> Option<[DVec2; 2]> {
/// stroke geometry when the layer is a vector with a stroke style, and how far its effects paint past it. Only the first item of a
/// layer's vector data is recorded, so the others count through the click-target-based bounds, without their strokes.
pub fn bounding_box_document_with_stroke_and_effects(&self, layer: LayerNodeIdentifier) -> Option<[DVec2; 2]> {
let stroked = self.layer_vector_data.get(&layer).and_then(|item| {
let stroke = self
.layer_appearance_attributes
Expand All @@ -359,8 +361,10 @@ impl DocumentMetadata {
let paths = paths_from_item_attributes(item.as_ref()).unwrap_or_else(|| no_paths());
item.element().stroke_inclusive_bounding_box_with_transform(paths, self.transform_to_document(layer), stroke.as_ref())
});
let [min, max] = [stroked, self.bounding_box_document(layer)].into_iter().flatten().reduce(Quad::combine_bounds)?;

[stroked, self.bounding_box_document(layer)].into_iter().flatten().reduce(Quad::combine_bounds)
let reach = self.layer_effects_reach.get(&layer).copied().unwrap_or_default();
Some([min - reach, max + reach])
}

/// Get the bounding box of the click target of the specified layer in viewport space
Expand Down Expand Up @@ -732,7 +736,7 @@ mod tests {
let later_item = ClickTarget::new_with_path(line(100., 110.), 0.);
metadata.click_targets.insert(layer, vec![Arc::new(later_item)]);

let [min, max] = metadata.bounding_box_document_with_stroke(layer).unwrap();
let [min, max] = metadata.bounding_box_document_with_stroke_and_effects(layer).unwrap();
assert_eq!((min.x, max.x), (0., 110.));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1063,11 +1063,11 @@ impl NodeNetworkInterface {
Some(transformed.bounding_box())
}

/// Calculates the document bounds in document space, expanding vector layer bounds to include the rendered
/// stroke width. Used for export so the output canvas captures strokes that overflow the path geometry.
pub fn document_bounds_document_space_with_stroke(&self, include_artboards: bool) -> Option<[DVec2; 2]> {
/// Calculates the document bounds in document space, expanding layer bounds to include the rendered stroke width and
/// effects. Used for export so the output canvas captures strokes and shadows that overflow the path geometry.
pub fn document_bounds_document_space_with_stroke_and_effects(&self, include_artboards: bool) -> Option<[DVec2; 2]> {
self.document_metadata.document_bounds(include_artboards, true, || {
self.combined_document_bounds(include_artboards, |metadata, layer| metadata.bounding_box_document_with_stroke(layer))
self.combined_document_bounds(include_artboards, |metadata, layer| metadata.bounding_box_document_with_stroke_and_effects(layer))
})
}

Expand All @@ -1084,17 +1084,17 @@ impl NodeNetworkInterface {
.reduce(Quad::combine_bounds)
}

/// Calculates the selected layer bounds in document space, expanding vector layer bounds to include the
/// rendered stroke width. Used for export so the output canvas captures strokes that overflow the path geometry.
pub fn selected_bounds_document_space_with_stroke(&self, include_artboards: bool, network_path: &[NodeId]) -> Option<[DVec2; 2]> {
/// Calculates the selected layer bounds in document space, expanding layer bounds to include the rendered stroke width
/// and effects. Used for export so the output canvas captures strokes and shadows that overflow the path geometry.
pub fn selected_bounds_document_space_with_stroke_and_effects(&self, include_artboards: bool, network_path: &[NodeId]) -> Option<[DVec2; 2]> {
let Some(selected_nodes) = self.selected_nodes_in_nested_network(network_path) else {
log::error!("Could not get selected nodes in selected_bounds_document_space_with_stroke");
log::error!("Could not get selected nodes in selected_bounds_document_space_with_stroke_and_effects");
return None;
};
selected_nodes
.selected_layers(&self.document_metadata)
.filter(|&layer| include_artboards || !self.is_artboard(&layer.to_node(), &[]))
.filter_map(|layer| self.document_metadata.bounding_box_document_with_stroke(layer))
.filter_map(|layer| self.document_metadata.bounding_box_document_with_stroke_and_effects(layer))
.reduce(Quad::combine_bounds)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,10 @@ impl NodeNetworkInterface {
pub fn update_appearance_attributes(&mut self, new_layer_appearance_attributes: HashMap<LayerNodeIdentifier, Arc<Appearance>>) {
self.document_metadata.layer_appearance_attributes = new_layer_appearance_attributes;
}

/// Update how far each layer's effects paint past its content.
pub fn update_effects_reach(&mut self, new_layer_effects_reach: HashMap<LayerNodeIdentifier, f64>) {
self.document_metadata.mark_changed();
self.document_metadata.layer_effects_reach = new_layer_effects_reach;
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
}
}
4 changes: 2 additions & 2 deletions editor/src/messages/portfolio/document_migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,8 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[
],
},
NodeReplacement {
node: graphene_std::raster_nodes::filter::blur::IDENTIFIER,
aliases: &["graphene_raster_nodes::filter::BlurNode", "graphene_std::filter::BlurNode"],
node: graphene_std::blending_nodes::effects::blur::IDENTIFIER,
aliases: &["raster_nodes::filter::BlurNode", "graphene_raster_nodes::filter::BlurNode", "graphene_std::filter::BlurNode"],
},
NodeReplacement {
node: graphene_std::raster_nodes::adjustments::brightness_contrast::IDENTIFIER,
Expand Down
10 changes: 6 additions & 4 deletions editor/src/node_graph_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,11 @@ impl NodeGraphExecutor {
};

// Calculate the bounding box of the region to be exported (artboard bounds always contribute).
// `AllArtwork` and `Selection` expand vector layer bounds by the rendered stroke width so strokes
// drawn at render-time (without a `Solidify Stroke`) aren't clipped at the export canvas edge.
// `AllArtwork` and `Selection` expand layer bounds by the rendered stroke width and effects reach so strokes
// and shadows drawn at render-time (without a `Solidify Stroke`) aren't clipped at the export canvas edge.
let bounds = match export_config.bounds {
ExportBounds::AllArtwork => document.network_interface.document_bounds_document_space_with_stroke(true),
ExportBounds::Selection => document.network_interface.selected_bounds_document_space_with_stroke(true, &[]),
ExportBounds::AllArtwork => document.network_interface.document_bounds_document_space_with_stroke_and_effects(true),
ExportBounds::Selection => document.network_interface.selected_bounds_document_space_with_stroke_and_effects(true, &[]),
ExportBounds::Artboard(id) => document.metadata().bounding_box_document(id),
}
.ok_or_else(|| "No bounding box".to_string())?;
Expand Down Expand Up @@ -1034,6 +1034,7 @@ impl NodeGraphExecutor {
clip_targets,
vector_data,
appearance_attributes,
effects_reach,
backgrounds: _,
} = render_output.metadata;

Expand All @@ -1050,6 +1051,7 @@ impl NodeGraphExecutor {
responses.add(DocumentMessage::UpdateClipTargets { clip_targets });
responses.add(DocumentMessage::UpdateVectorData { vector_data });
responses.add(DocumentMessage::UpdateAppearanceAttributes { appearance_attributes });
responses.add(DocumentMessage::UpdateEffectsReach { effects_reach });
responses.add(DocumentMessage::RenderScrollbars);
responses.add(DocumentMessage::RenderRulers);
responses.add(OverlaysMessage::Draw);
Expand Down
4 changes: 3 additions & 1 deletion editor/src/node_graph_executor/runtime/thumbnails/atlas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ pub fn draw_atlas(scene: &mut VelloSceneBuilder, layout: &ThumbnailAtlasLayout,
// The clip also limits content filling the whole scene, like a background, to the cell
let cell = Rect::new(origin.x, origin.y, origin.x + cell_size.x, origin.y + cell_size.y);
scene.push_clip_layer(Fill::NonZero, Affine::IDENTITY, &cell);
content.graphic().render_to_vello(scene, transform, &render_params);
scene.draw_placed(Affine::new(transform.to_cols_array()), |scene| {
content.graphic().render_to_vello(scene, DAffine2::IDENTITY, &render_params)
});
scene.pop_layer();
}
}
Expand Down
Loading
Loading