mirror of
https://github.com/storytold/AniCraft.git
synced 2026-11-28 13:38:05 -08:00
chore: merge main into fix/backlog-web-build
This commit is contained in:
commit
9fbe4a9f79
40 files changed
+1563
-166
No files matched your search
@@ -2,13 +2,13 @@
|
||||
"schema": "craft-nightly-release-policy/v3",
|
||||
"repository": "storytold/anicraft",
|
||||
"repository_id": 1419518094,
|
||||
"producer_workflow_id": null,
|
||||
"producer_workflow_id": 429745835,
|
||||
"producer_workflow_path": ".github/workflows/nightly.yml",
|
||||
"producer_tooling_revision": "605d58766e8f536564da8fc81d3676ac86816dea",
|
||||
"producer_workflow_ref": "storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@605d58766e8f536564da8fc81d3676ac86816dea",
|
||||
"producer_tooling_revision": "bf94b15b708089b95c4e2d1c978e66ecf1f2f4f3",
|
||||
"producer_workflow_ref": "storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@bf94b15b708089b95c4e2d1c978e66ecf1f2f4f3",
|
||||
"signer_workflow_path": ".github/workflows/nightly-sign.yml",
|
||||
"signer_tooling_revision": "605d58766e8f536564da8fc81d3676ac86816dea",
|
||||
"release_branch": "release",
|
||||
"signer_tooling_revision": "bf94b15b708089b95c4e2d1c978e66ecf1f2f4f3",
|
||||
"release_branch": "nightly-signer",
|
||||
"manual_actors": [
|
||||
"bflatastic",
|
||||
"dylanmtaylor",
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
name: AniCraft release-ref nightly signer
|
||||
|
||||
# Enabled for supervised manual dispatch on release. Main/release contents must match.
|
||||
# A reusable callee does not change context; this must be a real top-level release dispatch.
|
||||
# Enabled for supervised manual dispatch on the dedicated nightly-signer branch, which only ever
|
||||
# fast-forwards to reviewed main commits (never the stable release branch).
|
||||
# A reusable callee does not change context; this must be a real top-level signer-branch dispatch.
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
@@ -23,21 +24,37 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
release:
|
||||
# Actual context guards: official repository, manual dispatch, real release branch.
|
||||
# Actual context guards: official repository, manual dispatch, real nightly-signer branch.
|
||||
if: >-
|
||||
github.repository == 'storytold/anicraft' &&
|
||||
github.event_name == 'workflow_dispatch' &&
|
||||
github.ref == 'refs/heads/release' && github.ref_type == 'branch'
|
||||
github.ref == 'refs/heads/nightly-signer' && github.ref_type == 'branch'
|
||||
permissions:
|
||||
contents: write
|
||||
actions: read
|
||||
checks: read
|
||||
attestations: write
|
||||
id-token: write
|
||||
uses: storytold/craft-common-actions/.github/workflows/nightly-release.yml@605d58766e8f536564da8fc81d3676ac86816dea
|
||||
uses: storytold/craft-common-actions/.github/workflows/nightly-release.yml@bf94b15b708089b95c4e2d1c978e66ecf1f2f4f3
|
||||
with:
|
||||
tooling-revision: 605d58766e8f536564da8fc81d3676ac86816dea
|
||||
tooling-revision: bf94b15b708089b95c4e2d1c978e66ecf1f2f4f3
|
||||
app-name: anicraft
|
||||
producer_run_id: ${{ inputs.producer_run_id }}
|
||||
producer_run_attempt: ${{ inputs.producer_run_attempt }}
|
||||
secrets:
|
||||
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
|
||||
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
||||
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
|
||||
APPLE_ID: ${{ secrets.APPLE_ID }}
|
||||
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
||||
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
||||
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
|
||||
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
|
||||
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
|
||||
AZURE_SIGNING_ENDPOINT: ${{ secrets.AZURE_SIGNING_ENDPOINT }}
|
||||
AZURE_SIGNING_ACCOUNT: ${{ secrets.AZURE_SIGNING_ACCOUNT }}
|
||||
AZURE_CERT_PROFILE: ${{ secrets.AZURE_CERT_PROFILE }}
|
||||
LINUX_SIGNING_KEY: ${{ secrets.LINUX_SIGNING_KEY }}
|
||||
# No secrets: inherit or raw platform values in this caller. Only the isolated native
|
||||
# callee job may bind the existing release environment and export keys in its signing step.
|
||||
# callee job may bind the release environment and export its keys; that environment must
|
||||
# admit nightly-signer alongside release before the first dispatch.
|
||||
@@ -22,13 +22,14 @@ jobs:
|
||||
actions: read
|
||||
attestations: write
|
||||
id-token: write
|
||||
uses: storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@605d58766e8f536564da8fc81d3676ac86816dea
|
||||
uses: storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@bf94b15b708089b95c4e2d1c978e66ecf1f2f4f3
|
||||
with:
|
||||
tooling-revision: 605d58766e8f536564da8fc81d3676ac86816dea
|
||||
tooling-revision: bf94b15b708089b95c4e2d1c978e66ecf1f2f4f3
|
||||
app-name: anicraft
|
||||
manual-actors: '["bflatastic","dylanmtaylor","echelon","FredApps","skylartaylor"]'
|
||||
craft-fonts-ref: b076417b5880bd4154bd22f00695b1d28c6bea83
|
||||
# One producer run builds every listed platform for one all-or-nothing release. The pin is the
|
||||
# craft-common-actions main commit that merged #339 (bounded lineage compares), on top of the
|
||||
# Linux/macOS signer (#342).
|
||||
# craft-common-actions main commit that merged the exact-analysis admission (#371, after #370,
|
||||
# #369 and #364).
|
||||
platforms: '["windows-x86_64","linux-x86_64","macos-aarch64"]'
|
||||
linux-package-formats: '["deb","rpm","appimage","flatpak","oci","arch"]'
|
||||
+2
-2
@@ -22,7 +22,7 @@ People who have contributed to AniCraft. The repository starts from one initial
|
||||
* nocturney: localisation tests (Hebrew plurals, the product name).
|
||||
* Vincent Agerbech (va-moviestarplanet): XFL group placement.
|
||||
* scks1: raw drawings that align, distribute, turn and take strokes as one shape.
|
||||
* Untoldent: the selection stipple and its gradient detail (#404), the scene breadcrumb, names selected in dialogs.
|
||||
* Untoldent: the selection stipple and its gradient detail (#404), the scene breadcrumb, names selected in dialogs, the GPU's count of filtered scratch memory in flight (#664), no stale pasteboard fragments while stage tiles are replaced (#669).
|
||||
* gmrmad1: the zoom field, the Scale lock, playhead and scene-end fixes.
|
||||
* Koolskull: group registration at the centre of the artwork.
|
||||
* Kushagra Kumar (kk376): drawing with the camera layer hidden.
|
||||
@@ -37,6 +37,6 @@ People who have contributed to AniCraft. The repository starts from one initial
|
||||
* Hagai Baram (hrb9): the Hebrew fallback face, `iw` read as Hebrew, and right-to-left language detection, private-use tags included (#486).
|
||||
* FredApps: a test that linked artwork survives SVG export and re-import (#500).
|
||||
* Ayberk A. (AyberkA0): View Only the Active Layer, frame stepping that stops at the ends, a press that selects at once, an empty cell that selects, transparent PNG frames, the marquee that takes what it touches, Distribute to Layers, Match Size and Space Evenly, filter cards that fold, raw shapes moved from Properties, To Stage inside a symbol, aligning by outlines, and a swatch that closes the picker (#572 to #584).
|
||||
* ViktorBystrov72: stage zoom measured in device pixels, Hide Edges, and fitting the stage to an imported SVG (#590, #588, #587).
|
||||
* ViktorBystrov72: stage zoom measured in device pixels, Hide Edges, fitting the stage to an imported SVG, and the fitted zoom kept when the zoom field loses focus (#590, #588, #587, #633).
|
||||
* Neel Patel (N-NeelPatel): Convert Lines to Fills in a shape's properties (#562).
|
||||
* rcoenen: an imported Animate file that keeps its name, and the macOS crash on closing the window, with the move to egui 0.37 (#596, #594).
|
||||
@@ -18,6 +18,31 @@
|
||||
are now checked in headless Chrome by `scripts/web-check.sh`. Releases don't carry the web
|
||||
build yet (#316): the zip is made, the release workflow has to be told to attach it.
|
||||
|
||||
* **No line of the stage between merged fills** (backlog P-013, ADR 0138, #182). Two fills of
|
||||
one merged drawing that share an edge, such as a shape cut by a curve, showed a hairline of
|
||||
whatever was below along it: each was anti-aliased on its own and drawn over the other.
|
||||
Fills of one drawing are now added up where they meet, on the stage (CPU and GPU), in Test
|
||||
Movie and in every picture and video export; a mask drawn as several fills no longer leaks
|
||||
along their edges. The same frame takes the same time to draw (2.4 ms for 1,000 joined fills
|
||||
at 1280 × 720). Not yet in SVG, HTML and Lottie exports, where the viewer draws each fill.
|
||||
* **A preference for the marquee** (Preferences › Stage): **The marquee takes objects it
|
||||
touches**, on as before. Off, a box dragged with the Selection tool takes only the objects
|
||||
wholly inside it. Headless: `view.select_touching {on}`, and `touch` on `raw.select_rect`.
|
||||
* **The guide tells the truth** (backlog P-016). Every "not yet" in the guide was checked
|
||||
against the code. "Coming from Animate" no longer lists as missing what has shipped (moving
|
||||
the Tools panel, Asset Warp, the Paint Brush, Ctrl+J and the panel keys, saved workspaces,
|
||||
document tabs, Envelope, bone springs, the brush library and pressure curves, per-character
|
||||
styles, text on a path), and the drawing chapter covers the Paint Brush, pressure curves and
|
||||
the Brush Library.
|
||||
* **From outside** (M8): leaving the zoom field without typing
|
||||
keeps a fitted view, and the view's centre is right at very small zooms (ViktorBystrov72,
|
||||
#633); no fragments of an older picture show on the pasteboard while stage tiles are
|
||||
replaced (Untoldent, #669); the GPU counts the scratch memory of filtered work still in
|
||||
flight and hands a tile to the CPU instead of running out (Untoldent, #664; in the browser,
|
||||
where that can't be counted, filtered layers still draw on the GPU).
|
||||
* **A test that failed now and then** (`stage_work_is_submitted_only_inside_the_frame`): it
|
||||
watched the window's submit gate, which every other test that draws a frame opens and closes
|
||||
from its own thread. It now has a gate of its own; nothing in the app changed.
|
||||
## 0.3.0 (2026-11-28)
|
||||
|
||||
The first release since 0.2.1 (2026-11-12). It carries everything listed below, from the Flash 8 to
|
||||
|
||||
+22
-3
@@ -120,6 +120,11 @@ pub struct DisplayItem {
|
||||
/// image as drawn (`rest`) to where it shows (`shown`); renderers draw the image through
|
||||
/// its triangles. `None` for everything else (a warped shape's path is already bent).
|
||||
pub warp: Option<Arc<crate::warp::WarpMesh>>,
|
||||
/// This item and the one before it are shapes of one merged drawing (ADR 0031: the raw
|
||||
/// shapes of one keyframe, whose fills lie side by side and never under each other). Where
|
||||
/// two such fills share an edge a renderer adds up what each covers of a pixel instead of
|
||||
/// drawing one over the other, so nothing below shows through the edge (ADR 0138).
|
||||
pub joins: bool,
|
||||
}
|
||||
|
||||
/// Back-to-front list of shapes.
|
||||
@@ -1036,12 +1041,14 @@ fn eval_timeline(doc: &Document, tl: &Timeline, frame: u32, cx: &Ctx<'_>, out: &
|
||||
image: None,
|
||||
smooth: true,
|
||||
warp: None,
|
||||
joins: false,
|
||||
});
|
||||
}
|
||||
let Some((kf_start, elements)) = shown else { continue };
|
||||
// Data bindings (ADR 0118): a table's column in place of a bound instance's property.
|
||||
let elements = doc.bound_elements(elements, frame);
|
||||
let lc = LayerCtx { layer, frame, kf_start, clip, masks, guide, outline: layer_outline, xf: layer_xf };
|
||||
let merged = std::cell::Cell::new(usize::MAX);
|
||||
let lc = LayerCtx { layer, frame, kf_start, clip, masks, guide, outline: layer_outline, xf: layer_xf, merged: &merged };
|
||||
// A layer below full opacity (its own, or a folder's it is in; ADR 0111) fades as one:
|
||||
// its artwork composites in a group, and the group blends at the layer's opacity, so
|
||||
// its overlapping parts don't show through each other. Mask artwork ignores opacity,
|
||||
@@ -1075,6 +1082,10 @@ struct LayerCtx<'a> {
|
||||
outline: Option<Rgba>,
|
||||
/// The layer's space (and, inside a group, the group's) to stage space.
|
||||
xf: Affine,
|
||||
/// How long the display list was just after this layer's last merged shape went into it
|
||||
/// (`usize::MAX` before the first): a merged shape that goes in at that length follows
|
||||
/// another of the same drawing ([`DisplayItem::joins`]).
|
||||
merged: &'a std::cell::Cell<usize>,
|
||||
}
|
||||
|
||||
fn eval_element(doc: &Document, cx: &Ctx<'_>, lc: &LayerCtx<'_>, el: &Element, out: &mut DisplayList, play: Option<&Play<'_>>) {
|
||||
@@ -1083,7 +1094,7 @@ fn eval_element(doc: &Document, cx: &Ctx<'_>, lc: &LayerCtx<'_>, el: &Element, o
|
||||
if !cx.work.visit(el) {
|
||||
return;
|
||||
}
|
||||
let LayerCtx { layer, frame, kf_start, clip, masks, guide, outline: layer_outline, xf: layer_xf } = *lc;
|
||||
let LayerCtx { layer, frame, kf_start, clip, masks, guide, outline: layer_outline, xf: layer_xf, merged: _ } = *lc;
|
||||
// In the player, a symbol instance has its own path, and maybe properties a script set.
|
||||
let child = match (&el.kind, play) {
|
||||
(ElementKind::Symbol { .. }, Some(p)) => Some(p.child(el.id)),
|
||||
@@ -1114,7 +1125,12 @@ fn eval_element(doc: &Document, cx: &Ctx<'_>, lc: &LayerCtx<'_>, el: &Element, o
|
||||
Some(x) => x,
|
||||
None => (s.path.clone(), xf, s.fill.clone(), s.stroke.clone()),
|
||||
};
|
||||
let joins = s.merge && lc.merged.get() == out.items.len();
|
||||
if s.merge {
|
||||
lc.merged.set(out.items.len() + 1);
|
||||
}
|
||||
out.items.push(DisplayItem {
|
||||
joins,
|
||||
path,
|
||||
transform,
|
||||
fill,
|
||||
@@ -1172,6 +1188,7 @@ fn eval_element(doc: &Document, cx: &Ctx<'_>, lc: &LayerCtx<'_>, el: &Element, o
|
||||
image: None,
|
||||
smooth: true,
|
||||
warp: None,
|
||||
joins: false,
|
||||
};
|
||||
match &t.field {
|
||||
// Mask artwork: a field's text masks; its box and border don't.
|
||||
@@ -1203,7 +1220,9 @@ fn eval_element(doc: &Document, cx: &Ctx<'_>, lc: &LayerCtx<'_>, el: &Element, o
|
||||
(color, cx.group)
|
||||
};
|
||||
let inner = Ctx { color, depth: cx.depth + 1, root: Some((root_layer, root_el)), group, slice: None, camera: None, ..*cx };
|
||||
let lc = LayerCtx { xf, ..*lc };
|
||||
// A group's raw shapes merge only with each other: a drawing of their own.
|
||||
let merged = std::cell::Cell::new(usize::MAX);
|
||||
let lc = LayerCtx { xf, merged: &merged, ..*lc };
|
||||
for m in members.layers.iter().rev().filter(|l| l.visible && l.kind != LayerKind::Guide).filter_map(|l| l.keyframe_at(0)).flat_map(|k| k.elements.iter()) {
|
||||
eval_element(doc, &inner, &lc, m, out, play);
|
||||
}
|
||||
|
||||
@@ -1142,3 +1142,26 @@ fn layers_long_outlines_and_long_libraries_count_as_work() {
|
||||
let dl = evaluate(&modest, 0);
|
||||
assert!(!dl.left_out && dl.items.len() == 1 << 10);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shapes_of_one_merged_drawing_join_the_one_before() {
|
||||
// Raw shapes of one keyframe join each other (ADR 0138); a drawing object between them,
|
||||
// and another layer's drawing, don't.
|
||||
let raw = |id| {
|
||||
let mut e = shape_el(id, 0.0);
|
||||
if let ElementKind::Shape(s) = &mut e.kind {
|
||||
s.merge = true;
|
||||
}
|
||||
e
|
||||
};
|
||||
let mut d = Document::default();
|
||||
for e in [raw(1), raw(2), shape_el(3, 0.0), raw(4), raw(5)] {
|
||||
push(layer0(&mut d), 0, e);
|
||||
}
|
||||
let mut bottom = Layer::new(LayerId(7), "bottom");
|
||||
push(&mut bottom, 0, raw(6));
|
||||
push(&mut bottom, 0, raw(7));
|
||||
d.timeline_mut(0).layers.push(Arc::new(bottom));
|
||||
let joins: Vec<(u64, bool)> = evaluate(&d, 0).items.iter().map(|i| (i.element.0, i.joins)).collect();
|
||||
assert_eq!(joins, [(6, false), (7, true), (1, false), (2, true), (3, false), (4, false), (5, true)]);
|
||||
}
|
||||
@@ -46,7 +46,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Select Parts",
|
||||
"",
|
||||
None,
|
||||
"{x0, y0, x1, y1, add?: bool} the marquee, on every visible, unlocked layer: the parts of raw fills and strokes under the rectangle (cut at its edges, per layer) and the objects it touches",
|
||||
"{x0, y0, x1, y1, add?: bool, touch?: bool} the marquee, on every visible, unlocked layer: the parts of raw fills and strokes under the rectangle (cut at its edges, per layer) and the objects it touches, or with `touch` false only the objects wholly inside it (default: as view.select_touching is set)",
|
||||
true,
|
||||
select_rect,
|
||||
),
|
||||
@@ -631,11 +631,13 @@ fn on_editable_key(s: &Session) -> bool {
|
||||
}
|
||||
|
||||
/// The marquee (ADR 0041, 0044): on every visible, unlocked layer, the parts of raw shapes under
|
||||
/// the rectangle (cut at its edges) and the objects it touches (#522).
|
||||
/// the rectangle (cut at its edges) and the objects it touches (#522), or only those wholly
|
||||
/// inside it when touching isn't enough (`view.select_touching`).
|
||||
fn select_rect(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let a = Vec2::new(f32_req(p, "x0")?, f32_req(p, "y0")?);
|
||||
let b = Vec2::new(f32_req(p, "x1")?, f32_req(p, "y1")?);
|
||||
let add = opt_bool(p, "add")?.unwrap_or(false);
|
||||
let touch = opt_bool(p, "touch")?.unwrap_or(s.aids.select_touching);
|
||||
let r = Rect::from_points(a, b);
|
||||
if !add {
|
||||
s.selection.clear();
|
||||
@@ -655,10 +657,12 @@ fn select_rect(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
continue;
|
||||
}
|
||||
// An object (instance, group, drawing object, text, bitmap) the marquee touches is
|
||||
// taken whole (#522); a raw shape partly under it is cut at its edges.
|
||||
if contains(&r, &bounds) || mergeable(&e).is_none() {
|
||||
// taken whole (#522), unless only objects wholly inside it are wanted; a raw shape
|
||||
// partly under it is cut at its edges.
|
||||
let raw = mergeable(&e).is_some();
|
||||
if contains(&r, &bounds) || (touch && !raw) {
|
||||
picked.push(e.id);
|
||||
} else {
|
||||
} else if raw {
|
||||
partial.push(e.id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,16 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
c("view.guide_delete", "Delete Guide", "", None, "{index} removes this scene's guide `index`; refused while guides are locked", true, guide_delete),
|
||||
c("view.guides_clear", "Clear Guides", "View/Guides", None, "{} removes every guide from this scene (undoable)", true, guides_clear),
|
||||
c("view.snap_pixels", "Snap to Pixels", "View/Snapping", None, "{on?: bool} (default: toggle) points being drawn, dragged or moved go to whole stage pixels where nothing else snaps them", false, |s, p| toggle(s, p, |a| &mut a.snap_pixels)),
|
||||
c("view.aids", "Rulers, Grid and Guides", "", None, "{} whether the rulers, grid and guides show and snap, whether selection edges are hidden, the grid's and guides' settings, and this scene's guides [{axis, at}, ..]", false, |s, _| Ok(aids_json(s))),
|
||||
c(
|
||||
"view.select_touching",
|
||||
"Marquee Takes Touched Objects",
|
||||
"",
|
||||
None,
|
||||
"{on?: bool} (default: toggle) the marquee takes the objects it only touches (on, as AniCraft starts) or only the objects wholly inside it; kept with the preferences",
|
||||
false,
|
||||
|s, p| toggle(s, p, |a| &mut a.select_touching),
|
||||
),
|
||||
c("view.aids", "Rulers, Grid and Guides", "", None, "{} whether the rulers, grid and guides show and snap, whether selection edges are hidden, whether the marquee takes objects it only touches (select_touching), the grid's and guides' settings, and this scene's guides [{axis, at}, ..]", false, |s, _| Ok(aids_json(s))),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -65,6 +74,7 @@ pub(crate) fn aids_json(s: &Session) -> Value {
|
||||
"guides": {"show": a.show_guides, "lock": a.lock_guides, "snap": a.snap_guides, "accuracy": a.guide_accuracy.key(), "color": color_hex(s.doc.aids.guide_color), "list": guides_json(s)},
|
||||
"snap_pixels": a.snap_pixels,
|
||||
"snap_objects": s.style.snap_objects,
|
||||
"select_touching": a.select_touching,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -387,3 +387,26 @@ fn a_moved_selection_floats_until_it_is_deselected() {
|
||||
assert_eq!(run(&mut o, "draw.float", json!({}))["floating"], 0);
|
||||
assert!(o.floating.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn merged_fills_leave_no_line_of_the_stage_between_them() {
|
||||
// Issue #182: an oval drawn over a rectangle cuts it along a curve; the white stage must
|
||||
// not show along the cut (ADR 0138). Red and blue have no green; the stage is all green.
|
||||
let mut s = blank();
|
||||
run(&mut s, "draw.rect", json!({"x": 100, "y": 100, "w": 300, "h": 200, "fill": "#ff0000", "stroke": null}));
|
||||
run(&mut s, "draw.ellipse", json!({"x": 180, "y": 130, "w": 140, "h": 110, "fill": "#0000ff", "stroke": null}));
|
||||
assert_eq!(count(&s), (2, 0));
|
||||
let dl = anicraft_doc::evaluate(&s.doc, 0);
|
||||
assert!(dl.items.last().is_some_and(|i| i.joins), "the fills of one drawing join");
|
||||
// At a zoom that puts the curve across pixels every way.
|
||||
let scale = 1.37;
|
||||
let pm = anicraft_render::render_frame(&s.doc, 0, scale).unwrap();
|
||||
let px = |v: f32| (v * scale) as u32;
|
||||
let mut worst = 0.0f32;
|
||||
for y in px(105.0)..px(295.0) {
|
||||
for x in px(105.0)..px(395.0) {
|
||||
worst = worst.max(pm.pixel(x, y).unwrap()[1]);
|
||||
}
|
||||
}
|
||||
assert!(worst < 0.01, "the stage shows through: {worst}");
|
||||
}
|
||||
@@ -676,4 +676,14 @@ fn a_marquee_takes_the_instances_and_groups_it_touches() {
|
||||
run(&mut s, "raw.select_rect", json!({"x0": -10, "y0": 50, "x1": 350, "y1": 150}));
|
||||
let kinds: Vec<&'static str> = s.selected_elements().iter().map(|(_, e)| match e.kind { ElementKind::Symbol { .. } => "symbol", ElementKind::Group { .. } => "group", _ => "other" }).collect();
|
||||
assert!(kinds.contains(&"symbol") && kinds.contains(&"group") && kinds.len() == 2, "{kinds:?}");
|
||||
// With touching switched off, only what is wholly inside: the same marquee takes nothing,
|
||||
// and one around the group takes the group alone.
|
||||
assert_eq!(run(&mut s, "view.select_touching", json!({"on": false}))["select_touching"], false);
|
||||
run(&mut s, "raw.select_rect", json!({"x0": -10, "y0": 50, "x1": 350, "y1": 150}));
|
||||
assert!(s.selection.is_empty(), "{:?}", s.selection.id_list());
|
||||
run(&mut s, "raw.select_rect", json!({"x0": 50, "y0": -10, "x1": 310, "y1": 110}));
|
||||
assert!(matches!(s.selected_elements().as_slice(), [(_, e)] if matches!(e.kind, ElementKind::Group { .. })));
|
||||
// One marquee can ask for the other way.
|
||||
run(&mut s, "raw.select_rect", json!({"x0": -10, "y0": 50, "x1": 350, "y1": 150, "touch": true}));
|
||||
assert_eq!(s.selection.len(), 2);
|
||||
}
|
||||
@@ -86,12 +86,15 @@ pub struct ViewAids {
|
||||
pub snap_pixels: bool,
|
||||
pub grid_accuracy: Accuracy,
|
||||
pub guide_accuracy: Accuracy,
|
||||
/// The marquee takes the objects it only touches (the default); off, only the objects
|
||||
/// wholly inside it. Raw shapes are cut at its edges either way.
|
||||
pub select_touching: bool,
|
||||
}
|
||||
|
||||
impl Default for ViewAids {
|
||||
fn default() -> Self {
|
||||
// As in Animate: guides show and snap; the rulers, grid and pixel snapping are off.
|
||||
ViewAids { rulers: false, hide_edges: false, show_grid: false, show_guides: true, lock_guides: false, snap_grid: false, snap_guides: true, snap_pixels: false, grid_accuracy: Accuracy::Normal, guide_accuracy: Accuracy::Normal }
|
||||
ViewAids { rulers: false, hide_edges: false, show_grid: false, show_guides: true, lock_guides: false, snap_grid: false, snap_guides: true, snap_pixels: false, grid_accuracy: Accuracy::Normal, guide_accuracy: Accuracy::Normal, select_touching: true }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -137,6 +137,7 @@ fn transform(tr: &Value, t: f64) -> (Affine, f64) {
|
||||
|
||||
fn item(path: Path, transform: Affine, fill: Option<Paint>, stroke: Option<Stroke>, rule: FillRule) -> DisplayItem {
|
||||
DisplayItem {
|
||||
joins: false,
|
||||
path: Arc::new(path),
|
||||
transform,
|
||||
fill,
|
||||
|
||||
@@ -82,6 +82,10 @@ pub const CLIPPED: u32 = 1;
|
||||
/// soft mask its paint composites into the level's colour).
|
||||
pub const ART: u32 = 2;
|
||||
|
||||
/// An op header's flags above this many bits: the fill's run of joined fills
|
||||
/// ([`Fill::run`], ADR 0138), or 0.
|
||||
pub const RUN_SHIFT: u32 = 2;
|
||||
|
||||
/// An entry whose first word has this bit is a control entry, not a fill.
|
||||
pub const CTRL: u32 = 0x8000_0000;
|
||||
/// `[OPEN, group, 0, 0]`: push the colour so far and continue on transparent.
|
||||
@@ -349,7 +353,9 @@ pub fn bin_with(scene: &Scene, width: u32, height: u32, gpu: Option<&crate::gpu_
|
||||
} else {
|
||||
0
|
||||
};
|
||||
op_heads.extend_from_slice(&[kind, rule, ramp, flags]);
|
||||
// A run numbered past what the flags hold (a billion items) is drawn unjoined.
|
||||
let run = if f.run < 1 << (32 - RUN_SHIFT) { f.run } else { 0 };
|
||||
op_heads.extend_from_slice(&[kind, rule, ramp, flags | (run << RUN_SHIFT)]);
|
||||
}
|
||||
paints.extend_from_slice(&ramps);
|
||||
if paints.len() != PAINT_VEC4S * ops.len() + table_len {
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
// colour, all in f32, as the oracle does. A hairline (ADR 0048) is 1 − the distance from the
|
||||
// pixel centre to its nearest segment (crates/render/src/hairline.rs).
|
||||
//
|
||||
// A run of joined fills (ADR 0138; crates/render/src/lib.rs › Fill::run) is added up on its own
|
||||
// and composited once, when the next entry isn't one of it: fills of one merged drawing lie
|
||||
// side by side, so the pixels of an edge two of them share are covered by both together.
|
||||
//
|
||||
// Masks and groups (ADR 0029) are control entries in the same list, mirroring the oracle's band
|
||||
// compositor (crates/render/src/lib.rs): clip artwork unites into a level's coverage (a soft
|
||||
// mask's, ADR 0070, composites its paint and gives its opacity or luminance), levels
|
||||
@@ -70,6 +74,8 @@ const CLIPPED: u32 = 1u;
|
||||
const ART: u32 = 2u;
|
||||
const MAX_GROUP_DEPTH: u32 = 8u;
|
||||
const HAIRLINE: u32 = 2u;
|
||||
// An op's run of joined fills is its flags above this many bits (0: none).
|
||||
const RUN_SHIFT: u32 = 2u;
|
||||
|
||||
// Mean of clamp(u, 0, 1) for u running linearly from u0 to u1.
|
||||
fn avg_clamp(u0: f32, u1: f32) -> f32 {
|
||||
@@ -389,11 +395,37 @@ fn pixel(wg: vec3<u32>, lid: vec3<u32>) -> vec4<f32> {
|
||||
// artwork's colour so far.
|
||||
var level_mode = 0u;
|
||||
var level_colour = vec4<f32>(0.0);
|
||||
// The run of joined fills being added up: its number (0: none), its colour and how much
|
||||
// of the pixel it covers so far, the clip coverage its fills are drawn in, and whether it
|
||||
// is clip artwork.
|
||||
var run = 0u;
|
||||
var run_c = vec4<f32>(0.0);
|
||||
var run_k = 0.0;
|
||||
var run_m = 1.0;
|
||||
var run_art = false;
|
||||
let start = index[tile * 2u];
|
||||
let count = index[tile * 2u + 1u];
|
||||
for (var i = 0u; i < count; i++) {
|
||||
let e = params.at.x + (start + i) * 4u;
|
||||
let op = index[e];
|
||||
var id = 0u;
|
||||
if (op & CTRL) == 0u {
|
||||
id = index[params.at.y + op * 4u + 3u] >> RUN_SHIFT;
|
||||
}
|
||||
if run != 0u && run != id {
|
||||
// The run ends (the oracle's `Run::flush` and `Run::end`).
|
||||
if run_art {
|
||||
if level_mode != 0u {
|
||||
level_colour = run_c + level_colour * (1.0 - run_c.a);
|
||||
} else {
|
||||
level = level + run_k - level * run_k;
|
||||
}
|
||||
} else {
|
||||
let s = run_c * run_m;
|
||||
c = s + c * (1.0 - s.a);
|
||||
}
|
||||
run = 0u;
|
||||
}
|
||||
if (op & CTRL) != 0u {
|
||||
switch op {
|
||||
case OPEN: {
|
||||
@@ -456,6 +488,35 @@ fn pixel(wg: vec3<u32>, lid: vec3<u32>) -> vec4<f32> {
|
||||
cov = fold(w, rule);
|
||||
}
|
||||
let flags = index[h + 3u];
|
||||
if id != 0u {
|
||||
if run == 0u {
|
||||
run = id;
|
||||
run_c = vec4<f32>(0.0);
|
||||
run_k = 0.0;
|
||||
run_art = (flags & ART) != 0u;
|
||||
run_m = select(1.0, mask, (flags & CLIPPED) != 0u);
|
||||
}
|
||||
// The oracle's `Run::add`: side by side as far as the pixel has room; what can't
|
||||
// be lies over the run.
|
||||
let k = min(cov, 1.0);
|
||||
if k > 1e-4 {
|
||||
let s = shade(op, index[h], index[h + 2u], centre, x, y);
|
||||
if k >= 1.0 && run_k <= 0.0 && !run_art {
|
||||
// Covered whole with nothing in the run yet: drawn at once.
|
||||
if run_m > 1e-4 {
|
||||
c = s * run_m + c * (1.0 - s.a * run_m);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let over = run_k + k - 1.0;
|
||||
if over > 0.0 && run_k > 0.0 {
|
||||
run_c *= 1.0 - over / run_k * s.a;
|
||||
}
|
||||
run_c += s * k;
|
||||
run_k = min(run_k + k, 1.0);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (flags & ART) != 0u {
|
||||
if level_mode != 0u {
|
||||
// Soft mask artwork composites as drawn (the oracle's `composite`).
|
||||
@@ -478,6 +539,11 @@ fn pixel(wg: vec3<u32>, lid: vec3<u32>) -> vec4<f32> {
|
||||
let s = shade(op, index[h], index[h + 2u], centre, x, y);
|
||||
c = s * cov + c * (1.0 - s.a * cov);
|
||||
}
|
||||
// A run the tile's list ends with (clip artwork's always ends at its level's end).
|
||||
if run != 0u && !run_art {
|
||||
let s = run_c * run_m;
|
||||
c = s + c * (1.0 - s.a);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
+18
-7
@@ -212,6 +212,8 @@ pub struct GpuRenderer {
|
||||
/// When work may be submitted on the window's device ([`SubmitGate`], ADR 0105).
|
||||
gate: Option<Arc<SubmitGate>>,
|
||||
filtered_flight: Mutex<FilteredFlight<wgpu::SubmissionIndex>>,
|
||||
/// Whether the scratch allowance is kept ([`fences`]).
|
||||
fenced: bool,
|
||||
/// First device failure (an error in a render, an uncaptured error or the device's loss).
|
||||
/// Once set, the renderer refuses to draw and callers fall back to the CPU.
|
||||
broken: Arc<Mutex<Option<String>>>,
|
||||
@@ -258,15 +260,20 @@ pub const MAX_LAYER_PIXELS: u64 = 1 << 23;
|
||||
const SHARED_FILTER_BYTES: u64 = 64 << 20;
|
||||
const DISCRETE_FILTER_BYTES: u64 = 128 << 20;
|
||||
|
||||
fn filter_budget(device_type: wgpu::DeviceType, backend: wgpu::Backend) -> u64 {
|
||||
match (device_type, backend) {
|
||||
// Device::poll(Wait) cannot fence a browser WebGPU submission.
|
||||
(_, wgpu::Backend::BrowserWebGpu) => 0,
|
||||
(wgpu::DeviceType::DiscreteGpu, _) => DISCRETE_FILTER_BYTES,
|
||||
fn filter_budget(device_type: wgpu::DeviceType) -> u64 {
|
||||
match device_type {
|
||||
wgpu::DeviceType::DiscreteGpu => DISCRETE_FILTER_BYTES,
|
||||
_ => SHARED_FILTER_BYTES,
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether a submission can be waited for, which is what the scratch allowance is counted by.
|
||||
/// In the browser `Device::poll(Wait)` can't wait for one, so there the allowance isn't kept:
|
||||
/// filtered layers are drawn as before it, within the per-call limits ([`MAX_LAYER_PIXELS`]).
|
||||
fn fences(backend: wgpu::Backend) -> bool {
|
||||
backend != wgpu::Backend::BrowserWebGpu
|
||||
}
|
||||
|
||||
/// Charge short-lived buffers with a page-sized minimum. This is an admission
|
||||
/// estimate, not a driver memory report.
|
||||
fn scratch_allocation(bytes: u64) -> u64 {
|
||||
@@ -532,7 +539,8 @@ impl GpuRenderer {
|
||||
Home::Window(gate) => gate,
|
||||
Home::Own => None,
|
||||
},
|
||||
filtered_flight: Mutex::new(FilteredFlight::new(filter_budget(info.device_type, info.backend))),
|
||||
filtered_flight: Mutex::new(FilteredFlight::new(filter_budget(info.device_type))),
|
||||
fenced: fences(info.backend),
|
||||
broken,
|
||||
};
|
||||
r.self_test()?;
|
||||
@@ -547,6 +555,7 @@ impl GpuRenderer {
|
||||
use anicraft_doc::{ColorTransform, DisplayItem, ElementId, Filter, Group, LayerId, Paint, Pixels, Rgba};
|
||||
use anicraft_geom::{Affine, FillRule, Path};
|
||||
let item = |path: Path, fill: Paint| DisplayItem {
|
||||
joins: false,
|
||||
path: Arc::new(path),
|
||||
transform: Affine::IDENTITY,
|
||||
fill: Some(fill),
|
||||
@@ -728,7 +737,9 @@ impl GpuRenderer {
|
||||
/// Reserve scratch before encoding, then charge it until that submission completes. Both
|
||||
/// window textures and headless readbacks share the same queue and the same allowance.
|
||||
fn reserve_filtered(&self, layers: u64, output: u64) -> Result<Option<FilterReservation<'_>>, GpuError> {
|
||||
if layers == 0 { return Ok(None); }
|
||||
if layers == 0 || !self.fenced {
|
||||
return Ok(None);
|
||||
}
|
||||
let bytes = layers + output;
|
||||
let mut flight = self.filtered_flight.lock().unwrap_or_else(PoisonError::into_inner);
|
||||
let room = flight.make_room(bytes, |index| self.device.poll(wgpu::PollType::Wait {
|
||||
|
||||
+108
-1
@@ -17,6 +17,7 @@ const MEAN_TARGET: f64 = 1.0;
|
||||
|
||||
fn item(path: Path, fill: Paint) -> DisplayItem {
|
||||
DisplayItem {
|
||||
joins: false,
|
||||
path: Arc::new(path),
|
||||
transform: Affine::IDENTITY,
|
||||
fill: Some(fill),
|
||||
@@ -144,6 +145,44 @@ fn filtered_scratch_counts_the_extra_allocations_for_higher_filter_quality() {
|
||||
assert!(cost(&job) > low_quality, "extra passes have scratch costs at the same layer size");
|
||||
}
|
||||
|
||||
/// Fills of one merged drawing (ADR 0138), each after the first joining the one before: the
|
||||
/// two halves of a square cut by a curve, a strip along its right side, and an ellipse lying
|
||||
/// over all three (a shape moved onto the drawing and not merged yet), turned off the pixel
|
||||
/// grid so the shared edges cross pixels and tiles every way. `alpha` fades every other fill.
|
||||
fn joined_parts(alpha: f32) -> Vec<DisplayItem> {
|
||||
let v = Vec2::new;
|
||||
let mut a = Path::new();
|
||||
a.move_to(v(0.0, 0.0));
|
||||
a.line_to(v(40.0, 0.0));
|
||||
a.cubic_to(v(63.0, 25.0), v(17.0, 55.0), v(40.0, 80.0));
|
||||
a.line_to(v(0.0, 80.0));
|
||||
a.close();
|
||||
let mut b = Path::new();
|
||||
b.move_to(v(40.0, 0.0));
|
||||
b.line_to(v(80.0, 0.0));
|
||||
b.line_to(v(80.0, 80.0));
|
||||
b.line_to(v(40.0, 80.0));
|
||||
b.cubic_to(v(17.0, 55.0), v(63.0, 25.0), v(40.0, 0.0));
|
||||
b.close();
|
||||
let parts = [
|
||||
(a, Rgba::new(0.9, 0.1, 0.1, 1.0)),
|
||||
(b, Rgba::new(0.1, 0.2, 0.9, alpha)),
|
||||
(Path::rect(80.0, 0.0, 30.0, 80.0), Rgba::new(0.2, 0.7, 0.3, 1.0)),
|
||||
(Path::ellipse(70.0, 40.0, 30.0, 21.0), Rgba::new(1.0, 0.9, 0.2, alpha)),
|
||||
];
|
||||
let place = Affine::translate(21.3, 7.6).mul(&Affine::rotate(0.1));
|
||||
parts
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.map(|(n, (path, color))| {
|
||||
let mut i = item(path, Paint::Solid(color));
|
||||
i.transform = place;
|
||||
i.joins = n > 0;
|
||||
i
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Analytic scenes: each stresses one part of the coverage or paint model.
|
||||
fn scenes() -> Vec<(&'static str, DisplayList, View)> {
|
||||
let red = Rgba::new(0.9, 0.1, 0.1, 1.0);
|
||||
@@ -247,6 +286,8 @@ fn scenes() -> Vec<(&'static str, DisplayList, View)> {
|
||||
huge.color = ColorTransform::alpha(0.5).concat(&ColorTransform::tint(Rgba::hex(0x4cd07d), 0.7));
|
||||
out.push(("off-surface", list(vec![huge]), view(100, 80, Some(Rgba::WHITE))));
|
||||
out.push(("outlines", outlined(), view(150, 110, Some(Rgba::WHITE))));
|
||||
out.push(("joined fills", list(joined_parts(1.0)), view(150, 110, Some(Rgba::WHITE))));
|
||||
out.push(("joined fills, faded", list(joined_parts(0.5)), view(150, 110, None)));
|
||||
out.extend(composited_scenes());
|
||||
out
|
||||
}
|
||||
@@ -406,6 +447,21 @@ fn composited_scenes() -> Vec<(&'static str, DisplayList, View)> {
|
||||
dl.set_clip_mode(1, MaskMode::Luminance);
|
||||
dl.set_clip_mode(3, MaskMode::Alpha);
|
||||
out.push(("soft masks", dl, view(120, 100, Some(Rgba::WHITE))));
|
||||
// Joined fills (ADR 0138) as a mask's artwork, as a soft mask's, inside a mask, and in a
|
||||
// group that fades.
|
||||
let art = |clip: u32, alpha: f32| joined_parts(alpha).into_iter().map(move |mut i| {
|
||||
i.masks = Some(clip);
|
||||
i
|
||||
});
|
||||
let mut items = vec![clipped(item(Path::rect(0.0, 0.0, 150.0, 110.0), grad()), 0)];
|
||||
items.extend(art(0, 1.0));
|
||||
items.push(clipped(item(Path::rect(0.0, 0.0, 150.0, 110.0), Paint::Solid(blue)), 1));
|
||||
items.extend(art(1, 0.5));
|
||||
items.extend(joined_parts(0.5).into_iter().map(|i| in_group(clipped(i, 2), 0)));
|
||||
items.push(mask(Path::ellipse(75.0, 50.0, 61.3, 44.1), 2));
|
||||
let mut dl = DisplayList { items, clip_parents: vec![None, None, None], groups: vec![group(None, 0.7, BlendMode::Normal)], ..Default::default() };
|
||||
dl.set_clip_mode(1, MaskMode::Alpha);
|
||||
out.push(("joined fills in masks and a group", dl, view(150, 110, Some(Rgba::WHITE))));
|
||||
out
|
||||
}
|
||||
|
||||
@@ -423,8 +479,30 @@ fn emulate(b: &Binned, v: &View) -> Vec<Premul> {
|
||||
let mut stack: Vec<Premul> = Vec::new();
|
||||
let (mut mask, mut level) = (1.0f32, 0.0f32);
|
||||
let (mut level_mode, mut level_colour) = (0u32, [0.0f32; 4]);
|
||||
for i in 0..count {
|
||||
// The run of joined fills being added up (ADR 0138), as `fine.wgsl` keeps it.
|
||||
let (mut run, mut run_c, mut run_k, mut run_m, mut run_art) = (0u32, [0.0f32; 4], 0.0f32, 1.0f32, false);
|
||||
for i in 0..=count {
|
||||
// One more turn after the last entry ends a run the list ends with.
|
||||
let e = b.entries_at as usize + (start + i) * 4;
|
||||
let id = if i == count || b.index[e] & bn::CTRL != 0 { 0 } else { b.op_heads[b.index[e] as usize * 4 + 3] >> bn::RUN_SHIFT };
|
||||
if run != 0 && run != id {
|
||||
if run_art && level_mode != 0 {
|
||||
for k in 0..4 {
|
||||
level_colour[k] = run_c[k] + level_colour[k] * (1.0 - run_c[3]);
|
||||
}
|
||||
} else if run_art {
|
||||
level = level + run_k - level * run_k;
|
||||
} else {
|
||||
let s = run_c.map(|v| v * run_m);
|
||||
for k in 0..4 {
|
||||
c[k] = s[k] + c[k] * (1.0 - s[3]);
|
||||
}
|
||||
}
|
||||
run = 0;
|
||||
}
|
||||
if i == count {
|
||||
break;
|
||||
}
|
||||
let (op, first, n, bd) = (b.index[e] as usize, b.index[e + 1] as usize, b.index[e + 2] as usize, b.index[e + 3]);
|
||||
match b.index[e] {
|
||||
bn::OPEN => {
|
||||
@@ -478,6 +556,34 @@ fn emulate(b: &Binned, v: &View) -> Vec<Premul> {
|
||||
b.paints[b.op_heads[hd + 2] as usize + i]
|
||||
}
|
||||
};
|
||||
if id != 0 {
|
||||
if run == 0 {
|
||||
(run, run_c, run_k, run_art) = (id, [0.0; 4], 0.0, flags & bn::ART != 0);
|
||||
run_m = if flags & bn::CLIPPED != 0 { mask } else { 1.0 };
|
||||
}
|
||||
let k = cov.min(1.0);
|
||||
if k > 1e-4 {
|
||||
let s = shade();
|
||||
if k >= 1.0 && run_k <= 0.0 && !run_art {
|
||||
if run_m > 1e-4 {
|
||||
for j in 0..4 {
|
||||
c[j] = s[j] * run_m + c[j] * (1.0 - s[3] * run_m);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let over = run_k + k - 1.0;
|
||||
if over > 0.0 && run_k > 0.0 {
|
||||
let keep = 1.0 - over / run_k * s[3];
|
||||
run_c = run_c.map(|v| v * keep);
|
||||
}
|
||||
for j in 0..4 {
|
||||
run_c[j] += s[j] * k;
|
||||
}
|
||||
run_k = (run_k + k).min(1.0);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if flags & bn::ART != 0 {
|
||||
if level_mode != 0 {
|
||||
if cov > 1e-4 {
|
||||
@@ -817,6 +923,7 @@ fn degenerate_geometry_bins_without_trouble() {
|
||||
group,
|
||||
layer: None,
|
||||
hairline: false,
|
||||
run: 0,
|
||||
};
|
||||
// A fill naming a layer that isn't there draws nothing.
|
||||
let mut lost = fill(None, None);
|
||||
|
||||
@@ -8,6 +8,7 @@ use std::sync::Arc;
|
||||
|
||||
fn item(path: Path, fill: Paint, rule: FillRule) -> DisplayItem {
|
||||
DisplayItem {
|
||||
joins: false,
|
||||
path: Arc::new(path),
|
||||
transform: Affine::IDENTITY,
|
||||
fill: Some(fill),
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
//! Fills of one merged drawing join without a seam (ADR 0138, issue #182): where two of them
|
||||
//! share an edge, nothing below shows through it.
|
||||
|
||||
use super::*;
|
||||
use anicraft_doc::{ElementId, LayerId};
|
||||
use anicraft_geom::Path;
|
||||
use std::sync::Arc;
|
||||
|
||||
fn item(path: Path, color: Rgba, joins: bool) -> DisplayItem {
|
||||
DisplayItem {
|
||||
joins,
|
||||
path: Arc::new(path),
|
||||
transform: Affine::IDENTITY,
|
||||
fill: Some(Paint::Solid(color)),
|
||||
stroke: None,
|
||||
fill_rule: FillRule::NonZero,
|
||||
color: ColorTransform::IDENTITY,
|
||||
layer: LayerId(0),
|
||||
element: ElementId(0),
|
||||
outline: None,
|
||||
clip: None,
|
||||
masks: None,
|
||||
guide: false,
|
||||
group: None,
|
||||
image: None,
|
||||
smooth: true,
|
||||
warp: None,
|
||||
}
|
||||
}
|
||||
|
||||
const RED: Rgba = Rgba::new(1.0, 0.0, 0.0, 1.0);
|
||||
const BLUE: Rgba = Rgba::new(0.0, 0.0, 1.0, 1.0);
|
||||
|
||||
/// The two halves of an 80 × 80 square cut by a curve from its top to its bottom (and by a
|
||||
/// slanted line across the left half: three fills, as the merge leaves them).
|
||||
fn halves(joins: bool, left: Rgba, right: Rgba) -> Vec<DisplayItem> {
|
||||
let v = Vec2::new;
|
||||
let mut a = Path::new();
|
||||
a.move_to(v(0.0, 0.0));
|
||||
a.line_to(v(40.0, 0.0));
|
||||
a.cubic_to(v(63.0, 25.0), v(17.0, 55.0), v(40.0, 80.0));
|
||||
a.line_to(v(0.0, 80.0));
|
||||
a.close();
|
||||
let mut b = Path::new();
|
||||
b.move_to(v(40.0, 0.0));
|
||||
b.line_to(v(80.0, 0.0));
|
||||
b.line_to(v(80.0, 80.0));
|
||||
b.line_to(v(40.0, 80.0));
|
||||
b.cubic_to(v(17.0, 55.0), v(63.0, 25.0), v(40.0, 0.0));
|
||||
b.close();
|
||||
vec![item(a, left, false), item(b, right, joins)]
|
||||
}
|
||||
|
||||
fn draw(items: Vec<DisplayItem>, transform: Affine, background: Option<Rgba>) -> Pixmap {
|
||||
let dl = DisplayList { items, ..Default::default() };
|
||||
render(&dl, &View { transform, width: 100, height: 100, background }).unwrap().0
|
||||
}
|
||||
|
||||
/// The view the tests look through: off the pixel grid, turned a little, so the shared edge
|
||||
/// crosses pixels every way.
|
||||
fn askew() -> Affine {
|
||||
Affine::translate(10.3, 9.7).mul(&Affine::rotate(0.07))
|
||||
}
|
||||
|
||||
/// The most green in any pixel well inside the square: the white background showing through
|
||||
/// red and blue.
|
||||
fn leak(pm: &Pixmap) -> f32 {
|
||||
let mut worst = 0.0f32;
|
||||
for y in 22..78 {
|
||||
for x in 22..78 {
|
||||
worst = worst.max(pm.pixel(x, y).unwrap()[1]);
|
||||
}
|
||||
}
|
||||
worst
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn joined_fills_hide_what_is_below_along_their_shared_edge() {
|
||||
let apart = leak(&draw(halves(false, RED, BLUE), askew(), Some(Rgba::WHITE)));
|
||||
let joined = leak(&draw(halves(true, RED, BLUE), askew(), Some(Rgba::WHITE)));
|
||||
// Drawn one over the other, the edge lets up to a quarter of the background through.
|
||||
assert!(apart > 0.1, "the picture has a seam to hide: {apart}");
|
||||
assert!(joined < apart / 50.0, "joined {joined}, apart {apart}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn joined_fills_keep_their_opacity_along_the_edge() {
|
||||
// Two half-transparent fills side by side are half-transparent everywhere, the edge too
|
||||
// (one over the other, the edge would be denser where both cover a pixel).
|
||||
let half = |c: Rgba| Rgba::new(c.r, c.g, c.b, 0.5);
|
||||
let pm = draw(halves(true, half(RED), half(BLUE)), askew(), None);
|
||||
for y in 22..78 {
|
||||
for x in 22..78 {
|
||||
let a = pm.pixel(x, y).unwrap()[3];
|
||||
assert!((a - 0.5).abs() < 0.01, "({x}, {y}): {a}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_joined_fill_lying_over_another_is_drawn_over_it() {
|
||||
// Not side by side (a shape moved onto another and not merged yet): wherever one of them
|
||||
// covers a pixel whole the picture is the one drawn one over the other, exactly.
|
||||
let pair = |joins: bool| {
|
||||
let under = item(Path::rect(5.25, 5.5, 70.0, 60.0), Rgba::new(1.0, 0.0, 0.0, 0.8), false);
|
||||
let over = item(Path::ellipse(40.0, 36.0, 21.3, 17.7), Rgba::new(0.0, 0.0, 1.0, 0.6), joins);
|
||||
draw(vec![under, over], Affine::IDENTITY, Some(Rgba::WHITE))
|
||||
};
|
||||
let (joined, apart) = (pair(true), pair(false));
|
||||
let worst = joined.data.iter().zip(&apart.data).flat_map(|(a, b)| a.iter().zip(b).map(|(x, y)| (x - y).abs())).fold(0.0f32, f32::max);
|
||||
assert!(worst < 1e-5, "{worst}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_stroke_between_two_fills_keeps_them_apart() {
|
||||
// The first fill's stroke is drawn between the two fills, so they can't be added up.
|
||||
let mut items = halves(true, RED, BLUE);
|
||||
items[0].stroke = Some(anicraft_doc::Stroke::new(Rgba::BLACK, 2.0));
|
||||
let dl = DisplayList { items, ..Default::default() };
|
||||
assert_eq!(joined_runs(&dl), vec![0, 0]);
|
||||
// Three in a row are one run; a fill in another clip or group is not of it.
|
||||
let third = || item(Path::rect(80.0, 0.0, 10.0, 80.0), RED, true);
|
||||
let mut items = halves(true, RED, BLUE);
|
||||
items.push(third());
|
||||
let dl = DisplayList { items, ..Default::default() };
|
||||
let runs = joined_runs(&dl);
|
||||
assert!(runs[0] != 0 && runs[0] == runs[1] && runs[1] == runs[2], "{runs:?}");
|
||||
let mut items = halves(true, RED, BLUE);
|
||||
items.push(DisplayItem { group: Some(0), ..third() });
|
||||
let dl = DisplayList { items, ..Default::default() };
|
||||
let runs = joined_runs(&dl);
|
||||
assert!(runs[0] != 0 && runs[0] == runs[1] && runs[2] == 0, "{runs:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_mask_of_joined_fills_reveals_along_their_shared_edge() {
|
||||
// The two halves as a mask layer's artwork over a white square: all of it shows.
|
||||
let reveal = |joins: bool| {
|
||||
let mut items = vec![DisplayItem { clip: Some(0), ..item(Path::rect(0.0, 0.0, 80.0, 80.0), Rgba::WHITE, false) }];
|
||||
items.extend(halves(joins, RED, BLUE).into_iter().map(|i| DisplayItem { masks: Some(0), ..i }));
|
||||
let dl = DisplayList { items, clip_parents: vec![None], ..Default::default() };
|
||||
let pm = render(&dl, &View { transform: askew(), width: 100, height: 100, background: None }).unwrap().0;
|
||||
let mut least = 1.0f32;
|
||||
for y in 22..78 {
|
||||
for x in 22..78 {
|
||||
least = least.min(pm.pixel(x, y).unwrap()[3]);
|
||||
}
|
||||
}
|
||||
least
|
||||
};
|
||||
assert!(reveal(false) < 0.9, "apart, the mask has a seam: {}", reveal(false));
|
||||
assert!(reveal(true) > 0.995, "{}", reveal(true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn joined_fills_fade_together_in_a_group() {
|
||||
// Inside a symbol instance at half opacity the edge is as opaque as the rest.
|
||||
let mut items = halves(true, RED, BLUE);
|
||||
for i in &mut items {
|
||||
i.group = Some(0);
|
||||
}
|
||||
let groups = vec![anicraft_doc::Group { parent: None, alpha: 0.5, blend: BlendMode::Normal, filters: Arc::from(Vec::new()), clip: None }];
|
||||
let dl = DisplayList { items, groups, ..Default::default() };
|
||||
let pm = render(&dl, &View { transform: askew(), width: 100, height: 100, background: None }).unwrap().0;
|
||||
for y in 22..78 {
|
||||
for x in 22..78 {
|
||||
let a = pm.pixel(x, y).unwrap()[3];
|
||||
assert!((a - 0.5).abs() < 0.01, "({x}, {y}): {a}");
|
||||
}
|
||||
}
|
||||
}
|
||||
+232
-11
@@ -158,10 +158,11 @@ fn render_cut(dl: &DisplayList, view: &View, cut: bool) -> Result<(Pixmap, Rende
|
||||
// Filtered groups are drawn on their own, filtered, and come back as one image each.
|
||||
let runs = filtered_runs(dl);
|
||||
let in_run = in_runs(dl, &runs);
|
||||
let joined = joined_runs(dl);
|
||||
|
||||
// Phase 1 (parallel over items): cull, flatten, stroke and build shaders. Output keeps
|
||||
// display-list order.
|
||||
let mut prepared: Vec<Vec<Prepared>> = dl.items.par_iter().zip(&in_run).map(|(item, &skip)| if skip { Vec::new() } else { prepare(item, &view.transform, surface, soft_art(dl, item), cut) }).collect();
|
||||
let mut prepared: Vec<Vec<Prepared>> = dl.items.par_iter().zip(&in_run).zip(&joined).map(|((item, &skip), &run)| if skip { Vec::new() } else { prepare(item, &view.transform, surface, soft_art(dl, item), cut, run) }).collect();
|
||||
for r in &runs {
|
||||
if let (Some(op), Some(slot)) = (filtered_group(dl, r, view, surface)?, prepared.get_mut(r.start)) {
|
||||
slot.push(op);
|
||||
@@ -185,6 +186,7 @@ fn render_cut(dl: &DisplayList, view: &View, cut: bool) -> Result<(Pixmap, Rende
|
||||
op.bounds = op.bounds.intersect(&clips.bounds(c));
|
||||
!op.bounds.is_empty()
|
||||
});
|
||||
drop_lone_runs(&mut ops);
|
||||
stats.drawn = ops.len();
|
||||
for op in &ops {
|
||||
stats.edges += op.polys.iter().map(Vec::len).sum::<usize>();
|
||||
@@ -208,11 +210,20 @@ fn render_cut(dl: &DisplayList, view: &View, cut: bool) -> Result<(Pixmap, Rende
|
||||
// Open groups, outermost first: each composites into its own band buffer, which blends
|
||||
// into the one below at the group's alpha when the group's run of ops ends.
|
||||
let mut open: Vec<OpenGroup> = Vec::new();
|
||||
// The run of joined fills being added up (ADR 0138); it goes into the group or the rows
|
||||
// its fills are drawn in when the next op isn't one of it. Its buffers are this
|
||||
// thread's, kept from band to band and frame to frame (a run leaves them empty):
|
||||
// making them anew for every band cost as much as the drawing.
|
||||
let mut run = RUN.take();
|
||||
for op in &ops {
|
||||
let b = IRect { x0: op.bounds.x0, y0: op.bounds.y0.max(band.y0), x1: op.bounds.x1, y1: op.bounds.y1.min(band.y1) };
|
||||
if b.is_empty() {
|
||||
continue;
|
||||
}
|
||||
if run.id != 0 && run.id != op.run {
|
||||
let mask = run.clip.map(|c| band_clips.get(&clips, c, band, w, &mut cov, &mut row));
|
||||
run.flush(band.y0, w, open.last_mut().map_or(&mut *rows, |top| &mut top.buf), mask.as_deref().map(Vec::as_slice));
|
||||
}
|
||||
let want = op.group.and_then(|g| chains.get(g as usize)).map_or(&[][..], Vec::as_slice);
|
||||
let keep = open.iter().zip(want).take_while(|(o, g)| o.id == **g).count();
|
||||
while open.len() > keep {
|
||||
@@ -233,6 +244,16 @@ fn render_cut(dl: &DisplayList, view: &View, cut: bool) -> Result<(Pixmap, Rende
|
||||
cov.add_polygon(poly);
|
||||
}
|
||||
}
|
||||
if op.run != 0 {
|
||||
if let Some(top) = open.last_mut() {
|
||||
top.dirty = top.dirty.union(&b);
|
||||
}
|
||||
(run.id, run.clip) = (op.run, op.clip);
|
||||
let len = rows.len();
|
||||
let under = open.last_mut().map_or(&mut *rows, |top| &mut top.buf);
|
||||
run.add(&cov, op, b, (band.y0, w, len), &mut row, Some((under, mask.as_deref().map(Vec::as_slice))));
|
||||
continue;
|
||||
}
|
||||
match open.last_mut() {
|
||||
Some(top) => {
|
||||
top.dirty = top.dirty.union(&b);
|
||||
@@ -241,9 +262,14 @@ fn render_cut(dl: &DisplayList, view: &View, cut: bool) -> Result<(Pixmap, Rende
|
||||
None => composite(&cov, op, b, band.y0, w, rows, &mut row, mask.as_deref().map(Vec::as_slice)),
|
||||
}
|
||||
}
|
||||
if run.id != 0 {
|
||||
let mask = run.clip.map(|c| band_clips.get(&clips, c, band, w, &mut cov, &mut row));
|
||||
run.flush(band.y0, w, open.last_mut().map_or(&mut *rows, |top| &mut top.buf), mask.as_deref().map(Vec::as_slice));
|
||||
}
|
||||
while !open.is_empty() {
|
||||
close_group(&mut open, rows, &dl.groups, band.y0, w);
|
||||
}
|
||||
RUN.set(run);
|
||||
});
|
||||
// Tens of thousands of small polygon buffers: free them on the pool, off the frame's
|
||||
// critical path (it cost about 2 ms at 1080p).
|
||||
@@ -308,6 +334,19 @@ pub struct Fill {
|
||||
/// A hairline (outline mode, ADR 0048): `polys` are open polylines (a closed one repeats
|
||||
/// its first point), drawn by [`hairline`]'s distance coverage; `rule` doesn't apply.
|
||||
pub hairline: bool,
|
||||
/// Not 0: one of a run of joined fills (ADR 0138), the fills next to it in drawing order
|
||||
/// with the same number. They are fills of one merged drawing, which lie side by side, so
|
||||
/// a pixel two of them share an edge in is covered by both together, not by one over the
|
||||
/// other. Per pixel, a run starts transparent with nothing covered; each of its fills, of
|
||||
/// coverage `k` and colour `s`, with `c` of the pixel covered so far, first hides what it
|
||||
/// must overlap (`o = max(0, c + k − 1)`: the run's colour times `1 − o / c · s.a`), then
|
||||
/// adds `s · k`, and `c` becomes `min(1, c + k)`; when the run ends its colour, times its
|
||||
/// clip's coverage, goes src-over onto what is below. Where one fill covers the pixel
|
||||
/// whole this is src-over, so a fill that covers a pixel whole while the run has nothing
|
||||
/// there (`c` is 0) goes src-over onto what is below at once, inside its clip, and leaves
|
||||
/// `c` at 0. Clip artwork joins the same way, without that shortcut: a coverage clip
|
||||
/// unites with the run's `c` at its end, a soft one composites the run's colour.
|
||||
pub run: u32,
|
||||
}
|
||||
|
||||
/// A filtered group (a symbol instance with filters) as [`render`] draws it: its items on
|
||||
@@ -373,7 +412,8 @@ pub fn prepare_scene(dl: &DisplayList, view: &View) -> Result<(Scene, RenderStat
|
||||
let surface = IRect { x0: 0, y0: 0, x1: view.width as i32, y1: view.height as i32 };
|
||||
let runs = filtered_runs(dl);
|
||||
let in_run = in_runs(dl, &runs);
|
||||
let mut prepared: Vec<Vec<Prepared>> = dl.items.par_iter().zip(&in_run).map(|(item, &skip)| if skip { Vec::new() } else { prepare(item, &view.transform, surface, soft_art(dl, item), true) }).collect();
|
||||
let joined = joined_runs(dl);
|
||||
let mut prepared: Vec<Vec<Prepared>> = dl.items.par_iter().zip(&in_run).zip(&joined).map(|((item, &skip), &run)| if skip { Vec::new() } else { prepare(item, &view.transform, surface, soft_art(dl, item), true, run) }).collect();
|
||||
let mut layers = Vec::new();
|
||||
for r in &runs {
|
||||
if let (Some(setup), Some(slot)) = (filter_setup(dl, r, view, surface), prepared.get_mut(r.start)) {
|
||||
@@ -401,7 +441,8 @@ pub fn prepare_scene(dl: &DisplayList, view: &View) -> Result<(Scene, RenderStat
|
||||
op.bounds = op.bounds.intersect(&clips.bounds(c));
|
||||
!op.bounds.is_empty()
|
||||
});
|
||||
let fill = |op: Prepared| Fill { polys: op.polys, rule: op.rule, shader: op.shader, bounds: op.bounds, clip: op.clip, group: op.group, layer: op.layer, hairline: op.hairline };
|
||||
drop_lone_runs(&mut ops);
|
||||
let fill = |op: Prepared| Fill { polys: op.polys, rule: op.rule, shader: op.shader, bounds: op.bounds, clip: op.clip, group: op.group, layer: op.layer, hairline: op.hairline, run: op.run };
|
||||
let mut fills = Vec::with_capacity(ops.len());
|
||||
for op in ops {
|
||||
stats.edges += op.polys.iter().map(Vec::len).sum::<usize>();
|
||||
@@ -484,6 +525,7 @@ impl FilterSetup {
|
||||
group: Some(self.group),
|
||||
layer: None,
|
||||
hairline: false,
|
||||
run: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -680,6 +722,156 @@ struct Prepared {
|
||||
layer: Option<u32>,
|
||||
/// A hairline ([`Fill::hairline`]).
|
||||
hairline: bool,
|
||||
/// The run of joined fills it is in, or 0 ([`Fill::run`]).
|
||||
run: u32,
|
||||
}
|
||||
|
||||
/// Per item, the run of joined fills its fill is in, or 0 ([`Fill::run`]): an item that joins
|
||||
/// the one before it ([`DisplayItem::joins`]) when both fills are drawn as fills, in the same
|
||||
/// layer, clip and group, with nothing drawn between them (the earlier one has no stroke).
|
||||
fn joined_runs(dl: &DisplayList) -> Vec<u32> {
|
||||
let mut out = vec![0u32; dl.items.len()];
|
||||
let plain = |i: &DisplayItem| i.fill.is_some() && i.outline.is_none() && !i.guide && i.warp.is_none();
|
||||
for (at, pair) in dl.items.windows(2).enumerate() {
|
||||
let [a, b] = pair else { continue };
|
||||
if !(b.joins && plain(a) && plain(b) && a.stroke.is_none() && a.layer == b.layer && a.clip == b.clip && a.group == b.group && a.masks == b.masks) {
|
||||
continue;
|
||||
}
|
||||
let Some(&before) = out.get(at) else { continue };
|
||||
// A new run is numbered by its second item, which is never item 0.
|
||||
let id = if before != 0 { before } else { u32::try_from(at + 1).unwrap_or(0) };
|
||||
for slot in out.iter_mut().skip(at).take(2) {
|
||||
*slot = id;
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Takes the run off a fill no neighbour shares it with (the others were culled, or draw
|
||||
/// nothing): alone it is an ordinary fill.
|
||||
fn drop_lone_runs(ops: &mut [Prepared]) {
|
||||
let ids: Vec<u32> = ops.iter().map(|o| o.run).collect();
|
||||
for (i, op) in ops.iter_mut().enumerate() {
|
||||
let same = |j: Option<usize>| j.and_then(|j| ids.get(j)).is_some_and(|&r| r == op.run);
|
||||
if op.run != 0 && !same(i.checked_sub(1)) && !same(i.checked_add(1)) {
|
||||
op.run = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A run of joined fills in one band ([`Fill::run`]): its colour and how much of each pixel it
|
||||
/// covers so far, laid out like the band's rows, and the part drawn into.
|
||||
#[derive(Default)]
|
||||
struct Run {
|
||||
id: u32,
|
||||
clip: Option<u32>,
|
||||
colour: Vec<Premul>,
|
||||
cover: Vec<f32>,
|
||||
dirty: Option<IRect>,
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
/// A band's run buffers, for the next band this thread draws.
|
||||
static RUN: std::cell::RefCell<Run> = std::cell::RefCell::default();
|
||||
}
|
||||
|
||||
impl Run {
|
||||
/// Adds coverage `cov` (over `b`) of `op` to the run, in a band of `len` pixels, `w` to a
|
||||
/// row, whose first row is `band_y0`. With `under` (what the run will go onto, and the
|
||||
/// clip coverage it is drawn in), a pixel the fill covers whole where the run has nothing
|
||||
/// yet is drawn there at once: most pixels, which then cost what they do outside a run.
|
||||
fn add(&mut self, cov: &Coverage, op: &Prepared, b: IRect, (band_y0, w, len): (i32, usize, usize), c: &mut Vec<f32>, mut under: Option<(&mut [Premul], Option<&[f32]>)>) {
|
||||
if self.colour.len() < len {
|
||||
self.colour = vec![[0.0; 4]; len];
|
||||
self.cover = vec![0.0; len];
|
||||
}
|
||||
self.dirty = Some(self.dirty.map_or(b, |d| d.union(&b)));
|
||||
let bw = b.width();
|
||||
c.clear();
|
||||
c.resize(bw, 0.0);
|
||||
let solid = op.shader.is_solid();
|
||||
for ry in 0..b.height() {
|
||||
cov.resolve_row(ry, op.rule, c);
|
||||
let py = b.y0 + ry as i32;
|
||||
let start = (py - band_y0) as usize * w + b.x0 as usize;
|
||||
let (Some(colour), Some(cover)) = (self.colour.get_mut(start..start + bw), self.cover.get_mut(start..start + bw)) else { continue };
|
||||
// This row of what is under the run, and of its clip's coverage.
|
||||
let (mut below, mut clip) = (None, None);
|
||||
if let Some((dst, mask)) = under.as_mut() {
|
||||
below = dst.get_mut(start..start + bw);
|
||||
clip = mask.and_then(|m| m.get(start..start + bw));
|
||||
if mask.is_some() && clip.is_none() {
|
||||
below = None;
|
||||
}
|
||||
}
|
||||
for (i, ((r, have), &k)) in colour.iter_mut().zip(cover.iter_mut()).zip(c.iter()).enumerate() {
|
||||
let k = k.min(1.0);
|
||||
if k <= 1e-4 {
|
||||
continue;
|
||||
}
|
||||
let s = match solid {
|
||||
Some(s) => s,
|
||||
None => op.shader.at(b.x0 + i as i32, py),
|
||||
};
|
||||
if k >= 1.0 {
|
||||
if *have <= 0.0
|
||||
&& let Some(d) = below.as_mut().and_then(|row| row.get_mut(i))
|
||||
{
|
||||
let m = clip.map_or(1.0, |m| m.get(i).copied().unwrap_or(0.0));
|
||||
if m > 1e-4 {
|
||||
let inv = 1.0 - s[3] * m;
|
||||
*d = [s[0] * m + d[0] * inv, s[1] * m + d[1] * inv, s[2] * m + d[2] * inv, s[3] * m + d[3] * inv];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// Over what the run has there: src-over, which is what the lines below
|
||||
// come to.
|
||||
let keep = 1.0 - s[3];
|
||||
*r = [r[0] * keep + s[0], r[1] * keep + s[1], r[2] * keep + s[2], r[3] * keep + s[3]];
|
||||
*have = 1.0;
|
||||
continue;
|
||||
}
|
||||
// Side by side as far as the pixel has room; what can't be lies over the run.
|
||||
let over = *have + k - 1.0;
|
||||
if over > 0.0 && *have > 0.0 {
|
||||
let keep = 1.0 - over / *have * s[3];
|
||||
*r = [r[0] * keep, r[1] * keep, r[2] * keep, r[3] * keep];
|
||||
}
|
||||
*r = [r[0] + s[0] * k, r[1] + s[1] * k, r[2] + s[2] * k, r[3] + s[3] * k];
|
||||
*have = (*have + k).min(1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Ends the run: `each` gets every pixel drawn into (its index in the band, its colour and
|
||||
/// how much of it is covered), and the run is empty again.
|
||||
fn end(&mut self, band_y0: i32, w: usize, mut each: impl FnMut(usize, Premul, f32)) {
|
||||
self.id = 0;
|
||||
let Some(d) = self.dirty.take() else { return };
|
||||
for py in d.y0..d.y1 {
|
||||
let start = (py - band_y0) as usize * w + d.x0 as usize;
|
||||
let (Some(colour), Some(cover)) = (self.colour.get_mut(start..start + d.width()), self.cover.get_mut(start..start + d.width())) else { continue };
|
||||
for (i, (r, have)) in colour.iter_mut().zip(cover.iter_mut()).enumerate() {
|
||||
if *have > 0.0 {
|
||||
each(start + i, *r, *have);
|
||||
(*r, *have) = ([0.0; 4], 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Ends the run src-over onto `dst` (the band's rows, or a group's), inside `mask`.
|
||||
fn flush(&mut self, band_y0: i32, w: usize, dst: &mut [Premul], mask: Option<&[f32]>) {
|
||||
self.end(band_y0, w, |at, s, _| {
|
||||
let m = match mask {
|
||||
Some(mask) => mask.get(at).copied().unwrap_or(0.0),
|
||||
None => 1.0,
|
||||
};
|
||||
let Some(d) = dst.get_mut(at) else { return };
|
||||
let inv = 1.0 - s[3] * m;
|
||||
*d = [s[0] * m + d[0] * inv, s[1] * m + d[1] * inv, s[2] * m + d[2] * inv, s[3] * m + d[3] * inv];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// The clips of a display list: their mask artwork and where each can be non-zero.
|
||||
@@ -747,31 +939,56 @@ impl BandClips {
|
||||
// A soft mask: its artwork painted onto transparent, then each pixel's opacity or
|
||||
// luminance.
|
||||
let mut px: Vec<Premul> = vec![[0.0; 4]; w * band.height()];
|
||||
let mut run = Run::default();
|
||||
for op in clips.art.get(i).into_iter().flatten() {
|
||||
let b = op.bounds.intersect(&band);
|
||||
if b.is_empty() {
|
||||
continue;
|
||||
}
|
||||
if run.id != 0 && run.id != op.run {
|
||||
run.flush(band.y0, w, &mut px, None);
|
||||
}
|
||||
cov.reset(b);
|
||||
for poly in &op.polys {
|
||||
cov.add_polygon(poly);
|
||||
}
|
||||
if op.run != 0 {
|
||||
run.id = op.run;
|
||||
run.add(cov, op, b, (band.y0, w, px.len()), row, None);
|
||||
continue;
|
||||
}
|
||||
composite(cov, op, b, band.y0, w, &mut px, row, None);
|
||||
}
|
||||
run.flush(band.y0, w, &mut px, None);
|
||||
for (d, p) in buf.iter_mut().zip(&px) {
|
||||
*d = mode.reveal(*p);
|
||||
}
|
||||
}
|
||||
// Union of the artwork's coverage (a ∪ b = a + b − ab), anti-aliased like any fill.
|
||||
// Union of the artwork's coverage (a ∪ b = a + b − ab), anti-aliased like any fill; a
|
||||
// run of joined fills (ADR 0138) unites as one, with what it covers together.
|
||||
let mut run = Run::default();
|
||||
let unite = |buf: &mut [f32], at: usize, k: f32| {
|
||||
if let Some(d) = buf.get_mut(at) {
|
||||
*d = *d + k - *d * k;
|
||||
}
|
||||
};
|
||||
for op in clips.art.get(i).into_iter().flatten().filter(|_| !mode.is_soft()) {
|
||||
let b = op.bounds.intersect(&band);
|
||||
if b.is_empty() {
|
||||
continue;
|
||||
}
|
||||
if run.id != 0 && run.id != op.run {
|
||||
run.end(band.y0, w, |at, _, k| unite(&mut buf, at, k));
|
||||
}
|
||||
cov.reset(b);
|
||||
for poly in &op.polys {
|
||||
cov.add_polygon(poly);
|
||||
}
|
||||
if op.run != 0 {
|
||||
run.id = op.run;
|
||||
run.add(cov, op, b, (band.y0, w, buf.len()), row, None);
|
||||
continue;
|
||||
}
|
||||
row.clear();
|
||||
row.resize(b.width(), 0.0);
|
||||
for ry in 0..b.height() {
|
||||
@@ -784,6 +1001,7 @@ impl BandClips {
|
||||
}
|
||||
}
|
||||
}
|
||||
run.end(band.y0, w, |at, _, k| unite(&mut buf, at, k));
|
||||
if let Some(p) = parent {
|
||||
for (d, m) in buf.iter_mut().zip(p.iter()) {
|
||||
*d *= m;
|
||||
@@ -881,7 +1099,7 @@ fn drop_unseen(polys: &mut [Vec<Vec2>], surface: IRect) {
|
||||
/// the item is a soft mask's artwork, prepared with its paints like any artwork (still marked
|
||||
/// as mask artwork). `cut`: what can't reach a pixel is left out ([`unseen`]); off, the item is
|
||||
/// prepared whole, for the tests that show the pixels are the same.
|
||||
fn prepare(item: &DisplayItem, view: &Affine, surface: IRect, soft: bool, cut: bool) -> Vec<Prepared> {
|
||||
fn prepare(item: &DisplayItem, view: &Affine, surface: IRect, soft: bool, cut: bool, run: u32) -> Vec<Prepared> {
|
||||
let mut out = Vec::new();
|
||||
let m = view.mul(&item.transform);
|
||||
if !m.is_finite() {
|
||||
@@ -941,11 +1159,11 @@ fn prepare(item: &DisplayItem, view: &Affine, surface: IRect, soft: bool, cut: b
|
||||
})
|
||||
.collect();
|
||||
if let Some(b) = hairline::bounds(&polys, surface) {
|
||||
out.push(Prepared { polys, rule: FillRule::NonZero, shader, bounds: b, clip, masks, group, layer: None, hairline: true });
|
||||
out.push(Prepared { polys, rule: FillRule::NonZero, shader, bounds: b, clip, masks, group, layer: None, hairline: true, run: 0 });
|
||||
}
|
||||
return out;
|
||||
}
|
||||
let mut push = |mut polys: Vec<Vec<Vec2>>, rule, shader: Shader| {
|
||||
let mut push = |mut polys: Vec<Vec<Vec2>>, rule, shader: Shader, run: u32| {
|
||||
if shader.is_solid().is_some_and(|c| c[3] <= 0.0) {
|
||||
return;
|
||||
}
|
||||
@@ -954,12 +1172,12 @@ fn prepare(item: &DisplayItem, view: &Affine, surface: IRect, soft: bool, cut: b
|
||||
if cut && beyond {
|
||||
drop_unseen(&mut polys, surface);
|
||||
}
|
||||
out.push(Prepared { polys, rule, shader, bounds: b, clip, masks, group, layer: None, hairline: false });
|
||||
out.push(Prepared { polys, rule, shader, bounds: b, clip, masks, group, layer: None, hairline: false, run });
|
||||
}
|
||||
};
|
||||
|
||||
if is_mask {
|
||||
push(lines.iter().map(|l| l.points.clone()).collect(), item.fill_rule, Shader::Solid([1.0; 4]));
|
||||
push(lines.iter().map(|l| l.points.clone()).collect(), item.fill_rule, Shader::Solid([1.0; 4]), run);
|
||||
return out;
|
||||
}
|
||||
// The stroke is outlined from the flattened lines first, so the fill can then take them
|
||||
@@ -985,10 +1203,10 @@ fn prepare(item: &DisplayItem, view: &Affine, surface: IRect, soft: bool, cut: b
|
||||
}
|
||||
_ => Shader::new(fill, &m, &item.color, item.image.as_ref()).smoothed(item.smooth),
|
||||
};
|
||||
push(polys, item.fill_rule, shader);
|
||||
push(polys, item.fill_rule, shader, run);
|
||||
}
|
||||
if let Some((polys, shader)) = stroke {
|
||||
push(polys, FillRule::NonZero, shader);
|
||||
push(polys, FillRule::NonZero, shader, 0);
|
||||
}
|
||||
out
|
||||
}
|
||||
@@ -1061,6 +1279,8 @@ mod nine_slice_tests;
|
||||
mod layer_opacity_tests;
|
||||
#[cfg(test)]
|
||||
mod cut_tests;
|
||||
#[cfg(test)]
|
||||
mod join_tests;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
@@ -1071,6 +1291,7 @@ mod tests {
|
||||
|
||||
fn item(path: Path, fill: Paint) -> DisplayItem {
|
||||
DisplayItem {
|
||||
joins: false,
|
||||
path: Arc::new(path),
|
||||
transform: Affine::IDENTITY,
|
||||
fill: Some(fill),
|
||||
|
||||
@@ -957,6 +957,7 @@ mod tests {
|
||||
/// `path` stroked with `st` in 50 % black on a white 400 × 300 stage: each pixel's ink.
|
||||
fn drawn(path: &str, st: Stroke) -> Vec<f32> {
|
||||
let item = DisplayItem {
|
||||
joins: false,
|
||||
path: std::sync::Arc::new(Path::from_svg(path).unwrap()),
|
||||
transform: Affine::IDENTITY,
|
||||
fill: None,
|
||||
|
||||
@@ -563,6 +563,7 @@ mod tests {
|
||||
|
||||
fn item(path: Path, fill: Option<Paint>) -> DisplayItem {
|
||||
DisplayItem {
|
||||
joins: false,
|
||||
path: Arc::new(path),
|
||||
transform: Affine::IDENTITY,
|
||||
fill,
|
||||
@@ -752,6 +753,7 @@ mod group_tests {
|
||||
#[test]
|
||||
fn groups_become_opacity_groups_around_their_run() {
|
||||
let it = |g: Option<u32>| DisplayItem {
|
||||
joins: false,
|
||||
path: Arc::new(Path::rect(0.0, 0.0, 4.0, 4.0)),
|
||||
transform: Affine::IDENTITY,
|
||||
fill: Some(Paint::Solid(Rgba::BLACK)),
|
||||
@@ -781,6 +783,7 @@ mod group_tests {
|
||||
#[test]
|
||||
fn links_escape_xml_attributes_and_drop_denied_schemes() {
|
||||
let shape = DisplayItem {
|
||||
joins: false,
|
||||
path: Arc::new(Path::rect(0.0, 0.0, 10.0, 10.0)),
|
||||
transform: Affine::IDENTITY,
|
||||
fill: Some(Paint::Solid(Rgba::BLACK)),
|
||||
|
||||
@@ -26,6 +26,7 @@ fn bitmap_shape() -> Shape {
|
||||
/// The display item of `shape` (its warp's mesh when it bends it), placed by `transform`.
|
||||
fn item(shape: &Shape, transform: Affine, smooth: bool) -> DisplayItem {
|
||||
DisplayItem {
|
||||
joins: false,
|
||||
path: shape.path.clone(),
|
||||
transform,
|
||||
fill: shape.fill.clone(),
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 4.7 KiB |
@@ -0,0 +1,86 @@
|
||||
# ADR 0138: Fills of one merged drawing join without a seam
|
||||
|
||||
* Status: accepted (2026-11-27), built
|
||||
* Relates to: ADR 0031 (merge drawing), ADR 0002 (the render pipeline), ADR 0019 and ADR 0029
|
||||
(the GPU stage draws what the oracle prepares), ADR 0070 (soft masks), ADR 0122 (a moved raw
|
||||
selection floats), ADR 0125 (the roadmap as a guideline; backlog item P-013), issue #182
|
||||
|
||||
## Context
|
||||
|
||||
Merge drawing leaves one element per fill region. Two regions that meet share an edge exactly:
|
||||
the same Bézier pieces, one traced each way. Each fill was drawn on its own, anti-aliased, one
|
||||
over the other. In a pixel the shared edge crosses, the first fill covers a part `a` and the
|
||||
second the rest, `1 − a`, and drawing one over the other lets `a · (1 − a)` of what is below
|
||||
through: up to a quarter of the stage's colour, as a hairline along every shared edge
|
||||
(issue #182, a red fill cut by a curve on a white stage). The outlines are right; the mistake
|
||||
is in treating two coverages of one pixel as if they were independent, when the two fills lie
|
||||
side by side. It is the same on the CPU oracle and the GPU stage, which composites the way the
|
||||
oracle does, and in masks, where two such fills united as `a + b − ab`.
|
||||
|
||||
## Decision
|
||||
|
||||
1. **The display list says which fills are side by side.** `DisplayItem::joins` is set by
|
||||
`evaluate` on a shape of a merged drawing that follows another shape of the same drawing:
|
||||
the raw shapes of one keyframe on one layer (a group's, or a symbol's layer's, are drawings
|
||||
of their own). It is a fact about the document, so every renderer gets it and `evaluate`
|
||||
stays pure.
|
||||
|
||||
2. **A run of joined fills is added up, then composited once.** The renderer makes a run of
|
||||
consecutive joined fills that are drawn as fills in the same layer, clip and group, with
|
||||
nothing between them (a fill's own stroke ends the run: it is drawn before the next fill).
|
||||
Per pixel a run starts transparent, with nothing covered. Each fill, of coverage `k` and
|
||||
colour `s`, with `c` covered so far:
|
||||
* hides what it must overlap, `o = max(0, c + k − 1)`: the run's colour times
|
||||
`1 − o / c · s.a`;
|
||||
* adds `s · k`, and `c` becomes `min(1, c + k)`.
|
||||
|
||||
When the run ends its colour goes src-over onto what is below, times its clip's coverage.
|
||||
For two fills that share an edge `c + k = 1`: nothing overlaps, the colours add up to full
|
||||
cover and nothing below shows. Half-transparent fills side by side stay half-transparent
|
||||
along the edge, where one over the other made the edge denser.
|
||||
|
||||
3. **Side by side as far as the pixel has room, one over the other past that.** The rule
|
||||
takes two partial coverages of a pixel to overlap as little as they can. Where either fill
|
||||
covers the pixel whole it is exactly src-over, so fills that do lie over each other (a
|
||||
shape moved onto the drawing and still floating, ADR 0122; a file written by hand) are
|
||||
drawn as before everywhere except in pixels both their edges cross, and there the
|
||||
difference is a fraction of a pixel's coverage. We chose this over trusting the flag
|
||||
blindly (adding without the overlap term), which would brighten or darken overlapping
|
||||
fills over their whole area.
|
||||
|
||||
4. **Masks join the same way.** A coverage mask unites a run's coverage as one fill's; a soft
|
||||
mask composites the run's colour. A mask drawn as two fills no longer leaks or hides along
|
||||
their edge.
|
||||
|
||||
5. **The oracle defines it, the GPU follows.** `Fill::run` numbers the runs in a prepared
|
||||
scene. The fine shader keeps the run's colour and coverage per pixel and ends the run at
|
||||
the first entry that isn't of it; the number rides in the op header's flags. The parity
|
||||
tests compare both on joined fills in the open, in masks, in a soft mask and in a fading
|
||||
group.
|
||||
|
||||
6. **What it costs.** A pixel a fill covers whole, where the run has nothing yet, is drawn at
|
||||
once, so only the pixels along edges go through the run's buffers, which each render thread
|
||||
keeps. A 1280 × 720 frame of 1,000 joined fills takes the oracle 2.4 ms, and 2.5 ms drawn
|
||||
one over the other (the same within noise; with buffers made anew for every band it was
|
||||
5.8 ms).
|
||||
|
||||
## Consequences
|
||||
|
||||
* The hairline of #182 is gone from the stage (CPU and GPU), Test Movie and every raster export,
|
||||
for drawings made here and raw shapes opened from Animate files alike.
|
||||
* Pixels along the shared edges of merged fills change; nothing else does. One golden picture
|
||||
had such an edge and was made anew (`crates/xfl/tests/corpus/filters`, one row of 160
|
||||
pixels between a dark and a light fill): each pixel is now the even mix of the two fills it
|
||||
lies half in, (96, 111, 106), where it had the white stage in it, (148, 151, 132). The other
|
||||
31 corpus frames are within their tolerance and were left as they were.
|
||||
* Edges that are shared but flattened differently (two shapes that only happen to touch, not
|
||||
cut by the merge) add up to within the flattening tolerance, a tenth of a pixel, instead of
|
||||
exactly.
|
||||
* *Not covered:* the vector exports (SVG, HTML canvas, Lottie) write each fill as its own path,
|
||||
and a viewer that anti-aliases them one over the other shows the same hairline there; fills
|
||||
of one drawing separated in the stacking order by a line (the merge keeps a drawing's fills
|
||||
under its lines, so this is rare); a fill meeting a drawing object or another layer.
|
||||
* *Rejected:* growing each fill under its neighbours (wrong for transparent fills, and it
|
||||
needs to know which edges are shared); drawing a merged drawing through one coverage pass
|
||||
with a paint per region (a second rasterizer for both renderers); supersampling (it thins the
|
||||
hairline, never removes it).
|
||||
@@ -34,18 +34,20 @@ Animator and Designer, plus your own saved workspaces and Reset.
|
||||
| Find and Replace | **Edit › Find and Replace** (**Ctrl+F**). |
|
||||
| Publish Settings | **File › Publish Settings…** (**Ctrl+Shift+F12**). |
|
||||
|
||||
Not in AniCraft yet: Components, Code Snippets, the Assets panel, and moving the Tools panel.
|
||||
The Tools panel moves like the others: drag the dotted grip at its top. Not in AniCraft yet:
|
||||
Components, Code Snippets and the Assets panel.
|
||||
See [The workspace](workspace.md) for a tour.
|
||||
|
||||
## Tools and their keys
|
||||
|
||||
Each tool has the key you already know.
|
||||
Most tools have the key you already know.
|
||||
|
||||
| Tool | Key | Notes |
|
||||
|---|---|---|
|
||||
| Selection | **V** | Selects raw strokes and fills with the dot pattern; drag an edge to bend it. |
|
||||
| Subselection | **A** | Points and handles, on raw drawings and drawing objects. |
|
||||
| Free Transform | **Q** | Scale, skew (drag the line between two handles), rotate and move; Shift and Alt as you'd expect. Drag the white circle to move the transformation point, double-click it to centre it; a rotated instance's box turns with it. |
|
||||
| Asset Warp | **Shift+Q** | Pins that bend a shape or a bitmap. |
|
||||
| Gradient Transform | **F** | Its own button (no flyouts yet). Gradient and bitmap fills, with Lock Fill. |
|
||||
| Width | **U** | Variable-width strokes, with profiles in Properties. |
|
||||
| Bone | **M** | Joins symbol instances into an armature, or draws bones inside a shape. |
|
||||
@@ -54,6 +56,7 @@ Each tool has the key you already know.
|
||||
| Text | **T** | Static, dynamic and input text. |
|
||||
| Pencil | **Shift+Y** | Smooth, Straighten and Ink modes. |
|
||||
| Brush | **B** | Like Animate's Classic Brush: paints filled shapes, with pen pressure. |
|
||||
| Paint Brush | **Y** | Draws a line in the stroke colour; its width follows pen pressure. |
|
||||
| Eraser | **E** | Five erase modes and the Faucet. |
|
||||
| Rectangle | **R** | With corner radius. |
|
||||
| Oval | **O** | |
|
||||
@@ -67,9 +70,9 @@ Each tool has the key you already know.
|
||||
| Zoom | **Z** | |
|
||||
| Object Drawing | **J** | Toggles between merge drawing and drawing objects. |
|
||||
|
||||
Not in AniCraft yet: the Lasso, Polygon and Magic Wand tools, the 3D tools,
|
||||
Asset Warp, the Paint Brush and Fluid Brush, Deco and the Spray Brush. More on the tools in
|
||||
[Drawing](drawing.md).
|
||||
Not in AniCraft yet: the Lasso, Polygon and Magic Wand tools, the 3D tools, the Fluid Brush,
|
||||
Deco and the Spray Brush. More on the tools in [Drawing](drawing.md); Asset Warp is in
|
||||
[Masks, guides, camera and bones](masks-guides-camera-bones.md#asset-warp).
|
||||
|
||||
## Keys that work as in Animate
|
||||
|
||||
@@ -81,6 +84,7 @@ Asset Warp, the Paint Brush and Fluid Brush, Deco and the Spray Brush. More on t
|
||||
| Clear keyframe | **Shift+F6** | Insert › Timeline › Clear Keyframe |
|
||||
| Insert blank keyframe | **F7** | Insert › Timeline › Blank Keyframe |
|
||||
| Convert to symbol | **F8** | Modify › Convert to Symbol… |
|
||||
| Document Settings | **Ctrl+J** | Modify › Document Settings |
|
||||
| Actions panel | **F9** | Window › Actions |
|
||||
| Play and stop | **Enter** | Control › Play |
|
||||
| Previous and next frame | **,** and **.** | Control |
|
||||
@@ -104,6 +108,8 @@ Asset Warp, the Paint Brush and Fluid Brush, Deco and the Spray Brush. More on t
|
||||
| Add shape hint | **Ctrl+Shift+H** | Modify › Shape › Add Shape Hint |
|
||||
| Find and Replace, Find Next | **Ctrl+F**, **F3** | Edit › Find and Replace |
|
||||
| Movie Explorer | **Alt+F3** | Window › Movie Explorer |
|
||||
| Library, Timeline, Tools and Properties panels | **Ctrl+L**, **Ctrl+Alt+T**, **Ctrl+F2**, **Ctrl+F3** | Window |
|
||||
| Hide and show panels | **F4** | Window › Hide Panels |
|
||||
| Snap to objects | **Ctrl+Shift+/** | View › Snapping › Snap to Objects |
|
||||
| Zoom in and out | **Ctrl+=**, **Ctrl+-** | View |
|
||||
| Preferences (Windows and Linux) | **Ctrl+U** | Edit › Preferences… |
|
||||
@@ -115,14 +121,12 @@ frame, and **Shift+PageUp** and **Shift+PageDown** for the previous and next sce
|
||||
|
||||
### Keys that differ
|
||||
|
||||
* **Ctrl+K** opens AniCraft's command palette, which finds any command by name. Align is always on
|
||||
the right, and on **Ctrl+Alt+1** to **6**.
|
||||
* **Ctrl+K** opens AniCraft's command palette, which finds any command by name. The Align panel
|
||||
has no key by default; aligning is on **Ctrl+Alt+1** to **6**.
|
||||
* **Ctrl+G** and **Ctrl+Shift+G** group and ungroup, as in Animate. A drawing object that
|
||||
mixes colours, such as the result of a Union, is a group in AniCraft: double-click it to edit
|
||||
inside.
|
||||
* **Ctrl+F8** (New Symbol): not there yet. Draw something and convert it with **F8**.
|
||||
* **Ctrl+J** (Document Settings): it is **Modify › Document Settings**, with no key by default.
|
||||
* Panel toggles such as **Ctrl+L** for the Library have no key yet; use the **Window** menu.
|
||||
* **Ctrl+0** fits the stage in the window and **Ctrl+1** shows it at 100 %.
|
||||
|
||||
Any key can be changed in **Help › Keyboard Shortcuts** (**Ctrl+Alt+Shift+K**, as in Animate), so you can bring back a habit
|
||||
@@ -143,8 +147,8 @@ Press **J** for Object Drawing to draw shapes that stay separate. Scripts and th
|
||||
draw objects unless told otherwise.
|
||||
|
||||
This behaviour was rebuilt to match Animate closely, and the remaining differences are tracked in
|
||||
issue 42 on [GitHub issues](https://github.com/storytold/AniCraft/issues). One known gap:
|
||||
variable-width strokes don't take part in merging yet.
|
||||
issue 42 on [GitHub issues](https://github.com/storytold/AniCraft/issues). Variable-width
|
||||
strokes merge too: a piece cut from one keeps the widths it had there.
|
||||
|
||||
### Classic, motion and shape tweens
|
||||
|
||||
@@ -192,16 +196,24 @@ ActionScript 1.0 and 2.0, and scripts placed on instances. See [Interactivity](i
|
||||
formats you choose at once. See [Exporting and publishing](exporting-and-publish.md).
|
||||
* **Test Movie** (**Ctrl+Enter**) opens in its own window with an Output panel; **Esc** closes it.
|
||||
|
||||
## More that works as in Animate
|
||||
|
||||
| In Animate | In AniCraft |
|
||||
|---|---|
|
||||
| Several documents in tabs | A tab for each open document, below the menu bar. See [Document tabs](workspace.md#document-tabs). |
|
||||
| Saved workspaces | **Window › Workspace › Save Workspace…** and **Manage Workspaces…**. See [Workspaces](workspace.md#workspaces). |
|
||||
| Envelope | **Modify › Transform › Envelope**. The bent artwork is plain shapes afterwards, so there is no Delete Envelope. See [Envelope](drawing.md#envelope). |
|
||||
| Brush modes, pressure and brush presets | The Brush's options in Properties: five paint modes, with Paint Selection and Paint Inside, and a pressure curve. **Window › Brush Library** keeps the built-in brushes and your own. See [The Brush](drawing.md#the-brush). |
|
||||
| Bone springs and joint translation | **Properties › Bone**. One armature can mix symbol instances and shapes. See [Bone properties](masks-guides-camera-bones.md#bone-properties). |
|
||||
| Styles on single characters | Select characters with the Text tool and style them. See [Styling words and characters](text.md#styling-words-and-characters). |
|
||||
| Text on a path | **Modify › Text › Attach Text to Path**. See [Text on a path](text.md#text-on-a-path). |
|
||||
|
||||
## Not in AniCraft yet
|
||||
|
||||
Besides the tools and keys above, these are still to come:
|
||||
|
||||
* saved workspaces and several open documents at once;
|
||||
* Envelope and Delete Envelope, and editing a multi-colour drawing object without opening it;
|
||||
* editing a multi-colour drawing object without opening it;
|
||||
* motion tweens and bones from Animate documents;
|
||||
* spring and joint translation for bones, and armatures mixing symbols and shapes;
|
||||
* the Brush's Paint Selection and Paint Inside modes, pressure curves and a brush library;
|
||||
* per-character text styles and text on a path;
|
||||
* full screen and zoom in Test Movie;
|
||||
* shared libraries;
|
||||
* SWF, AIR and other runtime targets.
|
||||
|
||||
+25
-4
@@ -19,13 +19,16 @@ your hand.
|
||||
| Selection | **V** | Select, move and bend artwork |
|
||||
| Subselection | **A** | Edit points and curve handles |
|
||||
| Free Transform | **Q** | Scale, skew, rotate and move |
|
||||
| Asset Warp | **Shift+Q** | Bend a shape or a bitmap with pins |
|
||||
| Gradient Transform | **F** | Move, turn and stretch a gradient or bitmap fill |
|
||||
| Width | **U** | Vary a line's thickness along it |
|
||||
| Bone | **M** | Join symbol instances into a poseable armature |
|
||||
| Bind | **Shift+M** | Choose which points of a shape follow which bone |
|
||||
| Pen | **P** | Draw precise curves point by point |
|
||||
| Text | **T** | Type text on the stage |
|
||||
| Pencil | **Shift+Y** | Draw freehand lines |
|
||||
| Brush | **B** | Paint filled shapes |
|
||||
| Paint Brush | **Y** | Draw lines whose width follows pen pressure |
|
||||
| Eraser | **E** | Rub out lines and fills |
|
||||
| Rectangle | **R** | Draw rectangles and squares |
|
||||
| Oval | **O** | Draw ovals and circles |
|
||||
@@ -42,7 +45,7 @@ While a drawing tool is in your hand, its options appear at the top of **Propert
|
||||
and stroke, line style, and the tool's own settings. You can change any of these keys in the
|
||||
shortcut editor (**Ctrl+Alt+Shift+K**).
|
||||
|
||||
The Bone and Camera tools are covered in
|
||||
The Bone, Bind, Asset Warp and Camera tools are covered in
|
||||
[Masks, guides, camera and bones](masks-guides-camera-bones.md), and the Text tool in
|
||||
[Text](text.md).
|
||||
|
||||
@@ -66,8 +69,8 @@ you don't want, and fill the spaces.
|
||||
that never cut or merge, and they're easy to move, stack and edit one at a time.
|
||||
|
||||
To switch between them, press **J**, or tick **Object drawing** in the tool's options in
|
||||
Properties. The setting applies to the Rectangle, Oval, PolyStar, Line, Pen, Pencil and Brush
|
||||
tools.
|
||||
Properties. The setting applies to the Rectangle, Oval, PolyStar, Line, Pen, Pencil, Brush and
|
||||
Paint Brush tools.
|
||||
|
||||
The Eraser only erases merged drawing. Drawing objects, symbols and text are left alone by
|
||||
it. To turn a drawing object back into merged drawing, select it and choose **Modify › Break
|
||||
@@ -94,7 +97,9 @@ With the **Selection** tool (**V**) on merged drawing:
|
||||
* **Drag a marquee** to select the parts of fills and lines under it, cut at the marquee's
|
||||
edges, plus any objects it touches (symbol instances, groups, drawing objects, text and
|
||||
bitmaps are taken whole). **Shift** adds more. If you click away without
|
||||
changing anything, the drawing is whole again.
|
||||
changing anything, the drawing is whole again. To take only the objects that are wholly
|
||||
inside the marquee, turn off **The marquee takes objects it touches** in
|
||||
[Preferences](preferences-shortcuts-accessibility.md#stage).
|
||||
* **Drag an unselected line** or the edge of a fill to **bend** it into a curve through the
|
||||
pointer. Its ends stay put, and a straight edge bends into one even arc wherever you grab it.
|
||||
* **Ctrl-drag** (**⌘-drag** on a Mac) a line or the edge of a fill to add a **corner point**
|
||||
@@ -176,6 +181,22 @@ the tip sweeps. A click paints a single dab. The options set the **Size** (or pr
|
||||
The last three never cover lines. With
|
||||
a pen tablet, pressure sets the width, from 10 % to the full size.
|
||||
|
||||
**Pressure.** Under **Pressure**, tick **Size**, **Opacity** or both to choose what the pen's
|
||||
pressure changes. **Curve** shapes the response: pick one of the presets beside it, or drag
|
||||
the points of the curve (drag elsewhere on it to add a point, double-click a point to remove
|
||||
it). Without a pen, **Speed as pressure** makes a faster stroke thinner.
|
||||
|
||||
**Brushes.** The **Brush** menu in the options picks a ready-made brush, such as Ink Pen,
|
||||
Marker or Chalk. **Library…** beside it, or **Window › Brush Library**, shows every brush with
|
||||
a preview. To keep a brush of your own, set it up in Properties, type a name in the Brush
|
||||
Library and click **Save Brush**. Right-click a brush of yours to rename or delete it;
|
||||
**Import…** and **Export…** move your brushes between computers as a brush set file.
|
||||
|
||||
**The Paint Brush** (**Y**) draws a line in the stroke colour instead of a filled shape. Its
|
||||
width follows the pen's pressure and the brush's tapers, and you can reshape it afterwards
|
||||
with the Width tool (see [Variable-width lines](#variable-width-lines)). It uses the same
|
||||
brushes and pressure settings, and **[** and **]** change its size.
|
||||
|
||||
**Texture and scatter.** **Texture** lets a paper grain show through the paint, like charcoal
|
||||
on rough paper; the grain stays put on the stage, so strokes laid over each other share it.
|
||||
**Scatter** throws dabs either side of the stroke and varies their size, for spatter and
|
||||
|
||||
@@ -437,7 +437,9 @@ Lottie animations carry no sound. See [Exporting and Publish](exporting-and-publ
|
||||
|
||||
## Not yet
|
||||
|
||||
* Picking a colour from a bitmap's pixels with the Eyedropper.
|
||||
* Picking a colour from a bitmap's pixels with the Eyedropper tool (it picks up whole fills).
|
||||
The eyedropper of an open colour picker does take the colour of a pixel: see
|
||||
[Choosing colours](drawing.md#choosing-colours).
|
||||
* Panning beyond what the envelope does.
|
||||
* Convert Audio to Keyframes on the camera or an armature layer, a filter's values, or with a
|
||||
classic tween between the keys; the sound's own effect (a fade) isn't counted in its
|
||||
|
||||
@@ -202,7 +202,8 @@ function onTick(e:Event):void {
|
||||
* Event bubbling, mouse listeners on the stage, and event fields such as `stageX` and
|
||||
`charCode`.
|
||||
* `getChildByName`, stage properties, sound and timers from scripts.
|
||||
* `Event.CHANGE` and other text field events, `htmlText` and text formatting from scripts.
|
||||
* Text field events other than `Event.CHANGE`, and text formatting from scripts other than
|
||||
`htmlText`.
|
||||
* ActionScript 1.0 and 2.0, and scripts attached to instances in older documents.
|
||||
* `navigateToURL` and other calls that reach outside the movie are ignored and noted in Output.
|
||||
|
||||
|
||||
@@ -126,6 +126,11 @@ portable copy, `data/themes` beside the app). To check a file without opening An
|
||||
Both settings are also in **View › Stage Rendering**, so you can switch without opening
|
||||
Preferences.
|
||||
|
||||
* **Selection**: **The marquee takes objects it touches** is on to begin with: a box dragged
|
||||
with the Selection tool selects every symbol instance, group, drawing object, text and bitmap
|
||||
it reaches. Turn it off to select only the objects that are wholly inside the box. Shapes
|
||||
drawn without Object Drawing are cut at the box's edges either way.
|
||||
|
||||
* **Window graphics**: how the whole window is drawn. **Automatic** (the default) tries the best
|
||||
way for your computer first and the next one if it doesn't work. If the window flickers or
|
||||
goes black, choose another way: **DirectX 12**, **Vulkan** or **OpenGL** on Windows, **Metal**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Command reference
|
||||
|
||||
Everything you can do in AniCraft is a command: the menus, the shortcuts, the command palette (**Ctrl+K**, macOS **⌘K**), `anicraft-cli` and AI assistants over MCP all run the same 406 commands, listed here by menu. The id is what scripts and [working headless](../working-headless.md) use; the parameters are what a command takes as JSON. Commands that change the document are one undo step each. Your own shortcuts (**Help › Keyboard Shortcuts**) replace the defaults shown here; see the [shortcut reference](shortcuts.md).
|
||||
Everything you can do in AniCraft is a command: the menus, the shortcuts, the command palette (**Ctrl+K**, macOS **⌘K**), `anicraft-cli` and AI assistants over MCP all run the same 407 commands, listed here by menu. The id is what scripts and [working headless](../working-headless.md) use; the parameters are what a command takes as JSON. Commands that change the document are one undo step each. Your own shortcuts (**Help › Keyboard Shortcuts**) replace the defaults shown here; see the [shortcut reference](shortcuts.md).
|
||||
|
||||
This page is generated from the command registry, so it always matches the version of AniCraft it came with.
|
||||
|
||||
@@ -581,8 +581,10 @@ These commands have no menu item: the panels, the stage and the timeline use the
|
||||
Parameters: ``{index, at} moves this scene's guide `index` (as view.aids lists them) to `at`; refused while guides are locked``
|
||||
- **Delete Guide** `view.guide_delete` · changes the document
|
||||
Parameters: ``{index} removes this scene's guide `index`; refused while guides are locked``
|
||||
- **Marquee Takes Touched Objects** `view.select_touching`
|
||||
Parameters: `{on?: bool} (default: toggle) the marquee takes the objects it only touches (on, as AniCraft starts) or only the objects wholly inside it; kept with the preferences`
|
||||
- **Rulers, Grid and Guides** `view.aids`
|
||||
Parameters: `{} whether the rulers, grid and guides show and snap, whether selection edges are hidden, the grid's and guides' settings, and this scene's guides [{axis, at}, ..]`
|
||||
Parameters: `{} whether the rulers, grid and guides show and snap, whether selection edges are hidden, whether the marquee takes objects it only touches (select_touching), the grid's and guides' settings, and this scene's guides [{axis, at}, ..]`
|
||||
- **Combine Objects** `modify.combine` · changes the document
|
||||
Parameters: `{op: union|intersect|punch|crop} combines the selected shapes on the active layer, bottom to top as they are stacked (ADR 0073). union: one drawing object of everything (a group of the merged pieces when they have more than one colour or keep lines); intersect: the area every one covers, in the topmost's fill and stroke; punch: the topmost's area cut out of each of the others; crop: each of the others cut to the topmost's area. Punch and crop remove the topmost. A result of one fill (or one line) is a drawing object, one of several is a group of raw shapes → {op, created}`
|
||||
- **List Library** `library.items`
|
||||
@@ -636,7 +638,7 @@ These commands have no menu item: the panels, the stage and the timeline use the
|
||||
- **Move Point** `raw.move_point` · changes the document
|
||||
Parameters: ``{x, y, to_x, to_y, with?: [[x, y], ..], points?: [[id, cmd], ..], snap?, slop?, merge?: bool} moves the corner or end at (x, y), with every raw shape that shares it, to (to_x, to_y), snapped within `snap` to points, lines and fill edges (while Snap to Objects is on); the anchors at `with` move by as much; returns the points to pass on while a drag goes on``
|
||||
- **Select Parts** `raw.select_rect` · changes the document
|
||||
Parameters: `{x0, y0, x1, y1, add?: bool} the marquee, on every visible, unlocked layer: the parts of raw fills and strokes under the rectangle (cut at its edges, per layer) and the objects it touches`
|
||||
Parameters: ``{x0, y0, x1, y1, add?: bool, touch?: bool} the marquee, on every visible, unlocked layer: the parts of raw fills and strokes under the rectangle (cut at its edges, per layer) and the objects it touches, or with `touch` false only the objects wholly inside it (default: as view.select_touching is set)``
|
||||
- **Merge Shapes** `raw.merge` · changes the document
|
||||
Parameters: `{ids?: [..]} the raw shapes (default: the selection) merge again with the raw shapes they touch, in place`
|
||||
- **Selection Tool Target** `raw.hit`
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# Windows, Linux and macOS release-ref nightly: supervised manual go-live
|
||||
|
||||
**Enabled for supervised manual runs, not yet qualified.** The producer (`nightly.yml`, main) and the
|
||||
signer (`nightly-sign.yml`, release) keep only their exact context guards and run when one of the reviewed
|
||||
manual actors dispatches them. There is no schedule yet. The installed policy
|
||||
[`.github/nightly-signing-policy.json`](../.github/nightly-signing-policy.json) is the v3
|
||||
policy for `storytold/anicraft`. Once `nightly.yml` lands on `main`, populate `producer_workflow_id`
|
||||
before promoting the policy to `release`, read with:
|
||||
signer (`nightly-sign.yml`, on the dedicated `nightly-signer` branch) keep only their exact context
|
||||
guards and run when one of the reviewed manual actors dispatches them. There is no schedule yet. The
|
||||
installed policy [`.github/nightly-signing-policy.json`](../.github/nightly-signing-policy.json) is the
|
||||
v3 policy for `storytold/anicraft`. Its `producer_workflow_id` is `nightly.yml`'s registration on
|
||||
`main`, read with:
|
||||
|
||||
```bash
|
||||
gh api repos/storytold/anicraft/actions/workflows/nightly.yml --jq .id
|
||||
@@ -14,27 +14,39 @@ gh api repos/storytold/anicraft/actions/workflows/nightly.yml --jq .id
|
||||
The callers pass no platform secrets. The unsigned reusable caller's maximum OIDC/attestation
|
||||
permissions are for its isolated attester; its compiler narrows to contents and Actions read
|
||||
only, with no OIDC, attestation write, release environment or platform signing secrets.
|
||||
Shared tooling is pinned to `605d58766e8f536564da8fc81d3676ac86816dea`, the craft-common-actions
|
||||
main commit that merged [#339](https://github.com/storytold/craft-common-actions/pull/339) (bounded
|
||||
lineage compares and an issue reread at the end of candidate admission) on top of
|
||||
[#342](https://github.com/storytold/craft-common-actions/pull/342) (policy v3, the `platforms` input
|
||||
and the Linux and macOS legs). Both callers name it in `uses` and `tooling-revision`. A pin is reviewed
|
||||
source availability, not provider, queue, native signing or crypto qualification.
|
||||
Shared tooling is pinned to `be00e5ccd18b68e950c8a08532f2230e7c3d0cba`, the craft-common-actions
|
||||
main commit that merged [#371](https://github.com/storytold/craft-common-actions/pull/371) (the
|
||||
candidate is admitted on the built commit's own Sonar analysis, not main's latest) after
|
||||
[#370](https://github.com/storytold/craft-common-actions/pull/370) (the Windows and macOS nightly
|
||||
registry rows for the 14 apps) and
|
||||
[#369](https://github.com/storytold/craft-common-actions/pull/369) (shared helper checkouts kept out
|
||||
of the app's clean-source check, and macOS on `macos-15`), following
|
||||
[#364](https://github.com/storytold/craft-common-actions/pull/364) (the signer may run on the
|
||||
policy's signer branch) and [#363](https://github.com/storytold/craft-common-actions/pull/363) (the
|
||||
multi-app pipeline, which makes the signer's `app-name` input required and admits any reviewed
|
||||
registry app), with #342 (`a4f6fd51`, policy v3 and the `platforms` input) and #339 (`605d5876`)
|
||||
earlier. Both callers name it in `uses` and `tooling-revision`. A pin is reviewed source
|
||||
availability, not provider, queue, native signing or crypto qualification.
|
||||
Existing stable workflows are unchanged.
|
||||
|
||||
**The shared-workflow port is a prerequisite.** At this pin both reusable workflows admit only
|
||||
PhotoCraft: `nightly-unsigned.yml` requires `inputs.app-name == 'photocraft'` and
|
||||
`github.repository == 'storytold/photocraft'` on its build jobs, and `nightly-release.yml` requires the
|
||||
same repository in `validate` and every signing job (its concurrency group is
|
||||
`craft-release-ref-signer-photocraft`). A AniCraft dispatch therefore builds and signs nothing until
|
||||
`storytold/craft-common-actions` admits `storytold/anicraft`. No dispatch can produce a release before
|
||||
that port, and both callers' `uses`, `tooling-revision` and the policy pins must move to the same
|
||||
reviewed revision together. The port is craft-common-actions #363 ("run the shared nightly pipeline for
|
||||
any reviewed registry app"); until it merges these callers are inert.
|
||||
|
||||
**First runs.** The first runs are manual dispatches in this order: `nightly.yml` on `main` (only a
|
||||
listed manual actor passes the producer's plan step), then `nightly-sign.yml` on `release` with that
|
||||
producer run ID and attempt, by a listed manual actor.
|
||||
listed manual actor passes the producer's plan step), then `nightly-sign.yml` on `nightly-signer`
|
||||
with that producer run ID and attempt, by a listed manual actor.
|
||||
|
||||
**Signer branch.** The signer runs on `refs/heads/nightly-signer`, not on the stable `release`
|
||||
branch, so nightly signer files never need a stable release sync. The policy's `release_branch`
|
||||
names it and the signer's guard requires it; this app has no automatic dispatch transport, so
|
||||
nothing else targets the branch. The branch only fast-forwards to reviewed main commits, through the
|
||||
settings script's `advance` (no queued signer run, a trust-closure scan, then the full diff of
|
||||
`.github/` and `packaging/`), and the existing `release` environment must admit `nightly-signer`
|
||||
alongside `release` before the first dispatch (a repository settings change, not a workflow one).
|
||||
Its trust closure is all of `.github/` and `packaging/`, including `packaging/env.sh`, which
|
||||
`import-cert.sh` sources with the Apple keys. On that branch only the pinned `nightly-sign.yml`
|
||||
caller may reach an environment: no app workflow binds one, and the only caller of the shared stable
|
||||
`release.yml` is `release.yml`, whose callee must carry the stable-only environment guard. The
|
||||
contract tests check the in-repo part on every main PR; the settings scan also resolves the callee.
|
||||
Stable releases still come only from `refs/heads/release`. History does not carry over a switch
|
||||
between `release` and `nightly-signer`, so the switch happens before the first publication.
|
||||
|
||||
**Manual actors.** `bflatastic`, `dylanmtaylor`, `echelon`, `FredApps` and `skylartaylor`, in the
|
||||
producer's `manual-actors` and the policy's `manual_actors`. The list mirrors the release-managers
|
||||
@@ -54,15 +66,14 @@ the signer caller has no platform input.
|
||||
|
||||
## Installed policy values and their sources
|
||||
|
||||
Read on 2026-11-24; re-read anything that may have moved (and populate `producer_workflow_id` once
|
||||
`nightly.yml` is registered on `main`, plus any Sonar `debt` if needed) before the policy is promoted
|
||||
to `release`.
|
||||
Read on 2026-11-24, with `producer_workflow_id` filled on 2026-11-25; re-read anything that may have
|
||||
moved (plus any Sonar `debt` if needed) before `nightly-signer` is advanced to it.
|
||||
|
||||
| Field | Value | Source |
|
||||
|---|---|---|
|
||||
| `repository_id` | `1419518094` | `gh api repos/storytold/anicraft --jq .id` |
|
||||
| `producer_workflow_id` | `null` (pending `nightly.yml` on `main`) | `gh api repos/storytold/anicraft/actions/workflows/nightly.yml --jq .id` after `nightly.yml` reaches `main` |
|
||||
| `producer_tooling_revision`, `signer_tooling_revision`, `producer_workflow_ref` | `605d5876…` (craft-common-actions #339) | The callers' pin |
|
||||
| `producer_workflow_id` | `429745835` | `gh api repos/storytold/anicraft/actions/workflows/nightly.yml --jq .id` on `main` |
|
||||
| `producer_tooling_revision`, `signer_tooling_revision`, `producer_workflow_ref` | `be00e5cc…` (the exact-analysis admission, #371 after #370 and #369, following #364 on #363) | The callers' pin |
|
||||
| `manual_actors` / `automatic_signer_actors` | the five release managers / `[]` | release-managers team (id 19837241) members who can push; equals the producer caller's `manual-actors` |
|
||||
| `max_age_seconds`, `max_artifact_bytes` | `86400`, `2147483648` | Go-live checklist |
|
||||
| `platforms` | three rows | Storytold stable signing identities (`Learning Machines Inc`, Linux OpenPGP fingerprint `2B76741B414AAD6CD33E631213A005C0B9D7C3ED`, Apple Team ID `DJ6XS33FX8`) |
|
||||
@@ -74,8 +85,8 @@ to `release`.
|
||||
- `.github/workflows/nightly.yml`: default-main registration of the unsigned producer, named
|
||||
`AniCraft unsigned nightly`, enabled for manual dispatch by `manual-actors`; no signing secrets
|
||||
may be passed or inherited.
|
||||
- `.github/workflows/nightly-sign.yml`: top-level release registration, enabled for manual dispatch,
|
||||
and identical on `main` and `release` after reviewed promotion. It rejects wrong repository/event/actual
|
||||
- `.github/workflows/nightly-sign.yml`: top-level signer registration, enabled for manual dispatch on
|
||||
`nightly-signer`, which carries a reviewed main commit. It rejects wrong repository/event/actual
|
||||
branch, including same-name tags. Its constant whole-run concurrency is distinct from stable,
|
||||
cancellation is off and `queue: max` must be hosted-qualified. The caller itself passes no
|
||||
credentials; only the shared callee's sign jobs bind the `release` environment.
|
||||
@@ -83,11 +94,11 @@ to `release`.
|
||||
`storytold/craft-common-actions`. Both must resolve to a **real reviewed public immutable
|
||||
commit**; the defining workflow SHA and tooling input must match.
|
||||
- `.github/nightly-linux-signing-key.asc` must be committed with the stable Linux public key
|
||||
(`2B76741B414AAD6CD33E631213A005C0B9D7C3ED`) before Linux signing runs on `release`.
|
||||
(`2B76741B414AAD6CD33E631213A005C0B9D7C3ED`) before Linux signing runs on `nightly-signer`.
|
||||
|
||||
## Local regression checks
|
||||
|
||||
`python3 packaging/nightly-release-tests.py` verifies the nightly workflow contracts, exact context
|
||||
guards, manual actor lists, signer serialization (`anicraft-nightly-release`, `queue: max`,
|
||||
guards, manual actor lists, signer serialization (`anicraft-nightly-release`,
|
||||
`cancel-in-progress: false`), no-cache/no-platform-secret boundaries, shared tooling pin consistency,
|
||||
and `.github/nightly-signing-policy.json` schema and field invariants.
|
||||
+2
-2
@@ -103,7 +103,7 @@ The **Headless** column at the end of each table says whether `anicraft-cli` and
|
||||
|
||||
| Feature | Status | Notes | Headless |
|
||||
|---|---|---|---|
|
||||
| Selection | **partial** | Raw shapes, objects, marquee, bend an edge, move a corner ([ADR 0041](adr/0041-selection-tool-on-raw-drawings.md), [ADR 0044](adr/0044-selection-across-layers.md)). A marquee takes the instances and objects it touches, and View › Hide Edges hides the selection's marks ([ADR 0134](adr/0134-outside-parity-batch-zoom-outlines-and-egui-0-37.md)). Missing: a preference for the marquee to take only what it surrounds; the first-use hint about fills and outlines (P-017). |
|
||||
| Selection | **partial** | Raw shapes, objects, marquee, bend an edge, move a corner ([ADR 0041](adr/0041-selection-tool-on-raw-drawings.md), [ADR 0044](adr/0044-selection-across-layers.md)). A marquee takes the instances and objects it touches, and View › Hide Edges hides the selection's marks ([ADR 0134](adr/0134-outside-parity-batch-zoom-outlines-and-egui-0-37.md)). A preference says whether the marquee takes objects it only touches or only those wholly inside it (Preferences › Stage, `view.select_touching`). Missing: the first-use hint about fills and outlines (P-017). |
|
||||
| Subselection | **done** | [ADR 0042](adr/0042-subselection-and-merging-everywhere.md), [ADR 0045](adr/0045-raw-points-and-raw-shapes-inside-symbols.md). |
|
||||
| Free Transform | **partial** | Scale, skew, rotate, the transformation point, a box that turns with the object ([ADR 0111](adr/0111-the-transformation-point-a-turning-box-and-layer-opacity.md)), Envelope ([ADR 0080](adr/0080-drawing-parity-leftovers.md)). Missing: Distort. Open bug: rotation on Windows and FreeBSD ([#479](https://github.com/storytold/anicraft/issues/479)), not reproduced on Windows 10 (P-005). |
|
||||
| Gradient Transform | **done** | Gradient and bitmap fills, Lock Fill. |
|
||||
@@ -142,7 +142,7 @@ The **Headless** column at the end of each table says whether `anicraft-cli` and
|
||||
|
||||
| Feature | Status | Notes | Headless |
|
||||
|---|---|---|---|
|
||||
| Merge drawing: raw strokes and fills that cut and join | **done** | [ADR 0031](adr/0031-merge-drawing.md), [ADR 0041](adr/0041-selection-tool-on-raw-drawings.md), [ADR 0042](adr/0042-subselection-and-merging-everywhere.md), [ADR 0045](adr/0045-raw-points-and-raw-shapes-inside-symbols.md); [drawing](guide/drawing.md). Open bug: a hairline between merged curved fills ([#182](https://github.com/storytold/anicraft/issues/182), P-013). |
|
||||
| Merge drawing: raw strokes and fills that cut and join | **done** | [ADR 0031](adr/0031-merge-drawing.md), [ADR 0041](adr/0041-selection-tool-on-raw-drawings.md), [ADR 0042](adr/0042-subselection-and-merging-everywhere.md), [ADR 0045](adr/0045-raw-points-and-raw-shapes-inside-symbols.md); [drawing](guide/drawing.md). Fills that share an edge are drawn without a line of the stage between them ([ADR 0138](adr/0138-fills-of-one-merged-drawing-join-without-a-seam.md), [#182](https://github.com/storytold/anicraft/issues/182)). |
|
||||
| Object drawing | **done** | Edit inside by double-click. Editing without opening is missing ([#181](https://github.com/storytold/anicraft/issues/181)). |
|
||||
| Groups, nested, edited in place | **done** | [ADR 0073](adr/0073-groups-combine-objects-and-selection-modifiers.md). |
|
||||
| Break Apart | **done** | |
|
||||
|
||||
+6
-4
@@ -55,10 +55,9 @@ the changelog.
|
||||
| P-011 | Shape tweens morph a raw shape's outline with its fill (outside PR [#238](https://github.com/storytold/anicraft/issues/238)) | Tweens | S | | doc |
|
||||
| P-012 | Small hardening fixes from outside, in batches as they come (the second, of 2026-11-24, is in the changelog): overflow in `Vec2::length` ([#142](https://github.com/storytold/anicraft/issues/142)), alpha kept by `Rgba::to_hex` ([#233](https://github.com/storytold/anicraft/issues/233)), a test for path numbers past `f32` ([#130](https://github.com/storytold/anicraft/issues/130)), private-use language tags ([#486](https://github.com/storytold/anicraft/issues/486)), a test of SVG link sanitising ([#500](https://github.com/storytold/anicraft/issues/500)) | (robustness) | S each | | several |
|
||||
| P-009 | Timeline bugs: a click on the playhead acts on every layer ([#195](https://github.com/storytold/anicraft/issues/195), outside PR [#222](https://github.com/storytold/anicraft/issues/222)), several layers selected with Ctrl and Shift ([#512](https://github.com/storytold/anicraft/issues/512)), the layer count over the header icons ([#523](https://github.com/storytold/anicraft/issues/523)), the mask edge drawn in the layer colour ([#429](https://github.com/storytold/anicraft/issues/429)) | Timeline, layers | S each | | timeline |
|
||||
| P-013 | No hairline between merged curved fills ([#182](https://github.com/storytold/anicraft/issues/182)) | Drawing model | M | | geom |
|
||||
| P-014 | Pen pressure on every desktop: Linux Wayland (outside PR [#320](https://github.com/storytold/anicraft/issues/320)), reports from tablets ([#290](https://github.com/storytold/anicraft/issues/290)) | Tools | M | a tablet to test with | platform |
|
||||
| P-015 | Verified by hand on real machines: the Mac checklist of [ADR 0062](adr/0062-test-movie-window-and-macos-document-opening.md), a hybrid-GPU laptop, passes with Narrator, VoiceOver and Orca ([ADR 0064](adr/0064-accessibility-second-pass.md)), launcher icons on Fedora ([#348](https://github.com/storytold/anicraft/issues/348)) | Accessibility, platforms | M | the machines; the person | platform |
|
||||
| P-016 | The guide tells the truth: "Coming from Animate" still lists shipped features as missing; close the issues the appendix marks delivered (the lead does that) | (docs) | S | | docs |
|
||||
| P-016 | The guide tells the truth, what is left: every chapter's "not yet" list was checked against the code on 2026-11-27 and "Coming from Animate" no longer lists shipped features as missing; left is closing the issues the appendix marks delivered (the lead does that) | (docs) | S | | docs |
|
||||
|
||||
### Next: the parity gaps artists meet every day
|
||||
|
||||
@@ -141,6 +140,9 @@ As of 2026-11-24 (46 open):
|
||||
|
||||
| PR | What | Id | State | What it still needs, or what happened |
|
||||
|---|---|---|---|---|
|
||||
| [#669](https://github.com/storytold/anicraft/issues/669) | No stale pasteboard fragments while stage tiles are replaced | P-004 | **merged** | Merged as it is. |
|
||||
| [#664](https://github.com/storytold/anicraft/issues/664) | The GPU counts the scratch memory of filtered work still in flight | P-004 | **merged, changed** | Merged as it is; changed afterwards in the P-013 pull request: it refused every filtered tile in the browser, where a submission can't be waited for, so there the allowance isn't kept and filtered layers draw on the GPU as before. |
|
||||
| [#633](https://github.com/storytold/anicraft/issues/633) | Stage coordinates at tiny zooms, and the fitted zoom kept when the zoom field loses focus | P-012 | **merged** | Merged as it is. |
|
||||
| [#13](https://github.com/storytold/anicraft/issues/13) | Bound the work of evaluating nested symbols | (done) | **superseded by** | The P-002 change ([ADR 0128](adr/0128-one-work-allowance-and-frames-that-say-what-they-left-out.md)), which took its ideas into the allowance `main` already had: layers, symbol lookups and outline sizes count as work, and a frame that ran out says so. Its commits were not merged: they rewrite what [#497](https://github.com/storytold/anicraft/issues/497) rewrote, and its charge of one unit per library entry would cut honest documents with large libraries. Credited in `AUTHORS.md`. |
|
||||
| [#39](https://github.com/storytold/anicraft/issues/39) | Text that mixes directions | (P-008, done) | **superseded by** | Its commits are merged in the P-008 pull request, which rebuilds it on the styled-text layout ([ADR 0130](adr/0130-mixed-directions-and-fallback-faces.md)): lines found in reading order and never inside a cluster, and its tests, are kept; levels and reordering come from `craft-text`. Nothing in it is left out. |
|
||||
| [#40](https://github.com/storytold/anicraft/issues/40) | Letters from a fallback face | (P-008, done) | **superseded by** | Merged and rebuilt with [#39](https://github.com/storytold/anicraft/issues/39) ([ADR 0130](adr/0130-mixed-directions-and-fallback-faces.md)): its family list, the cluster that moves whole with its marks, invisible characters that are never missing and the note about boxes are kept; installed faces outside the list, which it left for later, are searched too. |
|
||||
@@ -195,7 +197,7 @@ As of 2026-11-24 (46 open):
|
||||
| [#583](https://github.com/storytold/anicraft/issues/583) | Next and Previous Frame stop at the ends ([#561](https://github.com/storytold/anicraft/issues/561)) | (done) | **superseded by** | Merged with its commit. |
|
||||
| [#582](https://github.com/storytold/anicraft/issues/582) | A press selects at once and the playhead follows a drag ([#561](https://github.com/storytold/anicraft/issues/561)) | (done) | **superseded by** | Merged with its commit. Left from [#561](https://github.com/storytold/anicraft/issues/561): whether the playhead may stand on an empty cell. |
|
||||
| [#581](https://github.com/storytold/anicraft/issues/581) | PNG frames and sequences can export transparent ([#536](https://github.com/storytold/anicraft/issues/536)) | (done) | **superseded by** | Merged with its commits, joined with the left-out note of [ADR 0128](adr/0128-one-work-allowance-and-frames-that-say-what-they-left-out.md). Left from [#536](https://github.com/storytold/anicraft/issues/536): a transparent GIF. |
|
||||
| [#580](https://github.com/storytold/anicraft/issues/580) | The marquee takes the objects it touches ([#522](https://github.com/storytold/anicraft/issues/522)) | (done) | **superseded by** | Merged with its commit. The reference app has a preference for this; ours is always on. |
|
||||
| [#580](https://github.com/storytold/anicraft/issues/580) | The marquee takes the objects it touches ([#522](https://github.com/storytold/anicraft/issues/522)) | (done) | **superseded by** | Merged with its commit. The reference app has a preference for this; ours came after (Preferences › Stage, `view.select_touching`), on to begin with. |
|
||||
| [#579](https://github.com/storytold/anicraft/issues/579) | Distribute to Layers ([#517](https://github.com/storytold/anicraft/issues/517)) | (done) | **superseded by** | Merged with its commits. Left in P-021: raw shapes, and Distribute to Keyframes. |
|
||||
| [#578](https://github.com/storytold/anicraft/issues/578) | Match Size and Space Evenly in Align ([#566](https://github.com/storytold/anicraft/issues/566)) | (done) | **superseded by** | Merged with its commits; it measures outlines as align does, and the Align panel's default height shows the new row. |
|
||||
| [#577](https://github.com/storytold/anicraft/issues/577) | Each filter in Properties is a card that folds ([#533](https://github.com/storytold/anicraft/issues/533), [#534](https://github.com/storytold/anicraft/issues/534)) | (done) | **superseded by** | Merged with its commit. |
|
||||
@@ -279,7 +281,7 @@ This integration depends on craft-libs #1962 and still requires hosted parity va
|
||||
| Architecture | M0 skeleton in place: geom → doc → render → engine → cli → shell, layering enforced by `cargo test` (`src/architecture_tests.rs`: lower layers only, no UI crates below the shell, and the AGENTS.md map must match). |
|
||||
| Rendering | CPU oracle with analytic AA, non-zero/even-odd, solid + linear/radial gradients (with reflect/repeat, focal points, elliptical radials and linear RGB, ADR 0074), round-join strokes. **A stroke is covered as one outline** (ADR 0110): the stroker builds each run of segments as an outline and unites the loops, so pixels where its pieces used to overlap (round joins and caps, the joints of wide curves, dashes that run together, a line crossing itself) are no longer up to half a pixel too dark, on the CPU and the GPU stage alike; a line with corners, flat or square ends is drawn pixel for pixel as its Convert Lines to Fills fill, a curved or round one within the 0.1 px flattening (not yet: one geometry for both on curves, a per-stroke outline cache, dashes measured along the curve). **Mask clipping**: the display list carries nested clips; a clip is the anti-aliased union of its mask fills (strokes and opacity ignored), intersected with any enclosing clip, computed once per render band; an empty mask hides everything under it. **Soft masks** (ADR 0070): a mask layer's mask type is Shape (coverage), Alpha (its artwork's opacity as drawn: gradients, faded shapes, strokes, bitmaps) or Luminance (brightness × opacity, SVG's coefficients), in the CPU oracle (analytic tests), the GPU stage (parity: mean 0.00006, worst 1 step of 255), SVG export (`<mask>` with `mask-type`), Lottie (alpha and luma track mattes) and the HTML canvas; Layer Properties › Mask type. **Group alpha**: a symbol instance below full opacity is a group in the display list; each render band composites the group's run of ops into its own buffer (nested groups stack) and blends it once at the group's alpha, so overlaps don't show through; SVG export writes `<g opacity>`. **Blend modes** (Animate's 14, on movie clip and button instances): an instance with one is an isolated group that blends at its close with the W3C separable formulas on premultiplied colour (Alpha and Erase keep or clear the backdrop); SVG gets CSS `mix-blend-mode`, Lottie the layer `bm`. **Bitmaps**: `Paint::Bitmap` fills (once or tiled) with bilinear sampling in premultiplied space, colour effects per sample; PNG/JPEG import to stage (a rectangle of the image's size); stored in the document as PNG (base64 in `.anicraft`), decoded once on first use; SVG export embeds each image once as a pattern. **Filters**: a filtered group is drawn on its own (by the same renderer, recursively, so nested filters work) into a buffer over its artwork grown by the filters' reach, filtered (box-blur passes; shadow and glow from the blurred, offset opacity; **bevel and gradient bevel** from the difference of the blurred opacity offset towards and away from the light, **gradient glow** from the glow's intensity, both through a colour ramp whose rest stop is pinned transparent, inner/outer/full and knockout, ADR 0025; colour matrix), and composited back as one image in its group, so alpha and blend apply; clips from inside the symbol apply before filtering and the instance's own clip after. Filters apply in list order and may be switched off (ADR 0091): `evaluate` leaves switched-off ones out, so every renderer and export draws them as absent. **GPU stage, first slice** (M3, ADR 0019; `--features gpu-stage`, off by default): Preferences › Stage › Renderer *GPU (preview)* draws the stage with wgpu compute from the oracle's own prepared fills (tile binning with per-row backdrops on the CPU, exact area coverage and src-over per pixel on the GPU): solid and gradient fills and strokes, non-zero and even-odd; masks, group opacity, blend modes, filters and bitmaps fall back to the CPU per tile, and the status bar says so. Parity with the oracle: max 1/255, mean < 0.0001/255 on the sample, stress and analytic scenes (tests skip without an adapter). 4K with 1,000 shapes: 8.8–9.0 ms vs the CPU's 17.4–17.8 ms. **Second slice** (ADR 0029): on the window's wgpu device the stage tiles are drawn straight into textures egui shows (no readback; a headless device with readback when the window is on OpenGL); **masks** (nested, united artwork), **group opacity** and **all 14 blend modes** on the GPU, same parity (max 1/255, mean ≤ 0.0011/255); 4K: 1,000 shapes in 2.1–2.4 ms, 10k shapes in 10.2 ms as stage tiles, masked scenes 7× the CPU. **Third slice** (ADR 0032): **bitmap fills** (textures uploaded once per image and cached under a 256 MB budget, sampled with the oracle's own bilinear filter, colour effect and repeat rules: byte-identical) and **all seven filters** (each filtered symbol drawn into a layer of its own and filtered by compute passes that run the oracle's resolved steps: max 1/255, mean ≤ 0.007/255) on the GPU; the shaders now build with Direct3D's FXC, so DX12 windows get the GPU stage too (parity suite green on Vulkan and DX12); software adapters are refused (the CPU is faster), the start-up self-test compares with the oracle. **The GPU is the default stage renderer**: theLine truncated
|
||||
| Timeline | **Frame selection**: click, Shift-click or drag across frames and layers; F5/Shift+F5, F6/F7 and Shift+F6 (keys, icon buttons and right-click menu) act on the whole selection; with no frame selection F5 extends every layer with frames at or after the playhead, and F5/F6/F7 move the playhead on as in Animate (F6/F7 on a keyframe key the next frame; `all_layers`/`advance` headless); drag selected keyframes left or right to move them, and up or down onto other layers (the source keeps empty frames) (with a drop outline; one undo step; keys they land on are replaced, and spans fill the frames left behind); removing or clearing selected frames that hold artwork asks first. **Cut/Copy/Paste Frames** (Ctrl+Alt+X/C/V, and plain Ctrl+X/C/V after clicking the timeline): own clipboard, copies cut exactly at the selection edges (mid-tween state kept), paste inserts like Animate, several layers paste onto the layers below (missing ones are created), fresh element ids, symbols travel with them. **Span length by dragging its end** (resize cursor, live outline with the length in frames and seconds; later frames move with it; a motion tween's keys stretch in proportion, ADR 0083). Side dock tab strips never run under the panel menu (names shrink with an ellipsis, then the strip scrolls). Headless: `layers`/`count` on the frame commands, `timeline.move_keyframes`, `timeline.cut_frames/copy_frames/paste_frames`. Layers (show/lock/outline), **timeline polish** (ADR 0061): a per-layer **onion skin toggle** column (Alt-click solos; left-out layers aren't onion-skinned; Edit Multiple Frames unaffected), the colour square toggles **View as Outlines** in the layer colour **on the stage only** (exports, Test Movie and the player draw the artwork as it is), the **colour chip** opens the layer colour (swatches, hex, More…), **onion frames of the parent timeline** dimmed around a symbol edited in place, **Layer Height** 100/200/300 %, **Layer Properties** (double-click the layer icon; name, show/lock, type, outline colour, outlines, onion, height; one undo step), **Frame View** (Tiny/Small/Normal/Medium/Large, Short rows) with the frame zoom in the timeline's bottom bar (the header fits at the default window size, tested); headless `layer.set_onion/set_color/set_height/set_properties/properties`; XFL `heightMultiplier`. Not yet: folder onion toggles, onion of deeper parent timelines, multi-layer Layer Properties and layer transparency, frame thumbnails (Preview). **Layers by drag and all at once** (M8, from the issue tracker): drag a layer by its name to reorder it or drop it on a folder (a line shows where it lands; folders, masks and guides move whole; one undo step; `layer.move {before | after | into}`), the eye, padlock and outline square above the layer names act on every layer (`all` on the three toggles), and the line between the layer names and the frames drags (150–600 pt, kept in the preferences). Not yet: several selected layers dragged together, dragging a layer onto another scene. Keyframes, blank keyframes, insert/remove frames, classic tweens with **ease presets and custom eases** (ADR 0081: Classic Ease with a strength and Quad, Cubic, Quart, Quint, Sine, Back, Circ, Bounce and Elastic In/Out/In Out; custom eases of up to 64 Bézier points in the Custom Ease window, x kept monotonic, overshoot allowed, keyboard operable, **shape tweens** (morph between any two shapes: segments made cubic, subpaths paired by size and grown from or shrunk to a point when counts differ, segment counts equalized by subdivision, windings matched and start points aligned; amber spans; classic ⇄ shape keeps the easing; **shape hints** (ADR 0023): Modify › Shape › Add Shape Hint (Ctrl+Shift+H) adds lettered markers `a`–`z` that the artist drags onto an edge on the first and last keyframe (rose until placed, amber placed on the first, mint on the last; right-click removes), the morph cuts both outlines at the hinted points and matches the pieces in order by length; `tween.add_hint/move_hint/remove_hint/clear_hints/hints`; not yet: View › Show Shape Hints, hints inside symbols edited in place), auto-key when editing inside a tween, frame labels, symbol nesting: graphics keep step with their timeline (loop, play once, single frame, first frame; set in Properties), movie clips loop their own timeline from when the instance appears (continuous across keyframes holding the same instance), buttons show their Up frame, looping playback. **Onion skin and Edit Multiple Frames** (ADR 0047): onion markers on the frame ruler (drag the start and end brackets; Always Show Markers, Anchor Markers, Onion 2 / Onion 5 / Onion All, also on a right-click on the ruler), frames before and after the playhead tinted in their own colours (theme blue and green, changeable in the onion menu, Reset) and fading with distance, Outlines, Keyframes Only, locked layers left out as in Animate, each layer's onion frames under its own artwork and over tLine truncated
|
||||
| Drawing | Selection (click, shift-add, marquee, drag-move, arrow nudge; **across layers**, ADR 0044: a selection holds artwork on several visible, unlocked layers, the timeline marks them, Properties shows mixed values), **Free Transform (Q)**: scale from corner/edge handles (Shift proportional, Alt from centre), **skew** by dragging the line between two handles (the opposite edge stays, Alt about the centre; outside PR #176), rotate outside corners (Shift snaps 15°), move; one undo step per drag. Rectangle (corner radius), oval, PolyStar, line (45° snap), hand, zoom. **Pen (P)**: click for corners, drag for smooth handles (Alt breaks them), close on the first point, Enter/Esc/last-point click finishes, Backspace takes back a point; one undo step per path. **Pencil (Shift+Y)**: Smooth (Schneider curve fitting with corner detection), Straighten and Ink modes, smoothing relative to the screen. **Subselection (A)**: anchors and handles on selected shapes, drag points/handles (anchors bring their handles; one undo step per drag), point marquee, double-click an edge to add a point, Delete removes points, right-click Make Smooth/Corner; closed shapes' start point and closing edge edit like any other. **Cut/Copy/Paste in Center/Paste in Place** (the clipboard carries symbols across documents; pasted raw shapes float, selected, until they are deselected, and Paste takes a picture copied in another app as a bitmap, ADR 0108; not yet: vectors copied in other apps). Free Transform: not yet a transformation point you can move (it is the box's centre) or a box that turns with a rotated object. **Rotate 90° CW/CCW, Flip H/V. Align** left/centre/right/top/middle/bottom (Ctrl+Alt+1…6; a single element aligns to the stage) and distribute. Convert to symbol / break apart; arrange; duplicate. Headless: `draw.path`, `draw.freehand`, `path.move_points/add_point/delete_points/convert_point`. **Paint Bucket (K)**: click a fill to recolour it, or inside an outline (one shape or several) to fill the enclosed area; gap size None/Small/Medium/Large closes openings; the fill is traced and curve-fitted into a new shape placed under its lines; open areas say so instead of flooding. **Ink Bottle (S)**: gives the clicked shape the current stroke. Headless: `paint.bucket`, `paint.ink`. Tool options show first in Properties while a drawing tool is active. **Text (T)** (ADR 0012): click to type on the stage, click or double-click text to edit it; font (installed families, plus the embedded Inter), size, colour, under or over the artwork, snap accuracy up to Always); Snap to Pixels; one snap engine for every drawing tool, the Selection tool's moves and Free Transform's handles (point › guide › line › grid › pixel, guides and grid per axis); stage only, never exported, on the CPU and GPU stage. Headless: `view.rulers`, `view.grid_show/grid_snap/grid_set`, `view.guides_show/guides_lock/guides_snap/guides_set`, `view.guide_add/guide_move/guide_delete/guides_clear`, `view.snap_pixels`, `view.aids`, `moving` on `draw.snap`. *Not yet:* units other than px, a movable ruler origin, a symbol's own guides, guides and grid from Animate files, Snap Align and Edit Snapping, snapping while rotating. bold, italic, alignment, letter/line spacing, wrap width; the last style is kept for new text; laid out by `anicraft-text` (`fontdb` discovery, `harfrust` shaping, `skrifa` outlines) and stored as outlines with the source, so rendering never needs the font; Break Apart makes a shape. **Variable-width strokes** (ADR 0018): a stroke's width varies along it through width points (position by arc length, a width on each side as a factor of the stroke width, smooth monotone interpolation); built-in profiles (Uniform, Taper both ends, Taper start, Taper end, Bulge, Pinch) in Properties › Width with a picture of each, and in the drawing tools' options for new strokes; the **Width tool (U)**: hover a stroke to see its width points, drag a handle to widen or narrow (Alt: one side), drag the dot to slide a point, drag anywhere on the stroke to add one, Delete removes; one undo step per drag; rendered by the oracle as trapezoids with outer round joins and cross-section caps, written by SVG and Lottie export as the same filled outlines; shape tweens blend profiles; `.anicraft` keeps them (older files open as uniform). Headless: `stroke.set_profile`, `stroke.set_width_point`, `stroke.delete_width_point`, `stroke.width_at`, `profile` on `element.set_stroke`, the drawing commands and `paint.ink`. Not yet: width data from or to Animate files, saved custom profiles, pressure. **Stroke styles** (ADR 0046): Properties › Style (Solid, Dashed with dash and gap, Dotted with spacing), Cap (None, Round, Square), Join (Miter, Round, Bevel) and Miter limit, also in the drawing tools' options for new strokes; drawn exactly by the oracle (butt and square caps, miters bevelled past the limit, dashes by arc length restarting per subpath, round dots, dashes keeping a widthLine truncated
|
||||
| Drawing | Selection (click, shift-add, marquee, drag-move, arrow nudge; **across layers**, ADR 0044: a selection holds artwork on several visible, unlocked layers, the timeline marks them, Properties shows mixed values), **Free Transform (Q)**: scale from corner/edge handles (Shift proportional, Alt from centre), **skew** by dragging the line between two handles (the opposite edge stays, Alt about the centre; outside PR #176), rotate outside corners (Shift snaps 15°), move; one undo step per drag. Rectangle (corner radius), oval, PolyStar, line (45° snap), hand, zoom. **Pen (P)**: click for corners, drag for smooth handles (Alt breaks them), close on the first point, Enter/Esc/last-point click finishes, Backspace takes back a point; one undo step per path. **Pencil (Shift+Y)**: Smooth (Schneider curve fitting with corner detection), Straighten and Ink modes, smoothing relative to the screen. **Subselection (A)**: anchors and handles on selected shapes, drag points/handles (anchors bring their handles; one undo step per drag), point marquee, double-click an edge to add a point, Delete removes points, right-click Make Smooth/Corner; closed shapes' start point and closing edge edit like any other. **Cut/Copy/Paste in Center/Paste in Place** (the clipboard carries symbols across documents; pasted raw shapes float, selected, until they are deselected, and Paste takes a picture copied in another app as a bitmap, ADR 0108; not yet: vectors copied in other apps). Free Transform: not yet a transformation point you can move (it is the box's centre) or a box that turns with a rotated object. **Rotate 90° CW/CCW, Flip H/V. Align** left/centre/right/top/middle/bottom (Ctrl+Alt+1…6; a single element aligns to the stage) and distribute. Convert to symbol / break apart; arrange; duplicate. Headless: `draw.path`, `draw.freehand`, `path.move_points/add_point/delete_points/convert_point`. **Paint Bucket (K)**: click a fill to recolour it, or inside an outline (one shape or several) to fill the enclosed area; gap size None/Small/Medium/Large closes openings; the fill is traced and curve-fitted into a new shape placed under its lines; open areas say so instead of flooding. **Ink Bottle (S)**: gives the clicked shape the current stroke. Headless: `paint.bucket`, `paint.ink`. Tool options show first in Properties while a drawing tool is active. **Text (T)** (ADR 0012): click to type on the stage, click or double-click text to edit it; font (installed families, plus the embedded Inter), size, colour, under or over the artwork, snap accuracy up to Always); Snap to Pixels; one snap engine for every drawing tool, the Selection tool's moves and Free Transform's handles (point › guide › line › grid › pixel, guides and grid per axis); stage only, never exported, on the CPU and GPU stage. Headless: `view.rulers`, `view.grid_show/grid_snap/grid_set`, `view.guides_show/guides_lock/guides_snap/guides_set`, `view.guide_add/guide_move/guide_delete/guides_clear`, `view.snap_pixels`, `view.aids`, `moving` on `draw.snap`. *Not yet:* units other than px, a movable ruler origin, a symbol's own guides, guides and grid from Animate files, Snap Align and Edit Snapping, snapping while rotating. bold, italic, alignment, letter/line spacing, wrap width; the last style is kept for new text; laid out by `anicraft-text` (`fontdb` discovery, `harfrust` shaping, `skrifa` outlines) and stored as outlines with the source, so rendering never needs the font; Break Apart makes a shape. **Variable-width strokes** (ADR 0018): a stroke's width varies along it through width points (position by arc length, a width on each side as a factor of the stroke width, smooth monotone interpolation); built-in profiles (Uniform, Taper both ends, Taper start, Taper end, Bulge, Pinch) in Properties › Width with a picture of each, and in the drawing tools' options for new strokes; the **Width tool (U)**: hover a stroke to see its width points, drag a handle to widen or narrow (Alt: one side), drag the dot to slide a point, drag anywhere on the stroke to add one, Delete removes; one undo step per drag; rendered by the oracle as trapezoids with outer round joins and cross-section caps, written by SVG and Lottie export as the same filled outlines; shape tweens blend profiles; `.anicraft` keeps them (older files open as uniform). Headless: `stroke.set_profile`, `stroke.set_width_point`, `stroke.delete_width_point`, `stroke.width_at`, `profile` on `element.set_stroke`, the drawing commands and `paint.ink`. Not yet: width data from or to Animate files, saved custom profiles, pressure. **Stroke styles** (ADR 0046): Properties › Style (Solid, Dashed with dash and gap, Dotted with spacing), Cap (None, Round, Square), Join (Miter, Round, Bevel) and Miter limit, also in the drawing tools' options for new strokes; drawn exactly by the oracle (butt and square caps, miters bevelled past the limit, dashes by arc length restarting per subpath, round dots, dashes keeping a widthLine truncated
|
||||
| Plug-ins | **WebAssembly plug-ins** (ADR 0017, `docs/plugins.md`): sandboxed modules run by `wasmi` with no imports but the AniCraft ABI (`anicraft.call`/`anicraft.response`: JSON requests that run registry commands, read a compact document view or the active layer's elements, and log); fuel (10⁹ instructions), memory (256 MiB), wall-clock (5 s), request, size and log limits, a fresh instance per run; file, plug-in, undo and clipboard commands refused. `plugin.install/list/run/remove/reload`; a run is atomic and one undo step named after the plug-in. App: **Commands** menu (Plug-ins, Install, Manage, Reload), palette entries, a dialog generated from the manifest's parameters with a live preview; plug-ins load from `<settings>/plugins` or `ANICRAFT_PLUGINS`; CLI `--plugins`. Samples in Rust (Star Field, Jitter Selection, guest SDK) in `examples/plugins`. Frame scripts: see Interactivity. **Exporter and ease plug-ins** (ADR 0088): `kind: "exporter"` declares a format (name, extension, options) and gets evaluated frames (`movie`, `frame`: the flattened display list, never the document), returning the file's bytes from `ac_export` (64 MiB cap, 5·10¹⁰ instructions, 10 min); File › Export lists it with an Export window (options, frames, file, progress bar and Cancel on a worker thread); `file.export_plugin`, `file.export_formats`, `anicraft-cli export --format <id>` and `formats`. `kind: "ease"` declares named eases, `ac_ease(i, t)` sampled into 257 values at load (NaN, unbounded or end-missing eases refused); `Easing::Sampled` keeps the table in the document, so it plays the same without the plug-in; the ease menus list them under Plug-in eases; `{plugin, ease}` easing params. Samples: Plain Text Frames and Stepped Eases, built and run in CI. Not yet: plug-in formats in Publish, bitmaps' pixels and sounds for exporters, ease plug-ins with parameters, background runs of command plug-ins, a binary document view. |
|
||||
| Interactivity | **Frame actions, frame scripts and Test Movie, first slice** (ADR 0024): a typed timeline action IR (`anicraft-actions`: stop, play, go to a frame or label in a scene, next/previous frame and scene, trace, set x/y/alpha/visible/rotation/scale, instance-name target paths) on keyframes and on button and movie clip instances (click, press, release, over, out); a pure, deterministic, budgeted player in `anicraft-doc` (`step(doc, &state, &events)`; movie clip playheads, button Up/Over/Down states with Hit-frame hit tests, script-set properties) drawn by `evaluate_player`, while `evaluate` and exports stay script-free. **Actions panel** (F9: structured lists, targets/labels/scenes picked from the document; movie clip timelines too), instance name and events in Properties, an "a" on keyframes with actions. **Frame scripts** on the plug-in host (`kind: "frame-script"`, entry points, `player`/`action` ops, 20 M instructions per frame shared, no document access). **Test Movie** (Control › Test Movie, Ctrl+Enter): the player at the document frame rate in its own window with the pointer, restart/pause/step and an Output panel. **A window of its own on the desktop** (ADR 0062): sized to the stage at 100 % (smaller to fit the screen), titled with the document, back where it was last (not on Wayland, where the desktop places windows), with the keyboard when it opens; Esc or Ctrl+W (⌘W) closes it, Ctrl+Enter restarts it in place, and the editor's Ctrl/Alt shortcuts work from it; floating inside the editor in the web build, where the system can't open windows (it says so), or by choice in Preferences › Test Movie. Not yet: full screen, zoom in the movie window, remembering its size. Headless: `actions.set/clear/list`, `instance.set_name`, `control.test_movie` (timed pointer events, returns output and state). **HTML canvas export** (ADR 0028, `file.export_html`, File › Export › Export HTML Canvas…): one self-contained page (data, player and drawing code inline; images and sounds embedded) that plays in any browser with canvas 2D; every used timeline baked frame by frame (tweens of every kind exact, identical paths, paints and frames stored once), movie clips, buttons with Hit areas and every action run by `player.js`, a port of the Rust player checked against it step by step in Boa (state, output and display list); masks and fading/blending groups on offscreen layers; **filters and Subtract/Invert in the page** (ADR 0072: `filters.js`, a port of the renderer's filters run over the group's pixels on a layer that reaches past the canvas by the filters' reach, Subtract and Invert composited per pixel, results kept while the group is unchanged; equal to the oracle's pixels within 9.3e-4 in Boa; 3.4 ms a frame for the demo's filters at 1080p while they change); Web Audio for Event/Start/Stop/Stream sounds; bitmap tints, 9-slice scaling and plug-in frame scripts reported. Not yet: 9-slice in the page, keeping a moving filtered group's pixels, filters off the main thread. **Kept frame scripts** (ADR 0013 tier 1): scripts written in another language (an Animate document's ActionScript) kept verbatim on keyframes with their language, symbol linkage classes and the document class; the Actions panel's **Script** view (monospace editor with line numbers, language, live and undoable), the same "a" marker, Class rows in Properties; `script.set/clear/list/set_class`; **ActionScript timeline subset runs** (ADR 0013 tier 2): a hand-written, bounded lexer and parser (`anicraft_actions::as3`) lower stop/play/go to/next and previous frame and scene on instance-name paths, mouse listeners (click, down, up, roll over and out; named or inline functions, `currentTarget`), `trace` and property settings to the action IR, compiled once per script; anything else is reported with line and column and the script doesn't run (never half-run), `navigateToURL` and the like are ignored and noted; the player keeps listeners per instance, Test Movie's Output says which scripts run and which don't and why, the Script view lists problems in place, the XFL report and `script.list/check` say what runs, and the HTML page runs the same steps (`player.js` checked against the Rust player). **ActionScript small logic** (ADR 0052): scripts compile to a small typed script IR evaluated by the player with fuel (100,000 per script or listener call, 1,000,000 per step; an endless loop or a run-time error stops its script with an Output line and the movie plays on): typed variables (Number, int, uint, Boolean, String, untyped) kept per timeline instance across its frame scripts, expressions as ECMA-262 has them, `if`/`else`, `for`/`while`/`do`, functions with parameters, results and recursion, called from any frame of the same timeline (a timeline-level link step; names that aren't there keep the script from running, said in place), property reads of instances and timelines (`x`, `y`, `alpha`, `visible`, `rotation`, `scaleX/Y`, `currentFrame`, `tLine truncated
|
||||
| Headless | CLI: info, render, render-seq, **gif**, **apng**, **webp**, commands, exec, run, serve (JSON-lines). **MCP server** (`anicraft-cli mcp`, `docs/mcp.md`): stdio JSON-RPC, protocol 2025-06-18 (and 2025-03-26, 2024-11-05); five tools over the command registry (list, run, run a script, describe the document, render a frame as a PNG picture); confirmation tiers and undo apply as in the app. **Live control** (ADR 0104, `docs/control-protocol.md`): `anicraft --control <port>` and `anicraft-cli mcp --bridge <port>` run the same tools on the open window, on this computer only, with a per-run token in `control.json`. **Automation roots** (ADR 0124, AGENTS.md rule 18): `mcp` refuses to start without `--automation-read-root` and `--automation-write-root`; an assistant's commands read inside the read roots and write inside the write root only, checked in the engine (`engine::access`: given paths before the command runs, every `vfs` call, ffmpeg, XFL folders and the plug-in registry) on the resolved path (`..`, links, junctions, letter case), with errors that name the root; the bridge carries the roots and the window applies them per call (control protocol 2); `serve` takes them optionally (not yet: roots saved in the app's preferences as a cap on any bridge, a shared craft-libs helper, environment variables, file handles held open against a swapped link). |
|
||||
|
||||
@@ -33,11 +33,12 @@ OUTPUT="$DIST/anicraft-$VERSION-macos-aarch64-nightly.zip"
|
||||
nightly_compile_gui
|
||||
|
||||
APP="$NIGHTLY_WORK/stage/$MAC_NIGHTLY_APP"
|
||||
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
|
||||
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources/docs"
|
||||
cp "$NIGHTLY_GUI" "$APP/Contents/MacOS/AniCraft"
|
||||
chmod 755 "$APP/Contents/MacOS/AniCraft"
|
||||
cp "$ROOT/assets/app-icon/anicraft-nightly.icns" "$APP/Contents/Resources/anicraft-nightly.icns"
|
||||
nightly_copy_notices "$APP/Contents/Resources"
|
||||
# Launcher admits notices under Resources/docs, not beside the icon.
|
||||
nightly_copy_notices "$APP/Contents/Resources/docs"
|
||||
# The private mktemp cwd is the helper authority root: stage the template inside it.
|
||||
cp "$HERE/Info.plist.in" "$NIGHTLY_WORK/Info.plist.in"
|
||||
(cd "$NIGHTLY_WORK" && python3 "$HERE/nightly_plist.py" --template Info.plist.in \
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
"""The macOS Nightly signing and verification scripts, run on any POSIX host against generated
|
||||
fixtures and stand-in Apple tools (codesign, notarytool, stapler, spctl, security, ditto, plutil,
|
||||
lipo) that log their arguments. This proves the scripts' order, refusals and cleanup; it is not a
|
||||
real signature, notarization or Mac run."""
|
||||
lipo) that log their arguments. The unsigned producer also runs with a stub GUI build. These
|
||||
check the scripts and bundle layout, not native signing, notarization or Mac execution."""
|
||||
import base64
|
||||
import importlib.util
|
||||
import json
|
||||
@@ -27,6 +27,7 @@ COMMIT = "b" * 40
|
||||
VERSION = "0.3.0-nightly.20261123.4567.1.g" + COMMIT[:12]
|
||||
ASSET = f"anicraft-{VERSION}-macos-aarch64-nightly.zip"
|
||||
APP = "AniCraft Nightly.app"
|
||||
APP_NOTICES = ("README.md", "LICENSE-MIT", "LICENSE-APACHE", "NOTICE", "ATTRIBUTION.md")
|
||||
TEAM = "ABCDE12345"
|
||||
IDENTITY = "0123456789ABCDEF0123456789ABCDEF01234567"
|
||||
SECRETS = {
|
||||
@@ -183,6 +184,49 @@ class Fixture:
|
||||
z.writestr(info, b"" if path.is_dir() else path.read_bytes())
|
||||
return self.input
|
||||
|
||||
def package(self, font_licences):
|
||||
"""Drive the real producer from a clean fixture checkout, without Cargo or Apple tools."""
|
||||
source = HERE.parents[1]
|
||||
checkout = self.root / "source"
|
||||
checkout.mkdir()
|
||||
for relative in (*APP_NOTICES, "packaging/env.sh", "packaging/nightly-common.sh", "packaging/nightly_paths.py",
|
||||
"packaging/macos/nightly.sh", "packaging/macos/nightly-lib.sh",
|
||||
"packaging/macos/Info.plist.in", "packaging/macos/nightly_plist.py",
|
||||
"assets/app-icon/anicraft-nightly.icns"):
|
||||
target = checkout / relative
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copyfile(source / relative, target)
|
||||
env = self.env(**dict.fromkeys(SECRETS))
|
||||
|
||||
def git(*args):
|
||||
return subprocess.run(["git", "-c", "core.hooksPath=/dev/null", "-c", "commit.gpgsign=false", *args],
|
||||
cwd=checkout, env=env, check=True, capture_output=True, text=True, timeout=30).stdout
|
||||
|
||||
git("init", "-q")
|
||||
git("add", "--", ".")
|
||||
git("-c", "user.name=Fixture", "-c", "user.email=fixture@example.invalid", "commit", "-qm", "Packaging fixture")
|
||||
commit = git("rev-parse", "HEAD").strip()
|
||||
version = VERSION[:-12] + commit[:12]
|
||||
# Generated licence text exercises the copier without depending on a font checkout.
|
||||
fonts = self.root / "craft-fonts"
|
||||
for family, data in font_licences.items():
|
||||
licence = fonts / "fonts" / family / "OFL.txt"
|
||||
licence.parent.mkdir(parents=True)
|
||||
licence.write_bytes(data)
|
||||
# The existing cargo stub fails for every invocation. Only this producer fixture emits a GUI.
|
||||
(self.bin / "cargo").write_text(
|
||||
'#!/bin/sh\nset -eu\n'
|
||||
'gui="$CARGO_TARGET_DIR/aarch64-apple-darwin/release/anicraft"\n'
|
||||
'mkdir -p "$(dirname "$gui")"\n'
|
||||
"printf \"#!/bin/sh\\necho 'AniCraft %s (nightly-v1)'\\n\" \"$ANICRAFT_VERSION\" >\"$gui\"\n",
|
||||
)
|
||||
result = self.run(checkout / "packaging/macos/nightly.sh", "--arch", "aarch64", **dict.fromkeys(SECRETS),
|
||||
DIST=str(self.dist), CARGO_TARGET_DIR=str(self.root / "target"), CRAFT_FONTS_DIR=str(fonts),
|
||||
ANICRAFT_BUILD_CHANNEL="nightly-v1", ANICRAFT_VERSION=version,
|
||||
ANICRAFT_BUILD_SHA=commit, ANICRAFT_BUILD_DATE="2026-11-23")
|
||||
assert result.returncode == 0, result.stdout
|
||||
return self.dist / ASSET.replace(VERSION, version)
|
||||
|
||||
def env(self, **changes):
|
||||
env = {"PATH": f"{self.bin}:{os.environ['PATH']}", "HOME": str(self.root), "SHIM_LOG": str(self.log),
|
||||
"SHIM_TEAM": TEAM, "SHIM_IDENTITY": IDENTITY, "RUNNER_TEMP": str(self.temp), **SECRETS}
|
||||
@@ -410,6 +454,39 @@ class Verify(unittest.TestCase):
|
||||
|
||||
|
||||
class Build(unittest.TestCase):
|
||||
def test_unsigned_archive_has_launcher_layout_and_keeps_all_notices(self):
|
||||
f = Fixture(self)
|
||||
fonts = {"fixture-one": b"generated font notice one", "fixture-two": b"generated font notice two"}
|
||||
archive = f.package(fonts)
|
||||
source = HERE.parents[1]
|
||||
resources = f"{APP}/Contents/Resources"
|
||||
icon = "anicraft-nightly.icns"
|
||||
notice_files = {name: (source / name).read_bytes() for name in APP_NOTICES}
|
||||
notice_files.update({f"OFL-{family}.txt": data for family, data in fonts.items()})
|
||||
# Shipped Launcher v0.20.3 accepts these leaves only in Resources/docs, except for the root icon.
|
||||
expected_files = {f"{resources}/docs/{name}": data for name, data in notice_files.items()}
|
||||
expected_files[f"{resources}/{icon}"] = (source / "assets/app-icon" / icon).read_bytes()
|
||||
contents = f"{APP}/Contents"
|
||||
gui = f"{contents}/MacOS/AniCraft"
|
||||
with zipfile.ZipFile(archive) as zipped:
|
||||
entries = zipped.infolist()
|
||||
names = {entry.filename for entry in entries}
|
||||
self.assertEqual(len(entries), len({name.casefold() for name in names}), "unique paths, ignoring case")
|
||||
self.assertEqual({entry.filename for entry in entries if not entry.is_dir()},
|
||||
set(expected_files) | {gui, f"{contents}/Info.plist", f"{contents}/PkgInfo"})
|
||||
self.assertTrue({entry.filename for entry in entries if entry.is_dir()} <= {
|
||||
f"{APP}/", f"{contents}/", f"{contents}/MacOS/", f"{resources}/", f"{resources}/docs/"})
|
||||
for path, data in expected_files.items():
|
||||
with self.subTest(path=path):
|
||||
self.assertEqual(zipped.read(path), data)
|
||||
mode = zipped.getinfo(path).external_attr >> 16
|
||||
self.assertTrue(stat.S_ISREG(mode))
|
||||
self.assertFalse(mode & 0o111)
|
||||
mode = zipped.getinfo(gui).external_attr >> 16
|
||||
self.assertTrue(stat.S_ISREG(mode) and mode & stat.S_IXUSR)
|
||||
result = f.run("nightly-verify.sh", "--input", archive, "--expect", "unsigned", **dict.fromkeys(SECRETS))
|
||||
self.assertEqual(result.returncode, 0, result.stdout)
|
||||
|
||||
def test_compilation_refuses_signing_material_before_building(self):
|
||||
f = Fixture(self)
|
||||
for name in ("APPLE_CERTIFICATE", "APPLE_PASSWORD", "MACOS_SIGN_IDENTITY", "WINDOWS_CERTIFICATE", "AZURE_CLIENT_SECRET", "LINUX_SIGNING_KEY"):
|
||||
|
||||
@@ -9,7 +9,16 @@ import unittest
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
INSTALLED_POLICY = ROOT / ".github/nightly-signing-policy.json"
|
||||
|
||||
# The dedicated signer branch the installed policy names and the signer guard requires.
|
||||
SIGNER_BRANCH = "nightly-signer"
|
||||
|
||||
NIGHTLY_PLATFORMS = ("windows-x86_64", "linux-x86_64", "macos-aarch64")
|
||||
# The pinned shared registry enables Windows, Linux and macOS for AniCraft.
|
||||
SIGNER_SECRETS = {
|
||||
"AZURE_CERT_PROFILE", "AZURE_CLIENT_ID", "AZURE_CLIENT_SECRET", "AZURE_SIGNING_ACCOUNT",
|
||||
"AZURE_SIGNING_ENDPOINT", "AZURE_TENANT_ID", "LINUX_SIGNING_KEY", "APPLE_CERTIFICATE",
|
||||
"APPLE_CERTIFICATE_PASSWORD", "APPLE_ID", "APPLE_PASSWORD", "APPLE_TEAM_ID", "KEYCHAIN_PASSWORD",
|
||||
}
|
||||
# Each platform's one trust field in policy v3, and the public stable identity it must name.
|
||||
NIGHTLY_TRUST = {
|
||||
"windows-x86_64": ("publisher_subject",
|
||||
@@ -48,6 +57,49 @@ def assert_nightly_serialization(source):
|
||||
raise ValueError("nightly serialization must use its stable group, max queue and no cancellation")
|
||||
|
||||
|
||||
def caller_entries(lines, indent):
|
||||
"""Split the callers' plain YAML block entries; refuse other forms at checked levels."""
|
||||
entries = {}
|
||||
children = None
|
||||
for line in lines:
|
||||
if children is not None and line.startswith(" " * (indent + 1)):
|
||||
children.append(line)
|
||||
continue
|
||||
row = re.fullmatch(r" " * indent + r"([A-Za-z0-9_-]+):(?: (.*))?", line)
|
||||
if row is None or row[1] in entries:
|
||||
raise ValueError("malformed or duplicate caller mapping entry")
|
||||
children = []
|
||||
entries[row[1]] = row[2], children
|
||||
return entries
|
||||
|
||||
|
||||
def assert_caller_secrets(source, job_name, names):
|
||||
"""Check the actual caller's root, job and secret blocks without a YAML dependency."""
|
||||
lines = [line for line in source.splitlines() if line.strip() and not line.lstrip().startswith("#")]
|
||||
root = caller_entries(lines, 0)
|
||||
job_marker, job_lines = root.pop("jobs", (None, []))
|
||||
jobs = caller_entries(job_lines, 2)
|
||||
if job_marker is not None or set(jobs) != {job_name} or jobs[job_name][0] is not None:
|
||||
raise ValueError("the caller must have one plain job block")
|
||||
job = caller_entries(jobs[job_name][1], 4)
|
||||
if "environment" in job or "environment" in root or "secrets" in root:
|
||||
raise ValueError("only the native callee may bind the environment")
|
||||
if names:
|
||||
if "secrets" not in job:
|
||||
raise ValueError("signer requires an explicit target-specific secret map")
|
||||
mode, secret_lines = job.pop("secrets")
|
||||
expected = {name: ("${{ secrets." + name + " }}", []) for name in names}
|
||||
if mode is not None or caller_entries(secret_lines, 6) != expected:
|
||||
raise ValueError("signer must forward exactly the reviewed same-name secret references")
|
||||
elif "secrets" in job:
|
||||
raise ValueError("unsigned caller must not pass secrets")
|
||||
for value, children in (*root.values(), *job.values()):
|
||||
outside_map = "\n".join([value or "", *children])
|
||||
# Scan all remaining text: quoted braces can appear before a secret reference.
|
||||
if re.search(r"(?im)^\s*environment:|\bsecrets\b", outside_map):
|
||||
raise ValueError("secret bindings belong only in the signer map")
|
||||
|
||||
|
||||
def literal_off(condition):
|
||||
expression = " ".join(condition.split())
|
||||
if expression.startswith("${{") and expression.endswith("}}"):
|
||||
@@ -227,8 +279,49 @@ class TrustedSourcePreparation(unittest.TestCase):
|
||||
with self.subTest(workflow=name):
|
||||
self.assertNotRegex(executable, r"(?im)^\s*(?:-\s*)?uses:\s*[^\n]*cache")
|
||||
self.assertNotRegex(executable, r"(?im)^\s*[^\s:#]*cache[^\s:#]*:")
|
||||
self.assertNotRegex(executable, r"(?im)^\s*(?:environment|secrets):")
|
||||
self.assertNotIn("secrets.", executable)
|
||||
|
||||
def test_signer_forwards_exactly_the_reviewed_secret_names(self):
|
||||
signer = (ROOT / ".github/workflows/nightly-sign.yml").read_text()
|
||||
assert_caller_secrets(signer, "release", SIGNER_SECRETS)
|
||||
|
||||
def test_signer_refuses_missing_extra_alias_duplicate_or_inherited_secrets(self):
|
||||
signer = (ROOT / ".github/workflows/nightly-sign.yml").read_text()
|
||||
header = " secrets:\n"
|
||||
linux = " LINUX_SIGNING_KEY: ${{ secrets.LINUX_SIGNING_KEY }}\n"
|
||||
self.assertIn(linux, signer)
|
||||
mutations = {
|
||||
"missing name": signer.replace(linux, ""),
|
||||
"extra name": signer + " EXTRA: ${{ secrets.EXTRA }}\n",
|
||||
"renamed source": signer.replace(linux, linux.replace("secrets.LINUX_SIGNING_KEY", "secrets.APPLE_ID")),
|
||||
"duplicate name": signer.replace(linux, linux + linux),
|
||||
"duplicate map": signer + header + linux,
|
||||
"quoted duplicate map": signer + ' "secrets": inherit\n',
|
||||
"inherit": signer.split(header)[0] + " secrets: inherit\n",
|
||||
"yaml alias": signer.replace(linux, " LINUX_SIGNING_KEY: *other\n"),
|
||||
"yaml merge": signer + " <<: *other\n",
|
||||
"environment": signer + " environment: release\n",
|
||||
"secret outside map": signer.replace("${{ inputs.producer_run_id }}", "${{ secrets.APPLE_ID }}"),
|
||||
}
|
||||
for change, source in mutations.items():
|
||||
with self.subTest(change=change), self.assertRaises(ValueError):
|
||||
assert_caller_secrets(source, "release", SIGNER_SECRETS)
|
||||
|
||||
def test_unsigned_caller_has_no_secrets(self):
|
||||
producer = (ROOT / ".github/workflows/nightly.yml").read_text()
|
||||
assert_caller_secrets(producer, "unsigned", set())
|
||||
for suffix in (" secrets: {}\n", " secrets: inherit\n",
|
||||
" secrets:\n EXTRA: ${{ secrets.EXTRA }}\n",
|
||||
" extra: ${{ secrets['EXTRA'] }}\n", " secrets: inherit\n"):
|
||||
with self.subTest(suffix=suffix), self.assertRaises(ValueError):
|
||||
assert_caller_secrets(producer + suffix, "unsigned", set())
|
||||
|
||||
def test_unsigned_caller_refuses_secret_after_format_brace(self):
|
||||
producer = (ROOT / ".github/workflows/nightly.yml").read_text()
|
||||
# This inert fixture is never dispatched; the brace is part of the format string.
|
||||
env = "env:\n EXAMPLE: ${{ format('value {0}', secrets.EXAMPLE_ONLY) }}\n\n"
|
||||
source = producer.replace("jobs:\n", env + "jobs:\n", 1)
|
||||
with self.assertRaisesRegex(ValueError, "secret bindings belong only in the signer map"):
|
||||
assert_caller_secrets(source, "unsigned", set())
|
||||
|
||||
|
||||
class NightlyTrustAnchors(unittest.TestCase):
|
||||
@@ -276,7 +369,7 @@ class NightlyEnabledCallers(unittest.TestCase):
|
||||
"github.ref_type == 'branch' && (github.event_name == 'schedule' || "
|
||||
"github.event_name == 'workflow_dispatch')",
|
||||
"nightly-sign.yml": "github.repository == 'storytold/anicraft' && github.event_name == 'workflow_dispatch' && "
|
||||
"github.ref == 'refs/heads/release' && github.ref_type == 'branch'",
|
||||
"github.ref == 'refs/heads/" + SIGNER_BRANCH + "' && github.ref_type == 'branch'",
|
||||
}
|
||||
|
||||
def test_enabled_jobs_keep_exact_context_guards(self):
|
||||
@@ -330,16 +423,15 @@ class NightlyInstalledPolicy(unittest.TestCase):
|
||||
self.assertEqual(set(self.policy), expected)
|
||||
self.assertEqual(self.policy["schema"], "craft-nightly-release-policy/v3")
|
||||
self.assertEqual(self.policy["repository"], "storytold/anicraft")
|
||||
self.assertEqual(self.policy["release_branch"], "release")
|
||||
self.assertIs(type(self.policy["repository_id"]), int)
|
||||
self.assertGreater(self.policy["repository_id"], 0)
|
||||
# producer_workflow_id is null until nightly.yml is registered on main; once set it must be a positive int.
|
||||
if self.policy["producer_workflow_id"] is not None:
|
||||
self.assertIs(type(self.policy["producer_workflow_id"]), int)
|
||||
self.assertGreater(self.policy["producer_workflow_id"], 0)
|
||||
self.assertNotEqual(self.policy["producer_workflow_id"],
|
||||
self.policy["candidate_policy"]["required_workflows"][0]["workflow_id"],
|
||||
"the producer is not its own quality workflow")
|
||||
self.assertEqual(self.policy["release_branch"], SIGNER_BRANCH, "the signer runs on its dedicated branch")
|
||||
# Both read from the GitHub API (the repository and nightly.yml's registration on main).
|
||||
for key in ("repository_id", "producer_workflow_id"):
|
||||
with self.subTest(key=key):
|
||||
self.assertIs(type(self.policy[key]), int)
|
||||
self.assertGreater(self.policy[key], 0)
|
||||
self.assertNotEqual(self.policy["producer_workflow_id"],
|
||||
self.policy["candidate_policy"]["required_workflows"][0]["workflow_id"],
|
||||
"the producer is not its own quality workflow")
|
||||
|
||||
def test_paths_and_tooling_match_the_callers(self):
|
||||
pin = caller_pin("nightly.yml")
|
||||
@@ -408,6 +500,316 @@ class NightlyInstalledPolicy(unittest.TestCase):
|
||||
self.assertIn(item["type"], sonar["issue_types"])
|
||||
self.assertRegex(item["hash"], r"^[0-9a-f]{32}$")
|
||||
|
||||
def test_sonar_policy_keeps_the_shared_candidate_contract(self):
|
||||
"""The Sonar shape craft-common-actions' candidate contract() admits, refused here first.
|
||||
|
||||
An empty issue scope, an accepted condition outside the reviewed issue types, a metric in both
|
||||
lists, a missing live gate condition or a widened security bound is refused at admission, so
|
||||
this suite must catch it before a nightly run can. `debt` stays empty, so any unresolved
|
||||
vulnerability on main is still refused; accepting the new-code rating only records the
|
||||
reviewed A threshold instead of demanding a clean rating the live gate does not.
|
||||
"""
|
||||
sonar = self.policy["candidate_policy"]["sonar"]
|
||||
accepted = {"bugs": "BUG", "vulnerabilities": "VULNERABILITY", "code_smells": "CODE_SMELL",
|
||||
"security_rating": "VULNERABILITY", "new_security_rating": "VULNERABILITY"}
|
||||
gate = {"new_reliability_rating", "new_security_rating", "new_maintainability_rating",
|
||||
"new_coverage", "new_duplicated_lines_density", "new_security_hotspots_reviewed"}
|
||||
self.assertTrue(sonar["issue_types"], "an empty issue scope is refused as unreviewed")
|
||||
self.assertEqual(len(sonar["issue_types"]), len(set(sonar["issue_types"])))
|
||||
metrics = {}
|
||||
for field in ("accepted_conditions", "required_conditions"):
|
||||
for condition in sonar[field]:
|
||||
with self.subTest(field=field, metric=condition.get("metric")):
|
||||
expected = {"metric", "comparator", "error_threshold"}
|
||||
if field == "accepted_conditions":
|
||||
expected.add("maximum")
|
||||
self.assertEqual(set(condition), expected)
|
||||
self.assertNotIn(condition["metric"], metrics, "one condition per gate metric")
|
||||
metrics[condition["metric"]] = condition
|
||||
self.assertIn(condition["comparator"], ("GT", "LT"))
|
||||
self.assertRegex(condition["error_threshold"], r"^(?:0|[1-9][0-9]*)(?:\.[0-9]+)?$")
|
||||
if field != "accepted_conditions":
|
||||
continue
|
||||
self.assertIn(condition["metric"], accepted, "an accepted metric outside the reviewed map")
|
||||
self.assertIn(accepted[condition["metric"]], sonar["issue_types"],
|
||||
"an accepted failure must lie inside the reviewed issue scope")
|
||||
self.assertEqual(condition["comparator"], "GT")
|
||||
self.assertRegex(condition["maximum"], r"^(?:0|[1-9][0-9]*)(?:\.[0-9]+)?$")
|
||||
maximum = float(condition["maximum"])
|
||||
if condition["metric"] in ("security_rating", "new_security_rating"):
|
||||
self.assertEqual(int(maximum), maximum, "the A..E bound is a whole rating")
|
||||
self.assertTrue(1 <= maximum <= 5, "the security bound stays A..E")
|
||||
self.assertEqual(condition["error_threshold"], "1", "the reviewed A threshold stays")
|
||||
else:
|
||||
self.assertLessEqual(maximum, len(sonar["debt"]), "accepted failures exceed the reviewed debt")
|
||||
self.assertEqual({accepted[c["metric"]] for c in sonar["accepted_conditions"]}, set(sonar["issue_types"]),
|
||||
"accepted conditions and reviewed issue types must cover the same scope")
|
||||
self.assertEqual(set(metrics), gate, "every live gate condition stays gated exactly once")
|
||||
|
||||
|
||||
SHARED = "storytold/craft-common-actions/.github/workflows/"
|
||||
# App workflows reviewed to call the shared stable release.yml. That callee must carry the
|
||||
# stable-only environment guard (dry runs and non-release refs bind no environment); the
|
||||
# nightly-signer settings scan checks the resolved callee before creating or advancing the branch.
|
||||
REVIEWED_STABLE_RELEASE_CALLERS = {"release.yml"}
|
||||
|
||||
|
||||
def app_workflows():
|
||||
return {path.name: path.read_text() for path in sorted((ROOT / ".github/workflows").glob("*.y*ml"))}
|
||||
|
||||
|
||||
WORKFLOW_KEY = re.compile(r'''("(?:[^"\\]|\\.)*"|'(?:[^']|'')*'|[^\s'"#{}\[\],:&*!|>%@`?-][^:#,{}]*?|-[^\s:#][^:#,{}]*?)\s*:(?:\s+(.*))?$''')
|
||||
|
||||
|
||||
def _workflow_key(text):
|
||||
if text.startswith('"'):
|
||||
return None if "\\" in text else text[1:-1]
|
||||
if text.startswith("'"):
|
||||
return text[1:-1].replace("''", "'")
|
||||
return text
|
||||
|
||||
|
||||
def _workflow_value(text):
|
||||
"""A one-line scalar value without its comment and quotes; None when escaped or unterminated."""
|
||||
text = text.strip()
|
||||
if text.startswith('"'):
|
||||
quoted = re.match(r'"((?:[^"\\]|\\.)*)"\s*(?:#.*)?$', text)
|
||||
return None if quoted is None or "\\" in quoted.group(1) else quoted.group(1)
|
||||
if text.startswith("'"):
|
||||
quoted = re.match(r"'((?:[^']|'')*)'\s*(?:#.*)?$", text)
|
||||
return None if quoted is None else quoted.group(1).replace("''", "'")
|
||||
return re.split(r"\s+#", text, maxsplit=1)[0].strip()
|
||||
|
||||
|
||||
def _strip_comment(text):
|
||||
"""(text without its comment, unterminated) using a quote-aware scan.
|
||||
|
||||
As in YAML, a quote opens a quoted scalar only where a scalar starts (line start or after
|
||||
`:`, `-`, `,`, `{` or `[`), and a `#` starts a comment only outside quotes, at the start or
|
||||
after whitespace.
|
||||
"""
|
||||
quote, index = None, 0
|
||||
while index < len(text):
|
||||
char = text[index]
|
||||
if quote == '"':
|
||||
if char == "\\":
|
||||
index += 2
|
||||
continue
|
||||
if char == '"':
|
||||
quote = None
|
||||
elif quote == "'":
|
||||
if char == "'":
|
||||
if text[index + 1:index + 2] == "'":
|
||||
index += 2
|
||||
continue
|
||||
quote = None
|
||||
elif char in "\"'" and text[:index].rstrip()[-1:] in ("", ":", "-", ",", "{", "["):
|
||||
quote = char
|
||||
elif char == "#" and (index == 0 or text[index - 1] in " \t"):
|
||||
return text[:index].rstrip(), False
|
||||
index += 1
|
||||
return text.rstrip(), quote is not None
|
||||
|
||||
|
||||
FLOW_QUOTED = re.compile(r"\"(?:[^\"\\]|\\.)*\"|'(?:[^']|'')*'")
|
||||
FLOW_FORBIDDEN_KEYS = {"environment", "uses"}
|
||||
|
||||
|
||||
def workflow_entries(source):
|
||||
"""Every mapping entry in a workflow, plus the YAML forms this reader refuses.
|
||||
|
||||
A narrow reader, not a YAML parser (none ships with the runner's Python). Each entry is
|
||||
(line, key, value, multiline): plain, single- and double-quoted keys and one-line values in
|
||||
block and simple one-line flow mappings. Block scalar bodies are skipped, and an entry whose
|
||||
value is a block scalar or continues on the next lines is marked multiline. It refuses whatever
|
||||
could hide a key from it: escaped double-quoted keys, explicit `?` keys, merge keys, anchors,
|
||||
aliases, tags, tab indentation and nested or multi-line flow.
|
||||
"""
|
||||
lines = source.splitlines()
|
||||
entries, refused, block = [], [], None
|
||||
|
||||
def continues(index, indent):
|
||||
for follow in lines[index + 1:]:
|
||||
stripped = follow.strip()
|
||||
if not stripped or stripped.startswith("#"):
|
||||
continue
|
||||
deeper = len(follow) - len(follow.lstrip(" ")) > indent
|
||||
return deeper and not stripped.startswith("- ") and WORKFLOW_KEY.match(stripped) is None
|
||||
return False
|
||||
|
||||
for index, raw in enumerate(lines):
|
||||
number = index + 1
|
||||
stripped = raw.strip()
|
||||
indent = len(raw) - len(raw.lstrip(" "))
|
||||
if block is not None:
|
||||
if not stripped or indent > block:
|
||||
continue
|
||||
block = None
|
||||
if not stripped or stripped.startswith("#"):
|
||||
continue
|
||||
if "\t" in raw[:indent + 1]:
|
||||
refused.append(f"line {number}: tab indentation"); continue
|
||||
body, unterminated = _strip_comment(stripped)
|
||||
if unterminated:
|
||||
refused.append(f"line {number}: unterminated or multi-line quoted scalar"); continue
|
||||
if not body:
|
||||
continue
|
||||
while body.startswith("- "):
|
||||
body = body[2:].lstrip()
|
||||
if body == "?" or body.startswith("? "):
|
||||
refused.append(f"line {number}: explicit key"); continue
|
||||
match = WORKFLOW_KEY.match(body)
|
||||
value = body
|
||||
if match is not None:
|
||||
key, value = _workflow_key(match.group(1)), match.group(2) or ""
|
||||
if key is None:
|
||||
refused.append(f"line {number}: escaped double-quoted key"); continue
|
||||
if key == "<<":
|
||||
refused.append(f"line {number}: merge key"); continue
|
||||
plain = re.sub(r"\$\{\{.*?\}\}", "", value).strip()
|
||||
bare = re.sub(r"\"(?:[^\"\\]|\\.)*\"|'(?:[^']|'')*'", "''", plain)
|
||||
if re.match(r"[&*!]", plain):
|
||||
refused.append(f"line {number}: anchor, alias or tag")
|
||||
is_block = re.fullmatch(r"[|>][0-9+-]*", plain) is not None
|
||||
if match is not None:
|
||||
entries.append((number, key, _workflow_value(value),
|
||||
is_block or ((value == "" or not is_block) and continues(index, indent))))
|
||||
if "{" in bare and bare != "{}":
|
||||
masked = re.fullmatch(r"\{([^{}\[\]]*)\}", FLOW_QUOTED.sub("''", value.strip()))
|
||||
flow = re.fullmatch(r"\{([^{}\[\]]*)\}", value.strip())
|
||||
if any(set(scalar[1:-1]) & set("#{}[],") for scalar in FLOW_QUOTED.findall(value)):
|
||||
refused.append(f"line {number}: flow mapping quoted scalar with # or flow punctuation")
|
||||
elif masked is None or flow is None:
|
||||
refused.append(f"line {number}: nested or multi-line flow mapping")
|
||||
else:
|
||||
# The masked text only proves the shape: a quoted key ("uses", 'environment') keeps
|
||||
# its identity, so the entries are read from the original mapping text, never ''.
|
||||
for item in flow.group(1).split(","):
|
||||
entry = WORKFLOW_KEY.match(item.strip())
|
||||
key = _workflow_key(entry.group(1)) if entry else None
|
||||
if key is None:
|
||||
refused.append(f"line {number}: unreadable flow mapping entry")
|
||||
elif key in FLOW_FORBIDDEN_KEYS:
|
||||
refused.append(f"line {number}: {key} in a flow mapping (must be block style)")
|
||||
else:
|
||||
entries.append((number, key, _workflow_value(entry.group(2) or ""), False))
|
||||
if match is not None and is_block:
|
||||
block = indent
|
||||
return entries, refused
|
||||
|
||||
|
||||
def workflow_keys(source):
|
||||
"""(line, key) for every mapping entry, plus the refused YAML forms."""
|
||||
entries, refused = workflow_entries(source)
|
||||
return [(number, key) for number, key, _, _ in entries], refused
|
||||
|
||||
|
||||
SHARED_CALLEE = re.compile(r"storytold/craft-common-actions/\.github/workflows/([\w.-]+\.ya?ml)@(\S+)", re.IGNORECASE)
|
||||
INSPECTED_KEYS = {"environment", "uses"}
|
||||
|
||||
|
||||
def trust_closure_problems(workflows):
|
||||
"""The nightly-signer trust-closure scan over app workflow sources; empty when the tree is safe.
|
||||
|
||||
Every key it inspects comes from workflow_entries(), never a regex over the raw text.
|
||||
"""
|
||||
problems, stable_callers, signer_calls = [], set(), 0
|
||||
for name, source in workflows.items():
|
||||
entries, refused = workflow_entries(source)
|
||||
problems.extend(name + " uses YAML the scan cannot read (" + reason + ")" for reason in refused)
|
||||
for number, key, value, multiline in entries:
|
||||
if key not in INSPECTED_KEYS:
|
||||
continue
|
||||
if key == "environment":
|
||||
problems.append(f"{name} binds an environment directly (line {number})")
|
||||
continue
|
||||
if value is None or multiline:
|
||||
problems.append(f"{name} has a uses value the scan cannot read (line {number})")
|
||||
continue
|
||||
callee = SHARED_CALLEE.fullmatch(value)
|
||||
if callee is None:
|
||||
if re.search(r"craft-common-actions", value, re.IGNORECASE) and re.search(r"workflows/(nightly-)?release\.ya?ml", value, re.IGNORECASE):
|
||||
problems.append(f"{name} has an unrecognised shared release caller (line {number})")
|
||||
continue
|
||||
workflow, ref = callee.group(1), callee.group(2)
|
||||
if workflow.lower() in ("nightly-release.yml", "nightly-release.yaml"):
|
||||
if name == "nightly-sign.yml":
|
||||
signer_calls += 1
|
||||
if name != "nightly-sign.yml" or not re.fullmatch(r"[0-9a-f]{40}", ref):
|
||||
problems.append(name + " calls nightly-release.yml@" + ref)
|
||||
if workflow.lower() in ("release.yml", "release.yaml"):
|
||||
stable_callers.add(name)
|
||||
if ref != "main" and not re.fullmatch(r"[0-9a-f]{40}", ref):
|
||||
problems.append(name + " calls release.yml@" + ref + "; use @main or a reviewed full SHA")
|
||||
if stable_callers != REVIEWED_STABLE_RELEASE_CALLERS:
|
||||
problems.append("shared release.yml callers are " + ", ".join(sorted(stable_callers)))
|
||||
if signer_calls != 1:
|
||||
problems.append("nightly-sign.yml must call nightly-release.yml exactly once")
|
||||
return problems
|
||||
|
||||
|
||||
class NightlySignerBranchTrustClosure(unittest.TestCase):
|
||||
"""On refs/heads/nightly-signer, only the pinned signer caller may reach an environment."""
|
||||
|
||||
def test_trust_closure_scan_passes_on_this_tree(self):
|
||||
self.assertEqual(trust_closure_problems(app_workflows()), [])
|
||||
|
||||
def test_trust_closure_scan_refuses_each_route_into_an_environment(self):
|
||||
tree = app_workflows()
|
||||
bad = {
|
||||
"a workflow binds an environment": {**tree, "extra.yml": "jobs:\n x:\n runs-on: ubuntu-latest\n environment: release\n"},
|
||||
"a double-quoted environment key": {**tree, "extra.yml": 'jobs:\n x:\n runs-on: ubuntu-latest\n "environment": release\n'},
|
||||
"a single-quoted environment key": {**tree, "extra.yml": "jobs:\n x:\n runs-on: ubuntu-latest\n 'environment' : release\n"},
|
||||
"an environment mapping": {**tree, "extra.yml": "jobs:\n x:\n runs-on: ubuntu-latest\n environment:\n name: release\n"},
|
||||
"an environment in a flow mapping": {**tree, "extra.yml": "jobs:\n x: {runs-on: ubuntu-latest, environment: release}\n"},
|
||||
"an escaped key": {**tree, "extra.yml": 'jobs:\n x:\n runs-on: ubuntu-latest\n "environ\\u006dent": release\n'},
|
||||
"a merge key": {**tree, "extra.yml": "base: &b\n runs-on: ubuntu-latest\njobs:\n x:\n <<: *b\n"},
|
||||
"an explicit key": {**tree, "extra.yml": "jobs:\n x:\n ? environment\n : release\n"},
|
||||
"a nested flow mapping": {**tree, "extra.yml": "jobs:\n x: {steps: [{run: a}]}\n"},
|
||||
"a double-quoted uses key copying the signer": {**tree, "extra.yml": 'jobs:\n x:\n "uses": ' + SHARED + "nightly-release.yml@" + "a" * 40 + "\n"},
|
||||
"a single-quoted uses key": {**tree, "extra.yml": "jobs:\n x:\n 'uses': " + SHARED + "nightly-release.yml@" + "a" * 40 + "\n"},
|
||||
"a quoted uses value": {**tree, "extra.yml": 'jobs:\n x:\n uses: "' + SHARED + "nightly-release.yml@" + "a" * 40 + '"\n'},
|
||||
"uses in a flow mapping": {**tree, "extra.yml": "jobs:\n x: {uses: " + SHARED + "nightly-release.yml@" + "a" * 40 + "}\n"},
|
||||
"a differently cased owner": {**tree, "extra.yml": "jobs:\n x:\n uses: Storytold/Craft-Common-Actions/.github/workflows/nightly-release.yml@" + "a" * 40 + "\n"},
|
||||
"a folded uses value": {**tree, "extra.yml": "jobs:\n x:\n uses: >-\n " + SHARED + "nightly-release.yml@" + "a" * 40 + "\n"},
|
||||
"a continued uses value": {**tree, "extra.yml": "jobs:\n x:\n uses: " + SHARED + "\n nightly-release.yml@" + "a" * 40 + "\n"},
|
||||
"a quoted second signer call": {**tree, "nightly-sign.yml": tree["nightly-sign.yml"] + " again:\n \"uses\": " + SHARED + "nightly-release.yml@" + "a" * 40 + "\n"},
|
||||
"a hash inside a quoted flow scalar": {**tree, "extra.yml": 'jobs:\n x: {name: "a} # b", runs-on: ubuntu-latest, environment: release, steps: []}\n'},
|
||||
"a single-quoted hash in a flow scalar": {**tree, "extra.yml": "jobs:\n x: {name: 'a # b', runs-on: ubuntu-latest}\n"},
|
||||
"a comma inside a quoted flow scalar": {**tree, "extra.yml": 'jobs:\n x: {name: "a, environment: release", runs-on: ubuntu-latest}\n'},
|
||||
"a bracket inside a quoted flow scalar": {**tree, "extra.yml": 'jobs:\n x: {name: "[a]", runs-on: ubuntu-latest}\n'},
|
||||
"an unterminated quote": {**tree, "extra.yml": 'jobs:\n x:\n name: "a\n b"\n runs-on: ubuntu-latest\n'},
|
||||
"environment in any flow mapping": {**tree, "extra.yml": "jobs:\n x:\n runs-on: ubuntu-latest\n with: {environment: release}\n"},
|
||||
"a double-quoted environment key in a flow mapping": {**tree, "extra.yml": 'jobs:\n x:\n runs-on: ubuntu-latest\n with: {"environment": release}\n'},
|
||||
"a single-quoted environment key in a flow mapping": {**tree, "extra.yml": "jobs:\n x:\n runs-on: ubuntu-latest\n with: {'environment': release}\n"},
|
||||
"a double-quoted uses key in a flow mapping": {**tree, "extra.yml": 'jobs:\n x: {"uses": ' + SHARED + "nightly-release.yml@" + "a" * 40 + "}\n"},
|
||||
"uses in any flow mapping": {**tree, "extra.yml": "jobs:\n x:\n steps:\n - {uses: actions/checkout@v4}\n"},
|
||||
"another caller of the signer": {**tree, "extra.yml": "jobs:\n x:\n uses: " + SHARED + "nightly-release.yml@" + "a" * 40 + "\n"},
|
||||
"a mutable signer pin": {**tree, "nightly-sign.yml": re.sub(r"nightly-release\.yml@[0-9a-f]{40}", "nightly-release.yml@main", tree["nightly-sign.yml"])},
|
||||
"a new stable release caller": {**tree, "extra.yml": "jobs:\n x:\n uses: " + SHARED + "release.yml@main\n"},
|
||||
"a stable caller on a branch or tag ref": {**tree, "release.yml": tree["release.yml"].replace(SHARED + "release.yml@main", SHARED + "release.yml@v1")},
|
||||
}
|
||||
for label, workflows in bad.items():
|
||||
with self.subTest(case=label):
|
||||
self.assertTrue(trust_closure_problems(workflows))
|
||||
|
||||
def test_quoted_keys_in_a_flow_mapping_are_read_not_masked(self):
|
||||
entries, refused = workflow_entries('jobs:\n x: {runs-on: ubuntu-latest, "name": build}\n')
|
||||
self.assertEqual(refused, [])
|
||||
self.assertIn((2, "name", "build", False), entries, "a quoted key keeps its identity")
|
||||
self.assertIn((2, "runs-on", "ubuntu-latest", False), entries)
|
||||
_, refused = workflow_entries("jobs:\n x: {runs-on: ubuntu-latest, 'environment': release}\n")
|
||||
self.assertEqual(refused, ["line 2: environment in a flow mapping (must be block style)"])
|
||||
|
||||
def test_signer_guard_and_policy_name_the_same_branch(self):
|
||||
app = json.loads(INSTALLED_POLICY.read_text())["repository"].split("/", 1)[1]
|
||||
sign = (ROOT / ".github/workflows/nightly-sign.yml").read_text()
|
||||
(_, guard), = job_conditions(sign.split("\njobs:\n", 1)[1])
|
||||
self.assertIn("github.ref == 'refs/heads/" + SIGNER_BRANCH + "'", guard)
|
||||
self.assertNotIn("refs/heads/release", sign, "the signer no longer runs on the stable branch")
|
||||
self.assertEqual(re.findall(r"(?m)^ app-name: (\S+)$", sign), [app], "the shared signer needs the reviewed registry app")
|
||||
self.assertEqual(json.loads(INSTALLED_POLICY.read_text())["release_branch"], SIGNER_BRANCH)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main(verbosity=2)
|
||||
@@ -386,6 +386,9 @@ fn preferences(app: &mut App, ctx: &egui::Context) {
|
||||
let mut reset_confirms = false;
|
||||
let mut about_act: Option<crate::desktop_ui::Act> = None;
|
||||
let mut theme_act: Option<ThemeAct> = None;
|
||||
// The marquee's choice is the session's (`view.select_touching`), so a script can set it
|
||||
// too; the command runs once the window is drawn.
|
||||
let mut touching = app.s.aids.select_touching;
|
||||
let to_about = std::mem::take(&mut app.prefs_to_about);
|
||||
let title = if crate::platform::OS == crate::platform::Os::Mac { tr!("Settings") } else { tr!("Preferences") };
|
||||
let shown = crate::windows::new(ctx, title)
|
||||
@@ -594,6 +597,13 @@ fn preferences(app: &mut App, ctx: &egui::Context) {
|
||||
form_note(ui, LW, text(Type::Caption, s));
|
||||
}
|
||||
}
|
||||
ui.add_space(4.0);
|
||||
form_row(ui, LW, tr!("Selection"), |ui| {
|
||||
ui.vertical(|ui| {
|
||||
crate::theme::checkbox(ui, &mut touching, text(Type::Body, tr!("The marquee takes objects it touches")));
|
||||
form_note(ui, toggle_indent, text(Type::Caption, tr!("Off, dragging a box with the Selection tool takes only the objects that are wholly inside it. Shapes drawn without Object Drawing are cut at the box's edges either way.")));
|
||||
});
|
||||
});
|
||||
// How the window itself is drawn (#207, #255): read when AniCraft starts.
|
||||
let backends = crate::platform::window_backends(crate::platform::OS);
|
||||
if !backends.is_empty() {
|
||||
@@ -727,6 +737,9 @@ fn preferences(app: &mut App, ctx: &egui::Context) {
|
||||
if let Some(a) = about_act {
|
||||
crate::desktop_ui::apply(app, a);
|
||||
}
|
||||
if touching != app.s.aids.select_touching {
|
||||
app.run("view.select_touching", json!({"on": touching}));
|
||||
}
|
||||
if p != app.prefs {
|
||||
app.set_prefs(ctx, p);
|
||||
}
|
||||
|
||||
+75
-38
@@ -127,64 +127,96 @@ pub fn wanted(pref: StageRenderer) -> StageRenderer {
|
||||
|
||||
// ----- when stage work may be submitted on the window's device (ADR 0105) ----------------------
|
||||
|
||||
/// The gate stage work on the window's device is submitted through: open while the window's
|
||||
/// thread runs the app's frame, closed while it may be reconfiguring a surface.
|
||||
/// A window's gate, which stage work on the window's device is submitted through: open while
|
||||
/// the window's thread runs the app's frame, closed while it may be reconfiguring a surface.
|
||||
/// With it, the window a waiting submission asks for a frame (the window opens again with a
|
||||
/// new one after its device was lost, ADR 0092).
|
||||
#[cfg(gpu_stage)]
|
||||
static GATE: std::sync::OnceLock<std::sync::Arc<anicraft_gpu::SubmitGate>> = std::sync::OnceLock::new();
|
||||
/// The window a waiting submission asks for a frame (the window opens again with a new one
|
||||
/// after its device was lost, ADR 0092).
|
||||
struct WindowGate {
|
||||
gate: std::sync::Arc<anicraft_gpu::SubmitGate>,
|
||||
wake: std::sync::Arc<std::sync::Mutex<Option<egui::Context>>>,
|
||||
}
|
||||
|
||||
#[cfg(gpu_stage)]
|
||||
static WAKE: std::sync::Mutex<Option<egui::Context>> = std::sync::Mutex::new(None);
|
||||
impl WindowGate {
|
||||
/// A closed gate owned by the calling thread (the window's).
|
||||
fn new() -> WindowGate {
|
||||
use std::sync::{Arc, Mutex, PoisonError};
|
||||
let wake: Arc<Mutex<Option<egui::Context>>> = Arc::default();
|
||||
let asked = wake.clone();
|
||||
let gate = Arc::new(anicraft_gpu::SubmitGate::new(move || {
|
||||
let ctx = asked.lock().unwrap_or_else(PoisonError::into_inner).clone();
|
||||
if let Some(ctx) = ctx {
|
||||
ctx.request_repaint();
|
||||
}
|
||||
}));
|
||||
WindowGate { gate, wake }
|
||||
}
|
||||
|
||||
/// The frame of the window `ctx` begins: the gate is open until the result is dropped.
|
||||
fn frame(&self, ctx: &egui::Context) -> InFrame {
|
||||
let mut wake = self.wake.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
|
||||
if wake.as_ref() != Some(ctx) {
|
||||
*wake = Some(ctx.clone());
|
||||
}
|
||||
drop(wake);
|
||||
self.gate.open();
|
||||
InFrame(Some(self.gate.clone()))
|
||||
}
|
||||
|
||||
/// A window of its own is drawn inside the frame: the gate is closed until the result is
|
||||
/// dropped.
|
||||
fn pause(&self) -> Paused {
|
||||
self.gate.close();
|
||||
Paused(Some(self.gate.clone()))
|
||||
}
|
||||
}
|
||||
|
||||
/// The one window's gate. Everything that opens and closes it goes through a [`WindowGate`],
|
||||
/// so a test of the gating makes its own: the tests that run the app's frame, on many threads
|
||||
/// at once, open and close this one all the time.
|
||||
#[cfg(gpu_stage)]
|
||||
static WINDOW: std::sync::OnceLock<WindowGate> = std::sync::OnceLock::new();
|
||||
/// Submissions that went ahead without a frame, as last written to the log.
|
||||
#[cfg(gpu_stage)]
|
||||
static GATE_TIMEOUTS: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
|
||||
|
||||
/// The gate a frame or a pause holds (none without the GPU stage, or before the first frame).
|
||||
#[cfg(gpu_stage)]
|
||||
fn gate(ctx: &egui::Context) -> &'static std::sync::Arc<anicraft_gpu::SubmitGate> {
|
||||
use std::sync::PoisonError;
|
||||
let mut wake = WAKE.lock().unwrap_or_else(PoisonError::into_inner);
|
||||
if wake.as_ref() != Some(ctx) {
|
||||
*wake = Some(ctx.clone());
|
||||
}
|
||||
drop(wake);
|
||||
GATE.get_or_init(|| {
|
||||
std::sync::Arc::new(anicraft_gpu::SubmitGate::new(|| {
|
||||
let ctx = WAKE.lock().unwrap_or_else(PoisonError::into_inner).clone();
|
||||
if let Some(ctx) = ctx {
|
||||
ctx.request_repaint();
|
||||
}
|
||||
}))
|
||||
})
|
||||
}
|
||||
type Held = Option<std::sync::Arc<anicraft_gpu::SubmitGate>>;
|
||||
#[cfg(not(gpu_stage))]
|
||||
type Held = ();
|
||||
|
||||
/// The app's frame, for the stage renderer: while this lives the window's thread is inside
|
||||
/// [`eframe::App::ui`], so it isn't reconfiguring a surface and stage work may be submitted.
|
||||
#[must_use]
|
||||
pub struct InFrame(());
|
||||
pub struct InFrame(Held);
|
||||
|
||||
/// Call first thing in the frame, on the window's thread; keep the result until the frame ends.
|
||||
#[cfg_attr(not(gpu_stage), allow(unused_variables))]
|
||||
pub fn in_frame(ctx: &egui::Context) -> InFrame {
|
||||
#[cfg(gpu_stage)]
|
||||
{
|
||||
let gate = gate(ctx);
|
||||
gate.open();
|
||||
let window = WINDOW.get_or_init(WindowGate::new);
|
||||
let frame = window.frame(ctx);
|
||||
// Work that waited for a frame that never came (a window that draws none) went ahead:
|
||||
// said once per tenfold, it is the old race's way back in.
|
||||
let timeouts = gate.waited().1;
|
||||
let timeouts = window.gate.waited().1;
|
||||
let said = GATE_TIMEOUTS.load(std::sync::atomic::Ordering::Relaxed);
|
||||
if timeouts > 0 && (said == 0 || timeouts >= said.saturating_mul(10)) {
|
||||
GATE_TIMEOUTS.store(timeouts, std::sync::atomic::Ordering::Relaxed);
|
||||
crate::startup::line(&format!("stage work was submitted without waiting for a frame {timeouts} time(s) (the window drew none for {} ms)", anicraft_gpu::SUBMIT_WAIT.as_millis()));
|
||||
}
|
||||
frame
|
||||
}
|
||||
#[cfg(not(gpu_stage))]
|
||||
InFrame(())
|
||||
}
|
||||
|
||||
impl Drop for InFrame {
|
||||
fn drop(&mut self) {
|
||||
#[cfg(gpu_stage)]
|
||||
if let Some(gate) = GATE.get() {
|
||||
if let Some(gate) = &self.0 {
|
||||
gate.close();
|
||||
}
|
||||
}
|
||||
@@ -194,20 +226,22 @@ impl Drop for InFrame {
|
||||
/// eframe sets that window's surface up and draws it inside the call, so stage work waits
|
||||
/// there too.
|
||||
#[must_use]
|
||||
pub struct Paused(());
|
||||
pub struct Paused(Held);
|
||||
|
||||
pub fn paused() -> Paused {
|
||||
#[cfg(gpu_stage)]
|
||||
if let Some(gate) = GATE.get() {
|
||||
gate.close();
|
||||
}
|
||||
return match WINDOW.get() {
|
||||
Some(window) => window.pause(),
|
||||
None => Paused(None),
|
||||
};
|
||||
#[cfg(not(gpu_stage))]
|
||||
Paused(())
|
||||
}
|
||||
|
||||
impl Drop for Paused {
|
||||
fn drop(&mut self) {
|
||||
#[cfg(gpu_stage)]
|
||||
if let Some(gate) = GATE.get() {
|
||||
if let Some(gate) = &self.0 {
|
||||
gate.open();
|
||||
}
|
||||
}
|
||||
@@ -374,8 +408,8 @@ mod imp {
|
||||
let shared = match &window {
|
||||
// Through the gate: the window reconfigures its surface between frames (ADR 0105).
|
||||
Some(rs) => {
|
||||
let on_window = match super::GATE.get() {
|
||||
Some(gate) => GpuRenderer::shared_gated(&rs.adapter, rs.device.clone(), rs.queue.clone(), gate.clone()),
|
||||
let on_window = match super::WINDOW.get() {
|
||||
Some(window) => GpuRenderer::shared_gated(&rs.adapter, rs.device.clone(), rs.queue.clone(), window.gate.clone()),
|
||||
None => GpuRenderer::shared(&rs.adapter, rs.device.clone(), rs.queue.clone()),
|
||||
};
|
||||
match on_window {
|
||||
@@ -688,9 +722,12 @@ mod tests {
|
||||
fn stage_work_is_submitted_only_inside_the_frame() {
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
// A gate of this test's own, as the window has one: the window's is opened and closed
|
||||
// by every test that runs the app's frame, on other threads, while this one looks.
|
||||
let ctx = egui::Context::default();
|
||||
let frame = in_frame(&ctx);
|
||||
let gate = GATE.get().cloned().unwrap();
|
||||
let window = WindowGate::new();
|
||||
let frame = window.frame(&ctx);
|
||||
let gate = window.gate.clone();
|
||||
let submit = |gate: &std::sync::Arc<anicraft_gpu::SubmitGate>| {
|
||||
let g = gate.clone();
|
||||
std::thread::spawn(move || g.run(|| ()))
|
||||
@@ -708,7 +745,7 @@ mod tests {
|
||||
submit(&gate).join().unwrap();
|
||||
assert_eq!(gate.waited().0, waits, "nothing waits inside the frame");
|
||||
// While a floating window or Test Movie draws inside the frame: it waits for that.
|
||||
let floating = paused();
|
||||
let floating = window.pause();
|
||||
let work = submit(&gate);
|
||||
assert!(waiting(waits + 1), "it waits while a window is being set up");
|
||||
let held = !work.is_finished();
|
||||
@@ -720,7 +757,7 @@ mod tests {
|
||||
assert!(waiting(waits + 2), "it waits between frames");
|
||||
let held = held && !work.is_finished();
|
||||
assert!(ctx.has_requested_repaint(), "the waiting work asks for a frame");
|
||||
let frame = in_frame(&ctx);
|
||||
let frame = window.frame(&ctx);
|
||||
work.join().unwrap();
|
||||
drop(frame);
|
||||
// The window's own thread never waits (it can't be reconfiguring while it submits).
|
||||
|
||||
@@ -2889,6 +2889,7 @@ mod pattern_tests {
|
||||
fn item(path: Path, fill: bool, stroke: Option<f32>) -> anicraft_engine::doc::DisplayItem {
|
||||
use anicraft_engine::doc::{ColorTransform, DisplayItem, ElementId, LayerId, Paint, Rgba, Stroke};
|
||||
DisplayItem {
|
||||
joins: false,
|
||||
path: std::sync::Arc::new(path),
|
||||
transform: Affine::IDENTITY,
|
||||
fill: fill.then_some(Paint::Solid(Rgba::new(1.0, 0.0, 0.0, 1.0))),
|
||||
|
||||
Reference in new issue
Block a user