mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-17 23:38:06 +08:00
Replace the IntoPaint trait with direct Graphic-typed node inputs (#4442)
This commit is contained in:
committed by
Dennis Kobert
parent
a41fdb3d75
commit
03262e1bab
@@ -6,8 +6,6 @@ use canvas_utils::{Canvas, CanvasHandle};
|
||||
use core_types::attribute::{Attr, OwnedAttr, Transform};
|
||||
use core_types::color::SRGBA8;
|
||||
use core_types::gpoll::GPoll;
|
||||
#[cfg(target_family = "wasm")]
|
||||
use core_types::list::List;
|
||||
|
||||
#[cfg(target_family = "wasm")]
|
||||
use core_types::ATTR_TRANSFORM;
|
||||
@@ -25,16 +23,10 @@ pub use graphene_canvas_utils as canvas_utils;
|
||||
#[cfg(target_family = "wasm")]
|
||||
use graphic_types::Graphic;
|
||||
#[cfg(target_family = "wasm")]
|
||||
use graphic_types::IntoGraphicList;
|
||||
#[cfg(target_family = "wasm")]
|
||||
use graphic_types::Vector;
|
||||
#[cfg(target_family = "wasm")]
|
||||
use graphic_types::markers::EditorMergedLayers;
|
||||
use graphic_types::raster_types::Image;
|
||||
use graphic_types::raster_types::{CPU, GPU, Raster};
|
||||
#[cfg(target_family = "wasm")]
|
||||
use graphic_types::vector_types::gradient::Gradient;
|
||||
#[cfg(target_family = "wasm")]
|
||||
use rendering::{Render, RenderParams, RenderSvgSegmentList, SvgRender};
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -204,23 +196,7 @@ fn create_canvas(_: impl Ctx) -> CanvasHandle {
|
||||
/// Renders a view of the input graphic within an area defined by the *Footprint*.
|
||||
#[cfg(target_family = "wasm")]
|
||||
#[node_macro::node(category(""))]
|
||||
async fn rasterize<T: Clone + Send + Sync + dyn_any::StaticTypeSized>(
|
||||
_: impl Ctx,
|
||||
_: (),
|
||||
#[implementations(
|
||||
Vector,
|
||||
Raster<CPU>,
|
||||
Graphic,
|
||||
Color,
|
||||
Gradient,
|
||||
)]
|
||||
mut data: IList<T>,
|
||||
footprint: Footprint,
|
||||
mut canvas: CanvasHandle,
|
||||
) -> (Raster<CPU>, Attr<Transform>, OwnedAttr<EditorMergedLayers>)
|
||||
where
|
||||
List<T>: Render + Clone + IntoGraphicList,
|
||||
{
|
||||
async fn rasterize(_: impl Ctx, _: (), mut data: IList<Graphic<'static>>, footprint: Footprint, mut canvas: CanvasHandle) -> (Raster<CPU>, Attr<Transform>, OwnedAttr<EditorMergedLayers>) {
|
||||
use glam::{DAffine2, DVec2};
|
||||
|
||||
if footprint.transform.matrix2.determinant() == 0. {
|
||||
@@ -232,7 +208,7 @@ where
|
||||
// Snapshot the input as a List<Graphic> so the renderer can recurse into the original child layers
|
||||
// when collecting metadata, exposing their click targets to editor tools (same mechanism as Boolean Operation).
|
||||
// The copy is owned before the first await: the input's arena content dies with the spawning evaluation.
|
||||
let upstream_graphic_list = data.clone().into_graphic_list();
|
||||
let upstream_graphic_list = data.clone();
|
||||
let merged_layers = OwnedAttr::new(Some(&upstream_graphic_list));
|
||||
|
||||
let mut render = SvgRender::new();
|
||||
|
||||
@@ -350,16 +350,16 @@ fn fill<'e>(
|
||||
ctx: impl Ctx + ExtractArena<'e> + ExtractIndex + InjectIndex + Copy,
|
||||
/// The content with vector paths to apply the fill style to.
|
||||
(element, content_appearance): (Vector, Attr<AppearanceMarker>),
|
||||
/// The fill to paint the path with.
|
||||
/// The paint to fill the path's interior with.
|
||||
#[default(Color::BLACK)]
|
||||
fill: IList<Graphic<'static>>,
|
||||
paint: IList<Graphic<'static>>,
|
||||
_backup_color: IList<Color>,
|
||||
_backup_gradient: IList<Gradient>,
|
||||
_gradient_form: GradientForm,
|
||||
_has_transform: bool,
|
||||
_transform: DAffine2,
|
||||
) -> Result<(Vector, Attr<'e, AppearanceMarker>), Interrupt> {
|
||||
let mut paint = paint_table(fill);
|
||||
let mut paint = paint_table(paint);
|
||||
default_gradient_paint(&mut paint, element.bounding_box(), _gradient_form, _has_transform.then_some(_transform));
|
||||
let appearance = stamped_appearance(*content_appearance, Coverage::new_fill(), &paint, CoverPlacement::Above);
|
||||
let parked_appearance = park_appearance(ctx.arena(), appearance)?;
|
||||
@@ -372,7 +372,7 @@ fn fill<'e>(
|
||||
fn fill_graphic_leveled<'e>(
|
||||
ctx: impl Ctx + ExtractArena<'e> + ExtractIndex + InjectIndex + Copy,
|
||||
(element, content_appearance): (Graphic<'static>, Attr<AppearanceMarker>),
|
||||
#[default(Color::BLACK)] fill: IList<Graphic<'static>>,
|
||||
#[default(Color::BLACK)] paint: IList<Graphic<'static>>,
|
||||
_backup_color: IList<Color>,
|
||||
_backup_gradient: IList<Gradient>,
|
||||
_gradient_form: GradientForm,
|
||||
@@ -383,7 +383,7 @@ fn fill_graphic_leveled<'e>(
|
||||
RenderBoundingBox::Rectangle(bounds) => Some(bounds),
|
||||
_ => None,
|
||||
};
|
||||
let mut paint = paint_table(fill);
|
||||
let mut paint = paint_table(paint);
|
||||
default_gradient_paint(&mut paint, bounds, _gradient_form, _has_transform.then_some(_transform));
|
||||
let appearance = stamped_appearance(*content_appearance, Coverage::new_fill(), &paint, CoverPlacement::Above);
|
||||
let parked_appearance = park_appearance(ctx.arena(), appearance)?;
|
||||
|
||||
Reference in New Issue
Block a user