Skip to content

Commit 12d6335

Browse files
committed
Cleanup for Cow usage
1 parent 5bd9f69 commit 12d6335

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

node-graph/libraries/rendering/src/renderer.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ impl Render for List<Vector> {
11451145
}
11461146

11471147
Some(Graphic::Vector(_) | Graphic::RasterCPU(_) | Graphic::RasterGPU(_) | Graphic::Graphic(_)) => {
1148-
if let Some(fill_graphic_list) = fill_graphic_list.as_ref() {
1148+
if let Some(fill_graphic_list) = fill_graphic_list.as_deref() {
11491149
let face_clip_id = format!("clip-{}", generate_uuid());
11501150
write!(&mut render.svg_defs, r##"<clipPath id="{face_clip_id}"><path d="{face_d}"/></clipPath>"##).unwrap();
11511151
emit_svg_fill_clip(render, &face_clip_id, fill_graphic_list, item_transform, render_params);
@@ -1160,7 +1160,7 @@ impl Render for List<Vector> {
11601160
&& !use_face_fill
11611161
&& !wants_stroke_below
11621162
&& !override_paint_order
1163-
&& let (Some(clip_id), Some(fill_graphic_list)) = (clip_id.as_ref(), fill_graphic_list.as_ref())
1163+
&& let (Some(clip_id), Some(fill_graphic_list)) = (clip_id.as_ref(), fill_graphic_list.as_deref())
11641164
{
11651165
emit_svg_fill_clip(render, clip_id, fill_graphic_list, item_transform, render_params);
11661166
}
@@ -1248,7 +1248,7 @@ impl Render for List<Vector> {
12481248
if !needs_separate_alignment_fill
12491249
&& !use_face_fill
12501250
&& (wants_stroke_below || override_paint_order)
1251-
&& let (Some(clip_id), Some(fill_graphic_list)) = (clip_id.as_ref(), fill_graphic_list.as_ref())
1251+
&& let (Some(clip_id), Some(fill_graphic_list)) = (clip_id.as_ref(), fill_graphic_list.as_deref())
12521252
{
12531253
emit_svg_fill_clip(render, clip_id, fill_graphic_list, item_transform, render_params);
12541254
}
@@ -1342,17 +1342,16 @@ impl Render for List<Vector> {
13421342
let use_layer = can_draw_aligned_stroke;
13431343
let wants_stroke_below = stroke.as_ref().is_some_and(|s| s.paint_order == vector::style::PaintOrder::StrokeBelow);
13441344

1345+
// Try to use ATTR_FILL_GRAPHIC attribute, which is set by `fill_graphic` debug node, then fall back to Fill enum.
1346+
// TODO: Drop the Fill fall back once the Fill node becomes ready to store corresponding Graphic list directly.
1347+
let fill_graphic_list: Option<Cow<List<Graphic>>> = self
1348+
.attribute::<List<Graphic>>(ATTR_FILL_GRAPHIC, index)
1349+
.filter(|t| !t.is_empty())
1350+
.map(Cow::Borrowed)
1351+
.or_else(|| fill_to_graphic_list(element.style.fill()).map(Cow::Owned));
1352+
13451353
let do_fill_path = |scene: &mut Scene, context: &mut RenderContext, path: &kurbo::BezPath, fill_rule: peniko::Fill| {
1346-
// Try to use ATTR_FILL_GRAPHIC attribute, which is set by `fill_graphic` debug node, then fall back to Fill enum.
1347-
// TODO: Drop the Fill fall back once the Fill node becomes ready to store corresponding Graphic list directly.
1348-
let Some(fill_graphic) = self
1349-
.attribute::<List<Graphic>>(ATTR_FILL_GRAPHIC, index)
1350-
.filter(|t| !t.is_empty())
1351-
.map(Cow::Borrowed)
1352-
.or_else(|| fill_to_graphic_list(element.style.fill()).map(Cow::Owned))
1353-
else {
1354-
return;
1355-
};
1354+
let Some(fill_graphic) = fill_graphic_list.as_deref() else { return };
13561355

13571356
for paint_idx in 0..fill_graphic.len() {
13581357
let Some(paint) = fill_graphic.element(paint_idx) else { continue };

0 commit comments

Comments
 (0)