Concept to Vector: a part-at-a-time trace finishes instead of stopping

- TraceSteps::step finishes the trace when every layer is already traced,
  instead of returning no result from then on.
- Drop the comment about Overlapping relabeling a layer's mask, which the
  stacked trace from #7204 replaced.
- The task bar test clicks the button it finds by its label; an image's
  four actions wrap onto a second row in the test's window.
- Test that a hidden clipping path's stroke still moves the inserted row.
- docs/ui-parity.md names every part Cancel waits for on the web build.
- American spelling in new comments; docs/gaps.md G18 names no vendor.
This commit is contained in:
dotCooCoo
2026-11-13 20:26:33 -08:00
parent 083f6dec9d
commit 2907edc001
9 changed files with 37 additions and 31 deletions
+1 -1
View File
@@ -162,7 +162,7 @@ impl super::Provider for TraceStyles {
Ok(out)
}
/// The image decoded in the first part; then for each style, its colour layers found in one
/// The image decoded in the first part; then for each style, its color layers found in one
/// part and each layer traced in a part of its own ([`tr::TraceSteps`]), or all of them in
/// one part where the style stacks them (Overlapping with Fills).
fn parts(&self, request: &Request) -> Option<Box<dyn Parts>> {
+10 -2
View File
@@ -387,7 +387,7 @@ fn malformed_results_panics_and_cancels_keep_no_job_and_change_nothing() {
}
/// A part at a time (the web build's way): the built-in provider decodes the image in one part,
/// finds a style's colour layers in another and traces one layer a part (all of them in one part
/// finds a style's color layers in another and traces one layer a part (all of them in one part
/// for a style that stacks them), and makes the variations
/// one call makes; Cancel takes effect before the next part, inside a style.
#[test]
@@ -404,7 +404,7 @@ fn the_built_in_styles_are_made_a_part_at_a_time() {
first_style_parts = calls;
}
}
// The decode, the layers found, and the four colours' layers each a part.
// The decode, the layers found, and the four colors' layers each a part.
assert!(first_style_parts >= 5, "{first_style_parts} parts before the first style was made");
assert_eq!(parts.made(), run.run(&|_, _| true).unwrap());
@@ -662,6 +662,14 @@ fn insert_goes_beside_the_image_in_a_group_with_art_far_away() {
let r = s.execute("conceptVector.insert", &json!({"job": job, "variations": ["flatColor"]})).unwrap();
let placed = bounds(&s, r["ids"][0].as_u64().unwrap());
assert!(placed.x0 >= 1000.0 + GAP, "painted clipping path: {placed:?}");
// Hidden, the clipping path still paints its stroke, so the row still goes past it.
s.execute("edit.undo", &json!({})).unwrap();
s.execute("object.hide", &json!({"ids": [mask]})).unwrap();
assert!(!s.doc().unwrap().doc.node(NodeId(mask)).unwrap().visible);
let r = s.execute("conceptVector.insert", &json!({"job": job, "variations": ["flatColor"]})).unwrap();
let placed = bounds(&s, r["ids"][0].as_u64().unwrap());
assert!(placed.x0 >= 1000.0 + GAP, "hidden painted clipping path: {placed:?}");
}
/// An Image Trace object whose art paints past its image (here a drop shadow) keeps the row clear
+9 -10
View File
@@ -218,8 +218,6 @@ fn trace_paths(img: &Raster, params: &TraceParams, max_anchors: usize, steps: St
// A layer takes about ten bytes a pixel of its box while it is traced (its mask, the labels
// of its components, the stack that fills them, its edges): as many layers at a time as fit
// in half a gigabyte, so that a large image is not traced at the cost of gigabytes.
// (Overlapping labels a layer's mask once more before it is traced, with its labels and stack
// freed before the trace starts.)
let at_a_time = ((512 << 20) / (p.largest() * 10)).max(1);
let total = p.layers.len() as u64;
if !steps(0, total) {
@@ -262,7 +260,7 @@ impl std::ops::Deref for Source<'_> {
}
}
/// A trace with its colour layers found and ordered, none of them traced yet.
/// A trace with its color layers found and ordered, none of them traced yet.
struct Prepared<'a> {
src: Source<'a>,
/// A copy with a JPEG's block edges (see `deblock`) or a photo's noise (see `smooth`) smoothed
@@ -359,7 +357,7 @@ impl Prepared<'_> {
}
/// A trace made a part at a time, for a caller with no thread to trace on that must let other
/// work run between the parts (the web build). The first [`TraceSteps::step`] finds the colour
/// work run between the parts (the web build). The first [`TraceSteps::step`] finds the color
/// layers and each later one traces one layer, bottom first, one at a time (Overlapping with
/// Fills, without Create Strokes, traces all of them in the second step, as its layers are traced
/// together); the result is the one [`trace_within`] gives.
@@ -409,13 +407,14 @@ impl TraceSteps {
let paths = prepared.job(0).stacked(&prepared.layers, prepared.largest(), &|_, _| true)?;
return Ok(Some(grouped((*prepared).finish_stacked(paths), &self.img, &self.params)));
}
let Some(&(r, ci)) = prepared.layers.get(traced.len()) else { return Ok(None) };
let (paths, anchors) = {
// With every layer traced already the result is finished below.
let mut anchors = anchors;
if let Some(&(r, ci)) = prepared.layers.get(traced.len()) {
let job = prepared.job(anchors);
let paths = job.layer(r, ci);
(paths, job.anchors.load(Ordering::Relaxed))
};
traced.push(Some(paths.ok_or(TraceError::TooComplex { max: self.max_anchors })?));
anchors = job.anchors.load(Ordering::Relaxed);
traced.push(Some(paths.ok_or(TraceError::TooComplex { max: self.max_anchors })?));
}
if traced.len() < prepared.layers.len() {
self.state = StepState::Layers(prepared, traced, anchors);
return Ok(None);
@@ -424,7 +423,7 @@ impl TraceSteps {
}
}
/// Finds the colour layers of `src` traced with `params` and the order they stack in, telling
/// Finds the color layers of `src` traced with `params` and the order they stack in, telling
/// `steps(0, 0)` after each stage; Logo mode traces the whole image at once.
fn prepare<'a>(src: Source<'a>, params: &TraceParams, max_anchors: usize, steps: Steps) -> Result<Begun<'a>, TraceError> {
let (w, h) = (src.width as usize, src.height as usize);
+2 -1
View File
@@ -1017,7 +1017,8 @@ fn a_watched_trace_counts_its_layers_and_stops_when_told() {
}
/// A trace made a part at a time finds its layers in the first part and traces one layer a part
/// after it, and gives what one call gives, Auto Grouping, Logo mode and the anchor budget included.
/// after it (all of them in the second part for Overlapping with Fills, which stacks them), and
/// gives what one call gives, Auto Grouping, Logo mode and the anchor budget included.
#[test]
fn a_trace_made_a_part_at_a_time_matches_one_made_at_once() {
fn parts(img: &Raster, p: &TraceParams, max: usize) -> (usize, Result<TraceResult, TraceError>) {
+8 -10
View File
@@ -10256,14 +10256,12 @@ fn the_task_bar_traces_an_image_then_expands_the_trace() {
app.run("file.place", json!({"name": "half.png", "dataBase64": data, "link": false, "at": [200, 150]})).unwrap();
app.select_tool("selection");
let ctx = egui::Context::default();
let click_first = |app: &mut VectorcraftApp| {
frame(app, &ctx, vec![]);
frame(app, &ctx, vec![]);
let bar = task_bar_rect(&ctx).expect("the task bar shows");
// Left to right: the frame's margin, the handle and its spacing, then the first button, in
// the middle of the first row (the frame's margin and half a 30 pt row), since an image's
// actions can wrap onto a second row.
let at = pos2(bar.left() + 8.0 + 4.0 + 6.0 + 12.0, bar.top() + 7.0 + 15.0);
// Clicks the button labeled `label`, which must be the bar's first. In this 800 pt window an
// image's four actions take two rows, so the button is found by its label, not by its place.
let click_first = |app: &mut VectorcraftApp, label: &str| {
let labels = task_bar_labels(app, &ctx);
assert_eq!(labels.first().map(|(t, _)| t.as_str()), Some(label), "{labels:?}");
let at = labels[0].1.center();
let button = |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() };
frame(app, &ctx, vec![egui::Event::PointerMoved(at)]);
frame(app, &ctx, vec![button(true)]);
@@ -10274,11 +10272,11 @@ fn the_task_bar_traces_an_image_then_expands_the_trace() {
st.selection.objects.first().and_then(|id| st.doc.node(*id)).cloned().unwrap()
};
assert!(matches!(first(&app).kind, NodeKind::Image(_)));
click_first(&mut app);
click_first(&mut app, "Image Trace");
assert_eq!(first(&app).name.as_deref(), Some("Image Trace"), "the image was traced");
assert_eq!(app.ui.open_panel, None, "the Image Trace panel is left as it was");
click_first(&mut app);
click_first(&mut app, "Expand");
let expanded = first(&app);
assert_ne!(expanded.name.as_deref(), Some("Image Trace"), "the trace was expanded");
let mut images = 0;
+1 -1
View File
@@ -9,7 +9,7 @@
//! are named as that provider names its styles. The results stay in this session
//! until Insert Selected puts the ticked ones in the document as one undo step
//! (`conceptVector.insert`). The web build has no thread for it, so it makes one part a frame
//! (the built-in provider: the image decoded, a style's colour layers found, or one colour layer
//! (the built-in provider: the image decoded, a style's color layers found, or one color layer
//! traced, or all of them for a style that stacks its layers), and Cancel takes effect before the
//! next part. Unit tests that set neither
//! `off_the_ui_thread` nor `by_frames` run the command at once.
@@ -358,7 +358,7 @@ fn a_preview_stops_at_its_point_limit_within_one_path() {
}
/// As on the web (no thread): Generate returns with the run going and nothing made; each frame
/// makes one part (the image decoded, a style's colour layers found, one layer traced), the styles
/// makes one part (the image decoded, a style's color layers found, one layer traced), the styles
/// are made in order, and the last part's frame shows them all.
#[test]
fn on_the_web_generate_makes_one_part_a_frame() {
@@ -388,7 +388,7 @@ fn on_the_web_generate_makes_one_part_a_frame() {
assert_eq!((undo_steps(&app), root_count(&app)), (steps, roots), "Generate changes nothing");
}
/// On the web, Cancel takes effect inside a style: after the image's colour layers are found and
/// On the web, Cancel takes effect inside a style: after the image's color layers are found and
/// one is traced, the run is dropped, and nothing is shown or changed.
#[test]
fn on_the_web_cancel_stops_a_style_part_way() {
@@ -397,7 +397,7 @@ fn on_the_web_cancel_stops_a_style_part_way() {
app.concept_runs.styles = vec!["flatColor".into()];
let (steps, roots) = (undo_steps(&app), root_count(&app));
generate(&mut app).unwrap();
// The image decoded, its colour layers found, and the first layer traced.
// The image decoded, its color layers found, and the first layer traced.
for _ in 0..3 {
poll(&mut app);
assert_eq!(made_so_far(&app), Some(0), "the one style is still being made");
+2 -2
View File
@@ -832,8 +832,8 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi
by id (`crates/engine/src/concept_vector.rs`); the only one is built in and makes five offline Image Trace
styles.
- **Missing:** Text to Vector Graphic, Generative Recolor, Generative Shape Fill (#766), Generative Expand,
Concept to Vector's prompt-led generation and raster output, Prompt to Edit, Rewrite Text. Adobe's run on
its cloud models; ours would be a pluggable provider.
Concept to Vector's prompt-led generation and raster output, Prompt to Edit, Rewrite Text. The reference features run on
cloud models; ours would be a pluggable provider.
- **Needs:** an owner decision on models and providers.
- **Estimate:** 30–60 h after that decision.
+1 -1
View File
@@ -405,7 +405,7 @@ next unit in the order a right-click on a ruler lists them, from Feet back to Po
| Image Trace panel: holding the eye button next to View down shows the selected Image Trace objects' source image on the canvas | done | Per the public documentation, the control next to View is pressed and held to compare the trace result with the source image (<https://web.archive.org/web/20250831090623/https://helpx.adobe.com/illustrator/using/image-trace.html>). On release the objects show their View again; the document, its View and the undo history are unchanged. `RenderOptions::trace_source`; `panels/image_trace.rs` headless test `holding_the_eye_button_shows_the_source_image_until_released`, render test `trace_source_draws_the_source_image_of_the_listed_objects`. The Control bar and Properties have no such button |
| Live trace result bounds and selection highlights exclude the retained bitmap; source-image views retain it | done | All TraceView modes and rotated result bounds regression-covered; ordinary hidden group behavior retained |
| Image Trace panel: the Preview checkbox before Trace chooses whether a setting change traces the selected Image Trace object again at once | done | Per the public documentation, Preview shows the result of the current settings and Trace traces with them (<https://web.archive.org/web/20250831090623/https://helpx.adobe.com/illustrator/using/image-trace.html>). Preview is on by default and kept with the UI preferences; Reset to Default leaves it. Off, changes wait in the panel until Trace applies them as one undo step, or until Preview is turned on again. Changes stay with the object they were made for while another object is selected, and come back when it is selected again. `imageTrace.preview {on?}`, `ui.set {imageTracePreview}`; `panels/image_trace.rs` headless tests (`with_preview_off_a_slider_change_waits_for_trace`, `turning_preview_on_traces_the_changes_that_waited`, `preview_turned_on_with_nothing_selected_traces_when_the_object_is_selected_again`, `settings_that_wait_stay_with_their_object`, `settings_that_wait_come_back_when_their_object_is_selected_again`, `settings_that_wait_are_dropped_when_their_object_changed_since`, `preview_is_kept_with_the_preferences_and_reset_to_default_leaves_it`) |
| Concept to Vector panel: Window › Concept to Vector and Object › Concept to Vector… (also the context menu, the Contextual Task Bar, Properties' Quick Actions and the Control bar) open it for one image or unexpanded Image Trace object; it makes 1 to 8 styles side by side and Insert Selected puts the ticked ones to the right of the image as one undo step | partial | The help page describes choosing up to 8 styles of the selected image to compare side by side (<https://helpx.adobe.com/illustrator/desktop/use-generative-ai/generate-vector-artwork-from-images.html>). The built-in provider makes five offline Image Trace styles with Detail 0 to 100; its prompt field is disabled and it makes no raster output. On the web build a run is made one part a frame, so Cancel takes effect inside a style; the Detailed Color and Gray Tones styles trace all their color layers in one part, and Cancel waits for that part to end. `conceptVector.providers`, `conceptVector.generate`, `conceptVector.results`, `conceptVector.cancel`, `conceptVector.insert`; `panels/concept_vector.rs` headless tests |
| Concept to Vector panel: Window › Concept to Vector and Object › Concept to Vector… (also the context menu, the Contextual Task Bar, Properties' Quick Actions and the Control bar) open it for one image or unexpanded Image Trace object; it makes 1 to 8 styles side by side and Insert Selected puts the ticked ones to the right of the image as one undo step | partial | The help page describes choosing up to 8 styles of the selected image to compare side by side (<https://helpx.adobe.com/illustrator/desktop/use-generative-ai/generate-vector-artwork-from-images.html>). The built-in provider makes five offline Image Trace styles with Detail 0 to 100; its prompt field is disabled and it makes no raster output. On the web build a run is made one part a frame, so Cancel takes effect inside a style. Decoding the image, finding a style's color layers and tracing one layer are each one part; the Detailed Color and Gray Tones styles trace all their color layers in one part. Cancel waits for the part in progress to end. `conceptVector.providers`, `conceptVector.generate`, `conceptVector.results`, `conceptVector.cancel`, `conceptVector.insert`; `panels/concept_vector.rs` headless tests |
| Toolbar without group labels by default, one or two columns; All Tools drawer by flyout group with shortcuts, its menu (Reset, Basic, Advanced) and Show section | done | #1751; a preference brings the labels back; `toolbar.show` sets the Fill/Stroke, Coloring, Draw Mode and Screen Mode controls |
| Actions panel: ≡ › Save Actions… saves the current set with all its actions to a file and ≡ › Load Actions… adds a saved set ([Manage a set of actions](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/manage-a-set-of-actions.html)) | partial | `ui.actionSet.save`, `ui.actionSet.load`; `panels/actions.rs` tests. The file is VectorCraft's own `.vcactions` JSON; Reset, Clear and Replace Actions remain |
| Actions panel: ≡ › Load Actions… also reads action sets saved as `.aia` files ([Actions panel overview](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/actions-panel-overview.html)) | partial | `actionSet.read`, `ui.actionSet.load`; `tests/actionset.rs`, `panels/actions.rs` tests, `import_fuzz`. Only steps with a label and no recorded values come in, as menu commands that run with no values and open no dialog, matched by label; the other steps, recorded menu items included, are left out and counted |