Files
photocraft/crates/engine/tests/shape_kernel_budget.rs
T
David MannandClaude Opus 5.5 16000b01ef Address CodeRabbit review: batch 17 findings
Engine: droplet dependency capture skips disabled steps; a nested Batch
that was cancelled or could not write its error log fails the caller;
runDroplet forwards overrideOpen; actions.rename follows named Batch
steps; Batch steps inside a script count against MAX_SCRIPT_STEPS;
output claims compare destination identity; Save and Close never
replaces a read-only source. ATN: Md must be a BlnM enumeration,
adjustment-layer names must round-trip, Calculations exports a missing
blending as Multiply, Apply Image refuses unnamed-layer transparency.
Filters: Shape Blur records its resolved geometry, reserves its kernel
memory first, and reports a preparation failure as an error, not a
cancel; Crop keeps an artboard preset when the size is unchanged and
fits the board on a turned crop.

Codecs/cms/algo: zero-axis FITS image HDUs are empty; a GIF walk that
breaks off before the trailer fails closed; two-value .3dl shaper rows
are applied; fragmented custom kernels are refused and their work polls
cancellation.

UI: Conditional branches play through panel playback; paused actions
refuse to resume after being replaced; Playback Options OK validates
its fields; transform double-click ignores a hidden pivot; path boxes
snap to a stationary selection; modal blocking uses the effective tool;
a picker-consumed release clears snap lines and ends a Move drag; the
Crop preset control shows Selection and checks only it; Crop box undo
restores frame_from_selection; Bosnian fill labels.

Tests: timing asserts moved to an ignored test, plus the review's
coverage nitpicks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 11:37:38 +01:00

26 lines
1.3 KiB
Rust

//! A custom Shape Blur kernel is admitted against the working-memory budget before its coverage
//! buffer is allocated, also when a smart filter re-renders it. Its own binary: the budget is
//! process-wide.
use photocraft_geom::Rect;
use photocraft_raster::memory::{self, Policy};
use serde_json::json;
#[test]
fn custom_shape_kernel_is_admitted_before_allocation() {
let knots = json!([[0, 0], [10, 0], [10, 10], [0, 10]]);
let params = json!({"radius":1000,"shapePath":{"subpaths":[{"closed":true,"knots":knots}]}});
let mut surface = photocraft_raster::Surface::new(photocraft_color::PixelFormat::RGBA8);
surface.write_region(Rect::new(0, 0, 1, 1), &[1.0, 0.0, 0.0, 1.0]);
let canvas = Rect::new(0, 0, 1, 1);
let render = || photocraft_engine::filters::apply_filter_to_surface("filter.blur.shapeBlur", &params, &surface, canvas, None, canvas);
// The default budget renders it.
assert!(render().unwrap().is_some());
// A 1 MiB budget cannot hold the 2001² coverage floats (16 MB).
memory::configure(Policy { percent: None, absolute_bytes: 1 << 20 });
let refused = render();
memory::configure(Policy::default());
let err = refused.expect_err("the kernel must be refused before allocation");
assert!(err.to_string().contains("working memory"), "{err}");
}