VectorCraft: An open-source, vector art tool written by scratch in pure Rust
Make renderer and SVG module dependencies explicit
Dylan M. Taylor7e44df55a94f
diff --git a/crates/render/src/blobs.rs b/crates/render/src/blobs.rsindex ea2f41b26..2cecb1324 100644--- a/crates/render/src/blobs.rs+++ b/crates/render/src/blobs.rs@@ -1,4 +1,4 @@-use super::*;+use super::{Affine, Arc, BezPath, Ink, Node, Pixmap, Shape, images, ink, paint};/// `key`'s pixels in the shared image store; `touch` marks them used.pub(crate) fn lookup(key: &images::ImageKey, touch: bool) -> Option<Arc<Pixmap>> {diff --git a/crates/render/src/bounds.rs b/crates/render/src/bounds.rsindex 05fb6f0f4..dec8db1c5 100644--- a/crates/render/src/bounds.rs+++ b/crates/render/src/bounds.rs@@ -1,4 +1,4 @@-use super::*;+use super::{BezPath, Document, FillRule, Node, NodeKind, Rect, SymbolBoxes, brush_fx, fx};/// Bounds of everything `n` paints, as the renderer culls it: its members, strokes, brush art and/// geometry effects, and the shadows and glows of it and its members. Symbol instances arediff --git a/crates/render/src/frame.rs b/crates/render/src/frame.rsindex 29b317ce4..2191bc06a 100644--- a/crates/render/src/frame.rs+++ b/crates/render/src/frame.rs@@ -1,6 +1,6 @@use super::options::{AntiAlias, RenderOptions};use super::threads::single_threaded_context;-use super::*;+use super::{Affine, Arc, BezPath, Document, FillRule, HashMap, Ink, Node, Rect, RenderContext, SymbolBoxes, TextObject, live};/// Hasher for pointer-keyed caches: a multiply-xorshift (SipHash showed up in frame profiles).#[derive(Default, Clone, Copy)]diff --git a/crates/render/src/fx/bounds.rs b/crates/render/src/fx/bounds.rsindex f19270140..41c9eca2b 100644--- a/crates/render/src/fx/bounds.rs+++ b/crates/render/src/fx/bounds.rs@@ -1,6 +1,8 @@use super::predicates::{has_fx, has_object_fx};use super::raster::doc_raster_ppi;-use super::*;+use super::{+ Affine, AppearanceItem, Arc, BezPath, Document, Effect, FillRule, GeomContext, Node, NodeKind, Rect, Renderer, Shape, SymbolBoxes, effects,+};fn node_bezpath(n: &Node) -> Option<BezPath> {match &n.kind {diff --git a/crates/render/src/fx/entries.rs b/crates/render/src/fx/entries.rsindex f933f2307..cd9acb109 100644--- a/crates/render/src/fx/entries.rs+++ b/crates/render/src/fx/entries.rs@@ -1,5 +1,8 @@use super::raster::ViewCrop;-use super::*;+use super::{+ Affine, AppearanceItem, Arc, BezPath, Channels, Cms, DefaultHasher, FillRule, Hash, Hasher, Node, NodeId, NodeKind, PathEl, Point, RasterFx,+ Rect, Size, Weak, effects,+};/// What [`Renderer::raster_fx`] paints effects around.pub(super) struct Content<'a> {diff --git a/crates/render/src/fx/pixels.rs b/crates/render/src/fx/pixels.rsindex 27fb7f588..e73e708dd 100644--- a/crates/render/src/fx/pixels.rs+++ b/crates/render/src/fx/pixels.rs@@ -6,7 +6,10 @@ use super::raster::{DRAG_PIXEL_BUDGET, PIXEL_BUDGET, PixelEntry, ViewCrop, content_changing, doc_raster_ppi, drag_scale, draw_placed, draw_scaled, filter_region,filter_region_within, hard_edged, image_size, linear_key, looks_around, pan_margin,};-use super::*;+use super::{+ Affine, AppearanceItem, Arc, BezPath, Channels, DefaultHasher, Document, FillRule, Frame, GeomContext, Hash, Hasher, Ink, Node, PixelFx,+ RasterFx, Rect, RenderContext, Renderer, Shape, blend_mode, effects, fill_rule, paint, peniko,+};impl Renderer {/// Paint `content` through the content-changing effects of `rfx` (Gaussian Blur, Feather, thediff --git a/crates/render/src/fx/predicates.rs b/crates/render/src/fx/predicates.rsindex 2f4d66adb..f54d996a9 100644--- a/crates/render/src/fx/predicates.rs+++ b/crates/render/src/fx/predicates.rs@@ -1,5 +1,5 @@use super::bounds::drawn_bounds;-use super::*;+use super::{Affine, AppearanceItem, Effect, Frame, Node, NodeKind, RasterFx, Rect, SymbolBoxes, Vec2, effects};fn visible(effects: &[Effect]) -> bool {effects.iter().any(|e| e.visible)diff --git a/crates/render/src/fx/raster.rs b/crates/render/src/fx/raster.rsindex 20d0ddcdd..6648b321d 100644--- a/crates/render/src/fx/raster.rs+++ b/crates/render/src/fx/raster.rs@@ -1,5 +1,5 @@use super::entries::{Drawn, Inputs, Made, raster_bytes};-use super::*;+use super::{Affine, Document, EdgeMode, Filter, FilterPrimitive, Ink, RasterFx, Rect, RenderContext, Vec2, effects, peniko};pub(super) fn shadow_filter(dx: f64, dy: f64, blur: f64, color: peniko::Color) -> Filter {Filter::from_primitive(FilterPrimitive::DropShadowOnly {diff --git a/crates/render/src/fx/renderer.rs b/crates/render/src/fx/renderer.rsindex ccd8d9ad7..7924f51a6 100644--- a/crates/render/src/fx/renderer.rs+++ b/crates/render/src/fx/renderer.rs@@ -5,7 +5,10 @@ use super::raster::{DRAG_PIXEL_BUDGET, MAX_RASTERIZE, PIXEL_BUDGET, ViewCrop, content_changing, doc_raster_ppi, image_size, linear_key, pan_margin, pcolor, shade,shade_filter, shadow_filter, silhouette,};-use super::*;+use super::{+ Affine, Arc, BezPath, FillRule, Frame, GeomContext, Ink, Node, NodeKind, RasterFx, Rect, RenderContext, Renderer, Shape, Vec2, blend_mode,+ effects, fill_rule, peniko,+};impl Renderer {/// Drop shadow / outer glow `fx` (shadow-cache slot `i` of `n`) as a cached raster: thediff --git a/crates/render/src/geometry.rs b/crates/render/src/geometry.rsindex 90053c8cd..c9c472727 100644--- a/crates/render/src/geometry.rs+++ b/crates/render/src/geometry.rs@@ -1,4 +1,4 @@-use super::*;+use super::{BezPath, Rect, kurbo};/// Most dashes a dotted guide is drawn with (1.5 on, 2.5 off on screen); a longer one is solid.pub(crate) const MAX_GUIDE_DASHES: f64 = 100_000.0;diff --git a/crates/render/src/node_checks.rs b/crates/render/src/node_checks.rsindex a85854443..6e2be3f2e 100644--- a/crates/render/src/node_checks.rs+++ b/crates/render/src/node_checks.rs@@ -1,4 +1,4 @@-use super::*;+use super::{Affine, AppearanceItem, Arc, BezPath, Node, NodeKind, StrokeLayer, brush_fx, effects};/// Most pixels from the origin that a shape handed to the rasterizer may reach, or a stroke be/// wide. A document's art stays within 4 million points, 2.6 billion pixels at the closest zoom.diff --git a/crates/render/src/options.rs b/crates/render/src/options.rsindex 7aaf365b2..036c85da0 100644--- a/crates/render/src/options.rs+++ b/crates/render/src/options.rs@@ -1,5 +1,5 @@use super::geometry::region_pixels;-use super::*;+use super::{Arc, NodeId, Rect, encode, proof};/// Largest raster an export may ask [`Renderer::render_region`] for, per side. The CPU rasteriser/// addresses at most `u16::MAX` pixels per side (and panics at that edge).diff --git a/crates/render/src/paint.rs b/crates/render/src/paint.rsindex 5dfb6307c..7b3b3ec72 100644--- a/crates/render/src/paint.rs+++ b/crates/render/src/paint.rs@@ -5,7 +5,7 @@ use vectorcraft_geom::{Rect, Vec2};use vello_cpu::RenderContext;use vello_cpu::peniko::{self, ColorStop};-use super::*;+use super::{BlendMode, Compose, FillRule, Mix, vello_cpu};use crate::Frame;/// Set the context paint (colours as frame `f` paints them). Returns false if nothing should bediff --git a/crates/render/src/renderer.rs b/crates/render/src/renderer.rsindex e713841b7..81fb0c573 100644--- a/crates/render/src/renderer.rs+++ b/crates/render/src/renderer.rs@@ -12,7 +12,11 @@ use super::options::{AntiAlias, ISOLATION_DIM, MAX_CONTEXT_SIDE, RenderOptions,use super::paint::{SUBSTITUTED, blend_mode, fill_rule};use super::text_geom::{TextGeom, text_geom, text_geom_snapped};use super::threads::{default_threads, single_threaded_context};-use super::*;+use super::{+ Affine, AppearanceItem, Arc, BezPath, BlendMode, Compose, Composite, Document, FillRule, FrameCache, HashMap, Ink, Mix, Node, NodeId, NodeKind,+ Pixmap, Rect, RenderContext, Renderer, Resources, Shape, StrokeAlign, StrokeLayer, SymbolBoxes, TextObject, TraceView, brush_fx, effects, fx,+ group, ink, kurbo, live, lru, peniko, proof, vello_cpu,+};mod images;mod nodes;diff --git a/crates/render/src/renderer/images.rs b/crates/render/src/renderer/images.rsindex f87a1edb9..372b6103b 100644--- a/crates/render/src/renderer/images.rs+++ b/crates/render/src/renderer/images.rs@@ -1,4 +1,7 @@-use super::*;+use super::{+ Affine, Arc, BezPath, Document, FillRule, Frame, HashMap, Pixmap, Rect, RenderContext, Renderer, Shape, blob_key, blob_pixmap, fill_rule,+ image_mip, ink, lookup, mip_level, peniko, vello_cpu,+};use crate::images;impl Renderer {diff --git a/crates/render/src/renderer/nodes.rs b/crates/render/src/renderer/nodes.rsindex 6eedf3da1..7e1fd1f11 100644--- a/crates/render/src/renderer/nodes.rs+++ b/crates/render/src/renderer/nodes.rs@@ -1,4 +1,9 @@-use super::*;+use super::{+ Affine, Arc, BezPath, ClipEntry, ClipPaintEntry, Compose, Composite, Document, FillRule, Frame, GeomEntry, ISOLATION_DIM, Ink, MAX_GUIDE_DASHES,+ Node, NodeId, NodeKind, Rect, RenderContext, RenderOptions, Renderer, Shape, SymbolBoxes, TraceView, blend_mode, brush_fx, effects, fx, group,+ holds_instance, holds_plugin_effect, kurbo, lru, mask_value, painted_items, plain_image, polygon_length, rects_overlap, single_plain_fill,+ text_geom_snapped,+};impl Renderer {/// Cached cull bounds of a node (containers union their cached children), symbol instancesdiff --git a/crates/render/src/renderer/paint.rs b/crates/render/src/renderer/paint.rsindex 36e3e53e9..9a6a48142 100644--- a/crates/render/src/renderer/paint.rs+++ b/crates/render/src/renderer/paint.rs@@ -1,4 +1,8 @@-use super::*;+use super::{+ Affine, AppearanceItem, Arc, BezPath, BlendMode, Compose, FillRule, Frame, Ink, Mix, Node, Rect, RenderContext, Renderer, Shape, SliceEntry,+ Slices, StrokeAlign, StrokeEntry, StrokeLayer, TextGeom, blend_mode, drawable, effects, fill_rule, fx, kurbo, lru, owns_stroke, peniko,+ rects_overlap,+};use crate::paint;impl Renderer {diff --git a/crates/render/src/renderer/text.rs b/crates/render/src/renderer/text.rsindex f5536a667..c478861ea 100644--- a/crates/render/src/renderer/text.rs+++ b/crates/render/src/renderer/text.rs@@ -1,4 +1,8 @@-use super::*;+use super::{+ Affine, AppearanceItem, Arc, BezPath, BlendMode, FillRule, Frame, MAX_INLINE_DEPTH, MISSING_INLINE_LOGGED, Node, NodeKind, PlacedEntry,+ PlacedKey, Rect, RenderContext, Renderer, SUBSTITUTED, Shape, TextGeom, TextObject, blend_mode, blob_pixmap, depends_on_document, fx, holds_type,+ image_mip, ink, kurbo, lru, peniko, place, proof, stain_bits, text_geom, text_geom_snapped, vello_cpu,+};use crate::paint;impl Renderer {diff --git a/crates/render/src/text_geom.rs b/crates/render/src/text_geom.rsindex 9c2ddad2f..1408b397b 100644--- a/crates/render/src/text_geom.rs+++ b/crates/render/src/text_geom.rs@@ -1,4 +1,4 @@-use super::*;+use super::{Affine, Arc, BezPath, Node, Rect, Shape, TextObject, lru};/// The whole text's glyph outlines as one path, and which of them each run draws.pub(crate) struct TextGeom {diff --git a/crates/render/src/threads.rs b/crates/render/src/threads.rsindex 13a833a3b..eb1fb66ea 100644--- a/crates/render/src/threads.rs+++ b/crates/render/src/threads.rs@@ -1,4 +1,4 @@-use super::*;+use super::{RenderContext, vello_cpu};/// A render context on the calling thread. vello_cpu's `RenderContext::new` defaults to a/// multithreaded dispatcher, which panics on filter effects (glows, shadows, blur).diff --git a/crates/svg/src/export/nodes.rs b/crates/svg/src/export/nodes.rsindex 69d700844..6ce6a5427 100644--- a/crates/svg/src/export/nodes.rs+++ b/crates/svg/src/export/nodes.rs@@ -1,7 +1,10 @@use super::output::{sanitize_id, valid_xml_value, xml_attr_escape};use super::paint::{StrokePlan, has_raster, pixel_gradient};use super::text::OUTLINE_TOLERANCE;-use super::*;+use super::{+ Affine, AppearanceItem, BezPath, BlendMode, Document, FillRule, Node, NodeKind, Paint, PathData, Props, Rect, StrokeLayer, Writer, Written,+ WrittenShape, blend_css, css, fmt_num, stroke, xml_escape,+};/// A symbol's `<symbol>` def and the instance transforms that can `<use>` it.pub(super) struct SymbolDef {diff --git a/crates/svg/src/export/paint.rs b/crates/svg/src/export/paint.rsindex 412098b72..6662978b0 100644--- a/crates/svg/src/export/paint.rs+++ b/crates/svg/src/export/paint.rs@@ -1,6 +1,10 @@use super::nodes::{MASK, doc_path};use super::output::sanitize_id;-use super::*;+use super::{+ Affine, BezPath, BlendMode, Color, FillLayer, FillRule, GradientKind, GradientPaint, HashMap, ImageBlob, ImageMode, LineCap, LineJoin,+ LinkedImage, Node, NodeKind, Paint, PathData, Point, Props, Rect, StrokeAlign, StrokeLayer, Writer, Written, base64_encode, blend_css, fmt_num,+ stroke, xml_escape,+};/// Image `b` as SVG viewers show it: PNG, JPEG, GIF, WebP and SVG as they are, other formats (a/// CMYK TIFF) as PNG.diff --git a/crates/svg/src/export/text.rs b/crates/svg/src/export/text.rsindex 7b5e55d84..20d87e2d1 100644--- a/crates/svg/src/export/text.rs+++ b/crates/svg/src/export/text.rs@@ -1,5 +1,9 @@use super::output::xml_text;-use super::*;+use super::{+ Affine, AppearanceItem, Arc, BTreeSet, BezPath, BlendMode, CharStyle, FillRule, FontDb, FontFace, GradientKind, HashMap, Justify, Node, NodeId,+ NodeKind, Paint, PathData, Props, Rect, StrokeAlign, TextKind, TextObject, Writer, base64_encode, css, css_string, fmt_num, font_descriptor,+ xml_escape,+};/// `chars` (sorted) as a CSS `unicode-range` (`U+41-5A,U+61`).fn unicode_range(chars: &BTreeSet<char>) -> String {diff --git a/crates/svg/src/import/convert.rs b/crates/svg/src/import/convert.rsindex 18e8b756b..40c2cf577 100644--- a/crates/svg/src/import/convert.rs+++ b/crates/svg/src/import/convert.rs@@ -1,4 +1,4 @@-use super::*;+use super::{Affine, Arc, BezPath, BlendMode, Color, FillRule, GradientStop, HashMap, Node, Point, XNode, roxmltree};/// `n` with every object id (its descendants' and its mask art's too) zeroed, to compare art.pub(super) fn without_ids(n: &Node) -> Node {diff --git a/crates/svg/src/import/importer.rs b/crates/svg/src/import/importer.rsindex f487eb4ee..82cbfd7da 100644--- a/crates/svg/src/import/importer.rs+++ b/crates/svg/src/import/importer.rs@@ -1,7 +1,11 @@use super::convert::{aff, bezpath, blend, clip_shapes, gradient_stops, is_plain, made_up, rule, uncut, unique_name, without_ids};use super::layers::filter_names;use super::prepass::link;-use super::*;+use super::{+ Affine, Appearance, AppearanceItem, Arc, BlendMode, Color, Dash, FillLayer, FillRule, Gradient, GradientGeom, GradientKind, GradientPaint,+ GradientStop, ImageBlob, ImageObject, Importer, LineCap, LineJoin, Node, NodeKind, Paint, PathData, PatternDef, Point, Rect, Reuse, StrokeLayer,+ Vec2, fnv1a, fx, shapes, spread, text, vector_effect,+};/// How many clip paths deep (`<clipPath clip-path>`) an object's clip is read.const MAX_CLIP_NEST: usize = 16;diff --git a/crates/svg/src/import/layers.rs b/crates/svg/src/import/layers.rsindex 8dad45368..04e388794 100644--- a/crates/svg/src/import/layers.rs+++ b/crates/svg/src/import/layers.rs@@ -1,6 +1,6 @@use super::convert::made_up;use super::importer::{CSS_PX_PER_IN, PT_PER_IN};-use super::*;+use super::{Affine, Arc, FromStr, HashSet, Node, NodeId, NodeKind, Rect, Unit, XNode, roxmltree};/// What marks a nested `<g>` as a sublayer rather than a group: our export writes it on the layers/// it writes inside layers. (Inkscape's `inkscape:groupmode="layer"` counts too.)diff --git a/crates/svg/src/import/prepass.rs b/crates/svg/src/import/prepass.rsindex eb9519567..8018138dc 100644--- a/crates/svg/src/import/prepass.rs+++ b/crates/svg/src/import/prepass.rs@@ -1,6 +1,9 @@use super::convert::{MADE_UP_ID, href};use super::layers::{INKSCAPE, marked_layer};-use super::*;+use super::{+ Cow, ForeignAttribute, HashMap, HashSet, ImportOptions, MAX_SVG_SCRIPTS, Node, SVG_EVENTS, XNode, css, css_transform, files, roxmltree,+ symbol_units, vector_effect,+};/// What usvg would lose, found in the XML before it runs ([`prepass`]).#[derive(Default)]